Export the active client's wto_ws.log, latest .clog (bounded to 16 MiB), and a client-logs/summary.json metadata snapshot in diagnostics ZIPs without touching player saves. Log build completion, game launch arguments, PID, runtime duration, and hex-annotated Windows NTSTATUS/HRESULT exit codes in the launcher log and status bar. Checked: root typecheck, launcher typecheck, launcher electron-vite build, and exit code formatter runtime check.
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { z } from 'zod';
|
|
import { APP_ERROR_CODES } from '../errors.ts';
|
|
|
|
const GameExitSchema = z.object({
|
|
code: z.number().int().nullable(),
|
|
signal: z.string().nullable(),
|
|
logFolder: z.string(),
|
|
});
|
|
|
|
export type GameExit = z.output<typeof GameExitSchema>;
|
|
|
|
/** Append the unsigned 32-bit hex form for Windows NTSTATUS/HRESULT exit codes. */
|
|
export function formatExitCode(code: number): string {
|
|
if (code >= 0 && code <= 0xffff) return String(code);
|
|
return `${code} (0x${(code >>> 0).toString(16).toUpperCase().padStart(8, '0')})`;
|
|
}
|
|
|
|
export const LaunchStateSchema = z.object({
|
|
phase: z.enum([
|
|
'ready', 'checking', 'building', 'starting-server', 'starting-game', 'running',
|
|
'server-running', 'game-exited', 'stopping', 'port-busy', 'version-changed', 'server-exited', 'failed',
|
|
]),
|
|
copyId: z.uuid().optional(),
|
|
port: z.number().int().min(1).max(65535).optional(),
|
|
filesWritten: z.number().int().nonnegative().optional(),
|
|
filesTotal: z.number().int().nonnegative().optional(),
|
|
file: z.string().optional(),
|
|
actualVersion: z.string().nullable().optional(),
|
|
gameExit: GameExitSchema.optional(),
|
|
error: z.enum(APP_ERROR_CODES).optional(),
|
|
});
|
|
|
|
export type LaunchState = z.output<typeof LaunchStateSchema>;
|
|
|
|
export const LabInfoSchema = z.object({
|
|
copyPath: z.string(),
|
|
port: z.number().int().min(1).max(65535),
|
|
});
|