- Pure-Go HFS+ offline helper disk (REIMSHELP) bypassing Recovery's missing pkgutil & read-only installer target, with automatic blank-disk APFS formatting and non-blank safety confirmation - Recovery mode UX: rename Finish install to Exit recovery mode, add Enter recovery mode via OpenCore boot picker (--boot-selection), show Attach offline image on VM page with ~1 GB Apple online recovery fallback download - Pre-apply WHPX kernel-irqchip=off when nested-virt probe fails and filter benign TSC deadline timer warnings - QMP keyboard typing (type clipboard / one-click Recovery command) and offline-install network toggle
42 lines
1.7 KiB
TypeScript
42 lines
1.7 KiB
TypeScript
import { t } from '../i18n'
|
|
import { Locale, Task } from '../types'
|
|
|
|
/** Insert or replace a task by id; events can arrive out of order, keep the newest. */
|
|
export function upsertTask(prev: Record<string, Task>, task: Task): Record<string, Task> {
|
|
const cur = prev[task.id]
|
|
if (cur && cur.updated_at > task.updated_at && cur.status !== 'running') return prev
|
|
return { ...prev, [task.id]: task }
|
|
}
|
|
|
|
/** The task to show in the status bar: the most recently updated running one. */
|
|
export function currentTask(all: Record<string, Task>): { task: Task | null; running: number } {
|
|
const running = Object.values(all).filter((x) => x.status === 'running')
|
|
running.sort((a, b) => b.updated_at - a.updated_at)
|
|
return { task: running[0] ?? null, running: running.length }
|
|
}
|
|
|
|
/** Localized title; the upstream step (English) goes in the tooltip. */
|
|
export function taskTitle(locale: Locale, task: Task): string {
|
|
switch (task.kind) {
|
|
case 'installer-download': return t(locale, 'taskDownload', { v: task.subject })
|
|
case 'recovery-download': return t(locale, 'taskRecoveryDownload', { name: task.subject })
|
|
case 'vm-create': return t(locale, 'taskCreate', { name: task.subject })
|
|
case 'runtime-install': return t(locale, 'taskRuntime', { v: task.subject })
|
|
default: return task.subject
|
|
}
|
|
}
|
|
|
|
/** "8.3 / 18.4 GB · 42 MB/s" */
|
|
export function taskDetail(task: Task): string {
|
|
const parts: string[] = []
|
|
if (task.total > 0) parts.push(`${bytes(task.done)} / ${bytes(task.total)}`)
|
|
else if (task.done > 0) parts.push(bytes(task.done))
|
|
if (task.rate > 0) parts.push(`${bytes(task.rate)}/s`)
|
|
return parts.join(' · ')
|
|
}
|
|
|
|
function bytes(b: number): string {
|
|
if (b >= 1e9) return `${(b / 1e9).toFixed(1)} GB`
|
|
return `${Math.max(1, Math.ceil(b / 1e6))} MB`
|
|
}
|