diff options
| author | 2026-03-26 09:02:10 +0800 | |
|---|---|---|
| committer | 2026-03-26 09:02:10 +0800 | |
| commit | 94b0d8e208363c802c12b56d8bdbef574dd1fb91 (patch) | |
| tree | e86c8d46e73262c67c1755aaf4202cbcd1f8f844 /packages/ui/src/client.ts | |
| parent | 7d0e92e6d3b172adfe552ffae9b97f8dad6f63ae (diff) | |
| parent | 3a31d3004b2814cd8a26d49a0f8a96636411dcd2 (diff) | |
| download | DropOut-94b0d8e208363c802c12b56d8bdbef574dd1fb91.tar.gz DropOut-94b0d8e208363c802c12b56d8bdbef574dd1fb91.zip | |
Add game lifecycle management and instance import/export tools (#117)
## Summary by Sourcery
Add centralized game process and instance lifecycle management, shared
cache-aware path resolution, and instance import/export/repair
capabilities across backend and UI.
New Features:
- Track a single running game process in the backend, expose stop-game
control, and emit structured game-exited events with instance and
version context.
- Introduce instance path resolution that supports shared caches for
versions, libraries, and assets, and use it across game start, install,
and version management APIs.
- Add import, export, and repair operations for instances, including
zip-based archive support and automatic recovery of on-disk instances.
- Expose new instance lifecycle and repair APIs to the frontend and wire
them through the client and instance store.
- Add per-instance start/stop controls in the instances view and
instance selection in the bottom bar for launching games.
Enhancements:
- Guard instance operations with per-instance locks and track active
operations such as launch, install, delete, and import/export.
- Improve handling of Microsoft login errors and polling status, with
clearer user feedback and safer interval management.
- Simplify config mutation during shared cache migration and centralize
instance directory resolution in the backend.
- Initialize a game lifecycle listener at app startup to keep UI state
in sync with backend game exit events.
Build:
- Configure the Vite dev server to use a fixed localhost host and port
for the UI dev environment.
Diffstat (limited to 'packages/ui/src/client.ts')
| -rw-r--r-- | packages/ui/src/client.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/packages/ui/src/client.ts b/packages/ui/src/client.ts index 18d2377..6f354d2 100644 --- a/packages/ui/src/client.ts +++ b/packages/ui/src/client.ts @@ -12,6 +12,7 @@ import type { InstalledForgeVersion, InstalledVersion, Instance, + InstanceRepairResult, JavaCatalog, JavaDownloadInfo, JavaInstallation, @@ -119,6 +120,16 @@ export function duplicateInstance( }); } +export function exportInstance( + instanceId: string, + archivePath: string, +): Promise<string> { + return invoke<string>("export_instance", { + instanceId, + archivePath, + }); +} + export function fetchAdoptiumJava( majorVersion: number, imageType: string, @@ -267,6 +278,16 @@ export function installVersion( }); } +export function importInstance( + archivePath: string, + newName?: string, +): Promise<Instance> { + return invoke<Instance>("import_instance", { + archivePath, + newName, + }); +} + export function isFabricInstalled( instanceId: string, gameVersion: string, @@ -351,6 +372,10 @@ export function refreshJavaCatalog(): Promise<JavaCatalog> { return invoke<JavaCatalog>("refresh_java_catalog"); } +export function repairInstances(): Promise<InstanceRepairResult> { + return invoke<InstanceRepairResult>("repair_instances"); +} + export function resumeJavaDownloads(): Promise<JavaInstallation[]> { return invoke<JavaInstallation[]>("resume_java_downloads"); } @@ -383,6 +408,10 @@ export function startGame( }); } +export function stopGame(): Promise<string> { + return invoke<string>("stop_game"); +} + export function startMicrosoftLogin(): Promise<DeviceCodeResponse> { return invoke<DeviceCodeResponse>("start_microsoft_login"); } |