diff --git a/README-compose.md b/README-compose.md index 139042b..f883c16 100644 --- a/README-compose.md +++ b/README-compose.md @@ -12,6 +12,10 @@ Lifecycle scripts (mode-aware) are available: - `./scripts/start.sh --prod` - `./scripts/status.sh --dev|--prod` - `./scripts/stop.sh --dev|--prod [--wipe]` +- `.\scripts\start.ps1 --dev` +- `.\scripts\start.ps1 --prod` +- `.\scripts\status.ps1 --dev|--prod` +- `.\scripts\stop.ps1 --dev|--prod [--wipe]` ## 1) Prepare environment and secrets diff --git a/README.md b/README.md index 2be7a4a..a19cef8 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,10 @@ Run the entire platform with one command: ./scripts/start.sh ``` +```powershell +.\scripts\start.ps1 +``` + ### Services started: | Service | Purpose | Exposed port | @@ -65,7 +69,7 @@ Run the entire platform with one command: Open the app at `http://localhost:3000`. The frontend container proxies `/api`, `/auth`, `/health`, `/metrics`, `/docs`, `/redoc`, `/openapi.json` and `/ws/*` (with WebSocket upgrade) to the `api` service, so browser clients only need to talk to port 3000. -### What `start.sh` does automatically +### What `start.sh` / `start.ps1` do automatically - verifies required tools (`docker`, `docker compose`, `curl`, `rg`) - creates `.env` on first run with generated secrets (`POSTGRES_PASSWORD`, `JWT_SECRET_KEY`) @@ -92,10 +96,17 @@ docker compose logs -f frontend api worker # tail live logs ./scripts/stop.sh --wipe # stop + wipe volumes ``` +```powershell +.\scripts\status.ps1 # compose + health summary +docker compose logs -f frontend api worker # tail live logs +.\scripts\stop.ps1 # stop stack +.\scripts\stop.ps1 --wipe # stop + wipe volumes +``` + ### Troubleshooting - If Docker daemon is not running, start Docker Desktop / Docker Engine first. -- If startup fails after a major change, run `./scripts/stop.sh --wipe` and then `./scripts/start.sh`. +- If startup fails after a major change, run `./scripts/stop.sh --wipe` (or `.\scripts\stop.ps1 --wipe` on Windows) and then restart. - If ports are already in use, stop conflicting services or adjust host port bindings in `compose.yaml` plus overlay files. ## 🎮 Examples & Demo @@ -131,7 +142,7 @@ During dev the Vite server listens on `http://localhost:5173`; since `VITE_API_B If you are new to this codebase, follow this order: -1. **Run the stack first** with `./scripts/start.sh` so you can see the full upload → analysis → results flow end-to-end. +1. **Run the stack first** with `./scripts/start.sh` (or `.\scripts\start.ps1` on Windows) so you can see the full upload → analysis → results flow end-to-end. 2. **Read the backend entrypoint** (`backend/app/main.py`) and API router composition (`backend/app/api/router.py`) to understand how routes are wired. 3. **Study the analysis pipeline** in `backend/app/application/services/analysis_service.py` and worker task orchestration in `backend/app/workers/tasks.py`. 4. **Review plugin-based checks** under `backend/app/plugins/` (Hadolint, compose runnability, security checks, resource estimation). diff --git a/backend/app/api/routers/ws.py b/backend/app/api/routers/ws.py index 3958712..753eee2 100644 --- a/backend/app/api/routers/ws.py +++ b/backend/app/api/routers/ws.py @@ -4,11 +4,59 @@ from fastapi import APIRouter, Query, WebSocket, WebSocketDisconnect from app.core.security import decode_token +from app.infrastructure.db.repositories import JobRepository +from app.infrastructure.db.session import SessionLocal +from app.infrastructure.events.bus import redis_client from app.infrastructure.events.bus import subscribe router = APIRouter(tags=["websockets"]) +async def _job_belongs_to_user(job_id: uuid.UUID, user_id: uuid.UUID) -> bool: + async with SessionLocal() as session: + repo = JobRepository(session) + job = await repo.get_job(job_id, user_id) + return job is not None + + +async def _user_has_container_access(user_id: uuid.UUID, container_id: str) -> bool: + pattern = f"deploy:{user_id}:*" + cursor = 0 + while True: + cursor, keys = await redis_client.scan(cursor=cursor, match=pattern, count=100) + for key in keys: + raw_state = await redis_client.get(key) + if not raw_state: + continue + try: + state = json.loads(raw_state) + except json.JSONDecodeError: + continue + if not isinstance(state, dict): + continue + ids: set[str] = set() + top_id = state.get("container_id") + if isinstance(top_id, str) and top_id: + ids.add(top_id) + top_ids = state.get("container_ids") + if isinstance(top_ids, list): + for row in top_ids: + if isinstance(row, str) and row: + ids.add(row) + containers = state.get("containers") + if isinstance(containers, list): + for row in containers: + if isinstance(row, dict): + row_id = row.get("id") + if isinstance(row_id, str) and row_id: + ids.add(row_id) + if container_id in ids: + return True + if cursor == 0: + break + return False + + @router.websocket("/ws/jobs/{job_id}") async def job_updates( websocket: WebSocket, @@ -20,13 +68,18 @@ async def job_updates( payload = decode_token(token) if payload.get("type") != "access": raise ValueError("wrong token type") - _ = uuid.UUID(payload["sub"]) - uuid.UUID(job_id) - except Exception: + user_id = uuid.UUID(payload["sub"]) + job_uuid = uuid.UUID(job_id) + except (KeyError, TypeError, ValueError): await websocket.send_json({"error": "invalid token"}) await websocket.close(code=4401) return + if not await _job_belongs_to_user(job_uuid, user_id): + await websocket.send_json({"error": "forbidden"}) + await websocket.close(code=4403) + return + try: async for event in subscribe(f"job:{job_id}:events"): await websocket.send_text(json.dumps(event)) @@ -45,11 +98,16 @@ async def container_metrics( payload = decode_token(token) if payload.get("type") != "access": raise ValueError("wrong token type") - _ = uuid.UUID(payload["sub"]) - except Exception: + user_id = uuid.UUID(payload["sub"]) + except (KeyError, TypeError, ValueError): await websocket.send_json({"error": "invalid token"}) await websocket.close(code=4401) return + + if not await _user_has_container_access(user_id, container_id): + await websocket.send_json({"error": "forbidden"}) + await websocket.close(code=4403) + return try: async for event in subscribe(f"container:{container_id}:metrics"): await websocket.send_text(json.dumps(event)) @@ -72,7 +130,7 @@ async def user_container_metrics( if payload.get("sub") != user_id: raise ValueError("user mismatch") uuid.UUID(user_id) - except Exception: + except (KeyError, TypeError, ValueError): await websocket.send_json({"error": "invalid token"}) await websocket.close(code=4401) return @@ -81,3 +139,29 @@ async def user_container_metrics( await websocket.send_text(json.dumps(event)) except WebSocketDisconnect: return + + +@router.websocket("/ws/users/{user_id}/events") +async def user_events( + websocket: WebSocket, + user_id: str, + token: str = Query(...), +) -> None: + await websocket.accept() + try: + payload = decode_token(token) + if payload.get("type") != "access": + raise ValueError("wrong token type") + if payload.get("sub") != user_id: + raise ValueError("user mismatch") + uuid.UUID(user_id) + except (KeyError, TypeError, ValueError): + await websocket.send_json({"error": "invalid token"}) + await websocket.close(code=4401) + return + + try: + async for event in subscribe(f"user:{user_id}:events"): + await websocket.send_text(json.dumps(event)) + except WebSocketDisconnect: + return diff --git a/backend/app/application/services/analysis_service.py b/backend/app/application/services/analysis_service.py index 6c1d6dc..4bb2bb7 100644 --- a/backend/app/application/services/analysis_service.py +++ b/backend/app/application/services/analysis_service.py @@ -64,6 +64,22 @@ def _grade(score: int) -> str: return "F" +def _build_analysis_started_payload(context: dict[str, Any]) -> dict[str, Any]: + filename = context.get("filename") + source = context.get("source") + dockerfile_content = context.get("dockerfile_content") + compose_content = context.get("compose_content") + analysis_type = "compose" if isinstance(compose_content, str) and compose_content else "dockerfile" + effective_source = compose_content if analysis_type == "compose" else dockerfile_content + line_count = len(effective_source.splitlines()) if isinstance(effective_source, str) else 0 + payload: dict[str, Any] = {"analysis_type": analysis_type, "line_count": max(1, line_count)} + if isinstance(filename, str) and filename: + payload["filename"] = filename + if isinstance(source, str) and source: + payload["source"] = source + return payload + + class AnalysisService: def __init__(self, session: AsyncSession) -> None: self.session = session @@ -140,7 +156,8 @@ async def analyze_content( async def run_job_with_plugins( self, user_id: uuid.UUID, job_id: uuid.UUID, context: dict[str, Any], plugin_names: Iterable[str] ) -> dict[str, Any]: - await publish_event(DomainEvent("user.analysis.started", str(user_id), str(job_id), payload=context)) + safe_start_payload = _build_analysis_started_payload(context) + await publish_event(DomainEvent("user.analysis.started", str(user_id), str(job_id), payload=safe_start_payload)) await self.repo.update_status(job_id, user_id, JobStatus.running) await self.session.commit() diff --git a/backend/app/workers/tasks.py b/backend/app/workers/tasks.py index 6692f6b..a31ab81 100644 --- a/backend/app/workers/tasks.py +++ b/backend/app/workers/tasks.py @@ -88,7 +88,17 @@ async def run_project_analysis(ctx, payload: dict) -> dict: repo = JobRepository(session) svc = AnalysisService(session) - await publish_event(DomainEvent("project.analysis_started", str(user_id), str(job_id), payload={"project_path": str(project_path)})) + await publish_event( + DomainEvent( + "project.analysis_started", + str(user_id), + str(job_id), + payload={ + "dockerfile_count": len(dockerfiles), + "compose_count": len(compose_files), + }, + ) + ) await repo.update_status(job_id, user_id, JobStatus.running) await session.commit() diff --git a/backend/tests/test_analysis_service.py b/backend/tests/test_analysis_service.py index dce5b46..b31d383 100644 --- a/backend/tests/test_analysis_service.py +++ b/backend/tests/test_analysis_service.py @@ -1,6 +1,6 @@ from unittest.mock import AsyncMock -from app.application.services.analysis_service import AnalysisService +from app.application.services.analysis_service import AnalysisService, _build_analysis_started_payload def test_normalize_issue_uses_level_when_severity_missing(): @@ -70,3 +70,20 @@ def test_normalize_issue_dclint_rdjson_code_object(): assert issue.line == 7 assert issue.severity == "error" assert issue.suggestion == "Bind ports to a host interface." + + +def test_build_analysis_started_payload_omits_source_content(): + payload = _build_analysis_started_payload( + { + "filename": "docker-compose.yml", + "source": "upload", + "compose_content": "services:\n web:\n image: nginx:1.27\n", + "dockerfile_content": "", + } + ) + assert payload["analysis_type"] == "compose" + assert payload["line_count"] == 3 + assert payload["filename"] == "docker-compose.yml" + assert payload["source"] == "upload" + assert "compose_content" not in payload + assert "dockerfile_content" not in payload diff --git a/backend/tests/test_ws_metrics.py b/backend/tests/test_ws_metrics.py index 983ead8..7feb9fe 100644 --- a/backend/tests/test_ws_metrics.py +++ b/backend/tests/test_ws_metrics.py @@ -1,5 +1,6 @@ import json import uuid +from unittest.mock import AsyncMock from app.core.security import create_token @@ -18,6 +19,7 @@ async def fake_subscribe(channel: str): } monkeypatch.setattr("app.api.routers.ws.subscribe", fake_subscribe) + monkeypatch.setattr("app.api.routers.ws._user_has_container_access", AsyncMock(return_value=True)) with client.websocket_connect(f"/ws/metrics/web-container?token={token}") as websocket: message = websocket.receive_text() @@ -42,6 +44,7 @@ async def fake_subscribe(channel: str): } monkeypatch.setattr("app.api.routers.ws.subscribe", fake_subscribe) + monkeypatch.setattr("app.api.routers.ws._job_belongs_to_user", AsyncMock(return_value=True)) with client.websocket_connect(f"/ws/jobs/{job_id}?token={token}") as websocket: message = websocket.receive_text() @@ -77,3 +80,54 @@ async def fake_subscribe(channel: str): ) as websocket: payload = websocket.receive_json() assert payload["error"] == "invalid token" + + +def test_ws_jobs_rejects_non_owner_subscription(client, monkeypatch): + user_id = uuid.uuid4() + job_id = uuid.uuid4() + token = create_token(str(user_id), "access", 30) + monkeypatch.setattr("app.api.routers.ws._job_belongs_to_user", AsyncMock(return_value=False)) + + with client.websocket_connect(f"/ws/jobs/{job_id}?token={token}") as websocket: + payload = websocket.receive_json() + assert payload["error"] == "forbidden" + + +def test_ws_metrics_rejects_non_owner_subscription(client, monkeypatch): + user_id = uuid.uuid4() + token = create_token(str(user_id), "access", 30) + monkeypatch.setattr("app.api.routers.ws._user_has_container_access", AsyncMock(return_value=False)) + + with client.websocket_connect(f"/ws/metrics/web-container?token={token}") as websocket: + payload = websocket.receive_json() + assert payload["error"] == "forbidden" + + +def test_ws_user_events_streams_with_matching_token(client, monkeypatch): + user_id = uuid.uuid4() + token = create_token(str(user_id), "access", 30) + + async def fake_subscribe(channel: str): + assert channel == f"user:{user_id}:events" + yield { + "event_name": "user.analysis.completed", + "user_id": str(user_id), + "job_id": "j-1", + "payload": {"status": "done"}, + } + + monkeypatch.setattr("app.api.routers.ws.subscribe", fake_subscribe) + + with client.websocket_connect(f"/ws/users/{user_id}/events?token={token}") as websocket: + payload = websocket.receive_json() + assert payload["event_name"] == "user.analysis.completed" + + +def test_ws_user_events_rejects_user_mismatch(client): + user_id = uuid.uuid4() + other_user_id = uuid.uuid4() + token = create_token(str(user_id), "access", 30) + + with client.websocket_connect(f"/ws/users/{other_user_id}/events?token={token}") as websocket: + payload = websocket.receive_json() + assert payload["error"] == "invalid token" diff --git a/frontend/package-lock.json b/frontend/package-lock.json index f6e135d..2b12c77 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -8,13 +8,18 @@ "name": "frontend", "version": "0.0.0", "dependencies": { + "@lottiefiles/dotlottie-react": "^0.19.4", "@radix-ui/react-progress": "1.1.2", "@radix-ui/react-slot": "1.1.2", "@radix-ui/react-tabs": "1.1.3", + "@react-three/drei": "^10.7.7", + "@react-three/fiber": "^9.6.1", + "@rive-app/react-canvas": "^4.28.6", "class-variance-authority": "0.7.1", "clsx": "2.1.1", + "gsap": "^3.15.0", "lucide-react": "0.487.0", - "motion": "^12.38.0", + "motion": "^12.40.0", "next-themes": "0.4.6", "react": "^19.2.0", "react-dom": "^19.2.0", @@ -22,7 +27,10 @@ "react-syntax-highlighter": "^16.1.1", "recharts": "2.15.2", "sonner": "2.0.3", - "tailwind-merge": "3.2.0" + "tailwind-merge": "3.2.0", + "three": "^0.184.0", + "three-vanta": "npm:three@^0.121.1", + "vanta": "^0.5.24" }, "devDependencies": { "@eslint/js": "^9.39.4", @@ -307,6 +315,12 @@ "node": ">=6.9.0" } }, + "node_modules/@dimforge/rapier3d-compat": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@dimforge/rapier3d-compat/-/rapier3d-compat-0.12.0.tgz", + "integrity": "sha512-uekIGetywIgopfD97oDL5PfeezkFpNhwlzlaEYNOA0N6ghdsOvh/HYjSMek5Q2O1PYvRSDFcqFVJl4r4ZBwOow==", + "license": "Apache-2.0" + }, "node_modules/@emnapi/core": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.9.1.tgz", @@ -600,6 +614,50 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@lottiefiles/dotlottie-react": { + "version": "0.19.4", + "resolved": "https://registry.npmjs.org/@lottiefiles/dotlottie-react/-/dotlottie-react-0.19.4.tgz", + "integrity": "sha512-YgX1Ie0gK9MEA89Ap7Ic/lOv85sOzELV3y3RAQ4GrB79+wJ4gLga9Ge59mWzBqjlbT8bZNhNPEm+jYyV8kMYqg==", + "license": "MIT", + "dependencies": { + "@lottiefiles/dotlottie-web": "0.74.0" + }, + "engines": { + "node": ">=18.17.0", + "npm": ">=9.5.0" + }, + "peerDependencies": { + "react": "^17 || ^18 || ^19" + } + }, + "node_modules/@lottiefiles/dotlottie-web": { + "version": "0.74.0", + "resolved": "https://registry.npmjs.org/@lottiefiles/dotlottie-web/-/dotlottie-web-0.74.0.tgz", + "integrity": "sha512-rG12+dJSVhQDdleGr9epR7zU/UJ6hh8jzBDHAurClHP5t5dSrOh3eP3UCFxolpVPcobaRVYsBnYg4HQokQewpg==", + "license": "MIT", + "engines": { + "node": ">=18.17.0", + "npm": ">=9.5.0" + } + }, + "node_modules/@mediapipe/tasks-vision": { + "version": "0.10.17", + "resolved": "https://registry.npmjs.org/@mediapipe/tasks-vision/-/tasks-vision-0.10.17.tgz", + "integrity": "sha512-CZWV/q6TTe8ta61cZXjfnnHsfWIdFhms03M9T7Cnd5y2mdpylJM0rF1qRq+wsQVRMLz1OYPVEBU9ph2Bx8cxrg==", + "license": "Apache-2.0" + }, + "node_modules/@monogrid/gainmap-js": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/@monogrid/gainmap-js/-/gainmap-js-3.4.0.tgz", + "integrity": "sha512-2Z0FATFHaoYJ8b+Y4y4Hgfn3FRFwuU5zRrk+9dFWp4uGAdHGqVEdP7HP+gLA3X469KXHmfupJaUbKo1b/aDKIg==", + "license": "MIT", + "dependencies": { + "promise-worker-transferable": "^1.0.4" + }, + "peerDependencies": { + "three": ">= 0.159.0" + } + }, "node_modules/@napi-rs/wasm-runtime": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.1.tgz", @@ -920,6 +978,112 @@ } } }, + "node_modules/@react-three/drei": { + "version": "10.7.7", + "resolved": "https://registry.npmjs.org/@react-three/drei/-/drei-10.7.7.tgz", + "integrity": "sha512-ff+J5iloR0k4tC++QtD/j9u3w5fzfgFAWDtAGQah9pF2B1YgOq/5JxqY0/aVoQG5r3xSZz0cv5tk2YuBob4xEQ==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.26.0", + "@mediapipe/tasks-vision": "0.10.17", + "@monogrid/gainmap-js": "^3.0.6", + "@use-gesture/react": "^10.3.1", + "camera-controls": "^3.1.0", + "cross-env": "^7.0.3", + "detect-gpu": "^5.0.56", + "glsl-noise": "^0.0.0", + "hls.js": "^1.5.17", + "maath": "^0.10.8", + "meshline": "^3.3.1", + "stats-gl": "^2.2.8", + "stats.js": "^0.17.0", + "suspend-react": "^0.1.3", + "three-mesh-bvh": "^0.8.3", + "three-stdlib": "^2.35.6", + "troika-three-text": "^0.52.4", + "tunnel-rat": "^0.1.2", + "use-sync-external-store": "^1.4.0", + "utility-types": "^3.11.0", + "zustand": "^5.0.1" + }, + "peerDependencies": { + "@react-three/fiber": "^9.0.0", + "react": "^19", + "react-dom": "^19", + "three": ">=0.159" + }, + "peerDependenciesMeta": { + "react-dom": { + "optional": true + } + } + }, + "node_modules/@react-three/fiber": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/@react-three/fiber/-/fiber-9.6.1.tgz", + "integrity": "sha512-zF0rsKcVYpcJwbFEnv2HkHX9cvOEgsfQo/X8lwmR2dn13S4qEQJXir9fxf5js2LQFoXqxOY7MDkOkYx2uZ4gSg==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.17.8", + "@types/webxr": "*", + "base64-js": "^1.5.1", + "buffer": "^6.0.3", + "its-fine": "^2.0.0", + "react-use-measure": "^2.1.7", + "scheduler": "^0.27.0", + "suspend-react": "^0.1.3", + "use-sync-external-store": "^1.4.0", + "zustand": "^5.0.3" + }, + "peerDependencies": { + "expo": ">=43.0", + "expo-asset": ">=8.4", + "expo-file-system": ">=11.0", + "expo-gl": ">=11.0", + "react": ">=19 <19.3", + "react-dom": ">=19 <19.3", + "react-native": ">=0.78", + "three": ">=0.156" + }, + "peerDependenciesMeta": { + "expo": { + "optional": true + }, + "expo-asset": { + "optional": true + }, + "expo-file-system": { + "optional": true + }, + "expo-gl": { + "optional": true + }, + "react-dom": { + "optional": true + }, + "react-native": { + "optional": true + } + } + }, + "node_modules/@rive-app/canvas": { + "version": "2.37.8", + "resolved": "https://registry.npmjs.org/@rive-app/canvas/-/canvas-2.37.8.tgz", + "integrity": "sha512-nffrPG+VkBKHAxZdcqYlP5M+n/mOAoagj774HH397UPTsfC27gwQURg64i6dX7WswMc5qIVX0rzCrZ86Wb2HOA==", + "license": "MIT" + }, + "node_modules/@rive-app/react-canvas": { + "version": "4.28.6", + "resolved": "https://registry.npmjs.org/@rive-app/react-canvas/-/react-canvas-4.28.6.tgz", + "integrity": "sha512-tMEb7uDr+xuPny4HRVnkfGDHgTCkTFn15u7GHj12hC94N59g/dO15TiGr9312GVTO82FulOymOKy6sgxZyi5rw==", + "license": "MIT", + "dependencies": { + "@rive-app/canvas": "2.37.8" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0" + } + }, "node_modules/@rolldown/binding-android-arm64": { "version": "1.0.0-rc.10", "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.0-rc.10.tgz", @@ -1468,6 +1632,12 @@ "vite": "^5.2.0 || ^6 || ^7 || ^8" } }, + "node_modules/@tweenjs/tween.js": { + "version": "23.1.3", + "resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-23.1.3.tgz", + "integrity": "sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==", + "license": "MIT" + }, "node_modules/@tybys/wasm-util": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz", @@ -1542,6 +1712,12 @@ "integrity": "sha512-Ps3T8E8dZDam6fUyNiMkekK3XUsaUEik+idO9/YjPtfj2qruF8tFBXS7XhtE4iIXBLxhmLjP3SXpLhVf21I9Lw==", "license": "MIT" }, + "node_modules/@types/draco3d": { + "version": "1.4.10", + "resolved": "https://registry.npmjs.org/@types/draco3d/-/draco3d-1.4.10.tgz", + "integrity": "sha512-AX22jp8Y7wwaBgAixaSvkoG4M/+PlAcm3Qs4OW8yT9DM4xUpWKeFhLueTAyZF39pviAdcDdeJoACapiAceqNcw==", + "license": "MIT" + }, "node_modules/@types/estree": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", @@ -1575,6 +1751,12 @@ "undici-types": "~7.16.0" } }, + "node_modules/@types/offscreencanvas": { + "version": "2019.7.3", + "resolved": "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.7.3.tgz", + "integrity": "sha512-ieXiYmgSRXUDeOntE1InxjWyvEelZGP63M+cGuquuRLuIKKT1osnkXjxev9B7d1nXSug5vpunx+gNlbVxMlC9A==", + "license": "MIT" + }, "node_modules/@types/prismjs": { "version": "1.26.6", "resolved": "https://registry.npmjs.org/@types/prismjs/-/prismjs-1.26.6.tgz", @@ -1585,7 +1767,6 @@ "version": "19.2.14", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz", "integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==", - "devOptional": true, "license": "MIT", "dependencies": { "csstype": "^3.2.2" @@ -1601,6 +1782,15 @@ "@types/react": "^19.2.0" } }, + "node_modules/@types/react-reconciler": { + "version": "0.28.9", + "resolved": "https://registry.npmjs.org/@types/react-reconciler/-/react-reconciler-0.28.9.tgz", + "integrity": "sha512-HHM3nxyUZ3zAylX8ZEyrDNd2XZOnQ0D5XfunJF5FLQnZbHHYq4UWvW1QfelQNXv1ICNkwYhfxjwfnqivYB6bFg==", + "license": "MIT", + "peerDependencies": { + "@types/react": "*" + } + }, "node_modules/@types/react-syntax-highlighter": { "version": "15.5.13", "resolved": "https://registry.npmjs.org/@types/react-syntax-highlighter/-/react-syntax-highlighter-15.5.13.tgz", @@ -1611,12 +1801,38 @@ "@types/react": "*" } }, + "node_modules/@types/stats.js": { + "version": "0.17.4", + "resolved": "https://registry.npmjs.org/@types/stats.js/-/stats.js-0.17.4.tgz", + "integrity": "sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA==", + "license": "MIT" + }, + "node_modules/@types/three": { + "version": "0.184.1", + "resolved": "https://registry.npmjs.org/@types/three/-/three-0.184.1.tgz", + "integrity": "sha512-6q4VdiqVsrTRqmk62/BnlcAvIrnDM0zf2ZDVKI5kZiniWrSaOHaQzmbp+BNzoggc/8tgW412pL//wZIxu2PPTA==", + "license": "MIT", + "dependencies": { + "@dimforge/rapier3d-compat": "~0.12.0", + "@tweenjs/tween.js": "~23.1.3", + "@types/stats.js": "*", + "@types/webxr": ">=0.5.17", + "fflate": "~0.8.2", + "meshoptimizer": "~1.1.1" + } + }, "node_modules/@types/unist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", "license": "MIT" }, + "node_modules/@types/webxr": { + "version": "0.5.24", + "resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.24.tgz", + "integrity": "sha512-h8fgEd/DpoS9CBrjEQXR+dIDraopAEfu4wYVNY2tEPwk60stPWhvZMf4Foo5FakuQ7HFZoa8WceaWFervK2Ovg==", + "license": "MIT" + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "8.57.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.57.1.tgz", @@ -1912,6 +2128,24 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/@use-gesture/core": { + "version": "10.3.1", + "resolved": "https://registry.npmjs.org/@use-gesture/core/-/core-10.3.1.tgz", + "integrity": "sha512-WcINiDt8WjqBdUXye25anHiNxPc0VOrlT8F6LLkU6cycrOGUDyY/yyFmsg3k8i5OLvv25llc0QC45GhR/C8llw==", + "license": "MIT" + }, + "node_modules/@use-gesture/react": { + "version": "10.3.1", + "resolved": "https://registry.npmjs.org/@use-gesture/react/-/react-10.3.1.tgz", + "integrity": "sha512-Yy19y6O2GJq8f7CHf7L0nxL8bf4PZCPaVOCgJrusOeFHY1LvHgYXnmnXg6N5iwAnbgbZCDjo60SiM6IPJi9C5g==", + "license": "MIT", + "dependencies": { + "@use-gesture/core": "10.3.1" + }, + "peerDependencies": { + "react": ">= 16.8.0" + } + }, "node_modules/@vitejs/plugin-react": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-6.0.1.tgz", @@ -2045,6 +2279,26 @@ "dev": true, "license": "MIT" }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/baseline-browser-mapping": { "version": "2.10.9", "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.9.tgz", @@ -2058,6 +2312,15 @@ "node": ">=6.0.0" } }, + "node_modules/bidi-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/bidi-js/-/bidi-js-1.0.3.tgz", + "integrity": "sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==", + "license": "MIT", + "dependencies": { + "require-from-string": "^2.0.2" + } + }, "node_modules/brace-expansion": { "version": "1.1.12", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", @@ -2103,6 +2366,30 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -2113,6 +2400,19 @@ "node": ">=6" } }, + "node_modules/camera-controls": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/camera-controls/-/camera-controls-3.1.2.tgz", + "integrity": "sha512-xkxfpG2ECZ6Ww5/9+kf4mfg1VEYAoe9aDSY+IwF0UEs7qEzwy0aVRfs2grImIECs/PoBtWFrh7RXsQkwG922JA==", + "license": "MIT", + "engines": { + "node": ">=22.0.0", + "npm": ">=10.5.1" + }, + "peerDependencies": { + "three": ">=0.126.1" + } + }, "node_modules/caniuse-lite": { "version": "1.0.30001780", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001780.tgz", @@ -2259,11 +2559,28 @@ "url": "https://opencollective.com/express" } }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", - "dev": true, "license": "MIT", "dependencies": { "path-key": "^3.1.0", @@ -2445,6 +2762,15 @@ "dev": true, "license": "MIT" }, + "node_modules/detect-gpu": { + "version": "5.0.70", + "resolved": "https://registry.npmjs.org/detect-gpu/-/detect-gpu-5.0.70.tgz", + "integrity": "sha512-bqerEP1Ese6nt3rFkwPnGbsUF9a4q+gMmpTVVOEzoCyeCc+y7/RvJnQZJx1JwhgQI5Ntg0Kgat8Uu7XpBqnz1w==", + "license": "MIT", + "dependencies": { + "webgl-constants": "^1.1.1" + } + }, "node_modules/detect-libc": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", @@ -2465,6 +2791,12 @@ "csstype": "^3.0.2" } }, + "node_modules/draco3d": { + "version": "1.5.7", + "resolved": "https://registry.npmjs.org/draco3d/-/draco3d-1.5.7.tgz", + "integrity": "sha512-m6WCKt/erDXcw+70IJXnG7M3awwQPAsZvJGX5zY7beBqpELw6RDGkYVU0W43AFxye4pDZ5i2Lbyc/NNGqwjUVQ==", + "license": "Apache-2.0" + }, "node_modules/electron-to-chromium": { "version": "1.5.321", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.321.tgz", @@ -2760,6 +3092,12 @@ } } }, + "node_modules/fflate": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz", + "integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==", + "license": "MIT" + }, "node_modules/file-entry-cache": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", @@ -2834,13 +3172,13 @@ } }, "node_modules/framer-motion": { - "version": "12.38.0", - "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-12.38.0.tgz", - "integrity": "sha512-rFYkY/pigbcswl1XQSb7q424kSTQ8q6eAC+YUsSKooHQYuLdzdHjrt6uxUC+PRAO++q5IS7+TamgIw1AphxR+g==", + "version": "12.40.0", + "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-12.40.0.tgz", + "integrity": "sha512-uaBd3qC1v3KQqBEjwTUd183K6PbS+j0yR9w9VmEOLWA/tnUcSn8Xa3uck7t4dgpDoUss8xQTcj8W2L07lrnLFg==", "license": "MIT", "dependencies": { - "motion-dom": "^12.38.0", - "motion-utils": "^12.36.0", + "motion-dom": "^12.40.0", + "motion-utils": "^12.39.0", "tslib": "^2.4.0" }, "peerDependencies": { @@ -2911,6 +3249,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/glsl-noise": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/glsl-noise/-/glsl-noise-0.0.0.tgz", + "integrity": "sha512-b/ZCF6amfAUb7dJM/MxRs7AetQEahYzJ8PtgfrmEdtw6uyGOr+ZSGtgjFm6mfsBkxJ4d2W7kg+Nlqzqvn3Bc0w==", + "license": "MIT" + }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", @@ -2918,6 +3262,12 @@ "dev": true, "license": "ISC" }, + "node_modules/gsap": { + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/gsap/-/gsap-3.15.0.tgz", + "integrity": "sha512-dMW4CWBTUK1AEEDeZc1g4xpPGIrSf9fJF960qbTZmN/QwZIWY5wgliS6JWl9/25fpTGJrMRtSjGtOmPnfjZB+A==", + "license": "Standard 'no charge' license: https://gsap.com/standard-license." + }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -2990,6 +3340,32 @@ "integrity": "sha512-PDEfEF102G23vHmPhLyPboFCD+BkMGu+GuJe2d9/eH4FsCwvgBpnc9n0pGE+ffKdph38s6foEZiEjdgHdzp+IA==", "license": "CC0-1.0" }, + "node_modules/hls.js": { + "version": "1.6.16", + "resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.6.16.tgz", + "integrity": "sha512-VSIRpLfRwlAAdGL4wiTucx2ScRipo0ed1FBatWkyt832jC4CReKstga6yIhYVwGu9LOBjuX9wzmRMeQdBJtzEA==", + "license": "Apache-2.0" + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -3000,6 +3376,12 @@ "node": ">= 4" } }, + "node_modules/immediate": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", + "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==", + "license": "MIT" + }, "node_modules/import-fresh": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", @@ -3103,13 +3485,30 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/is-promise": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", + "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==", + "license": "MIT" + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true, "license": "ISC" }, + "node_modules/its-fine": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/its-fine/-/its-fine-2.0.0.tgz", + "integrity": "sha512-KLViCmWx94zOvpLwSlsx6yOCeMhZYaxrJV87Po5k/FoZzcPSahvK5qJ7fYhS61sZi5ikmh2S3Hz55A2l3U69ng==", + "license": "MIT", + "dependencies": { + "@types/react-reconciler": "^0.28.9" + }, + "peerDependencies": { + "react": "^19.0.0" + } + }, "node_modules/jiti": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.6.1.tgz", @@ -3210,6 +3609,15 @@ "node": ">= 0.8.0" } }, + "node_modules/lie": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", + "integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==", + "license": "MIT", + "dependencies": { + "immediate": "~3.0.5" + } + }, "node_modules/lightningcss": { "version": "1.32.0", "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", @@ -3545,6 +3953,16 @@ "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, + "node_modules/maath": { + "version": "0.10.8", + "resolved": "https://registry.npmjs.org/maath/-/maath-0.10.8.tgz", + "integrity": "sha512-tRvbDF0Pgqz+9XUa4jjfgAQ8/aPKmQdWXilFu2tMy4GWj4NOsx99HlULO4IeREfbO3a0sA145DZYyvXPkybm0g==", + "license": "MIT", + "peerDependencies": { + "@types/three": ">=0.134.0", + "three": ">=0.134.0" + } + }, "node_modules/magic-string": { "version": "0.30.21", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", @@ -3555,6 +3973,21 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/meshline": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/meshline/-/meshline-3.3.1.tgz", + "integrity": "sha512-/TQj+JdZkeSUOl5Mk2J7eLcYTLiQm2IDzmlSvYm7ov15anEcDJ92GHqqazxTSreeNgfnYu24kiEvvv0WlbCdFQ==", + "license": "MIT", + "peerDependencies": { + "three": ">=0.137" + } + }, + "node_modules/meshoptimizer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-1.1.1.tgz", + "integrity": "sha512-oRFNWJRDA/WTrVj7NWvqa5HqE1t9MYDj2VaWirQCzCCrAd2GHrqR/sQezCxiWATPNlKTcRaPRHPJwIRoPBAp5g==", + "license": "MIT" + }, "node_modules/minimatch": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", @@ -3569,12 +4002,12 @@ } }, "node_modules/motion": { - "version": "12.38.0", - "resolved": "https://registry.npmjs.org/motion/-/motion-12.38.0.tgz", - "integrity": "sha512-uYfXzeHlgThchzwz5Te47dlv5JOUC7OB4rjJ/7XTUgtBZD8CchMN8qEJ4ZVsUmTyYA44zjV0fBwsiktRuFnn+w==", + "version": "12.40.0", + "resolved": "https://registry.npmjs.org/motion/-/motion-12.40.0.tgz", + "integrity": "sha512-yjrHUrBFW6kQvjJwRsoiPSAhC5tRwRqNGJWmiJ4CrGnbKp0V88AdzkhBmDoqIsIPfarOe0Uddd37Xq43/gIocA==", "license": "MIT", "dependencies": { - "framer-motion": "^12.38.0", + "framer-motion": "^12.40.0", "tslib": "^2.4.0" }, "peerDependencies": { @@ -3595,18 +4028,18 @@ } }, "node_modules/motion-dom": { - "version": "12.38.0", - "resolved": "https://registry.npmjs.org/motion-dom/-/motion-dom-12.38.0.tgz", - "integrity": "sha512-pdkHLD8QYRp8VfiNLb8xIBJis1byQ9gPT3Jnh2jqfFtAsWUA3dEepDlsWe/xMpO8McV+VdpKVcp+E+TGJEtOoA==", + "version": "12.40.0", + "resolved": "https://registry.npmjs.org/motion-dom/-/motion-dom-12.40.0.tgz", + "integrity": "sha512-HxU3ZaBwNPVQUBQf1xxgq+7JrPNZvjLVxgbpEZL7RrWJnsxOf0/OM+yrHG9ogLQ31Do/r57Oz2gQWPK+6q62mg==", "license": "MIT", "dependencies": { - "motion-utils": "^12.36.0" + "motion-utils": "^12.39.0" } }, "node_modules/motion-utils": { - "version": "12.36.0", - "resolved": "https://registry.npmjs.org/motion-utils/-/motion-utils-12.36.0.tgz", - "integrity": "sha512-eHWisygbiwVvf6PZ1vhaHCLamvkSbPIeAYxWUuL3a2PD/TROgE7FvfHWTIH4vMl798QLfMw15nRqIaRDXTlYRg==", + "version": "12.39.0", + "resolved": "https://registry.npmjs.org/motion-utils/-/motion-utils-12.39.0.tgz", + "integrity": "sha512-8nadJAJjTtqRkmRF36FoJTrywK9nnFmnPwnSMyxaOCU7GDjN9RTMJIxx9De8ErM+vpPhMccr/6fo5WciyQLnMQ==", "license": "MIT" }, "node_modules/ms": { @@ -3770,7 +4203,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -3832,6 +4264,12 @@ "dev": true, "license": "MIT" }, + "node_modules/potpack": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/potpack/-/potpack-1.0.2.tgz", + "integrity": "sha512-choctRBIV9EMT9WGAZHn3V7t0Z2pMQyl0EZE6pFc/6ml3ssw7Dlf/oAOvFwjm1HVsqfQN8GfeFyJ+d8tRzqueQ==", + "license": "ISC" + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -3851,6 +4289,16 @@ "node": ">=6" } }, + "node_modules/promise-worker-transferable": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/promise-worker-transferable/-/promise-worker-transferable-1.0.4.tgz", + "integrity": "sha512-bN+0ehEnrXfxV2ZQvU2PetO0n4gqBD4ulq3MI1WOPLgr7/Mg9yRQkX5+0v1vagr74ZTsl7XtzlaYDo2EuCeYJw==", + "license": "Apache-2.0", + "dependencies": { + "is-promise": "^2.1.0", + "lie": "^3.0.2" + } + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", @@ -3998,6 +4446,21 @@ "react-dom": ">=16.6.0" } }, + "node_modules/react-use-measure": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/react-use-measure/-/react-use-measure-2.1.7.tgz", + "integrity": "sha512-KrvcAo13I/60HpwGO5jpW7E9DfusKyLPLvuHlUyP5zqnmAPhNc6qTRjUQrdTADl0lpPpDVU2/Gg51UlOGHXbdg==", + "license": "MIT", + "peerDependencies": { + "react": ">=16.13", + "react-dom": ">=16.13" + }, + "peerDependenciesMeta": { + "react-dom": { + "optional": true + } + } + }, "node_modules/recharts": { "version": "2.15.2", "resolved": "https://registry.npmjs.org/recharts/-/recharts-2.15.2.tgz", @@ -4052,6 +4515,15 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -4129,7 +4601,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, "license": "MIT", "dependencies": { "shebang-regex": "^3.0.0" @@ -4142,7 +4613,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -4178,6 +4648,32 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/stats-gl": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/stats-gl/-/stats-gl-2.4.2.tgz", + "integrity": "sha512-g5O9B0hm9CvnM36+v7SFl39T7hmAlv541tU81ME8YeSb3i1CIP5/QdDeSB3A0la0bKNHpxpwxOVRo2wFTYEosQ==", + "license": "MIT", + "dependencies": { + "@types/three": "*", + "three": "^0.170.0" + }, + "peerDependencies": { + "@types/three": "*", + "three": "*" + } + }, + "node_modules/stats-gl/node_modules/three": { + "version": "0.170.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.170.0.tgz", + "integrity": "sha512-FQK+LEpYc0fBD+J8g6oSEyyNzjp+Q7Ks1C568WWaoMRLW+TkNNWmenWeGgJjV105Gd+p/2ql1ZcjYvNiPZBhuQ==", + "license": "MIT" + }, + "node_modules/stats.js": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/stats.js/-/stats.js-0.17.0.tgz", + "integrity": "sha512-hNKz8phvYLPEcRkeG1rsGmV5ChMjKDAWU7/OJJdDErPBNChQXxCo3WZurGpnWc6gZhAzEPFad1aVgyOANH1sMw==", + "license": "MIT" + }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -4204,6 +4700,15 @@ "node": ">=8" } }, + "node_modules/suspend-react": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/suspend-react/-/suspend-react-0.1.3.tgz", + "integrity": "sha512-aqldKgX9aZqpoDp3e8/BZ8Dm7x1pJl+qI3ZKxDN0i/IQTWUwBx/ManmlVJ3wowqbno6c2bmiIfs+Um6LbsjJyQ==", + "license": "MIT", + "peerDependencies": { + "react": ">=17.0" + } + }, "node_modules/tailwind-merge": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.2.0.tgz", @@ -4235,6 +4740,51 @@ "url": "https://opencollective.com/webpack" } }, + "node_modules/three": { + "version": "0.184.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.184.0.tgz", + "integrity": "sha512-wtTRjG92pM5eUg/KuUnHsqSAlPM296brTOcLgMRqEeylYTh/CdtvKUvCyyCQTzFuStieWxvZb8mVTMvdPyUpxg==", + "license": "MIT" + }, + "node_modules/three-mesh-bvh": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/three-mesh-bvh/-/three-mesh-bvh-0.8.3.tgz", + "integrity": "sha512-4G5lBaF+g2auKX3P0yqx+MJC6oVt6sB5k+CchS6Ob0qvH0YIhuUk1eYr7ktsIpY+albCqE80/FVQGV190PmiAg==", + "license": "MIT", + "peerDependencies": { + "three": ">= 0.159.0" + } + }, + "node_modules/three-stdlib": { + "version": "2.36.1", + "resolved": "https://registry.npmjs.org/three-stdlib/-/three-stdlib-2.36.1.tgz", + "integrity": "sha512-XyGQrFmNQ5O/IoKm556ftwKsBg11TIb301MB5dWNicziQBEs2g3gtOYIf7pFiLa0zI2gUwhtCjv9fmjnxKZ1Cg==", + "license": "MIT", + "dependencies": { + "@types/draco3d": "^1.4.0", + "@types/offscreencanvas": "^2019.6.4", + "@types/webxr": "^0.5.2", + "draco3d": "^1.4.1", + "fflate": "^0.6.9", + "potpack": "^1.0.1" + }, + "peerDependencies": { + "three": ">=0.128.0" + } + }, + "node_modules/three-stdlib/node_modules/fflate": { + "version": "0.6.10", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.6.10.tgz", + "integrity": "sha512-IQrh3lEPM93wVCEczc9SaAOvkmcoQn/G8Bo1e8ZPlY3X3bnAxWaBdvTdvM1hP62iZp0BXWDy4vTAy4fF0+Dlpg==", + "license": "MIT" + }, + "node_modules/three-vanta": { + "name": "three", + "version": "0.121.1", + "resolved": "https://registry.npmjs.org/three/-/three-0.121.1.tgz", + "integrity": "sha512-+rYhNpW5W1aBdLkPQDld/GA4Sj/uOKJJKVpCAZUbpk/HZEiYRUlPt8+s+9nmxRglWmRHdBa3ERvUwqg4nmoA5w==", + "license": "MIT" + }, "node_modules/tiny-invariant": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz", @@ -4258,6 +4808,36 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, + "node_modules/troika-three-text": { + "version": "0.52.4", + "resolved": "https://registry.npmjs.org/troika-three-text/-/troika-three-text-0.52.4.tgz", + "integrity": "sha512-V50EwcYGruV5rUZ9F4aNsrytGdKcXKALjEtQXIOBfhVoZU9VAqZNIoGQ3TMiooVqFAbR1w15T+f+8gkzoFzawg==", + "license": "MIT", + "dependencies": { + "bidi-js": "^1.0.2", + "troika-three-utils": "^0.52.4", + "troika-worker-utils": "^0.52.0", + "webgl-sdf-generator": "1.1.1" + }, + "peerDependencies": { + "three": ">=0.125.0" + } + }, + "node_modules/troika-three-utils": { + "version": "0.52.4", + "resolved": "https://registry.npmjs.org/troika-three-utils/-/troika-three-utils-0.52.4.tgz", + "integrity": "sha512-NORAStSVa/BDiG52Mfudk4j1FG4jC4ILutB3foPnfGbOeIs9+G5vZLa0pnmnaftZUGm4UwSoqEpWdqvC7zms3A==", + "license": "MIT", + "peerDependencies": { + "three": ">=0.125.0" + } + }, + "node_modules/troika-worker-utils": { + "version": "0.52.0", + "resolved": "https://registry.npmjs.org/troika-worker-utils/-/troika-worker-utils-0.52.0.tgz", + "integrity": "sha512-W1CpvTHykaPH5brv5VHLfQo9D1OYuo0cSBEUQFFT/nBUzM8iD6Lq2/tgG/f1OelbAS1WtaTPQzE5uM49egnngw==", + "license": "MIT" + }, "node_modules/ts-api-utils": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz", @@ -4277,6 +4857,43 @@ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", "license": "0BSD" }, + "node_modules/tunnel-rat": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/tunnel-rat/-/tunnel-rat-0.1.2.tgz", + "integrity": "sha512-lR5VHmkPhzdhrM092lI2nACsLO4QubF0/yoOhzX7c+wIpbN1GjHNzCc91QlpxBi+cnx8vVJ+Ur6vL5cEoQPFpQ==", + "license": "MIT", + "dependencies": { + "zustand": "^4.3.2" + } + }, + "node_modules/tunnel-rat/node_modules/zustand": { + "version": "4.5.7", + "resolved": "https://registry.npmjs.org/zustand/-/zustand-4.5.7.tgz", + "integrity": "sha512-CHOUy7mu3lbD6o6LJLfllpjkzhHXSBlX8B9+qPddUsIfeF5S/UZ5q0kmCsnRqT1UHFQZchNFDDzMbQsuesHWlw==", + "license": "MIT", + "dependencies": { + "use-sync-external-store": "^1.2.2" + }, + "engines": { + "node": ">=12.7.0" + }, + "peerDependencies": { + "@types/react": ">=16.8", + "immer": ">=9.0.6", + "react": ">=16.8" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "immer": { + "optional": true + }, + "react": { + "optional": true + } + } + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -4376,6 +4993,30 @@ "punycode": "^2.1.0" } }, + "node_modules/use-sync-external-store": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.6.0.tgz", + "integrity": "sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" + } + }, + "node_modules/utility-types": { + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.11.0.tgz", + "integrity": "sha512-6Z7Ma2aVEWisaL6TvBCy7P8rm2LQoPv6dJ7ecIaIixHcwfbJ0x7mWdbcwlIM5IGQxPZSFYeqRCqlOOeKoJYMkw==", + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/vanta": { + "version": "0.5.24", + "resolved": "https://registry.npmjs.org/vanta/-/vanta-0.5.24.tgz", + "integrity": "sha512-fvieEbHy1ZS23zrcX+topzqAgA4Uct1enngOEWLFBgs9TtOf6RDFOYatH7KSVdrABzQDMCQ5myQy+nTSZZwLzg==", + "license": "MIT" + }, "node_modules/victory-vendor": { "version": "36.9.2", "resolved": "https://registry.npmjs.org/victory-vendor/-/victory-vendor-36.9.2.tgz", @@ -4476,11 +5117,21 @@ } } }, + "node_modules/webgl-constants": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/webgl-constants/-/webgl-constants-1.1.1.tgz", + "integrity": "sha512-LkBXKjU5r9vAW7Gcu3T5u+5cvSvh5WwINdr0C+9jpzVB41cjQAP5ePArDtk/WHYdVj0GefCgM73BA7FlIiNtdg==" + }, + "node_modules/webgl-sdf-generator": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/webgl-sdf-generator/-/webgl-sdf-generator-1.1.1.tgz", + "integrity": "sha512-9Z0JcMTFxeE+b2x1LJTdnaT8rT8aEp7MVxkNwoycNmJWwPdzoXzMh0BjJSh/AEFP+KPYZUli814h8bJZFIZ2jA==", + "license": "MIT" + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, "license": "ISC", "dependencies": { "isexe": "^2.0.0" @@ -4544,6 +5195,35 @@ "peerDependencies": { "zod": "^3.25.0 || ^4.0.0" } + }, + "node_modules/zustand": { + "version": "5.0.14", + "resolved": "https://registry.npmjs.org/zustand/-/zustand-5.0.14.tgz", + "integrity": "sha512-/8tAspM5LMPr28b3fwLYrtdj77ECpfZviaP75CMTnwO8ISyaE4GDIG/9rDDYq/cH9D2Xw2A2RXglLInmVBQB/g==", + "license": "MIT", + "engines": { + "node": ">=12.20.0" + }, + "peerDependencies": { + "@types/react": ">=18.0.0", + "immer": ">=9.0.6", + "react": ">=18.0.0", + "use-sync-external-store": ">=1.2.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "immer": { + "optional": true + }, + "react": { + "optional": true + }, + "use-sync-external-store": { + "optional": true + } + } } } } diff --git a/frontend/package.json b/frontend/package.json index b60d038..45b7e15 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -10,13 +10,18 @@ "preview": "vite preview" }, "dependencies": { + "@lottiefiles/dotlottie-react": "^0.19.4", "@radix-ui/react-progress": "1.1.2", "@radix-ui/react-slot": "1.1.2", "@radix-ui/react-tabs": "1.1.3", + "@react-three/drei": "^10.7.7", + "@react-three/fiber": "^9.6.1", + "@rive-app/react-canvas": "^4.28.6", "class-variance-authority": "0.7.1", "clsx": "2.1.1", + "gsap": "^3.15.0", "lucide-react": "0.487.0", - "motion": "^12.38.0", + "motion": "^12.40.0", "next-themes": "0.4.6", "react": "^19.2.0", "react-dom": "^19.2.0", @@ -24,7 +29,10 @@ "react-syntax-highlighter": "^16.1.1", "recharts": "2.15.2", "sonner": "2.0.3", - "tailwind-merge": "3.2.0" + "tailwind-merge": "3.2.0", + "three": "^0.184.0", + "three-vanta": "npm:three@^0.121.1", + "vanta": "^0.5.24" }, "devDependencies": { "@eslint/js": "^9.39.4", diff --git a/frontend/src/auth/AuthProvider.tsx b/frontend/src/auth/AuthProvider.tsx index a6fe8ba..b420cf6 100644 --- a/frontend/src/auth/AuthProvider.tsx +++ b/frontend/src/auth/AuthProvider.tsx @@ -10,6 +10,7 @@ import { readUserFromStorage, type User, } from "../utils/api"; +import { clearNotificationsForUser } from "../utils/notifications"; interface AuthContextValue { user: User | null; @@ -30,10 +31,11 @@ export function AuthProvider({ children }: { children: ReactNode }) { const [isBooting, setIsBooting] = useState(() => !!getAccessToken()); const logout = useCallback(() => { + clearNotificationsForUser(user?.id); clearSession(); setUser(null); setToken(null); - }, []); + }, [user?.id]); useEffect(() => { let cancelled = false; diff --git a/frontend/src/components/Layout.tsx b/frontend/src/components/Layout.tsx index 35f7161..a7cb9cf 100644 --- a/frontend/src/components/Layout.tsx +++ b/frontend/src/components/Layout.tsx @@ -3,6 +3,7 @@ import { useEffect, useState } from "react"; import { Link, useLocation } from "react-router-dom"; import { FileCode, History, Home, KeyRound, LogOut, BarChart3 } from "lucide-react"; import { useAuth } from "../auth/AuthProvider"; +import { NotificationEventBridge } from "./NotificationEventBridge"; import { NotificationPanel } from "./NotificationPanel"; import { Button } from "./ui/button"; import { checkHealth } from "../utils/api"; @@ -43,6 +44,7 @@ export function Layout({ children }: LayoutProps) { return (
+
diff --git a/frontend/src/components/NotificationEventBridge.tsx b/frontend/src/components/NotificationEventBridge.tsx new file mode 100644 index 0000000..82532ec --- /dev/null +++ b/frontend/src/components/NotificationEventBridge.tsx @@ -0,0 +1,187 @@ +import { useEffect, useRef } from "react"; + +import { useAuth } from "../auth/AuthProvider"; +import { jobs, ws, type DomainEvent, type JobStatus } from "../utils/api"; +import { pushNotification } from "../utils/notifications"; + +const RECENT_JOB_WINDOW_MS = 15 * 60 * 1000; + +function replayStateStorageKey(userId: string): string { + return `dqa:notifications:replay:${userId}`; +} + +function loadReplayState(userId: string): Record { + try { + const raw = localStorage.getItem(replayStateStorageKey(userId)); + if (!raw) return {}; + return JSON.parse(raw) as Record; + } catch { + return {}; + } +} + +function saveReplayState(userId: string, state: Record) { + localStorage.setItem(replayStateStorageKey(userId), JSON.stringify(state)); +} + +function notifyFromEvent(event: DomainEvent) { + const payload = event.payload ?? {}; + const jobSuffix = event.job_id ? event.job_id.slice(0, 8) : "unknown"; + const messageFromPayload = + typeof payload.message === "string" && payload.message.trim().length > 0 + ? payload.message + : undefined; + + switch (event.event_name) { + case "user.analysis.completed": + case "project.analysis_completed": + pushNotification( + "success", + "Analysis Complete", + `Job ${jobSuffix} finished successfully`, + { dedupeKey: `analysis.completed:${event.job_id ?? "none"}` }, + ); + return; + case "user.analysis.failed": + case "project.analysis_failed": + pushNotification( + "error", + "Analysis Failed", + messageFromPayload ?? `Job ${jobSuffix} failed`, + { dedupeKey: `analysis.failed:${event.job_id ?? "none"}` }, + ); + return; + case "container.started": + pushNotification( + "success", + "Containers Running", + "Compose containers started successfully", + { dedupeKey: `container.started:${event.job_id ?? "none"}` }, + ); + return; + case "container.stopped": + case "project.runtime_stopped": + pushNotification( + "warning", + "Runtime Stopped", + "Containers have stopped", + { dedupeKey: `${event.event_name}:${event.job_id ?? "none"}` }, + ); + return; + case "deploy.cleanup_started": + pushNotification( + "info", + "Cleanup Started", + "Removing containers created by the failed deploy", + { dedupeKey: `${event.event_name}:${event.job_id ?? "none"}` }, + ); + return; + case "deploy.cleanup_completed": + pushNotification( + "success", + "Cleanup Completed", + "Failed deploy containers were removed from the sandbox", + { dedupeKey: `${event.event_name}:${event.job_id ?? "none"}` }, + ); + return; + default: + return; + } +} + +export function NotificationEventBridge() { + const { user } = useAuth(); + const socketRef = useRef(null); + + useEffect(() => { + if (!user?.id) return; + let reconnectTimer: ReturnType | null = null; + let closedByEffect = false; + let replayState = loadReplayState(user.id); + + const reconcileMissedJobOutcomes = async () => { + try { + const allJobs = await jobs.list(); + const now = Date.now(); + const nextReplayState: Record = {}; + + for (const job of allJobs) { + const createdAt = Date.parse(job.created_at); + const isRecent = Number.isFinite(createdAt) && now - createdAt <= RECENT_JOB_WINDOW_MS; + const previousStatus = replayState[job.id]; + const statusChanged = previousStatus != null && previousStatus !== job.status; + const isFreshTerminal = + previousStatus == null && isRecent && (job.status === "done" || job.status === "failed"); + + if ((statusChanged || isFreshTerminal) && job.status === "done") { + pushNotification( + "success", + "Analysis Complete", + `Job ${job.id.slice(0, 8)} finished successfully`, + { dedupeKey: `analysis.completed:${job.id}`, dedupeWindowMs: 12 * 60 * 60 * 1000 }, + ); + } else if ((statusChanged || isFreshTerminal) && job.status === "failed") { + const resultMessage = + job.result && typeof job.result === "object" && "message" in job.result + ? job.result.message + : null; + pushNotification( + "error", + "Analysis Failed", + typeof resultMessage === "string" && resultMessage.trim() + ? resultMessage + : `Job ${job.id.slice(0, 8)} failed`, + { dedupeKey: `analysis.failed:${job.id}`, dedupeWindowMs: 12 * 60 * 60 * 1000 }, + ); + } + + nextReplayState[job.id] = job.status; + } + + replayState = nextReplayState; + saveReplayState(user.id, nextReplayState); + } catch { + // Non-blocking reconciliation best effort only. + } + }; + + const connect = () => { + if (closedByEffect) return; + const socket = ws.connectUserEvents(user.id); + socketRef.current = socket; + void reconcileMissedJobOutcomes(); + + socket.onmessage = (rawEvent) => { + try { + const event = JSON.parse(rawEvent.data as string) as DomainEvent; + notifyFromEvent(event); + } catch { + // ignore malformed payloads + } + }; + + socket.onclose = () => { + if (closedByEffect) return; + reconnectTimer = setTimeout(connect, 2000); + }; + }; + + connect(); + return () => { + closedByEffect = true; + if (reconnectTimer) { + clearTimeout(reconnectTimer); + } + if (socketRef.current) { + try { + socketRef.current.close(); + } catch { + // noop + } + socketRef.current = null; + } + }; + }, [user?.id]); + + return null; +} diff --git a/frontend/src/components/NotificationPanel.tsx b/frontend/src/components/NotificationPanel.tsx index 04c3c84..b3c5113 100644 --- a/frontend/src/components/NotificationPanel.tsx +++ b/frontend/src/components/NotificationPanel.tsx @@ -1,22 +1,23 @@ -import { useState } from "react"; -import { Bell, Check, Trash2, X } from "lucide-react"; +import { useEffect, useState } from "react"; +import { AlertCircle, AlertTriangle, Bell, Check, CheckCircle2, Info, Trash2, X } from "lucide-react"; import { useNotifications, markAllRead, + markNotificationRead, clearNotifications, type AppNotification, } from "../utils/notifications"; -function typeIcon(type: AppNotification["type"]) { +function TypeIcon({ type }: { type: AppNotification["type"] }) { switch (type) { case "success": - return "🟢"; + return ; case "warning": - return "🟡"; + return ; case "error": - return "🔴"; + return ; default: - return "🔵"; + return ; } } @@ -31,27 +32,62 @@ function timeAgo(ts: number): string { export function NotificationPanel() { const { notifications, unreadCount } = useNotifications(); const [open, setOpen] = useState(false); + const [activeFilter, setActiveFilter] = useState<"unread" | "all">("all"); + const panelId = "notification-panel"; + const filteredNotifications = + activeFilter === "unread" + ? notifications.filter((notification) => !notification.read) + : notifications; const handleToggle = () => { - if (!open && unreadCount > 0) { - markAllRead(); - } - setOpen(!open); + setOpen((prev) => { + const next = !prev; + if (next) { + setActiveFilter(unreadCount > 0 ? "unread" : "all"); + } + return next; + }); }; + useEffect(() => { + if (!open) return; + const onKeyDown = (event: KeyboardEvent) => { + if (event.key === "Escape") { + setOpen(false); + } + }; + window.addEventListener("keydown", onKeyDown); + return () => { + window.removeEventListener("keydown", onKeyDown); + }; + }, [open]); + return (
{open && ( @@ -60,55 +96,127 @@ export function NotificationPanel() { className="fixed inset-0 z-40" onClick={() => setOpen(false)} /> -
-
- Notifications -
+