compat.ts 830 B

123456789101112131415161718192021222324
  1. import type { CompatStatus, WallpaperCompat } from './types'
  2. import type { MessageKey } from './i18n'
  3. export function compatStatus(compat: WallpaperCompat | undefined): CompatStatus {
  4. if (!compat) return 'ok'
  5. if (compat.freshLaunch === 'crash') return 'crashes'
  6. if (compat.hotswapCrash) return compat.freshLaunch === 'ok' ? 'hotswap-only' : 'hotswap-untested'
  7. if (compat.runtimeCrashes) return 'unstable'
  8. return 'ok'
  9. }
  10. /** Hotswap crashed but a fresh launch worked */
  11. export function needsFreshLaunch(compat: WallpaperCompat | undefined): boolean {
  12. return !!compat?.hotswapCrash
  13. }
  14. export const COMPAT_LABELS: Record<CompatStatus, MessageKey> = {
  15. ok: 'compat.ok',
  16. crashes: 'compat.crashes',
  17. 'hotswap-only': 'compat.hotswapOnly',
  18. 'hotswap-untested': 'compat.hotswapUntested',
  19. unstable: 'compat.unstable'
  20. }