update download + apply flow

This commit is contained in:
2026-05-12 01:59:39 +03:00
parent 953263028b
commit 61fbe68251
4 changed files with 233 additions and 16 deletions
+15
View File
@@ -56,6 +56,12 @@ export type UpdateInfo = {
current_version: string
release_url: string
body: string
download_url: string | null
}
export type UpdateDownloadProgress = {
downloaded: number
total: number | null
}
export type CaptureRect = {
@@ -132,6 +138,15 @@ export const api = {
listen<UpdateInfo>("update-available", (e) => handler(e.payload)),
onHotkey: (handler: (kind: "start" | "stop" | "pause") => void): Promise<UnlistenFn> =>
listen<"start" | "stop" | "pause">("hotkey", (e) => handler(e.payload)),
downloadUpdate: (url: string) => invoke<void>("download_update", { url }),
applyUpdate: () => invoke<void>("apply_update"),
pendingUpdate: () => invoke<boolean>("pending_update"),
onUpdateDownloadProgress: (
handler: (p: UpdateDownloadProgress) => void,
): Promise<UnlistenFn> =>
listen<UpdateDownloadProgress>("update-download-progress", (e) =>
handler(e.payload),
),
}
export function formatBytes(n: number): string {