feat(launcher): add maintenance for installed game copies

This commit is contained in:
N0VAN0M4LY committed 2026-11-29 15:24:21 +08:00
1 parent 7d68dc0548
commit ef3648cb13
17 files changed
+672 -24

No files matched your search

+6
View File
@@ -18,6 +18,12 @@ export const APP_ERROR_CODES = [
'diagnostics_export_failed',
'copy_not_found',
'copies_write_failed',
'maintenance_busy',
'maintenance_location',
'maintenance_no_update',
'maintenance_cancelled',
'maintenance_failed',
'maintenance_source_changed',
'copy_location_in_use',
'launch_no_copy',
'launch_busy',
+14
View File
@@ -14,6 +14,7 @@ import {
TargetFolderInspectionSchema,
} from '../schemas/install.ts';
import { LabInfoSchema, LaunchStateSchema } from '../schemas/launch.ts';
import { MaintenanceInfoSchema, MaintenanceProgressSchema, MaintenanceRequestSchema } from '../schemas/maintenance.ts';
import { SettingsPatchSchema, SettingsSchema } from '../schemas/settings.ts';
/**
@@ -114,6 +115,18 @@ export const ipcContract = {
input: z.object({ id: CopyIdSchema, name: CopyNameSchema }),
output: CopiesSchema,
},
'copies:maintenanceInfo': {
input: z.object({ id: CopyIdSchema }),
output: MaintenanceInfoSchema,
},
'copies:maintain': {
input: MaintenanceRequestSchema,
output: CopiesSchema,
},
'copies:cancelMaintenance': {
input: z.void(),
output: z.void(),
},
'launch:getState': {
input: z.void(),
output: LaunchStateSchema,
@@ -157,6 +170,7 @@ export const ipcEvents = {
'event:install-progress': InstallProgressSchema,
'event:launch-state': LaunchStateSchema,
'event:copies-changed': CopiesSchema,
'event:copy-maintenance': MaintenanceProgressSchema,
} as const;
export type IpcChannel = keyof typeof ipcContract;
@@ -133,6 +133,9 @@ export const InstallRecordSchema = z.object({
/** Patches that did not fit when the copy was installed; their features are missing. */
unavailablePatches: z.array(UnavailablePatchSchema),
installedAt: z.string(),
lastCheckedAt: z.string().optional(),
/** Relative paths read from the installation source during the last copy or update. */
sourceFiles: z.array(z.string().min(1)).optional(),
});
export type InstallRecord = z.output<typeof InstallRecordSchema>;
@@ -0,0 +1,24 @@
import { z } from 'zod';
import { CopyIdSchema } from './install.ts';
export const MaintenanceOperationSchema = z.enum(['check', 'repair', 'update', 'delete']);
export const MaintenanceRequestSchema = z.object({
id: CopyIdSchema,
operation: MaintenanceOperationSchema,
deleteData: z.boolean().default(false),
});
export const MaintenanceInfoSchema = z.object({
sourceVersion: z.string().nullable(),
updateAvailable: z.boolean(),
});
export const MaintenanceProgressSchema = z.object({
id: CopyIdSchema,
operation: MaintenanceOperationSchema,
phase: z.enum(['checking', 'copying', 'applying']),
doneBytes: z.number().nonnegative(),
totalBytes: z.number().nonnegative(),
});
export type MaintenanceRequest = z.output<typeof MaintenanceRequestSchema>;
export type MaintenanceInfo = z.output<typeof MaintenanceInfoSchema>;
export type MaintenanceProgress = z.output<typeof MaintenanceProgressSchema>;