diff options
| author | 2026-02-25 02:06:07 +0800 | |
|---|---|---|
| committer | 2026-02-25 02:06:07 +0800 | |
| commit | 78ac61904d78d558d092eff08c9f261cbdb187e8 (patch) | |
| tree | 96f68d1f1554ee3a0532793afaaa52b0c73dcbec /packages/ui/src/types | |
| parent | 8ff3af6cb908fd824b512379dd21ed4f595ab6bb (diff) | |
| parent | 329734b23957b84cde2af459fa61c7385fb5b5f1 (diff) | |
| download | DropOut-78ac61904d78d558d092eff08c9f261cbdb187e8.tar.gz DropOut-78ac61904d78d558d092eff08c9f261cbdb187e8.zip | |
feat(ui): partial react rewrite (#77)
## Summary by Sourcery
Export backend data structures to TypeScript for the new React-based UI
and update CI to build additional targets.
New Features:
- Generate TypeScript definitions for core backend structs and enums
used by the UI.
- Now use our own Azure app(_DropOut_) to finish the authorize process.
Enhancements:
- Annotate existing Rust models with ts-rs metadata to control exported
TypeScript shapes, including tagged enums and opaque JSON fields.
Build:
- Add ts-rs as a dependency for generating TypeScript bindings from Rust
types.
CI:
- Extend the Semifold CI workflow to run on the dev branch and build
additional Linux musl and Windows GNU targets using cross where needed.
Diffstat (limited to 'packages/ui/src/types')
18 files changed, 607 insertions, 232 deletions
diff --git a/packages/ui/src/types/bindings/account.ts b/packages/ui/src/types/bindings/account.ts new file mode 100644 index 0000000..168d138 --- /dev/null +++ b/packages/ui/src/types/bindings/account.ts @@ -0,0 +1,28 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { OfflineAccount } from "./auth"; + +export type AccountStorage = { file_path: string }; + +/** + * Stored account data for persistence + */ +export type AccountStore = { + accounts: Array<StoredAccount>; + active_account_id: string | null; +}; + +export type StoredAccount = + | ({ type: "Offline" } & OfflineAccount) + | ({ type: "Microsoft" } & StoredMicrosoftAccount); + +/** + * Microsoft account with refresh token for persistence + */ +export type StoredMicrosoftAccount = { + username: string; + uuid: string; + access_token: string; + refresh_token: string | null; + ms_refresh_token: string | null; + expires_at: bigint; +}; diff --git a/packages/ui/src/types/bindings/assistant.ts b/packages/ui/src/types/bindings/assistant.ts new file mode 100644 index 0000000..827f008 --- /dev/null +++ b/packages/ui/src/types/bindings/assistant.ts @@ -0,0 +1,25 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type GenerationStats = { + totalDuration: bigint; + loadDuration: bigint; + promptEvalCount: bigint; + promptEvalDuration: bigint; + evalCount: bigint; + evalDuration: bigint; +}; + +export type Message = { role: string; content: string }; + +export type ModelInfo = { + id: string; + name: string; + size: string | null; + details: string | null; +}; + +export type StreamChunk = { + content: string; + done: boolean; + stats: GenerationStats | null; +}; diff --git a/packages/ui/src/types/bindings/auth.ts b/packages/ui/src/types/bindings/auth.ts new file mode 100644 index 0000000..563a924 --- /dev/null +++ b/packages/ui/src/types/bindings/auth.ts @@ -0,0 +1,32 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Account = + | ({ type: "offline" } & OfflineAccount) + | ({ type: "microsoft" } & MicrosoftAccount); + +export type DeviceCodeResponse = { + userCode: string; + deviceCode: string; + verificationUri: string; + expiresIn: bigint; + interval: bigint; + message: string | null; +}; + +export type MicrosoftAccount = { + username: string; + uuid: string; + accessToken: string; + refreshToken: string | null; + expiresAt: bigint; +}; + +export type MinecraftProfile = { id: string; name: string }; + +export type OfflineAccount = { username: string; uuid: string }; + +export type TokenResponse = { + access_token: string; + refresh_token: string | null; + expires_in: bigint; +}; diff --git a/packages/ui/src/types/bindings/config.ts b/packages/ui/src/types/bindings/config.ts new file mode 100644 index 0000000..e9de4f5 --- /dev/null +++ b/packages/ui/src/types/bindings/config.ts @@ -0,0 +1,61 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type AssistantConfig = { + enabled: boolean; + llmProvider: string; + ollamaEndpoint: string; + ollamaModel: string; + openaiApiKey: string | null; + openaiEndpoint: string; + openaiModel: string; + systemPrompt: string; + responseLanguage: string; + ttsEnabled: boolean; + ttsProvider: string; +}; + +/** + * Feature-gated arguments configuration + */ +export type FeatureFlags = { + /** + * Demo user: enables demo-related arguments when rules require it + */ + demoUser: boolean; + /** + * Quick Play: enable quick play arguments + */ + quickPlayEnabled: boolean; + /** + * Quick Play singleplayer world path (if provided) + */ + quickPlayPath: string | null; + /** + * Quick Play singleplayer flag + */ + quickPlaySingleplayer: boolean; + /** + * Quick Play multiplayer server address (optional) + */ + quickPlayMultiplayerServer: string | null; +}; + +export type LauncherConfig = { + minMemory: number; + maxMemory: number; + javaPath: string; + width: number; + height: number; + downloadThreads: number; + customBackgroundPath: string | null; + enableGpuAcceleration: boolean; + enableVisualEffects: boolean; + activeEffect: string; + theme: string; + logUploadService: string; + pastebinApiKey: string | null; + assistant: AssistantConfig; + useSharedCaches: boolean; + keepLegacyPerInstanceStorage: boolean; + featureFlags: FeatureFlags; +}; diff --git a/packages/ui/src/types/bindings/core.ts b/packages/ui/src/types/bindings/core.ts new file mode 100644 index 0000000..94e3bde --- /dev/null +++ b/packages/ui/src/types/bindings/core.ts @@ -0,0 +1,47 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * File information for instance file browser + */ +export type FileInfo = { + name: string; + path: string; + isDirectory: boolean; + size: bigint; + modified: bigint; +}; + +export type GithubRelease = { + tagName: string; + name: string; + publishedAt: string; + body: string; + htmlUrl: string; +}; + +/** + * Installed version info + */ +export type InstalledVersion = { id: string; type: string }; + +/** + * Migrate instance caches to shared global caches + */ +export type MigrationResult = { + movedFiles: number; + hardlinks: number; + copies: number; + savedBytes: bigint; + savedMb: number; +}; + +export type PastebinResponse = { url: string }; + +/** + * Version metadata for display in the UI + */ +export type VersionMetadata = { + id: string; + javaVersion: bigint | null; + isInstalled: boolean; +}; diff --git a/packages/ui/src/types/bindings/downloader.ts b/packages/ui/src/types/bindings/downloader.ts new file mode 100644 index 0000000..f2be278 --- /dev/null +++ b/packages/ui/src/types/bindings/downloader.ts @@ -0,0 +1,73 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * Metadata for resumable downloads stored in .part.meta file + */ +export type DownloadMetadata = { + url: string; + fileName: string; + totalSize: bigint; + downloadedBytes: bigint; + checksum: string | null; + timestamp: bigint; + segments: Array<DownloadSegment>; +}; + +/** + * Download queue for persistence + */ +export type DownloadQueue = { pendingDownloads: Array<PendingJavaDownload> }; + +/** + * A download segment for multi-segment parallel downloading + */ +export type DownloadSegment = { + start: bigint; + end: bigint; + downloaded: bigint; + completed: boolean; +}; + +export type DownloadTask = { + url: string; + path: string; + sha1: string | null; + sha256: string | null; +}; + +/** + * Progress event for Java download + */ +export type JavaDownloadProgress = { + fileName: string; + downloadedBytes: bigint; + totalBytes: bigint; + speedBytesPerSec: bigint; + etaSeconds: bigint; + status: string; + percentage: number; +}; + +/** + * Pending download task for queue persistence + */ +export type PendingJavaDownload = { + majorVersion: number; + imageType: string; + downloadUrl: string; + fileName: string; + fileSize: bigint; + checksum: string | null; + installPath: string; + createdAt: bigint; +}; + +export type ProgressEvent = { + file: string; + downloaded: bigint; + total: bigint; + status: string; + completedFiles: number; + totalFiles: number; + totalDownloadedBytes: bigint; +}; diff --git a/packages/ui/src/types/bindings/fabric.ts b/packages/ui/src/types/bindings/fabric.ts new file mode 100644 index 0000000..181f8be --- /dev/null +++ b/packages/ui/src/types/bindings/fabric.ts @@ -0,0 +1,74 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * Represents a Minecraft version supported by Fabric. + */ +export type FabricGameVersion = { version: string; stable: boolean }; + +/** + * Represents a Fabric intermediary mapping version. + */ +export type FabricIntermediaryVersion = { + maven: string; + version: string; + stable: boolean; +}; + +/** + * Launcher metadata from Fabric Meta API. + */ +export type FabricLauncherMeta = { + version: number; + libraries: FabricLibraries; + mainClass: FabricMainClass; +}; + +/** + * Libraries required by Fabric loader. + */ +export type FabricLibraries = { + client: Array<FabricLibrary>; + common: Array<FabricLibrary>; + server: Array<FabricLibrary>; +}; + +/** + * A single Fabric library dependency. + */ +export type FabricLibrary = { name: string; url: string | null }; + +/** + * Represents a combined loader + intermediary version entry. + */ +export type FabricLoaderEntry = { + loader: FabricLoaderVersion; + intermediary: FabricIntermediaryVersion; + launcherMeta: FabricLauncherMeta; +}; + +/** + * Represents a Fabric loader version from the Meta API. + */ +export type FabricLoaderVersion = { + separator: string; + build: number; + maven: string; + version: string; + stable: boolean; +}; + +/** + * Main class configuration for Fabric. + * Can be either a struct with client/server fields or a simple string. + */ +export type FabricMainClass = { client: string; server: string } | string; + +/** + * Information about an installed Fabric version. + */ +export type InstalledFabricVersion = { + id: string; + minecraftVersion: string; + loaderVersion: string; + path: string; +}; diff --git a/packages/ui/src/types/bindings/forge.ts b/packages/ui/src/types/bindings/forge.ts new file mode 100644 index 0000000..a9790e7 --- /dev/null +++ b/packages/ui/src/types/bindings/forge.ts @@ -0,0 +1,21 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * Represents a Forge version entry. + */ +export type ForgeVersion = { + version: string; + minecraftVersion: string; + recommended: boolean; + latest: boolean; +}; + +/** + * Information about an installed Forge version. + */ +export type InstalledForgeVersion = { + id: string; + minecraftVersion: string; + forgeVersion: string; + path: string; +}; diff --git a/packages/ui/src/types/bindings/game-version.ts b/packages/ui/src/types/bindings/game-version.ts new file mode 100644 index 0000000..1b1c395 --- /dev/null +++ b/packages/ui/src/types/bindings/game-version.ts @@ -0,0 +1,89 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Arguments = { + game: Record<string, unknown>; + jvm: Record<string, unknown>; +}; + +export type AssetIndex = { + id: string; + sha1: string; + size: bigint; + url: string; + totalSize: bigint | null; +}; + +export type DownloadArtifact = { + sha1: string | null; + size: bigint | null; + url: string; + path: string | null; +}; + +export type Downloads = { + client: DownloadArtifact; + server: DownloadArtifact | null; +}; + +/** + * Represents a Minecraft version JSON, supporting both vanilla and modded (Fabric/Forge) formats. + * Modded versions use `inheritsFrom` to reference a parent vanilla version. + */ +export type GameVersion = { + id: string; + /** + * Optional for mod loaders that inherit from vanilla + */ + downloads: Downloads | null; + /** + * Optional for mod loaders that inherit from vanilla + */ + assetIndex: AssetIndex | null; + libraries: Array<Library>; + mainClass: string; + minecraftArguments: string | null; + arguments: Arguments | null; + javaVersion: JavaVersion | null; + /** + * For mod loaders: the vanilla version this inherits from + */ + inheritsFrom: string | null; + /** + * Fabric/Forge may specify a custom assets version + */ + assets: string | null; + /** + * Release type (release, snapshot, old_beta, etc.) + */ + type: string | null; +}; + +export type JavaVersion = { component: string; majorVersion: bigint }; + +export type Library = { + downloads: LibraryDownloads | null; + name: string; + rules: Array<Rule> | null; + natives: Record<string, unknown>; + /** + * Maven repository URL for mod loader libraries + */ + url: string | null; +}; + +export type LibraryDownloads = { + artifact: DownloadArtifact | null; + classifiers: Record<string, unknown>; +}; + +export type OsRule = { + name: string | null; + version: string | null; + arch: string | null; +}; + +export type Rule = { + action: string; + os: OsRule | null; + features: Record<string, unknown>; +}; diff --git a/packages/ui/src/types/bindings/index.ts b/packages/ui/src/types/bindings/index.ts new file mode 100644 index 0000000..9bde037 --- /dev/null +++ b/packages/ui/src/types/bindings/index.ts @@ -0,0 +1,12 @@ +export * from "./account"; +export * from "./assistant"; +export * from "./auth"; +export * from "./config"; +export * from "./core"; +export * from "./downloader"; +export * from "./fabric"; +export * from "./forge"; +export * from "./game-version"; +export * from "./instance"; +export * from "./java"; +export * from "./manifest"; diff --git a/packages/ui/src/types/bindings/instance.ts b/packages/ui/src/types/bindings/instance.ts new file mode 100644 index 0000000..2c4f8ae --- /dev/null +++ b/packages/ui/src/types/bindings/instance.ts @@ -0,0 +1,33 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * Represents a game instance/profile + */ +export type Instance = { + id: string; + name: string; + gameDir: string; + versionId: string | null; + createdAt: bigint; + lastPlayed: bigint | null; + iconPath: string | null; + notes: string | null; + modLoader: string | null; + modLoaderVersion: string | null; + jvmArgsOverride: string | null; + memoryOverride: MemoryOverride | null; + javaPathOverride: string | null; +}; + +/** + * Configuration for all instances + */ +export type InstanceConfig = { + instances: Array<Instance>; + activeInstanceId: string | null; +}; + +/** + * Memory settings override for an instance + */ +export type MemoryOverride = { min: number; max: number }; diff --git a/packages/ui/src/types/bindings/java/core.ts b/packages/ui/src/types/bindings/java/core.ts new file mode 100644 index 0000000..099dea9 --- /dev/null +++ b/packages/ui/src/types/bindings/java/core.ts @@ -0,0 +1,41 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type JavaCatalog = { + releases: Array<JavaReleaseInfo>; + availableMajorVersions: Array<number>; + ltsVersions: Array<number>; + cachedAt: bigint; +}; + +export type JavaDownloadInfo = { + version: string; + release_name: string; + download_url: string; + file_name: string; + file_size: bigint; + checksum: string | null; + image_type: string; +}; + +export type JavaInstallation = { + path: string; + version: string; + arch: string; + vendor: string; + source: string; + is64bit: boolean; +}; + +export type JavaReleaseInfo = { + majorVersion: number; + imageType: string; + version: string; + releaseName: string; + releaseDate: string | null; + fileSize: bigint; + checksum: string | null; + downloadUrl: string; + isLts: boolean; + isAvailable: boolean; + architecture: string; +}; diff --git a/packages/ui/src/types/bindings/java/index.ts b/packages/ui/src/types/bindings/java/index.ts new file mode 100644 index 0000000..2f2754c --- /dev/null +++ b/packages/ui/src/types/bindings/java/index.ts @@ -0,0 +1,3 @@ +export * from "./core"; +export * from "./persistence"; +export * from "./providers"; diff --git a/packages/ui/src/types/bindings/java/persistence.ts b/packages/ui/src/types/bindings/java/persistence.ts new file mode 100644 index 0000000..7a2b576 --- /dev/null +++ b/packages/ui/src/types/bindings/java/persistence.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type JavaConfig = { + user_defined_paths: Array<string>; + preferred_java_path: string | null; + last_detection_time: bigint; +}; diff --git a/packages/ui/src/types/bindings/java/providers/adoptium.ts b/packages/ui/src/types/bindings/java/providers/adoptium.ts new file mode 100644 index 0000000..65fc42b --- /dev/null +++ b/packages/ui/src/types/bindings/java/providers/adoptium.ts @@ -0,0 +1,37 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type AdoptiumAsset = { + binary: AdoptiumBinary; + release_name: string; + version: AdoptiumVersionData; +}; + +export type AdoptiumBinary = { + os: string; + architecture: string; + image_type: string; + package: AdoptiumPackage; + updated_at: string | null; +}; + +export type AdoptiumPackage = { + name: string; + link: string; + size: bigint; + checksum: string | null; +}; + +export type AdoptiumVersionData = { + major: number; + minor: number; + security: number; + semver: string; + openjdk_version: string; +}; + +export type AvailableReleases = { + available_releases: Array<number>; + available_lts_releases: Array<number>; + most_recent_lts: number | null; + most_recent_feature_release: number | null; +}; diff --git a/packages/ui/src/types/bindings/java/providers/index.ts b/packages/ui/src/types/bindings/java/providers/index.ts new file mode 100644 index 0000000..3e28711 --- /dev/null +++ b/packages/ui/src/types/bindings/java/providers/index.ts @@ -0,0 +1 @@ +export * from "./adoptium"; diff --git a/packages/ui/src/types/bindings/manifest.ts b/packages/ui/src/types/bindings/manifest.ts new file mode 100644 index 0000000..2180962 --- /dev/null +++ b/packages/ui/src/types/bindings/manifest.ts @@ -0,0 +1,22 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Latest = { release: string; snapshot: string }; + +export type Version = { + id: string; + type: string; + url: string; + time: string; + releaseTime: string; + /** + * Java version requirement (major version number) + * This is populated from the version JSON file if the version is installed locally + */ + javaVersion: bigint | null; + /** + * Whether this version is installed locally + */ + isInstalled: boolean | null; +}; + +export type VersionManifest = { latest: Latest; versions: Array<Version> }; diff --git a/packages/ui/src/types/index.ts b/packages/ui/src/types/index.ts index b4412b8..9e592d7 100644 --- a/packages/ui/src/types/index.ts +++ b/packages/ui/src/types/index.ts @@ -1,232 +1 @@ -export type ViewType = "home" | "versions" | "settings" | "guide" | "instances"; - -export interface Version { - id: string; - type: string; - url: string; - time: string; - releaseTime: string; - javaVersion?: number; // Java major version requirement (e.g., 8, 17, 21) - isInstalled?: boolean; // Whether this version is installed locally -} - -export interface Account { - type: "Offline" | "Microsoft"; - username: string; - uuid: string; - access_token?: string; - refresh_token?: string; - expires_at?: number; // Unix timestamp for Microsoft accounts -} - -export interface DeviceCodeResponse { - user_code: string; - device_code: string; - verification_uri: string; - expires_in: number; - interval: number; - message?: string; -} - -export interface AssistantConfig { - enabled: boolean; - llm_provider: "ollama" | "openai"; - // Ollama settings - ollama_endpoint: string; - ollama_model: string; - // OpenAI settings - openai_api_key?: string; - openai_endpoint: string; - openai_model: string; - // Common settings - system_prompt: string; - response_language: string; - // TTS settings - tts_enabled: boolean; - tts_provider: string; -} - -export interface ModelInfo { - id: string; - name: string; - size?: string; - details?: string; -} - -export interface LauncherConfig { - min_memory: number; - max_memory: number; - java_path: string; - width: number; - height: number; - download_threads: number; - custom_background_path?: string; - enable_gpu_acceleration: boolean; - enable_visual_effects: boolean; - active_effect: string; - theme: string; - log_upload_service: "paste.rs" | "pastebin.com"; - pastebin_api_key?: string; - assistant: AssistantConfig; - // Storage management - use_shared_caches: boolean; - keep_legacy_per_instance_storage: boolean; - // Feature-gated argument flags - feature_flags: FeatureFlags; -} - -export interface FeatureFlags { - demo_user: boolean; - quick_play_enabled: boolean; - quick_play_path?: string; - quick_play_singleplayer: boolean; - quick_play_multiplayer_server?: string; -} - -export interface JavaInstallation { - path: string; - version: string; - is_64bit: boolean; -} - -export interface JavaDownloadInfo { - version: string; - release_name: string; - download_url: string; - file_name: string; - file_size: number; - checksum: string | null; - image_type: string; -} - -export interface JavaReleaseInfo { - major_version: number; - image_type: string; - version: string; - release_name: string; - release_date: string | null; - file_size: number; - checksum: string | null; - download_url: string; - is_lts: boolean; - is_available: boolean; - architecture: string; -} - -export interface JavaCatalog { - releases: JavaReleaseInfo[]; - available_major_versions: number[]; - lts_versions: number[]; - cached_at: number; -} - -export interface JavaDownloadProgress { - file_name: string; - downloaded_bytes: number; - total_bytes: number; - speed_bytes_per_sec: number; - eta_seconds: number; - status: string; - percentage: number; -} - -export interface PendingJavaDownload { - major_version: number; - image_type: string; - download_url: string; - file_name: string; - file_size: number; - checksum: string | null; - install_path: string; - created_at: number; -} - -export type JavaDownloadSource = "adoptium" | "mojang" | "azul"; - -// ==================== Fabric Types ==================== - -export interface FabricGameVersion { - version: string; - stable: boolean; -} - -export interface FabricLoaderVersion { - separator: string; - build: number; - maven: string; - version: string; - stable: boolean; -} - -export interface FabricLoaderEntry { - loader: FabricLoaderVersion; - intermediary: { - maven: string; - version: string; - stable: boolean; - }; - launcherMeta: { - version: number; - mainClass: { - client: string; - server: string; - }; - }; -} - -export interface InstalledFabricVersion { - id: string; - minecraft_version: string; - loader_version: string; - path: string; -} - -// ==================== Forge Types ==================== - -export interface ForgeVersion { - version: string; - minecraft_version: string; - recommended: boolean; - latest: boolean; -} - -export interface InstalledForgeVersion { - id: string; - minecraft_version: string; - forge_version: string; - path: string; -} - -// ==================== Mod Loader Type ==================== - -export type ModLoaderType = "vanilla" | "fabric" | "forge"; - -// ==================== Instance Types ==================== - -export interface Instance { - id: string; - name: string; - game_dir: string; - version_id?: string; - created_at: number; - last_played?: number; - icon_path?: string; - notes?: string; - mod_loader?: string; - mod_loader_version?: string; - jvm_args_override?: string; - memory_override?: MemoryOverride; -} - -export interface MemoryOverride { - min: number; // MB - max: number; // MB -} - -export interface FileInfo { - name: string; - path: string; - is_directory: boolean; - size: number; - modified: number; -} +export * from "./bindings"; |