Skip to content

Commit 3cdd6fa

Browse files
committed
init client
1 parent 70a9f96 commit 3cdd6fa

33 files changed

+3256
-0
lines changed

client/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

client/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# React + TypeScript + Vite
2+
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4+
5+
Currently, two official plugins are available:
6+
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9+
10+
## Expanding the ESLint configuration
11+
12+
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
13+
14+
- Configure the top-level `parserOptions` property like this:
15+
16+
```js
17+
export default tseslint.config({
18+
languageOptions: {
19+
// other options...
20+
parserOptions: {
21+
project: ["./tsconfig.node.json", "./tsconfig.app.json"],
22+
tsconfigRootDir: import.meta.dirname,
23+
},
24+
},
25+
});
26+
```
27+
28+
- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
29+
- Optionally add `...tseslint.configs.stylisticTypeChecked`
30+
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
31+
32+
```js
33+
// eslint.config.js
34+
import react from "eslint-plugin-react";
35+
36+
export default tseslint.config({
37+
// Set the react version
38+
settings: { react: { version: "18.3" } },
39+
plugins: {
40+
// Add the react plugin
41+
react,
42+
},
43+
rules: {
44+
// other rules...
45+
// Enable its recommended rules
46+
...react.configs.recommended.rules,
47+
...react.configs["jsx-runtime"].rules,
48+
},
49+
});
50+
```

client/components.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "new-york",
4+
"rsc": false,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.js",
8+
"css": "src/index.css",
9+
"baseColor": "slate",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils",
16+
"ui": "@/components/ui",
17+
"lib": "@/lib",
18+
"hooks": "@/hooks"
19+
}
20+
}

client/eslint.config.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
import reactHooks from "eslint-plugin-react-hooks";
4+
import reactRefresh from "eslint-plugin-react-refresh";
5+
import tseslint from "typescript-eslint";
6+
7+
export default tseslint.config(
8+
{ ignores: ["dist"] },
9+
{
10+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
11+
files: ["**/*.{ts,tsx}"],
12+
languageOptions: {
13+
ecmaVersion: 2020,
14+
globals: globals.browser,
15+
},
16+
plugins: {
17+
"react-hooks": reactHooks,
18+
"react-refresh": reactRefresh,
19+
},
20+
rules: {
21+
...reactHooks.configs.recommended.rules,
22+
"react-refresh/only-export-components": [
23+
"warn",
24+
{ allowConstantExport: true },
25+
],
26+
},
27+
},
28+
);

client/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + React + TS</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>

client/package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "client",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc -b && vite build",
9+
"lint": "eslint .",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"@radix-ui/react-icons": "^1.3.0",
14+
"@radix-ui/react-slot": "^1.1.0",
15+
"@radix-ui/react-tabs": "^1.1.1",
16+
"class-variance-authority": "^0.7.0",
17+
"clsx": "^2.1.1",
18+
"lucide-react": "^0.447.0",
19+
"react": "^18.3.1",
20+
"react-dom": "^18.3.1",
21+
"tailwind-merge": "^2.5.3",
22+
"tailwindcss-animate": "^1.0.7"
23+
},
24+
"devDependencies": {
25+
"@eslint/js": "^9.11.1",
26+
"@types/node": "^22.7.5",
27+
"@types/react": "^18.3.10",
28+
"@types/react-dom": "^18.3.0",
29+
"@vitejs/plugin-react": "^4.3.2",
30+
"autoprefixer": "^10.4.20",
31+
"eslint": "^9.11.1",
32+
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
33+
"eslint-plugin-react-refresh": "^0.4.12",
34+
"globals": "^15.9.0",
35+
"postcss": "^8.4.47",
36+
"tailwindcss": "^3.4.13",
37+
"typescript": "^5.5.3",
38+
"typescript-eslint": "^8.7.0",
39+
"vite": "^5.4.8"
40+
}
41+
}

client/postcss.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
}

client/public/vite.svg

Lines changed: 1 addition & 0 deletions
Loading

