From 1a103de2f1ef75cd73347953cbe27e14606df871 Mon Sep 17 00:00:00 2001 From: 苏向夜 Date: Wed, 18 Feb 2026 15:08:40 +0800 Subject: refactor(client): rewrite macros to generate client --- packages/ui-new/src/types/bindings/account.ts | 28 +++++++ packages/ui-new/src/types/bindings/downloader.ts | 10 +++ packages/ui-new/src/types/bindings/game-version.ts | 89 ++++++++++++++++++++++ packages/ui-new/src/types/bindings/game_version.ts | 89 ---------------------- packages/ui-new/src/types/bindings/index.ts | 3 +- packages/ui-new/src/types/bindings/instance.ts | 1 + packages/ui-new/src/types/bindings/java.ts | 52 ------------- packages/ui-new/src/types/bindings/java/core.ts | 41 ++++++++++ packages/ui-new/src/types/bindings/java/index.ts | 3 + .../ui-new/src/types/bindings/java/persistence.ts | 7 ++ .../src/types/bindings/java/providers/adoptium.ts | 37 +++++++++ .../src/types/bindings/java/providers/index.ts | 1 + packages/ui-new/src/types/index.ts | 1 + 13 files changed, 220 insertions(+), 142 deletions(-) create mode 100644 packages/ui-new/src/types/bindings/account.ts create mode 100644 packages/ui-new/src/types/bindings/game-version.ts delete mode 100644 packages/ui-new/src/types/bindings/game_version.ts delete mode 100644 packages/ui-new/src/types/bindings/java.ts create mode 100644 packages/ui-new/src/types/bindings/java/core.ts create mode 100644 packages/ui-new/src/types/bindings/java/index.ts create mode 100644 packages/ui-new/src/types/bindings/java/persistence.ts create mode 100644 packages/ui-new/src/types/bindings/java/providers/adoptium.ts create mode 100644 packages/ui-new/src/types/bindings/java/providers/index.ts create mode 100644 packages/ui-new/src/types/index.ts (limited to 'packages/ui-new/src/types') diff --git a/packages/ui-new/src/types/bindings/account.ts b/packages/ui-new/src/types/bindings/account.ts new file mode 100644 index 0000000..168d138 --- /dev/null +++ b/packages/ui-new/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; + 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-new/src/types/bindings/downloader.ts b/packages/ui-new/src/types/bindings/downloader.ts index a1734d5..f2be278 100644 --- a/packages/ui-new/src/types/bindings/downloader.ts +++ b/packages/ui-new/src/types/bindings/downloader.ts @@ -61,3 +61,13 @@ export type PendingJavaDownload = { 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-new/src/types/bindings/game-version.ts b/packages/ui-new/src/types/bindings/game-version.ts new file mode 100644 index 0000000..1b1c395 --- /dev/null +++ b/packages/ui-new/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; + jvm: Record; +}; + +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; + 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 | null; + natives: Record; + /** + * Maven repository URL for mod loader libraries + */ + url: string | null; +}; + +export type LibraryDownloads = { + artifact: DownloadArtifact | null; + classifiers: Record; +}; + +export type OsRule = { + name: string | null; + version: string | null; + arch: string | null; +}; + +export type Rule = { + action: string; + os: OsRule | null; + features: Record; +}; diff --git a/packages/ui-new/src/types/bindings/game_version.ts b/packages/ui-new/src/types/bindings/game_version.ts deleted file mode 100644 index 1b1c395..0000000 --- a/packages/ui-new/src/types/bindings/game_version.ts +++ /dev/null @@ -1,89 +0,0 @@ -// 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; - jvm: Record; -}; - -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; - 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 | null; - natives: Record; - /** - * Maven repository URL for mod loader libraries - */ - url: string | null; -}; - -export type LibraryDownloads = { - artifact: DownloadArtifact | null; - classifiers: Record; -}; - -export type OsRule = { - name: string | null; - version: string | null; - arch: string | null; -}; - -export type Rule = { - action: string; - os: OsRule | null; - features: Record; -}; diff --git a/packages/ui-new/src/types/bindings/index.ts b/packages/ui-new/src/types/bindings/index.ts index 510c240..9bde037 100644 --- a/packages/ui-new/src/types/bindings/index.ts +++ b/packages/ui-new/src/types/bindings/index.ts @@ -1,3 +1,4 @@ +export * from "./account"; export * from "./assistant"; export * from "./auth"; export * from "./config"; @@ -5,7 +6,7 @@ export * from "./core"; export * from "./downloader"; export * from "./fabric"; export * from "./forge"; -export * from "./game_version"; +export * from "./game-version"; export * from "./instance"; export * from "./java"; export * from "./manifest"; diff --git a/packages/ui-new/src/types/bindings/instance.ts b/packages/ui-new/src/types/bindings/instance.ts index 079e8f0..2c4f8ae 100644 --- a/packages/ui-new/src/types/bindings/instance.ts +++ b/packages/ui-new/src/types/bindings/instance.ts @@ -16,6 +16,7 @@ export type Instance = { modLoaderVersion: string | null; jvmArgsOverride: string | null; memoryOverride: MemoryOverride | null; + javaPathOverride: string | null; }; /** diff --git a/packages/ui-new/src/types/bindings/java.ts b/packages/ui-new/src/types/bindings/java.ts deleted file mode 100644 index 5db128e..0000000 --- a/packages/ui-new/src/types/bindings/java.ts +++ /dev/null @@ -1,52 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -/** - * Java image type: JRE or JDK - */ -export type ImageType = "jre" | "jdk"; - -/** - * Java catalog containing all available versions - */ -export type JavaCatalog = { - releases: Array; - availableMajorVersions: Array; - ltsVersions: Array; - cachedAt: bigint; -}; - -/** - * Java download information from Adoptium - */ -export type JavaDownloadInfo = { - version: string; - releaseName: string; - downloadUrl: string; - fileName: string; - fileSize: bigint; - checksum: string | null; - imageType: string; -}; - -export type JavaInstallation = { - path: string; - version: string; - is64bit: boolean; -}; - -/** - * Java release information for UI display - */ -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-new/src/types/bindings/java/core.ts b/packages/ui-new/src/types/bindings/java/core.ts new file mode 100644 index 0000000..d0dfcbd --- /dev/null +++ b/packages/ui-new/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; + available_major_versions: Array; + lts_versions: Array; + cached_at: 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; + is_64bit: boolean; +}; + +export type JavaReleaseInfo = { + major_version: number; + image_type: string; + version: string; + release_name: string; + release_date: string | null; + file_size: bigint; + checksum: string | null; + download_url: string; + is_lts: boolean; + is_available: boolean; + architecture: string; +}; diff --git a/packages/ui-new/src/types/bindings/java/index.ts b/packages/ui-new/src/types/bindings/java/index.ts new file mode 100644 index 0000000..2f2754c --- /dev/null +++ b/packages/ui-new/src/types/bindings/java/index.ts @@ -0,0 +1,3 @@ +export * from "./core"; +export * from "./persistence"; +export * from "./providers"; diff --git a/packages/ui-new/src/types/bindings/java/persistence.ts b/packages/ui-new/src/types/bindings/java/persistence.ts new file mode 100644 index 0000000..7a2b576 --- /dev/null +++ b/packages/ui-new/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; + preferred_java_path: string | null; + last_detection_time: bigint; +}; diff --git a/packages/ui-new/src/types/bindings/java/providers/adoptium.ts b/packages/ui-new/src/types/bindings/java/providers/adoptium.ts new file mode 100644 index 0000000..65fc42b --- /dev/null +++ b/packages/ui-new/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; + available_lts_releases: Array; + most_recent_lts: number | null; + most_recent_feature_release: number | null; +}; diff --git a/packages/ui-new/src/types/bindings/java/providers/index.ts b/packages/ui-new/src/types/bindings/java/providers/index.ts new file mode 100644 index 0000000..3e28711 --- /dev/null +++ b/packages/ui-new/src/types/bindings/java/providers/index.ts @@ -0,0 +1 @@ +export * from "./adoptium"; diff --git a/packages/ui-new/src/types/index.ts b/packages/ui-new/src/types/index.ts new file mode 100644 index 0000000..9e592d7 --- /dev/null +++ b/packages/ui-new/src/types/index.ts @@ -0,0 +1 @@ +export * from "./bindings"; -- cgit v1.2.3-70-g09d2