diff options
| author | 2026-02-18 15:08:40 +0800 | |
|---|---|---|
| committer | 2026-02-18 15:08:40 +0800 | |
| commit | 1a103de2f1ef75cd73347953cbe27e14606df871 (patch) | |
| tree | eecb01f025bd9941aaa42ccebee02109cb5c7942 /packages | |
| parent | 2c3de3ac5ab1ab59f7245ab9cbdfda9b4e96dcb0 (diff) | |
| download | DropOut-1a103de2f1ef75cd73347953cbe27e14606df871.tar.gz DropOut-1a103de2f1ef75cd73347953cbe27e14606df871.zip | |
refactor(client): rewrite macros to generate client
Diffstat (limited to 'packages')
28 files changed, 660 insertions, 186 deletions
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<void> { + return invoke<void>("set_active_instance", { + instanceId, + }); +} + +export function refreshAccount(): Promise<Account> { + return invoke<Account>("refresh_account"); +} + +export function getFabricGameVersions(): Promise<FabricGameVersion[]> { + return invoke<FabricGameVersion[]>("get_fabric_game_versions"); +} + +export function deleteInstance(instanceId: string): Promise<void> { + return invoke<void>("delete_instance", { + instanceId, + }); +} + +export function listOllamaModels(endpoint: string): Promise<ModelInfo[]> { + return invoke<ModelInfo[]>("list_ollama_models", { + endpoint, + }); +} + +export function getForgeVersionsForGame( + gameVersion: string, +): Promise<ForgeVersion[]> { + return invoke<ForgeVersion[]>("get_forge_versions_for_game", { + gameVersion, + }); +} + +export function getVersionMetadata( + instanceId: string, + versionId: string, +): Promise<VersionMetadata> { + return invoke<VersionMetadata>("get_version_metadata", { + instanceId, + versionId, + }); +} + +export function migrateSharedCaches(): Promise<MigrationResult> { + return invoke<MigrationResult>("migrate_shared_caches"); +} + +export function getInstance(instanceId: string): Promise<Instance> { + return invoke<Instance>("get_instance", { + instanceId, + }); +} + +export function getVersions(instanceId: string): Promise<Version[]> { + return invoke<Version[]>("get_versions", { + instanceId, + }); +} + +export function refreshJavaCatalog(): Promise<JavaCatalog> { + return invoke<JavaCatalog>("refresh_java_catalog"); +} + +export function getActiveAccount(): Promise<Account | null> { + return invoke<Account | null>("get_active_account"); +} + +export function getConfigPath(): Promise<string> { + return invoke<string>("get_config_path"); +} + +export function getForgeGameVersions(): Promise<string[]> { + return invoke<string[]>("get_forge_game_versions"); +} + +export function getPendingJavaDownloads(): Promise<PendingJavaDownload[]> { + return invoke<PendingJavaDownload[]>("get_pending_java_downloads"); +} + +export function listOpenaiModels(): Promise<ModelInfo[]> { + return invoke<ModelInfo[]>("list_openai_models"); +} + +export function getRecommendedJava( + requiredMajorVersion: number | null, +): Promise<JavaInstallation | null> { + return invoke<JavaInstallation | null>("get_recommended_java", { + requiredMajorVersion, + }); +} + +export function fetchAvailableJavaVersions(): Promise<number[]> { + return invoke<number[]>("fetch_available_java_versions"); +} + +export function listInstanceDirectory( + instanceId: string, + folder: string, +): Promise<FileInfo[]> { + return invoke<FileInfo[]>("list_instance_directory", { + instanceId, + folder, + }); +} + +export function detectJava(): Promise<JavaInstallation[]> { + return invoke<JavaInstallation[]>("detect_java"); +} + +export function openFileExplorer(path: string): Promise<void> { + return invoke<void>("open_file_explorer", { + path, + }); +} + +export function completeMicrosoftLogin(deviceCode: string): Promise<Account> { + return invoke<Account>("complete_microsoft_login", { + deviceCode, + }); +} + +export function startMicrosoftLogin(): Promise<DeviceCodeResponse> { + return invoke<DeviceCodeResponse>("start_microsoft_login"); +} + +export function deleteVersion( + instanceId: string, + versionId: string, +): Promise<void> { + return invoke<void>("delete_version", { + instanceId, + versionId, + }); +} + +export function checkVersionInstalled( + instanceId: string, + versionId: string, +): Promise<boolean> { + return invoke<boolean>("check_version_installed", { + instanceId, + versionId, + }); +} + +export function uploadToPastebin(content: string): Promise<PastebinResponse> { + return invoke<PastebinResponse>("upload_to_pastebin", { + content, + }); +} + +export function getGithubReleases(): Promise<GithubRelease[]> { + return invoke<GithubRelease[]>("get_github_releases"); +} + +export function assistantChat(messages: Message[]): Promise<Message> { + return invoke<Message>("assistant_chat", { + messages, + }); +} + +export function installFabric( + instanceId: string, + gameVersion: string, + loaderVersion: string, +): Promise<InstalledFabricVersion> { + return invoke<InstalledFabricVersion>("install_fabric", { + instanceId, + gameVersion, + loaderVersion, + }); +} + +export function assistantCheckHealth(): Promise<boolean> { + return invoke<boolean>("assistant_check_health"); +} + +export function installVersion( + instanceId: string, + versionId: string, +): Promise<void> { + return invoke<void>("install_version", { + instanceId, + versionId, + }); +} + +export function listInstalledVersions( + instanceId: string, +): Promise<InstalledVersion[]> { + return invoke<InstalledVersion[]>("list_installed_versions", { + instanceId, + }); +} + +export function isFabricInstalled( + instanceId: string, + gameVersion: string, + loaderVersion: string, +): Promise<boolean> { + return invoke<boolean>("is_fabric_installed", { + instanceId, + gameVersion, + loaderVersion, + }); +} + +export function createInstance(name: string): Promise<Instance> { + return invoke<Instance>("create_instance", { + name, + }); +} + +export function getVersionJavaVersion( + instanceId: string, + versionId: string, +): Promise<number | null> { + return invoke<number | null>("get_version_java_version", { + instanceId, + versionId, + }); +} + +export function getFabricLoadersForVersion( + gameVersion: string, +): Promise<FabricLoaderEntry[]> { + return invoke<FabricLoaderEntry[]>("get_fabric_loaders_for_version", { + gameVersion, + }); +} + +export function cancelJavaDownload(): Promise<void> { + return invoke<void>("cancel_java_download"); +} + +export function resumeJavaDownloads(): Promise<JavaInstallation[]> { + return invoke<JavaInstallation[]>("resume_java_downloads"); +} + +export function updateInstance(instance: Instance): Promise<void> { + return invoke<void>("update_instance", { + instance, + }); +} + +export function getFabricLoaderVersions(): Promise<FabricLoaderVersion[]> { + return invoke<FabricLoaderVersion[]>("get_fabric_loader_versions"); +} + +export function loginOffline(username: string): Promise<Account> { + return invoke<Account>("login_offline", { + username, + }); +} + +export function installForge( + instanceId: string, + gameVersion: string, + forgeVersion: string, +): Promise<InstalledForgeVersion> { + return invoke<InstalledForgeVersion>("install_forge", { + instanceId, + gameVersion, + forgeVersion, + }); +} + +export function detectAllJavaInstallations(): Promise<JavaInstallation[]> { + return invoke<JavaInstallation[]>("detect_all_java_installations"); +} + +export function downloadAdoptiumJava( + majorVersion: number, + imageType: string, + customPath: string | null, +): Promise<JavaInstallation> { + return invoke<JavaInstallation>("download_adoptium_java", { + majorVersion, + imageType, + customPath, + }); +} + +export function startGame( + instanceId: string, + versionId: string, +): Promise<string> { + return invoke<string>("start_game", { + instanceId, + versionId, + }); +} + +export function saveSettings(config: LauncherConfig): Promise<void> { + return invoke<void>("save_settings", { + config, + }); +} + +export function getSettings(): Promise<LauncherConfig> { + return invoke<LauncherConfig>("get_settings"); +} + +export function duplicateInstance( + instanceId: string, + newName: string, +): Promise<Instance> { + return invoke<Instance>("duplicate_instance", { + instanceId, + newName, + }); +} + +export function listInstances(): Promise<Instance[]> { + return invoke<Instance[]>("list_instances"); +} + +export function readRawConfig(): Promise<string> { + return invoke<string>("read_raw_config"); +} + +export function assistantChatStream(messages: Message[]): Promise<string> { + return invoke<string>("assistant_chat_stream", { + messages, + }); +} + +export function saveRawConfig(content: string): Promise<void> { + return invoke<void>("save_raw_config", { + content, + }); +} + +export function fetchAdoptiumJava( + majorVersion: number, + imageType: string, +): Promise<JavaDownloadInfo> { + return invoke<JavaDownloadInfo>("fetch_adoptium_java", { + majorVersion, + imageType, + }); +} + +export function deleteInstanceFile(path: string): Promise<void> { + return invoke<void>("delete_instance_file", { + path, + }); +} + +export function getActiveInstance(): Promise<Instance | null> { + return invoke<Instance | null>("get_active_instance"); +} + +export function fetchJavaCatalog(): Promise<JavaCatalog> { + return invoke<JavaCatalog>("fetch_java_catalog"); +} + +export function logout(): Promise<void> { + return invoke<void>("logout"); +} + +export function listInstalledFabricVersions( + instanceId: string, +): Promise<string[]> { + return invoke<string[]>("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<typeof buttonVariants> & { - asChild?: boolean + asChild?: boolean; }) { - const Comp = asChild ? Slot : "button" + const Comp = asChild ? Slot : "button"; return ( <Comp @@ -56,7 +56,7 @@ function Button({ className={cn(buttonVariants({ variant, size, className }))} {...props} /> - ) + ); } -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({ <CheckIcon className="size-3.5" /> </CheckboxPrimitive.Indicator> </CheckboxPrimitive.Root> - ) + ); } -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<typeof DialogPrimitive.Root>) { - return <DialogPrimitive.Root data-slot="dialog" {...props} /> + return <DialogPrimitive.Root data-slot="dialog" {...props} />; } function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>) { - return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} /> + return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />; } function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>) { - return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} /> + return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />; } function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>) { - return <DialogPrimitive.Close data-slot="dialog-close" {...props} /> + return <DialogPrimitive.Close data-slot="dialog-close" {...props} />; } 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<typeof DialogPrimitive.Content> & { - showCloseButton?: boolean + showCloseButton?: boolean; }) { return ( <DialogPortal data-slot="dialog-portal"> @@ -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({ )} </DialogPrimitive.Content> </DialogPortal> - ) + ); } 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({ <ScrollBar /> <ScrollAreaPrimitive.Corner /> </ScrollAreaPrimitive.Root> - ) + ); } 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" /> </ScrollAreaPrimitive.ScrollAreaScrollbar> - ) + ); } -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<typeof SelectPrimitive.Root>) { - return <SelectPrimitive.Root data-slot="select" {...props} /> + return <SelectPrimitive.Root data-slot="select" {...props} />; } function SelectGroup({ ...props }: React.ComponentProps<typeof SelectPrimitive.Group>) { - return <SelectPrimitive.Group data-slot="select-group" {...props} /> + return <SelectPrimitive.Group data-slot="select-group" {...props} />; } function SelectValue({ ...props }: React.ComponentProps<typeof SelectPrimitive.Value>) { - return <SelectPrimitive.Value data-slot="select-value" {...props} /> + return <SelectPrimitive.Value data-slot="select-value" {...props} />; } function SelectTrigger({ @@ -28,7 +28,7 @@ function SelectTrigger({ children, ...props }: React.ComponentProps<typeof SelectPrimitive.Trigger> & { - size?: "sm" | "default" + size?: "sm" | "default"; }) { return ( <SelectPrimitive.Trigger @@ -36,7 +36,7 @@ function SelectTrigger({ data-size={size} className={cn( "border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]: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 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", - className + className, )} {...props} > @@ -45,7 +45,7 @@ function SelectTrigger({ <ChevronDownIcon className="size-4 opacity-50" /> </SelectPrimitive.Icon> </SelectPrimitive.Trigger> - ) + ); } 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({ <SelectScrollDownButton /> </SelectPrimitive.Content> </SelectPrimitive.Portal> - ) + ); } 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({ </span> <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText> </SelectPrimitive.Item> - ) + ); } 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} > <ChevronUpIcon className="size-4" /> </SelectPrimitive.ScrollUpButton> - ) + ); } 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} > <ChevronDownIcon className="size-4" /> </SelectPrimitive.ScrollDownButton> - ) + ); } 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 ( <Sonner @@ -32,7 +32,7 @@ const Toaster = ({ ...props }: ToasterProps) => { } {...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} > <SwitchPrimitive.Thumb data-slot="switch-thumb" className={cn( - "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0" + "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0", )} /> </SwitchPrimitive.Root> - ) + ); } -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<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-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 index 1b1c395..1b1c395 100644 --- a/packages/ui-new/src/types/bindings/game_version.ts +++ b/packages/ui-new/src/types/bindings/game-version.ts 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<JavaReleaseInfo>; - availableMajorVersions: Array<number>; - ltsVersions: Array<number>; - 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<JavaReleaseInfo>; + available_major_versions: Array<number>; + lts_versions: Array<number>; + 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<string>; + 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<number>; + available_lts_releases: Array<number>; + 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/*"] + } + } } |