feat: add signed launcher updates with native lifecycle recovery

This commit is contained in:
Emil
2026-09-09 19:48:10 +03:00
parent 7c0eb20894
commit 1d08396b80
39 changed files with 2952 additions and 46 deletions
+26
View File
@@ -0,0 +1,26 @@
import { useEffect, useRef, useSyncExternalStore } from 'react'
import { isNative, native, watchUpdater } from '../services/native'
import { createUpdaterController } from '../services/updater'
import { initialUpdaterState, updaterMutating } from '../state/updater'
export function useUpdater(blockedReason: string | null) {
const controller = useRef(createUpdaterController({
status: native.updaterStatus,
check: native.checkUpdater,
install: native.installUpdater,
restart: native.restartUpdater,
open: native.openUpdaterRelease,
watch: watchUpdater,
})).current
const state = useSyncExternalStore(controller.subscribe, controller.snapshot, () => initialUpdaterState)
useEffect(() => { controller.setBlockedReason(blockedReason) }, [controller, blockedReason])
useEffect(() => {
if (isNative()) return controller.connect()
}, [controller])
return { state, mutating: updaterMutating(state),
check: () => { void controller.check() },
install: () => { void controller.install() },
restart: () => { void controller.restart() },
openRelease: () => { void controller.open() },
}
}