diff options
| author | 2026-02-25 02:06:07 +0800 | |
|---|---|---|
| committer | 2026-02-25 02:06:07 +0800 | |
| commit | 78ac61904d78d558d092eff08c9f261cbdb187e8 (patch) | |
| tree | 96f68d1f1554ee3a0532793afaaa52b0c73dcbec /src-tauri/src/core/fabric.rs | |
| 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 'src-tauri/src/core/fabric.rs')
| -rw-r--r-- | src-tauri/src/core/fabric.rs | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/src-tauri/src/core/fabric.rs b/src-tauri/src/core/fabric.rs index 32790c7..a6ef236 100644 --- a/src-tauri/src/core/fabric.rs +++ b/src-tauri/src/core/fabric.rs @@ -8,11 +8,14 @@ use serde::{Deserialize, Serialize}; use std::error::Error; use std::path::PathBuf; +use ts_rs::TS; const FABRIC_META_URL: &str = "https://meta.fabricmc.net/v2"; /// Represents a Fabric loader version from the Meta API. -#[derive(Debug, Deserialize, Serialize, Clone)] +#[derive(Debug, Deserialize, Serialize, Clone, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export, export_to = "fabric.ts")] pub struct FabricLoaderVersion { pub separator: String, pub build: i32, @@ -22,7 +25,9 @@ pub struct FabricLoaderVersion { } /// Represents a Fabric intermediary mapping version. -#[derive(Debug, Deserialize, Serialize, Clone)] +#[derive(Debug, Deserialize, Serialize, Clone, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export, export_to = "fabric.ts")] pub struct FabricIntermediaryVersion { pub maven: String, pub version: String, @@ -30,7 +35,9 @@ pub struct FabricIntermediaryVersion { } /// Represents a combined loader + intermediary version entry. -#[derive(Debug, Deserialize, Serialize, Clone)] +#[derive(Debug, Deserialize, Serialize, Clone, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export, export_to = "fabric.ts")] pub struct FabricLoaderEntry { pub loader: FabricLoaderVersion, pub intermediary: FabricIntermediaryVersion, @@ -39,7 +46,9 @@ pub struct FabricLoaderEntry { } /// Launcher metadata from Fabric Meta API. -#[derive(Debug, Deserialize, Serialize, Clone)] +#[derive(Debug, Deserialize, Serialize, Clone, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export, export_to = "fabric.ts")] pub struct FabricLauncherMeta { pub version: i32, pub libraries: FabricLibraries, @@ -48,7 +57,9 @@ pub struct FabricLauncherMeta { } /// Libraries required by Fabric loader. -#[derive(Debug, Deserialize, Serialize, Clone)] +#[derive(Debug, Deserialize, Serialize, Clone, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export, export_to = "fabric.ts")] pub struct FabricLibraries { pub client: Vec<FabricLibrary>, pub common: Vec<FabricLibrary>, @@ -56,7 +67,9 @@ pub struct FabricLibraries { } /// A single Fabric library dependency. -#[derive(Debug, Deserialize, Serialize, Clone)] +#[derive(Debug, Deserialize, Serialize, Clone, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export, export_to = "fabric.ts")] pub struct FabricLibrary { pub name: String, pub url: Option<String>, @@ -64,7 +77,9 @@ pub struct FabricLibrary { /// Main class configuration for Fabric. /// Can be either a struct with client/server fields or a simple string. -#[derive(Debug, Deserialize, Serialize, Clone)] +#[derive(Debug, Deserialize, Serialize, Clone, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export, export_to = "fabric.ts", untagged)] #[serde(untagged)] pub enum FabricMainClass { Structured { client: String, server: String }, @@ -89,14 +104,18 @@ impl FabricMainClass { } /// Represents a Minecraft version supported by Fabric. -#[derive(Debug, Deserialize, Serialize, Clone)] +#[derive(Debug, Deserialize, Serialize, Clone, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export, export_to = "fabric.ts")] pub struct FabricGameVersion { pub version: String, pub stable: bool, } /// Information about an installed Fabric version. -#[derive(Debug, Serialize, Clone)] +#[derive(Debug, Serialize, Clone, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export, export_to = "fabric.ts")] pub struct InstalledFabricVersion { pub id: String, pub minecraft_version: String, @@ -108,8 +127,8 @@ pub struct InstalledFabricVersion { /// /// # Returns /// A list of game versions that have Fabric intermediary mappings available. -pub async fn fetch_supported_game_versions( -) -> Result<Vec<FabricGameVersion>, Box<dyn Error + Send + Sync>> { +pub async fn fetch_supported_game_versions() +-> Result<Vec<FabricGameVersion>, Box<dyn Error + Send + Sync>> { let url = format!("{}/versions/game", FABRIC_META_URL); let resp = reqwest::get(&url) .await? @@ -122,8 +141,8 @@ pub async fn fetch_supported_game_versions( /// /// # Returns /// A list of all Fabric loader versions, ordered by build number (newest first). -pub async fn fetch_loader_versions( -) -> Result<Vec<FabricLoaderVersion>, Box<dyn Error + Send + Sync>> { +pub async fn fetch_loader_versions() +-> Result<Vec<FabricLoaderVersion>, Box<dyn Error + Send + Sync>> { let url = format!("{}/versions/loader", FABRIC_META_URL); let resp = reqwest::get(&url) .await? |