feat(launcher): launch the game through the guarded lab

This commit is contained in:
N0VAN0M4LY committed 2026-11-29 15:02:39 +08:00
1 parent d633280e23
commit e41b73aaa3
25 files changed
+920 -23

No files matched your search

@@ -0,0 +1,22 @@
import { z } from 'zod';
import { APP_ERROR_CODES } from '../errors.ts';
export const LaunchStateSchema = z.object({
phase: z.enum([
'ready', 'checking', 'building', 'starting-server', 'starting-game', 'running',
'stopping', 'port-busy', 'version-changed', 'server-exited', 'failed',
]),
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(),
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),
});
@@ -3,6 +3,9 @@ import { LANGUAGE_CHOICES } from '../languages.ts';
import { BACKGROUND_RANDOM, BackgroundChoiceSchema } from './background.ts';
const LanguageChoiceSchema = z.enum(LANGUAGE_CHOICES);
const WindowCloseSchema = z.enum(['quit', 'tray']);
const AfterGameStartsSchema = z.enum(['minimize', 'keep']);
const LabPathSchema = z.string().min(1).nullable();
/** The launcher's own settings (not the game's, not the local service's tuning). */
export const SettingsSchema = z.object({
@@ -11,6 +14,11 @@ export const SettingsSchema = z.object({
background: BackgroundChoiceSchema.default(BACKGROUND_RANDOM),
/** Fetch wallpapers from the game website's public gallery. */
officialWallpapers: z.boolean().default(true),
windowClose: WindowCloseSchema.default('quit'),
afterGameStarts: AfterGameStartsSchema.default('minimize'),
developerMode: z.boolean().default(true),
labStockPath: LabPathSchema.default(null),
labDataPath: LabPathSchema.default(null),
});
export type Settings = z.output<typeof SettingsSchema>;
@@ -20,6 +28,11 @@ export const SettingsPatchSchema = z.object({
language: LanguageChoiceSchema.optional(),
background: BackgroundChoiceSchema.optional(),
officialWallpapers: z.boolean().optional(),
windowClose: WindowCloseSchema.optional(),
afterGameStarts: AfterGameStartsSchema.optional(),
developerMode: z.boolean().optional(),
labStockPath: LabPathSchema.optional(),
labDataPath: LabPathSchema.optional(),
});
export type SettingsPatch = z.output<typeof SettingsPatchSchema>;