diff --git a/web/biome.json b/web/biome.json index 7d10a3fc..652dfcd4 100644 --- a/web/biome.json +++ b/web/biome.json @@ -21,7 +21,7 @@ "formatter": { "enabled": true, "indentStyle": "space", - "includes": ["!**/test/snapshots/**/*"] + "indentWidth": 2 }, "linter": { "enabled": true, diff --git a/web/bun.lockb b/web/bun.lockb index f00f21a7..2cfc647b 100755 Binary files a/web/bun.lockb and b/web/bun.lockb differ diff --git a/web/copy-build.js b/web/copy-build.js index 3be0c363..afade1e0 100644 --- a/web/copy-build.js +++ b/web/copy-build.js @@ -1,4 +1,11 @@ -import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { + existsSync, + mkdirSync, + readdirSync, + readFileSync, + rmSync, + writeFileSync, +} from "node:fs"; import { cp } from "node:fs/promises"; import { join, resolve } from "node:path"; @@ -44,7 +51,9 @@ async function main() { const INDEX_DEST = join(TEMPLATES_DIR, "index.html"); if (!existsSync(INDEX_SRC)) { - console.error(`Error: ${INDEX_SRC} does not exist. Make sure you built the frontend project first.`); + console.error( + `Error: ${INDEX_SRC} does not exist. Make sure you built the frontend project first.`, + ); process.exit(1); } diff --git a/web/src/components/code-viewer.tsx b/web/src/components/code-viewer.tsx index 9e1f3440..87f65533 100644 --- a/web/src/components/code-viewer.tsx +++ b/web/src/components/code-viewer.tsx @@ -1,14 +1,20 @@ -import type {VariantProps} from "class-variance-authority"; -import {Check, Copy} from "lucide-react"; -import {type HTMLProps, type ReactNode, useCallback, useEffect, useState} from "react"; -import {CopyToClipboard} from "react-copy-to-clipboard"; -import {useTranslation} from "react-i18next"; -import {PrismLight as SyntaxHighlighter} from "react-syntax-highlighter"; +import type { VariantProps } from "class-variance-authority"; +import { Check, Copy } from "lucide-react"; +import { + type HTMLProps, + type ReactNode, + useCallback, + useEffect, + useState, +} from "react"; +import { CopyToClipboard } from "react-copy-to-clipboard"; +import { useTranslation } from "react-i18next"; +import { PrismLight as SyntaxHighlighter } from "react-syntax-highlighter"; import java from "react-syntax-highlighter/dist/esm/languages/prism/java"; -import {materialDark} from "react-syntax-highlighter/dist/esm/styles/prism"; -import {toast} from "sonner"; -import {Button, type buttonVariants} from "@/components/ui/button"; -import {cn} from "@/lib/utils"; +import { materialDark } from "react-syntax-highlighter/dist/esm/styles/prism"; +import { toast } from "sonner"; +import { Button, type buttonVariants } from "@/components/ui/button"; +import { cn } from "@/lib/utils"; SyntaxHighlighter.registerLanguage("java", java); interface CopyButtonProps extends React.ComponentProps<"button"> { @@ -16,7 +22,9 @@ interface CopyButtonProps extends React.ComponentProps<"button"> { src?: string; } -export function CopyButton({ value }: Readonly>) { +export function CopyButton({ + value, +}: Readonly>) { const [hasCopied, setHasCopied] = useState(false); const { t } = useTranslation(); @@ -60,12 +68,18 @@ export default function CodeViewer({ showLineNumbers = true, wrapLongLines = true, }: Readonly) { - const lineProps: lineTagPropsFunction | HTMLProps | undefined = wrapLongLines - ? { style: { overflowWrap: "break-word", whiteSpace: "pre-wrap" } } - : undefined; + const lineProps: lineTagPropsFunction | HTMLProps | undefined = + wrapLongLines + ? { style: { overflowWrap: "break-word", whiteSpace: "pre-wrap" } } + : undefined; return (
-
+
{header}
{button} diff --git a/web/src/components/copyable-field.tsx b/web/src/components/copyable-field.tsx index afd2f569..7c26e4b4 100644 --- a/web/src/components/copyable-field.tsx +++ b/web/src/components/copyable-field.tsx @@ -12,7 +12,11 @@ interface CopyableFieldProps { text?: string; } -export function CopyableField({ label, value, text }: Readonly) { +export function CopyableField({ + label, + value, + text, +}: Readonly) { const [hasCopied, setHasCopied] = useState(false); const { t } = useTranslation(); @@ -40,8 +44,18 @@ export function CopyableField({ label, value, text }: Readonly{label}: {value && ( - )} diff --git a/web/src/components/magicui/line-shadow-text.tsx b/web/src/components/magicui/line-shadow-text.tsx index f034cd3f..c8618d47 100644 --- a/web/src/components/magicui/line-shadow-text.tsx +++ b/web/src/components/magicui/line-shadow-text.tsx @@ -1,7 +1,9 @@ -import {type MotionProps, motion } from "motion/react"; -import {cn} from "@/lib/utils"; +import { type MotionProps, motion } from "motion/react"; +import { cn } from "@/lib/utils"; -interface LineShadowTextProps extends Omit, keyof MotionProps>, MotionProps { +interface LineShadowTextProps + extends Omit, keyof MotionProps>, + MotionProps { shadowColor?: string; as?: React.ElementType; } diff --git a/web/src/components/magicui/rainbow-button.tsx b/web/src/components/magicui/rainbow-button.tsx index 3a67dc72..57bb689e 100644 --- a/web/src/components/magicui/rainbow-button.tsx +++ b/web/src/components/magicui/rainbow-button.tsx @@ -1,7 +1,7 @@ -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 React from "react"; -import {cn} from "@/lib/utils"; +import { cn } from "@/lib/utils"; const rainbowButtonVariants = cva( cn( diff --git a/web/src/components/memshell/main-config-card.tsx b/web/src/components/memshell/main-config-card.tsx index 6396aab3..5a8c8936 100644 --- a/web/src/components/memshell/main-config-card.tsx +++ b/web/src/components/memshell/main-config-card.tsx @@ -1,41 +1,56 @@ import { - ArrowUpRightIcon, - AxeIcon, - CommandIcon, - NetworkIcon, - ServerIcon, - ShieldOffIcon, - SwordIcon, - WaypointsIcon, - ZapIcon, + ArrowUpRightIcon, + AxeIcon, + CommandIcon, + NetworkIcon, + ServerIcon, + ShieldOffIcon, + SwordIcon, + WaypointsIcon, + ZapIcon, } from "lucide-react"; -import {type JSX, useCallback, useEffect, useId, useState} from "react"; -import {FormProvider, type UseFormReturn} from "react-hook-form"; -import {useTranslation} from "react-i18next"; -import {AntSwordTabContent} from "@/components/memshell/tabs/antsword-tab"; -import {BehinderTabContent} from "@/components/memshell/tabs/behinder-tab"; -import {CommandTabContent} from "@/components/memshell/tabs/command-tab"; +import { type JSX, useCallback, useEffect, useState } from "react"; +import { FormProvider, type UseFormReturn } from "react-hook-form"; +import { useTranslation } from "react-i18next"; +import { AntSwordTabContent } from "@/components/memshell/tabs/antsword-tab"; +import { BehinderTabContent } from "@/components/memshell/tabs/behinder-tab"; +import { CommandTabContent } from "@/components/memshell/tabs/command-tab"; import CustomTabContent from "@/components/memshell/tabs/custom-tab"; -import {GodzillaTabContent} from "@/components/memshell/tabs/godzilla-tab"; -import {NeoRegTabContent} from "@/components/memshell/tabs/neoreg-tab"; -import {Suo5TabContent} from "@/components/memshell/tabs/suo5-tab"; -import {Card, CardContent, CardHeader, CardTitle} from "@/components/ui/card.tsx"; +import { GodzillaTabContent } from "@/components/memshell/tabs/godzilla-tab"; +import { NeoRegTabContent } from "@/components/memshell/tabs/neoreg-tab"; +import { Suo5TabContent } from "@/components/memshell/tabs/suo5-tab"; import { - FormControl, - FormDescription, - FormField, - FormFieldItem, - FormFieldLabel, - FormItem, - FormLabel, - FormMessage, + Card, + CardContent, + CardHeader, + CardTitle, +} from "@/components/ui/card.tsx"; +import { + FormControl, + FormDescription, + FormField, + FormFieldItem, + FormFieldLabel, + FormItem, + FormLabel, + FormMessage, } from "@/components/ui/form.tsx"; -import {Label} from "@/components/ui/label.tsx"; -import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from "@/components/ui/select.tsx"; -import {Switch} from "@/components/ui/switch.tsx"; -import {Tabs, TabsList, TabsTrigger} from "@/components/ui/tabs"; -import {type MainConfig, type ServerConfig, ShellToolType} from "@/types/memshell"; -import type {MemShellFormSchema} from "@/types/schema.ts"; +import { Label } from "@/components/ui/label.tsx"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select.tsx"; +import { Switch } from "@/components/ui/switch.tsx"; +import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; +import { + type MainConfig, + type ServerConfig, + ShellToolType, +} from "@/types/memshell"; +import type { MemShellFormSchema } from "@/types/schema.ts"; const shellToolIcons: Record = { [ShellToolType.Behinder]: , @@ -79,7 +94,9 @@ export default function MainConfigCard({ const shellTool = form.watch("shellTool"); const { t } = useTranslation(); - const [serverVersionOptions, setServerVersionOptions] = useState(defaultServerVersionOptions); + const [serverVersionOptions, setServerVersionOptions] = useState( + defaultServerVersionOptions, + ); // 处理一下 shellTypes 由于 server 或 shellTool 变更时无法正常为 form.shellType 赋值的问题 useEffect(() => { @@ -95,7 +112,10 @@ export default function MainConfigCard({ setShellToolMap(newShellToolMap); const newShellTools = Object.keys(newShellToolMap); - setShellTools([...newShellTools.map((tool) => tool as ShellToolType), ShellToolType.Custom]); + setShellTools([ + ...newShellTools.map((tool) => tool as ShellToolType), + ShellToolType.Custom, + ]); const currentShellTool = form.getValues("shellTool"); @@ -233,10 +253,6 @@ export default function MainConfigCard({ [form, servers, shellToolMap], ); - const debugId = useId(); - const bypassId = useId(); - const shrinkId = useId(); - return ( diff --git a/web/src/components/memshell/package-config-card.tsx b/web/src/components/memshell/package-config-card.tsx index 7934a5be..ce287821 100644 --- a/web/src/components/memshell/package-config-card.tsx +++ b/web/src/components/memshell/package-config-card.tsx @@ -1,12 +1,22 @@ -import {PackageIcon} from "lucide-react"; -import {useEffect, useState} from "react"; -import {FormProvider, type UseFormReturn} from "react-hook-form"; -import {useTranslation} from "react-i18next"; -import {Card, CardContent, CardHeader, CardTitle} from "@/components/ui/card.tsx"; -import {FormControl, FormField, FormItem, FormLabel} from "@/components/ui/form.tsx"; -import {RadioGroup, RadioGroupItem} from "@/components/ui/radio-group.tsx"; -import type {PackerConfig} from "@/types/memshell"; -import type {MemShellFormSchema} from "@/types/schema.ts"; +import { PackageIcon } from "lucide-react"; +import { useEffect, useState } from "react"; +import { FormProvider, type UseFormReturn } from "react-hook-form"; +import { useTranslation } from "react-i18next"; +import { + Card, + CardContent, + CardHeader, + CardTitle, +} from "@/components/ui/card.tsx"; +import { + FormControl, + FormField, + FormItem, + FormLabel, +} from "@/components/ui/form.tsx"; +import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group.tsx"; +import type { PackerConfig } from "@/types/memshell"; +import type { MemShellFormSchema } from "@/types/schema.ts"; type Option = { name: string; @@ -49,7 +59,10 @@ export default function PackageConfigCard({ setOptions(mappedOptions); const currentValue = form.getValues("packingMethod"); - if (filteredOptions.length > 0 && (!currentValue || !filteredOptions.includes(currentValue))) { + if ( + filteredOptions.length > 0 && + (!currentValue || !filteredOptions.includes(currentValue)) + ) { form.setValue("packingMethod", filteredOptions[0]); } }, [form, packerConfig, server, shellType, t]); @@ -78,7 +91,10 @@ export default function PackageConfigCard({ className="grid grid-cols-2 md:grid-cols-3" > {options.map(({ name, value }) => ( - + @@ -96,7 +112,9 @@ export default function PackageConfigCard({ ) : (
- {t("loading")} + + {t("loading")} +
)} diff --git a/web/src/components/memshell/quick-usage.tsx b/web/src/components/memshell/quick-usage.tsx index d3f993b2..e34f0c44 100644 --- a/web/src/components/memshell/quick-usage.tsx +++ b/web/src/components/memshell/quick-usage.tsx @@ -1,6 +1,11 @@ import { ScrollTextIcon } from "lucide-react"; import { useTranslation } from "react-i18next"; -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card.tsx"; +import { + Card, + CardContent, + CardHeader, + CardTitle, +} from "@/components/ui/card.tsx"; export function QuickUsage() { const { t } = useTranslation(); diff --git a/web/src/components/memshell/results/agent.tsx b/web/src/components/memshell/results/agent.tsx index 1656a471..dd0db625 100644 --- a/web/src/components/memshell/results/agent.tsx +++ b/web/src/components/memshell/results/agent.tsx @@ -1,10 +1,10 @@ -import {ScrollTextIcon} from "lucide-react"; -import {useTranslation} from "react-i18next"; -import {Button} from "@/components/ui/button"; -import {Card, CardContent, CardHeader, CardTitle} from "@/components/ui/card"; -import {Separator} from "@/components/ui/separator"; -import {downloadBytes, formatBytes} from "@/lib/utils"; -import type {MemShellResult} from "@/types/memshell"; +import { ScrollTextIcon } from "lucide-react"; +import { useTranslation } from "react-i18next"; +import { Button } from "@/components/ui/button"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Separator } from "@/components/ui/separator"; +import { downloadBytes, formatBytes } from "@/lib/utils"; +import type { MemShellResult } from "@/types/memshell"; export function AgentResult({ packMethod, diff --git a/web/src/components/memshell/results/basic-info.tsx b/web/src/components/memshell/results/basic-info.tsx index 9307bb0a..3c080c19 100644 --- a/web/src/components/memshell/results/basic-info.tsx +++ b/web/src/components/memshell/results/basic-info.tsx @@ -1,20 +1,20 @@ -import {FileTextIcon} from "lucide-react"; -import {useTranslation} from "react-i18next"; -import {Card, CardContent, CardHeader, CardTitle} from "@/components/ui/card"; -import {Separator} from "@/components/ui/separator"; -import {shouldHidden} from "@/lib/utils"; +import { FileTextIcon } from "lucide-react"; +import { useTranslation } from "react-i18next"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Separator } from "@/components/ui/separator"; +import { shouldHidden } from "@/lib/utils"; import { - type AntSwordShellToolConfig, - type BehinderShellToolConfig, - type CommandShellToolConfig, - type GodzillaShellToolConfig, - type MemShellResult, - type NeoreGeorgShellToolConfig, - ShellToolType, - type Suo5ShellToolConfig, + type AntSwordShellToolConfig, + type BehinderShellToolConfig, + type CommandShellToolConfig, + type GodzillaShellToolConfig, + type MemShellResult, + type NeoreGeorgShellToolConfig, + ShellToolType, + type Suo5ShellToolConfig, } from "@/types/memshell"; -import {CopyableField} from "../../copyable-field"; -import {FeedbackAlert} from "./feedback-alert"; +import { CopyableField } from "../../copyable-field"; +import { FeedbackAlert } from "./feedback-alert"; export function BasicInfo({ generateResult }: Readonly<{ generateResult?: MemShellResult }>) { const { t } = useTranslation(); diff --git a/web/src/components/memshell/results/jar-result.tsx b/web/src/components/memshell/results/jar-result.tsx index 56e0376a..dab152b0 100644 --- a/web/src/components/memshell/results/jar-result.tsx +++ b/web/src/components/memshell/results/jar-result.tsx @@ -1,7 +1,7 @@ -import {useTranslation} from "react-i18next"; -import {Button} from "@/components/ui/button"; -import {downloadBytes} from "@/lib/utils"; -import type {MemShellResult} from "@/types/memshell"; +import { useTranslation } from "react-i18next"; +import { Button } from "@/components/ui/button"; +import { downloadBytes } from "@/lib/utils"; +import type { MemShellResult } from "@/types/memshell"; export function JarResult({ packResult, diff --git a/web/src/components/memshell/results/multi-packer.tsx b/web/src/components/memshell/results/multi-packer.tsx index b220abff..46f93f21 100644 --- a/web/src/components/memshell/results/multi-packer.tsx +++ b/web/src/components/memshell/results/multi-packer.tsx @@ -1,7 +1,14 @@ import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import CodeViewer from "@/components/code-viewer"; -import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; + export function MultiPackResult({ allPackResults, packMethod, @@ -30,7 +37,9 @@ export function MultiPackResult({