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/client.ts | 396 +++++++++++++++++++++ .../src/components/instance-editor-modal.tsx | 2 +- packages/ui-new/src/components/ui/button.tsx | 20 +- packages/ui-new/src/components/ui/card.tsx | 26 +- packages/ui-new/src/components/ui/checkbox.tsx | 16 +- packages/ui-new/src/components/ui/dialog.tsx | 38 +- packages/ui-new/src/components/ui/input.tsx | 10 +- packages/ui-new/src/components/ui/label.tsx | 14 +- packages/ui-new/src/components/ui/scroll-area.tsx | 14 +- packages/ui-new/src/components/ui/select.tsx | 44 +-- packages/ui-new/src/components/ui/separator.tsx | 14 +- packages/ui-new/src/components/ui/sonner.tsx | 14 +- packages/ui-new/src/components/ui/switch.tsx | 14 +- packages/ui-new/src/components/ui/tabs.tsx | 22 +- packages/ui-new/src/components/ui/textarea.tsx | 10 +- 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 + packages/ui-new/tsconfig.json | 8 +- 29 files changed, 749 insertions(+), 275 deletions(-) create mode 100644 packages/ui-new/src/client.ts 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') diff --git a/packages/ui-new/src/client.ts b/packages/ui-new/src/client.ts new file mode 100644 index 0000000..9f4ccf0 --- /dev/null +++ b/packages/ui-new/src/client.ts @@ -0,0 +1,396 @@ +import { invoke } from "@tauri-apps/api/core"; +import type { + Account, + DeviceCodeResponse, + FabricGameVersion, + FabricLoaderEntry, + FabricLoaderVersion, + FileInfo, + ForgeVersion, + GithubRelease, + InstalledFabricVersion, + InstalledForgeVersion, + InstalledVersion, + Instance, + JavaCatalog, + JavaDownloadInfo, + JavaInstallation, + LauncherConfig, + Message, + MigrationResult, + ModelInfo, + PastebinResponse, + PendingJavaDownload, + Version, + VersionMetadata, +} from "@/types"; + +export function setActiveInstance(instanceId: string): Promise { + return invoke("set_active_instance", { + instanceId, + }); +} + +export function refreshAccount(): Promise { + return invoke("refresh_account"); +} + +export function getFabricGameVersions(): Promise { + return invoke("get_fabric_game_versions"); +} + +export function deleteInstance(instanceId: string): Promise { + return invoke("delete_instance", { + instanceId, + }); +} + +export function listOllamaModels(endpoint: string): Promise { + return invoke("list_ollama_models", { + endpoint, + }); +} + +export function getForgeVersionsForGame( + gameVersion: string, +): Promise { + return invoke("get_forge_versions_for_game", { + gameVersion, + }); +} + +export function getVersionMetadata( + instanceId: string, + versionId: string, +): Promise { + return invoke("get_version_metadata", { + instanceId, + versionId, + }); +} + +export function migrateSharedCaches(): Promise { + return invoke("migrate_shared_caches"); +} + +export function getInstance(instanceId: string): Promise { + return invoke("get_instance", { + instanceId, + }); +} + +export function getVersions(instanceId: string): Promise { + return invoke("get_versions", { + instanceId, + }); +} + +export function refreshJavaCatalog(): Promise { + return invoke("refresh_java_catalog"); +} + +export function getActiveAccount(): Promise { + return invoke("get_active_account"); +} + +export function getConfigPath(): Promise { + return invoke("get_config_path"); +} + +export function getForgeGameVersions(): Promise { + return invoke("get_forge_game_versions"); +} + +export function getPendingJavaDownloads(): Promise { + return invoke("get_pending_java_downloads"); +} + +export function listOpenaiModels(): Promise { + return invoke("list_openai_models"); +} + +export function getRecommendedJava( + requiredMajorVersion: number | null, +): Promise { + return invoke("get_recommended_java", { + requiredMajorVersion, + }); +} + +export function fetchAvailableJavaVersions(): Promise { + return invoke("fetch_available_java_versions"); +} + +export function listInstanceDirectory( + instanceId: string, + folder: string, +): Promise { + return invoke("list_instance_directory", { + instanceId, + folder, + }); +} + +export function detectJava(): Promise { + return invoke("detect_java"); +} + +export function openFileExplorer(path: string): Promise { + return invoke("open_file_explorer", { + path, + }); +} + +export function completeMicrosoftLogin(deviceCode: string): Promise { + return invoke("complete_microsoft_login", { + deviceCode, + }); +} + +export function startMicrosoftLogin(): Promise { + return invoke("start_microsoft_login"); +} + +export function deleteVersion( + instanceId: string, + versionId: string, +): Promise { + return invoke("delete_version", { + instanceId, + versionId, + }); +} + +export function checkVersionInstalled( + instanceId: string, + versionId: string, +): Promise { + return invoke("check_version_installed", { + instanceId, + versionId, + }); +} + +export function uploadToPastebin(content: string): Promise { + return invoke("upload_to_pastebin", { + content, + }); +} + +export function getGithubReleases(): Promise { + return invoke("get_github_releases"); +} + +export function assistantChat(messages: Message[]): Promise { + return invoke("assistant_chat", { + messages, + }); +} + +export function installFabric( + instanceId: string, + gameVersion: string, + loaderVersion: string, +): Promise { + return invoke("install_fabric", { + instanceId, + gameVersion, + loaderVersion, + }); +} + +export function assistantCheckHealth(): Promise { + return invoke("assistant_check_health"); +} + +export function installVersion( + instanceId: string, + versionId: string, +): Promise { + return invoke("install_version", { + instanceId, + versionId, + }); +} + +export function listInstalledVersions( + instanceId: string, +): Promise { + return invoke("list_installed_versions", { + instanceId, + }); +} + +export function isFabricInstalled( + instanceId: string, + gameVersion: string, + loaderVersion: string, +): Promise { + return invoke("is_fabric_installed", { + instanceId, + gameVersion, + loaderVersion, + }); +} + +export function createInstance(name: string): Promise { + return invoke("create_instance", { + name, + }); +} + +export function getVersionJavaVersion( + instanceId: string, + versionId: string, +): Promise { + return invoke("get_version_java_version", { + instanceId, + versionId, + }); +} + +export function getFabricLoadersForVersion( + gameVersion: string, +): Promise { + return invoke("get_fabric_loaders_for_version", { + gameVersion, + }); +} + +export function cancelJavaDownload(): Promise { + return invoke("cancel_java_download"); +} + +export function resumeJavaDownloads(): Promise { + return invoke("resume_java_downloads"); +} + +export function updateInstance(instance: Instance): Promise { + return invoke("update_instance", { + instance, + }); +} + +export function getFabricLoaderVersions(): Promise { + return invoke("get_fabric_loader_versions"); +} + +export function loginOffline(username: string): Promise { + return invoke("login_offline", { + username, + }); +} + +export function installForge( + instanceId: string, + gameVersion: string, + forgeVersion: string, +): Promise { + return invoke("install_forge", { + instanceId, + gameVersion, + forgeVersion, + }); +} + +export function detectAllJavaInstallations(): Promise { + return invoke("detect_all_java_installations"); +} + +export function downloadAdoptiumJava( + majorVersion: number, + imageType: string, + customPath: string | null, +): Promise { + return invoke("download_adoptium_java", { + majorVersion, + imageType, + customPath, + }); +} + +export function startGame( + instanceId: string, + versionId: string, +): Promise { + return invoke("start_game", { + instanceId, + versionId, + }); +} + +export function saveSettings(config: LauncherConfig): Promise { + return invoke("save_settings", { + config, + }); +} + +export function getSettings(): Promise { + return invoke("get_settings"); +} + +export function duplicateInstance( + instanceId: string, + newName: string, +): Promise { + return invoke("duplicate_instance", { + instanceId, + newName, + }); +} + +export function listInstances(): Promise { + return invoke("list_instances"); +} + +export function readRawConfig(): Promise { + return invoke("read_raw_config"); +} + +export function assistantChatStream(messages: Message[]): Promise { + return invoke("assistant_chat_stream", { + messages, + }); +} + +export function saveRawConfig(content: string): Promise { + return invoke("save_raw_config", { + content, + }); +} + +export function fetchAdoptiumJava( + majorVersion: number, + imageType: string, +): Promise { + return invoke("fetch_adoptium_java", { + majorVersion, + imageType, + }); +} + +export function deleteInstanceFile(path: string): Promise { + return invoke("delete_instance_file", { + path, + }); +} + +export function getActiveInstance(): Promise { + return invoke("get_active_instance"); +} + +export function fetchJavaCatalog(): Promise { + return invoke("fetch_java_catalog"); +} + +export function logout(): Promise { + return invoke("logout"); +} + +export function listInstalledFabricVersions( + instanceId: string, +): Promise { + return invoke("list_installed_fabric_versions", { + instanceId, + }); +} diff --git a/packages/ui-new/src/components/instance-editor-modal.tsx b/packages/ui-new/src/components/instance-editor-modal.tsx index 012e62c..74e0873 100644 --- a/packages/ui-new/src/components/instance-editor-modal.tsx +++ b/packages/ui-new/src/components/instance-editor-modal.tsx @@ -196,7 +196,7 @@ export function InstanceEditorModal({ open, instance, onOpenChange }: Props) { const k = 1024; const sizes = ["B", "KB", "MB", "GB", "TB"]; const i = Math.floor(Math.log(bytes) / Math.log(k)); - return `${Math.round((bytes / Math.pow(k, i)) * 100) / 100} ${sizes[i]}`; + return `${Math.round((bytes / k ** i) * 100) / 100} ${sizes[i]}`; } function formatDate( diff --git a/packages/ui-new/src/components/ui/button.tsx b/packages/ui-new/src/components/ui/button.tsx index 37a7d4b..be181b0 100644 --- a/packages/ui-new/src/components/ui/button.tsx +++ b/packages/ui-new/src/components/ui/button.tsx @@ -1,8 +1,8 @@ -import * as React from "react" -import { Slot } from "@radix-ui/react-slot" -import { cva, type VariantProps } from "class-variance-authority" +import { Slot } from "@radix-ui/react-slot"; +import { cva, type VariantProps } from "class-variance-authority"; +import type * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const buttonVariants = cva( "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", @@ -33,8 +33,8 @@ const buttonVariants = cva( variant: "default", size: "default", }, - } -) + }, +); function Button({ className, @@ -44,9 +44,9 @@ function Button({ ...props }: React.ComponentProps<"button"> & VariantProps & { - asChild?: boolean + asChild?: boolean; }) { - const Comp = asChild ? Slot : "button" + const Comp = asChild ? Slot : "button"; return ( - ) + ); } -export { Button, buttonVariants } +export { Button, buttonVariants }; diff --git a/packages/ui-new/src/components/ui/card.tsx b/packages/ui-new/src/components/ui/card.tsx index 681ad98..cc1ff8a 100644 --- a/packages/ui-new/src/components/ui/card.tsx +++ b/packages/ui-new/src/components/ui/card.tsx @@ -1,6 +1,6 @@ -import * as React from "react" +import type * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function Card({ className, ...props }: React.ComponentProps<"div">) { return ( @@ -8,11 +8,11 @@ function Card({ className, ...props }: React.ComponentProps<"div">) { data-slot="card" className={cn( "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm", - className + className, )} {...props} /> - ) + ); } function CardHeader({ className, ...props }: React.ComponentProps<"div">) { @@ -21,11 +21,11 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) { data-slot="card-header" className={cn( "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6", - className + className, )} {...props} /> - ) + ); } function CardTitle({ className, ...props }: React.ComponentProps<"div">) { @@ -35,7 +35,7 @@ function CardTitle({ className, ...props }: React.ComponentProps<"div">) { className={cn("leading-none font-semibold", className)} {...props} /> - ) + ); } function CardDescription({ className, ...props }: React.ComponentProps<"div">) { @@ -45,7 +45,7 @@ function CardDescription({ className, ...props }: React.ComponentProps<"div">) { className={cn("text-muted-foreground text-sm", className)} {...props} /> - ) + ); } function CardAction({ className, ...props }: React.ComponentProps<"div">) { @@ -54,11 +54,11 @@ function CardAction({ className, ...props }: React.ComponentProps<"div">) { data-slot="card-action" className={cn( "col-start-2 row-span-2 row-start-1 self-start justify-self-end", - className + className, )} {...props} /> - ) + ); } function CardContent({ className, ...props }: React.ComponentProps<"div">) { @@ -68,7 +68,7 @@ function CardContent({ className, ...props }: React.ComponentProps<"div">) { className={cn("px-6", className)} {...props} /> - ) + ); } function CardFooter({ className, ...props }: React.ComponentProps<"div">) { @@ -78,7 +78,7 @@ function CardFooter({ className, ...props }: React.ComponentProps<"div">) { className={cn("flex items-center px-6 [.border-t]:pt-6", className)} {...props} /> - ) + ); } export { @@ -89,4 +89,4 @@ export { CardAction, CardDescription, CardContent, -} +}; diff --git a/packages/ui-new/src/components/ui/checkbox.tsx b/packages/ui-new/src/components/ui/checkbox.tsx index cb0b07b..e771797 100644 --- a/packages/ui-new/src/components/ui/checkbox.tsx +++ b/packages/ui-new/src/components/ui/checkbox.tsx @@ -1,10 +1,10 @@ -"use client" +"use client"; -import * as React from "react" -import * as CheckboxPrimitive from "@radix-ui/react-checkbox" -import { CheckIcon } from "lucide-react" +import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; +import { CheckIcon } from "lucide-react"; +import type * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function Checkbox({ className, @@ -15,7 +15,7 @@ function Checkbox({ data-slot="checkbox" className={cn( "peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", - className + className, )} {...props} > @@ -26,7 +26,7 @@ function Checkbox({ - ) + ); } -export { Checkbox } +export { Checkbox }; diff --git a/packages/ui-new/src/components/ui/dialog.tsx b/packages/ui-new/src/components/ui/dialog.tsx index 60cc10e..fc2261a 100644 --- a/packages/ui-new/src/components/ui/dialog.tsx +++ b/packages/ui-new/src/components/ui/dialog.tsx @@ -1,31 +1,31 @@ -import * as React from "react" -import * as DialogPrimitive from "@radix-ui/react-dialog" -import { XIcon } from "lucide-react" +import * as DialogPrimitive from "@radix-ui/react-dialog"; +import { XIcon } from "lucide-react"; +import type * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function Dialog({ ...props }: React.ComponentProps) { - return + return ; } function DialogTrigger({ ...props }: React.ComponentProps) { - return + return ; } function DialogPortal({ ...props }: React.ComponentProps) { - return + return ; } function DialogClose({ ...props }: React.ComponentProps) { - return + return ; } function DialogOverlay({ @@ -37,11 +37,11 @@ function DialogOverlay({ data-slot="dialog-overlay" className={cn( "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50", - className + className, )} {...props} /> - ) + ); } function DialogContent({ @@ -50,7 +50,7 @@ function DialogContent({ showCloseButton = true, ...props }: React.ComponentProps & { - showCloseButton?: boolean + showCloseButton?: boolean; }) { return ( @@ -59,7 +59,7 @@ function DialogContent({ data-slot="dialog-content" className={cn( "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg", - className + className, )} {...props} > @@ -75,7 +75,7 @@ function DialogContent({ )} - ) + ); } function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { @@ -85,7 +85,7 @@ function DialogHeader({ className, ...props }: React.ComponentProps<"div">) { className={cn("flex flex-col gap-2 text-center sm:text-left", className)} {...props} /> - ) + ); } function DialogFooter({ className, ...props }: React.ComponentProps<"div">) { @@ -94,11 +94,11 @@ function DialogFooter({ className, ...props }: React.ComponentProps<"div">) { data-slot="dialog-footer" className={cn( "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", - className + className, )} {...props} /> - ) + ); } function DialogTitle({ @@ -111,7 +111,7 @@ function DialogTitle({ className={cn("text-lg leading-none font-semibold", className)} {...props} /> - ) + ); } function DialogDescription({ @@ -124,7 +124,7 @@ function DialogDescription({ className={cn("text-muted-foreground text-sm", className)} {...props} /> - ) + ); } export { @@ -138,4 +138,4 @@ export { DialogPortal, DialogTitle, DialogTrigger, -} +}; diff --git a/packages/ui-new/src/components/ui/input.tsx b/packages/ui-new/src/components/ui/input.tsx index 8916905..73ea867 100644 --- a/packages/ui-new/src/components/ui/input.tsx +++ b/packages/ui-new/src/components/ui/input.tsx @@ -1,6 +1,6 @@ -import * as React from "react" +import type * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function Input({ className, type, ...props }: React.ComponentProps<"input">) { return ( @@ -11,11 +11,11 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) { "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]", "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", - className + className, )} {...props} /> - ) + ); } -export { Input } +export { Input }; diff --git a/packages/ui-new/src/components/ui/label.tsx b/packages/ui-new/src/components/ui/label.tsx index fb5fbc3..a3661df 100644 --- a/packages/ui-new/src/components/ui/label.tsx +++ b/packages/ui-new/src/components/ui/label.tsx @@ -1,9 +1,9 @@ -"use client" +"use client"; -import * as React from "react" -import * as LabelPrimitive from "@radix-ui/react-label" +import * as LabelPrimitive from "@radix-ui/react-label"; +import type * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function Label({ className, @@ -14,11 +14,11 @@ function Label({ data-slot="label" className={cn( "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", - className + className, )} {...props} /> - ) + ); } -export { Label } +export { Label }; diff --git a/packages/ui-new/src/components/ui/scroll-area.tsx b/packages/ui-new/src/components/ui/scroll-area.tsx index 9376f59..da6b2e2 100644 --- a/packages/ui-new/src/components/ui/scroll-area.tsx +++ b/packages/ui-new/src/components/ui/scroll-area.tsx @@ -1,7 +1,7 @@ -import * as React from "react" -import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area" +import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"; +import type * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function ScrollArea({ className, @@ -23,7 +23,7 @@ function ScrollArea({ - ) + ); } function ScrollBar({ @@ -41,7 +41,7 @@ function ScrollBar({ "h-full w-2.5 border-l border-l-transparent", orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent", - className + className, )} {...props} > @@ -50,7 +50,7 @@ function ScrollBar({ className="bg-border relative flex-1 rounded-full" /> - ) + ); } -export { ScrollArea, ScrollBar } +export { ScrollArea, ScrollBar }; diff --git a/packages/ui-new/src/components/ui/select.tsx b/packages/ui-new/src/components/ui/select.tsx index b8aab97..c611948 100644 --- a/packages/ui-new/src/components/ui/select.tsx +++ b/packages/ui-new/src/components/ui/select.tsx @@ -1,25 +1,25 @@ -import * as React from "react" -import * as SelectPrimitive from "@radix-ui/react-select" -import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react" +import * as SelectPrimitive from "@radix-ui/react-select"; +import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react"; +import type * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function Select({ ...props }: React.ComponentProps) { - return + return ; } function SelectGroup({ ...props }: React.ComponentProps) { - return + return ; } function SelectValue({ ...props }: React.ComponentProps) { - return + return ; } function SelectTrigger({ @@ -28,7 +28,7 @@ function SelectTrigger({ children, ...props }: React.ComponentProps & { - size?: "sm" | "default" + size?: "sm" | "default"; }) { return ( @@ -45,7 +45,7 @@ function SelectTrigger({ - ) + ); } function SelectContent({ @@ -63,7 +63,7 @@ function SelectContent({ "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", - className + className, )} position={position} align={align} @@ -74,7 +74,7 @@ function SelectContent({ className={cn( "p-1", position === "popper" && - "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1" + "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1", )} > {children} @@ -82,7 +82,7 @@ function SelectContent({ - ) + ); } function SelectLabel({ @@ -95,7 +95,7 @@ function SelectLabel({ className={cn("text-muted-foreground px-2 py-1.5 text-xs", className)} {...props} /> - ) + ); } function SelectItem({ @@ -108,7 +108,7 @@ function SelectItem({ data-slot="select-item" className={cn( "focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", - className + className, )} {...props} > @@ -122,7 +122,7 @@ function SelectItem({ {children} - ) + ); } function SelectSeparator({ @@ -135,7 +135,7 @@ function SelectSeparator({ className={cn("bg-border pointer-events-none -mx-1 my-1 h-px", className)} {...props} /> - ) + ); } function SelectScrollUpButton({ @@ -147,13 +147,13 @@ function SelectScrollUpButton({ data-slot="select-scroll-up-button" className={cn( "flex cursor-default items-center justify-center py-1", - className + className, )} {...props} > - ) + ); } function SelectScrollDownButton({ @@ -165,13 +165,13 @@ function SelectScrollDownButton({ data-slot="select-scroll-down-button" className={cn( "flex cursor-default items-center justify-center py-1", - className + className, )} {...props} > - ) + ); } export { @@ -185,4 +185,4 @@ export { SelectSeparator, SelectTrigger, SelectValue, -} +}; diff --git a/packages/ui-new/src/components/ui/separator.tsx b/packages/ui-new/src/components/ui/separator.tsx index 275381c..50733e0 100644 --- a/packages/ui-new/src/components/ui/separator.tsx +++ b/packages/ui-new/src/components/ui/separator.tsx @@ -1,9 +1,9 @@ -"use client" +"use client"; -import * as React from "react" -import * as SeparatorPrimitive from "@radix-ui/react-separator" +import * as SeparatorPrimitive from "@radix-ui/react-separator"; +import type * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function Separator({ className, @@ -18,11 +18,11 @@ function Separator({ orientation={orientation} className={cn( "bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px", - className + className, )} {...props} /> - ) + ); } -export { Separator } +export { Separator }; diff --git a/packages/ui-new/src/components/ui/sonner.tsx b/packages/ui-new/src/components/ui/sonner.tsx index 9f46e06..c9cd094 100644 --- a/packages/ui-new/src/components/ui/sonner.tsx +++ b/packages/ui-new/src/components/ui/sonner.tsx @@ -4,12 +4,12 @@ import { Loader2Icon, OctagonXIcon, TriangleAlertIcon, -} from "lucide-react" -import { useTheme } from "next-themes" -import { Toaster as Sonner, type ToasterProps } from "sonner" +} from "lucide-react"; +import { useTheme } from "next-themes"; +import { Toaster as Sonner, type ToasterProps } from "sonner"; const Toaster = ({ ...props }: ToasterProps) => { - const { theme = "system" } = useTheme() + const { theme = "system" } = useTheme(); return ( { } {...props} /> - ) -} + ); +}; -export { Toaster } +export { Toaster }; diff --git a/packages/ui-new/src/components/ui/switch.tsx b/packages/ui-new/src/components/ui/switch.tsx index b0363e3..14b3b5b 100644 --- a/packages/ui-new/src/components/ui/switch.tsx +++ b/packages/ui-new/src/components/ui/switch.tsx @@ -1,7 +1,7 @@ -import * as React from "react" -import * as SwitchPrimitive from "@radix-ui/react-switch" +import * as SwitchPrimitive from "@radix-ui/react-switch"; +import type * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function Switch({ className, @@ -12,18 +12,18 @@ function Switch({ data-slot="switch" className={cn( "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", - className + className, )} {...props} > - ) + ); } -export { Switch } +export { Switch }; diff --git a/packages/ui-new/src/components/ui/tabs.tsx b/packages/ui-new/src/components/ui/tabs.tsx index 497ba5e..2da77f2 100644 --- a/packages/ui-new/src/components/ui/tabs.tsx +++ b/packages/ui-new/src/components/ui/tabs.tsx @@ -1,9 +1,9 @@ -"use client" +"use client"; -import * as React from "react" -import * as TabsPrimitive from "@radix-ui/react-tabs" +import * as TabsPrimitive from "@radix-ui/react-tabs"; +import type * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function Tabs({ className, @@ -15,7 +15,7 @@ function Tabs({ className={cn("flex flex-col gap-2", className)} {...props} /> - ) + ); } function TabsList({ @@ -27,11 +27,11 @@ function TabsList({ data-slot="tabs-list" className={cn( "bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]", - className + className, )} {...props} /> - ) + ); } function TabsTrigger({ @@ -43,11 +43,11 @@ function TabsTrigger({ data-slot="tabs-trigger" className={cn( "data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", - className + className, )} {...props} /> - ) + ); } function TabsContent({ @@ -60,7 +60,7 @@ function TabsContent({ className={cn("flex-1 outline-none", className)} {...props} /> - ) + ); } -export { Tabs, TabsList, TabsTrigger, TabsContent } +export { Tabs, TabsList, TabsTrigger, TabsContent }; diff --git a/packages/ui-new/src/components/ui/textarea.tsx b/packages/ui-new/src/components/ui/textarea.tsx index 7f21b5e..4f6221b 100644 --- a/packages/ui-new/src/components/ui/textarea.tsx +++ b/packages/ui-new/src/components/ui/textarea.tsx @@ -1,6 +1,6 @@ -import * as React from "react" +import type * as React from "react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; function Textarea({ className, ...props }: React.ComponentProps<"textarea">) { return ( @@ -8,11 +8,11 @@ function Textarea({ className, ...props }: React.ComponentProps<"textarea">) { data-slot="textarea" className={cn( "border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", - className + className, )} {...props} /> - ) + ); } -export { Textarea } +export { Textarea }; 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"; diff --git a/packages/ui-new/tsconfig.json b/packages/ui-new/tsconfig.json index 59578c3..fec8c8e 100644 --- a/packages/ui-new/tsconfig.json +++ b/packages/ui-new/tsconfig.json @@ -2,12 +2,12 @@ "files": [], "references": [ { "path": "./tsconfig.app.json" }, - { "path": "./tsconfig.node.json" }, + { "path": "./tsconfig.node.json" } ], "compilerOptions": { "baseUrl": ".", "paths": { - "@/*": ["./src/*"], - }, - }, + "@/*": ["./src/*"] + } + } } -- cgit v1.2.3-70-g09d2