Files
Reims-Go/frontend/src/types.ts
T
NwflowerandClaude Opus 5.5 7cb6d5f910 refactor(frontend): move self-contained state out of App
Appearance, VM busy state, the in-app update, file drops and the theme event
stream are now hooks in lib/. VMAction moved to types.ts, so the VM page and
its parts no longer import each other, and error toasts have one builder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 22:02:05 -07:00

236 lines
8.0 KiB
TypeScript

// Backend types come from the Wails-generated models (wailsjs/go/models.ts,
// regenerated by `wails dev` / `wails build`). This file only adds what Go
// cannot say: string unions, and `| null` for slices Go may send as nil.
import { app, config, driver, host, installer, opencore, plugin, reims, runtime, version } from '../wailsjs/go/models'
/** A generated class as a plain data shape (no convertValues helper). */
type Model<T> = Omit<T, 'convertValues'>
export type BuiltinLocale = 'zh-CN' | 'en-US'
export type Locale = BuiltinLocale | (string & {})
export type Config = Model<config.Config> & {
locale: Locale
runtime_channel?: 'stable' | 'alpha' | ''
}
export type DisplayInfo = host.DisplayInfo
export type DisplayPreset = host.DisplayPreset
export type LogicalCPUInfo = host.LogicalCPUInfo
type GPUCompat = 'supported' | 'warn' | 'unsupported' | 'unknown'
export type GPUInfo = Omit<Model<host.GPUInfo>, 'compat'> & {
kind: 'discrete' | 'integrated' | 'virtual' | 'unknown'
compat?: GPUCompat
}
export type OptimizationStatus = 'recommended' | 'available' | 'experimental' | 'auto' | 'unavailable'
export type Optimization = Model<host.Optimization> & {
id: 'pcore_pin' | 'kernel_irqchip' | 'cold_reboot' | 'discrete_gpu' | string
status: OptimizationStatus
}
export type HostReport = Omit<Model<host.Report>, 'gpus' | 'recommended_gpu'> & {
whpx: 'ready' | 'hypervisor_off' | 'no_hypervisor' | 'missing' | 'unsupported'
pending_hypervisor_boot?: 'auto' | 'off' | ''
gpus: GPUInfo[]
recommended_gpu?: GPUInfo
}
export type InstalledRuntime = Model<runtime.Installed>
export type RemoteRuntime = Model<runtime.Remote> & {
channel: 'stable' | 'alpha'
}
type VMState = 'running' | 'stopped' | 'suspended' | 'broken' | 'driver_unavailable'
type VMPhase = 'normal' | 'installer' | 'recovery'
type GuestOSInfo = Model<driver.GuestOSInfo>
export type VMEndpoint = Model<driver.VMEndpoint> & {
kind: 'ssh' | 'wsl' | 'rdp' | 'vmconnect' | 'adb' | (string & {})
}
export type VMListItem = Omit<Model<driver.VMListItem>, 'guest_os' | 'phase' | 'endpoints'> & {
driver_id?: string
state: VMState
guest_os?: GuestOSInfo
phase?: VMPhase | (string & {})
endpoints?: VMEndpoint[]
}
/** The cross-driver VM model (GetVMInfo); the only detail a non-macOS VM has. */
export type VMInfo = Omit<Model<driver.VMInfo>, 'guest_os' | 'phase' | 'endpoints'> & {
guest_os?: GuestOSInfo
phase?: VMPhase | (string & {})
endpoints?: VMEndpoint[]
}
export type PendingChange = app.PendingChange
export type AppState = Omit<Model<app.AppState>, 'config' | 'host' | 'optimizations' | 'runtimes' | 'active_runtime' | 'vms'> & {
config: Config
host: HostReport
optimizations?: Optimization[]
runtimes: InstalledRuntime[] | null
active_runtime?: InstalledRuntime
vms: VMListItem[] | null
vm_list_error?: string
}
export type AppUpdateInfo = version.UpdateInfo
export type VMDetail = reims.VMDetail
export type SMBIOSIdentity = opencore.SMBIOSIdentity
export type VMStats = app.VMStats
export type VMNetworkSettings = Model<app.VMNetworkSettings>
export type VMNetworkPlan = Model<app.VMNetworkPlan>
export type DriveShareSettings = Model<app.DriveShareSettings>
export type SharedFolderInfo = Model<app.SharedFolderInfo>
export type SharedFolderSettings = Model<app.SharedFolderSettings>
export type SharedFolderMode = 'disabled' | 'ro' | 'rw'
export type VMAffinityMode = 'auto' | 'all' | 'pcores' | 'non_lpe' | 'custom'
export type VMAffinityUpdate = {
mode: VMAffinityMode
cpus?: number[]
disable_eco_qos: boolean
}
export type VMAffinityStatus = Omit<Model<app.VMAffinityStatus>, 'mode' | 'effective_mode'> & {
mode: VMAffinityMode
effective_mode: VMAffinityMode
}
/** One frame of a VM's screen (internal/app/thumbnail_flow.go). Empty data_url: none yet. */
export type VMThumbnail = app.VMThumbnail
export type ValidationIssue = reims.ValidationIssue
export type DiskResizeResult = driver.DiskResizeResult
export type DiskCompactResult = driver.DiskCompactResult
export type DiskSnapshot = driver.DiskSnapshot
export type StorageBreakdown = Model<app.StorageBreakdown>
export type SetOpts = reims.SetOpts
export type CreateOpts = Model<reims.CreateOpts> & {
network_mode?: 'off' | 'nat' | 'bridge'
uplink_guid?: string
source_mode?: 'offline' | 'apple' | 'installer' | 'disk'
disk_mode?: 'copy' | 'in-place'
disk_controller?: 'nvme' | 'ahci' | 'virtio'
graphics: 'reims-vgpu' | 'vmware-svga'
cpus: number
memory: string
gpu: string
resolution: string
displays: number
}
type TaskStatus = 'running' | 'done' | 'failed' | 'canceled'
export type InstallerKind = 'offline' | 'online'
export type InstallerPhase = 'queued' | 'downloading'
/** A tracked long-running job pushed as "reims:task" (internal/app/tasks.go). */
export type Task = Model<app.Task> & {
kind: 'installer-download' | 'recovery-download' | 'vm-create' | 'runtime-install' | 'app-update' | string
installer_kind?: InstallerKind | ''
installer_phase?: InstallerPhase | ''
status: TaskStatus
}
/** An offline installer Apple offers (`reims-util offline-installer list`). */
export type Release = installer.Release
/** A file kept in the installers directory. */
export type CachedInstaller = Model<installer.Cached> & {
kind: 'offline' | 'online' | 'ipsw' | 'other'
}
export type DataRootChoice = app.DataRootChoice
export type DataRootCheck = app.DataRootCheck
export type LocalizedText = plugin.LocalizedText
export type PermissionSpec = plugin.PermissionSpec
export type SettingProperty = plugin.SettingProperty
export type SettingsSchema = plugin.SettingsSchema
export type PluginInfo = plugin.PluginInfo
export type ScanReport = plugin.ScanReport
export type MarketCatalogItem = plugin.MarketCatalogItem
export type MarketBrowseResult = plugin.MarketBrowseResult
export type TokenDeriveRule = plugin.TokenDeriveRule
export type ThemeDecoration = plugin.ThemeDecoration
export type ThemeDecorationState = plugin.ThemeDecorationState
export type CustomThemeScheme = plugin.CustomThemeScheme
export type ActiveThemePayload = plugin.ActiveThemePayload
interface ResolvedLocaleFont {
family: string
url: string
weight?: string
style?: string
unicodeRange?: string
}
export type ResolvedLocalePack = Model<plugin.ResolvedLocalePack> & {
has_ui_messages?: boolean
plugin_messages?: Record<string, Record<string, string>>
fonts?: ResolvedLocaleFont[]
}
export type PanelContribution = plugin.PanelContribution
export type ViewContribution = plugin.ViewContribution
export type ImageSourceContribution = plugin.ImageSourceContribution
export type PluginUIContributions = app.PluginUIContributions
export type DriverSummary = driver.DriverSummary
/** A "reims:log" event (internal/app/app.go emitLog); not a Go struct, so not generated. */
export type VMAction =
| 'start'
| 'suspend'
| 'resume'
| 'discardSuspend'
| 'stop'
| 'forceStop'
| 'restart'
| 'focus'
| 'fullscreen'
| 'screenshot'
| 'eject'
| 'finishInstall'
| 'enterRecovery'
| 'attachInstaller'
| 'attachGuestTools'
| 'detachGuestTools'
| 'openSharedFolder'
| 'upgradeNVMe'
| 'exportDiagnostics'
| 'cloneVM'
| 'type'
| 'sendText'
| 'delete'
| 'openFolder'
export type VMBusyAction = VMAction | 'pluginCommand'
export interface LogEntry {
ts: string
source: string
line: string
}
export type VMKeymapPreset = 'off' | 'win_to_cmd' | 'swap_alt_win' | 'custom'
export type VMKeymapHostModifier = 'lwin' | 'rwin' | 'lalt' | 'ralt' | 'lctrl' | 'rctrl' | 'capslock'
export type VMKeymapGuestModifier = 'default' | 'lcmd' | 'rcmd' | 'lopt' | 'ropt' | 'lctrl' | 'rctrl' | 'esc' | 'disabled'
export interface VMKeymapUpdate {
preset: VMKeymapPreset
bindings: Partial<Record<VMKeymapHostModifier, VMKeymapGuestModifier>>
capture_host_shortcuts?: boolean
}
export interface VMKeymapStatus extends VMKeymapUpdate {
capture_host_shortcuts: boolean
needs_guest_tools: boolean
guest_connected: boolean
guest_agent_version?: number
required_agent_version: number
input_service_available: boolean
guest_keymap_active: boolean
hook_active: boolean
running: boolean
}