Skip to content

Commit 0aabbfa

Browse files
committed
perf: reduce js size
1 parent e042561 commit 0aabbfa

File tree

12 files changed

+45
-25
lines changed

12 files changed

+45
-25
lines changed

web/bun.lockb

-2.22 KB
Binary file not shown.

web/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@types/react-syntax-highlighter": "^15.5.13",
2323
"@vitejs/plugin-react": "^4.6.0",
2424
"rimraf": "^6.0.1",
25-
"tailwindcss": "^4.1.10",
25+
"tailwindcss": "^4.1.11",
2626
"typescript": "^5.8.3",
2727
"vite": "^7.0.0",
2828
"vite-bundle-visualizer": "^1.2.1"
@@ -31,7 +31,7 @@
3131
"@hookform/resolvers": "^5.1.1",
3232
"@radix-ui/react-navigation-menu": "^1.2.13",
3333
"@radix-ui/react-popover": "^1.1.14",
34-
"@tailwindcss/vite": "^4.1.10",
34+
"@tailwindcss/vite": "^4.1.11",
3535
"@tanstack/react-query": "^5.81.2",
3636
"class-variance-authority": "^0.7.1",
3737
"clsx": "^2.1.1",

web/src/components/code-viewer.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import { Check, Copy } from "lucide-react";
33
import { type HTMLProps, type ReactNode, useCallback, useEffect, useState } from "react";
44
import { CopyToClipboard } from "react-copy-to-clipboard";
55
import { useTranslation } from "react-i18next";
6-
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
6+
import { PrismLight as SyntaxHighlighter } from "react-syntax-highlighter";
7+
import java from "react-syntax-highlighter/dist/esm/languages/prism/java";
78
import { materialDark } from "react-syntax-highlighter/dist/esm/styles/prism";
89
import { toast } from "sonner";
910
import { Button, buttonVariants } from "@/components/ui/button";
1011
import { cn } from "@/lib/utils";
1112

13+
SyntaxHighlighter.registerLanguage("java", java);
1214
interface CopyButtonProps extends React.ComponentProps<"button"> {
1315
value: string;
1416
src?: string;
@@ -49,7 +51,7 @@ export function CopyButton({ value }: Readonly<CopyButtonProps & VariantProps<ty
4951
);
5052
}
5153

52-
export function CodeViewer({
54+
export default function CodeViewer({
5355
code,
5456
header,
5557
button,

web/src/components/main-config-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const shellToolIcons: Record<ShellToolType, JSX.Element> = {
4747
[ShellToolType.Custom]: <ZapIcon className="h-4 w-4" />,
4848
};
4949

50-
export function MainConfigCard({
50+
export default function MainConfigCard({
5151
mainConfig,
5252
form,
5353
servers,

web/src/components/package-config-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type Option = {
1313
value: string;
1414
};
1515

16-
export function PackageConfigCard({
16+
export default function PackageConfigCard({
1717
packerConfig,
1818
form,
1919
}: Readonly<{

web/src/components/results/multi-packer.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { TFunction } from "i18next";
22
import { useEffect, useState } from "react";
3-
import { CodeViewer } from "../code-viewer";
3+
import CodeViewer from "@/components/code-viewer";
44
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select";
5-
65
export function MultiPackResult({
76
allPackResults,
87
packMethod,

web/src/components/results/result-component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { TFunction } from "i18next";
2+
import CodeViewer from "@/components/code-viewer";
23
import { GenerateResult } from "@/types/shell";
3-
import { CodeViewer } from "../code-viewer";
44
import { AgentResult } from "./agent";
55
import { JarResult } from "./jar-result";
66
import { MultiPackResult } from "./multi-packer";

web/src/components/shell-result.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import { DownloadIcon } from "lucide-react";
22
import { useTranslation } from "react-i18next";
33
import { toast } from "sonner";
4-
import { CodeViewer } from "@/components/code-viewer.tsx";
4+
55
import { QuickUsage } from "@/components/quick-usage.tsx";
66
import { Button } from "@/components/ui/button.tsx";
77
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs.tsx";
88
import { downloadBytes } from "@/lib/utils.ts";
99
import { GenerateResult } from "@/types/shell.ts";
10+
import CodeViewer from "./code-viewer";
1011
import { BasicInfo } from "./results/basic-info";
1112
import { ResultComponent } from "./results/result-component";
1213

13-
export function ShellResult({
14+
export default function ShellResult({
1415
packResult,
1516
allPackResults,
1617
packMethod,

web/src/components/theme-provider.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createContext, useContext, useEffect, useState } from "react";
1+
import { createContext, useContext, useEffect, useMemo, useState } from "react";
22

33
type Theme = "dark" | "light" | "system";
44

@@ -25,7 +25,7 @@ export function ThemeProvider({
2525
defaultTheme = "system",
2626
storageKey = "vite-ui-theme",
2727
...props
28-
}: ThemeProviderProps) {
28+
}: Readonly<ThemeProviderProps>) {
2929
const [theme, setTheme] = useState<Theme>(() => (localStorage.getItem(storageKey) as Theme) || defaultTheme);
3030

3131
useEffect(() => {
@@ -45,13 +45,16 @@ export function ThemeProvider({
4545
root.classList.add(theme);
4646
}, [theme]);
4747

48-
const value = {
49-
theme,
50-
setTheme: (theme: Theme) => {
51-
localStorage.setItem(storageKey, theme);
52-
setTheme(theme);
53-
},
54-
};
48+
const value = useMemo(
49+
() => ({
50+
theme,
51+
setTheme: (theme: Theme) => {
52+
localStorage.setItem(storageKey, theme);
53+
setTheme(theme);
54+
},
55+
}),
56+
[theme, storageKey],
57+
);
5558

5659
return (
5760
<ThemeProviderContext.Provider {...props} value={value}>

web/src/pages/memshell.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { useForm } from "react-hook-form";
55
import { useTranslation } from "react-i18next";
66
import { useLoaderData } from "react-router-dom";
77
import { toast } from "sonner";
8-
import { MainConfigCard } from "@/components/main-config-card.tsx";
9-
import { PackageConfigCard } from "@/components/package-config-card.tsx";
10-
import { ShellResult } from "@/components/shell-result.tsx";
8+
import MainConfigCard from "@/components/main-config-card.tsx";
9+
import PackageConfigCard from "@/components/package-config-card.tsx";
10+
import ShellResult from "@/components/shell-result.tsx";
1111
import { Button } from "@/components/ui/button";
1212
import { Form } from "@/components/ui/form.tsx";
1313
import { env } from "@/config.ts";

0 commit comments

Comments
 (0)