client/src/App.css

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#root {
2+
max-width: 1280px;
3+
margin: 0 auto;
4+
padding: 2rem;
5+
text-align: center;
6+
}
7+
8+
.logo {
9+
height: 6em;
10+
padding: 1.5em;
11+
will-change: filter;
12+
transition: filter 300ms;
13+
}
14+
.logo:hover {
15+
filter: drop-shadow(0 0 2em #646cffaa);
16+
}
17+
.logo.react:hover {
18+
filter: drop-shadow(0 0 2em #61dafbaa);
19+
}
20+
21+
@keyframes logo-spin {
22+
from {
23+
transform: rotate(0deg);
24+
}
25+
to {
26+
transform: rotate(360deg);
27+
}
28+
}
29+
30+
@media (prefers-reduced-motion: no-preference) {
31+
a:nth-of-type(2) .logo {
32+
animation: logo-spin infinite 20s linear;
33+
}
34+
}
35+
36+
.card {
37+
padding: 2em;
38+
}
39+
40+
.read-the-docs {
41+
color: #888;
42+
}

client/src/App.tsx

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import { useState, useEffect } from "react";
2+
import { Send, Bell, Terminal, Files } from "lucide-react";
3+
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
4+
5+
import ConsoleTab from "./components/ConsoleTab";
6+
import Sidebar from "./components/Sidebar";
7+
import RequestsTab from "./components/RequestsTabs";
8+
import ResourcesTab, { Resource } from "./components/ResourcesTab";
9+
import NotificationsTab from "./components/NotificationsTab";
10+
11+
const App = () => {
12+
const [socket, setSocket] = useState<WebSocket | null>(null);
13+
const [resources, setResources] = useState<Resource[]>([]);
14+
const [selectedResource, setSelectedResource] = useState<Resource | null>(
15+
null,
16+
);
17+
const [resourceContent, setResourceContent] = useState<string>("");
18+
const [connectionStatus, setConnectionStatus] = useState<
19+
"disconnected" | "connected" | "error"
20+
>("disconnected");
21+
const [error, setError] = useState<string | null>(null);
22+
23+
useEffect(() => {
24+
const ws = new WebSocket("ws://localhost:3000");
25+
26+
ws.onopen = () => {
27+
console.log("Connected to WebSocket server");
28+
setConnectionStatus("connected");
29+
setSocket(ws);
30+
};
31+
32+
ws.onmessage = (event) => {
33+
const message = JSON.parse(event.data);
34+
console.log("Received message:", message);
35+
if (message.type === "resources") {
36+
setResources(message.data.resources);
37+
setError(null);
38+
} else if (message.type === "resource") {
39+
setResourceContent(JSON.stringify(message.data, null, 2));
40+
setError(null);
41+
} else if (message.type === "error") {
42+
setError(message.message);
43+
}
44+
};
45+
46+
ws.onerror = () => {
47+
setConnectionStatus("error");
48+
};
49+
50+
ws.onclose = () => {
51+
setConnectionStatus("disconnected");
52+
};
53+
54+
return () => ws.close();
55+
}, []);
56+
57+
const listResources = () => {
58+
if (socket) {
59+
socket.send(JSON.stringify({ type: "listResources" }));
60+
}
61+
};
62+
63+
const readResource = (uri: string) => {
64+
if (socket) {
65+
socket.send(JSON.stringify({ type: "readResource", uri }));
66+
}
67+
};
68+
69+
return (
70+
<div className="flex h-screen bg-gray-100">
71+
<Sidebar connectionStatus={connectionStatus} />
72+
<div className="flex-1 flex flex-col">
73+
<div className="flex-1 p-6">
74+
<Tabs defaultValue="requests">
75+
<TabsList className="mb-4">
76+
<TabsTrigger value="requests">
77+
<Send className="w-4 h-4 mr-2" />
78+
Requests
79+
</TabsTrigger>
80+
<TabsTrigger value="notifications">
81+
<Bell className="w-4 h-4 mr-2" />
82+
Notifications
83+
</TabsTrigger>
84+
<TabsTrigger value="resources">
85+
<Files className="w-4 h-4 mr-2" />
86+
Resources
87+
</TabsTrigger>
88+
<TabsTrigger value="console">
89+
<Terminal className="w-4 h-4 mr-2" />
90+
Console
91+
</TabsTrigger>
92+
</TabsList>
93+
94+
<RequestsTab />
95+
<ResourcesTab
96+
resources={resources}
97+
listResources={listResources}
98+
readResource={readResource}
99+
selectedResource={selectedResource}
100+
setSelectedResource={setSelectedResource}
101+
resourceContent={resourceContent}
102+
error={error}
103+
/>
104+
<NotificationsTab />
105+
<ConsoleTab />
106+
</Tabs>
107+
</div>
108+
</div>
109+
</div>
110+
);
111+
};
112+
113+
export default App;

0 commit comments

Comments
 (0)