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

41 lines
1.9 KiB
TypeScript
Raw Normal View History

import { contextBridge, ipcRenderer } from "electron/renderer";
import type {
CreatePublishJobResponse,
DesktopAccountInfo,
DesktopPublishTaskListResponse,
DesktopRuntimeSessionSyncRequest,
ListDesktopPublishTasksParams,
} 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>,
refreshRuntimeAccounts: () =>
ipcRenderer.invoke("desktop:refresh-runtime-accounts") as Promise<null>,
openPublishAccountConsole: (account: {
id: string;
platform: string;
platformUid: string;
displayName: string;
}) =>
ipcRenderer.invoke("desktop:open-publish-account-console", account) as Promise<null>,
unbindPublishAccount: (accountId: string, syncVersion: number) =>
ipcRenderer.invoke("desktop:unbind-publish-account", accountId, syncVersion) as Promise<null>,
listPublishTasks: (params?: ListDesktopPublishTasksParams) =>
ipcRenderer.invoke("desktop:list-publish-tasks", params) as Promise<DesktopPublishTaskListResponse>,
retryPublishTask: (taskId: string) =>
ipcRenderer.invoke("desktop:retry-publish-task", taskId) as Promise<CreatePublishJobResponse>,
syncRuntimeSession: (session: DesktopRuntimeSessionSyncRequest | null) =>
ipcRenderer.invoke("desktop:runtime-session-sync", session) as Promise<null>,
releaseRuntimeSession: (revoke?: boolean) =>
ipcRenderer.invoke("desktop:runtime-session-release", revoke) as Promise<null>,
},
};
contextBridge.exposeInMainWorld("desktopBridge", desktopBridge);