aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src-tauri/src/core/fabric.rs
diff options
context:
space:
mode:
author苏向夜 <fu050409@163.com>2026-02-18 15:08:40 +0800
committer苏向夜 <fu050409@163.com>2026-02-18 15:08:40 +0800
commit1a103de2f1ef75cd73347953cbe27e14606df871 (patch)
treeeecb01f025bd9941aaa42ccebee02109cb5c7942 /src-tauri/src/core/fabric.rs
parent2c3de3ac5ab1ab59f7245ab9cbdfda9b4e96dcb0 (diff)
downloadDropOut-1a103de2f1ef75cd73347953cbe27e14606df871.tar.gz
DropOut-1a103de2f1ef75cd73347953cbe27e14606df871.zip
refactor(client): rewrite macros to generate client
Diffstat (limited to 'src-tauri/src/core/fabric.rs')
-rw-r--r--src-tauri/src/core/fabric.rs54
1 files changed, 13 insertions, 41 deletions
diff --git a/src-tauri/src/core/fabric.rs b/src-tauri/src/core/fabric.rs
index 7385850..a6ef236 100644
--- a/src-tauri/src/core/fabric.rs
+++ b/src-tauri/src/core/fabric.rs
@@ -15,10 +15,7 @@ const FABRIC_META_URL: &str = "https://meta.fabricmc.net/v2";
/// Represents a Fabric loader version from the Meta API.
#[derive(Debug, Deserialize, Serialize, Clone, TS)]
#[serde(rename_all = "camelCase")]
-#[ts(
- export,
- export_to = "../../packages/ui-new/src/types/bindings/fabric.ts"
-)]
+#[ts(export, export_to = "fabric.ts")]
pub struct FabricLoaderVersion {
pub separator: String,
pub build: i32,
@@ -30,10 +27,7 @@ pub struct FabricLoaderVersion {
/// Represents a Fabric intermediary mapping version.
#[derive(Debug, Deserialize, Serialize, Clone, TS)]
#[serde(rename_all = "camelCase")]
-#[ts(
- export,
- export_to = "../../packages/ui-new/src/types/bindings/fabric.ts"
-)]
+#[ts(export, export_to = "fabric.ts")]
pub struct FabricIntermediaryVersion {
pub maven: String,
pub version: String,
@@ -43,10 +37,7 @@ pub struct FabricIntermediaryVersion {
/// Represents a combined loader + intermediary version entry.
#[derive(Debug, Deserialize, Serialize, Clone, TS)]
#[serde(rename_all = "camelCase")]
-#[ts(
- export,
- export_to = "../../packages/ui-new/src/types/bindings/fabric.ts"
-)]
+#[ts(export, export_to = "fabric.ts")]
pub struct FabricLoaderEntry {
pub loader: FabricLoaderVersion,
pub intermediary: FabricIntermediaryVersion,
@@ -57,10 +48,7 @@ pub struct FabricLoaderEntry {
/// Launcher metadata from Fabric Meta API.
#[derive(Debug, Deserialize, Serialize, Clone, TS)]
#[serde(rename_all = "camelCase")]
-#[ts(
- export,
- export_to = "../../packages/ui-new/src/types/bindings/fabric.ts"
-)]
+#[ts(export, export_to = "fabric.ts")]
pub struct FabricLauncherMeta {
pub version: i32,
pub libraries: FabricLibraries,
@@ -71,10 +59,7 @@ pub struct FabricLauncherMeta {
/// Libraries required by Fabric loader.
#[derive(Debug, Deserialize, Serialize, Clone, TS)]
#[serde(rename_all = "camelCase")]
-#[ts(
- export,
- export_to = "../../packages/ui-new/src/types/bindings/fabric.ts"
-)]
+#[ts(export, export_to = "fabric.ts")]
pub struct FabricLibraries {
pub client: Vec<FabricLibrary>,
pub common: Vec<FabricLibrary>,
@@ -84,10 +69,7 @@ pub struct FabricLibraries {
/// A single Fabric library dependency.
#[derive(Debug, Deserialize, Serialize, Clone, TS)]
#[serde(rename_all = "camelCase")]
-#[ts(
- export,
- export_to = "../../packages/ui-new/src/types/bindings/fabric.ts"
-)]
+#[ts(export, export_to = "fabric.ts")]
pub struct FabricLibrary {
pub name: String,
pub url: Option<String>,
@@ -97,11 +79,7 @@ pub struct FabricLibrary {
/// Can be either a struct with client/server fields or a simple string.
#[derive(Debug, Deserialize, Serialize, Clone, TS)]
#[serde(rename_all = "camelCase")]
-#[ts(
- export,
- export_to = "../../packages/ui-new/src/types/bindings/fabric.ts",
- untagged
-)]
+#[ts(export, export_to = "fabric.ts", untagged)]
#[serde(untagged)]
pub enum FabricMainClass {
Structured { client: String, server: String },
@@ -128,10 +106,7 @@ impl FabricMainClass {
/// Represents a Minecraft version supported by Fabric.
#[derive(Debug, Deserialize, Serialize, Clone, TS)]
#[serde(rename_all = "camelCase")]
-#[ts(
- export,
- export_to = "../../packages/ui-new/src/types/bindings/fabric.ts"
-)]
+#[ts(export, export_to = "fabric.ts")]
pub struct FabricGameVersion {
pub version: String,
pub stable: bool,
@@ -140,10 +115,7 @@ pub struct FabricGameVersion {
/// Information about an installed Fabric version.
#[derive(Debug, Serialize, Clone, TS)]
#[serde(rename_all = "camelCase")]
-#[ts(
- export,
- export_to = "../../packages/ui-new/src/types/bindings/fabric.ts"
-)]
+#[ts(export, export_to = "fabric.ts")]
pub struct InstalledFabricVersion {
pub id: String,
pub minecraft_version: String,
@@ -155,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?
@@ -169,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?