From e23e33adeaf8ee7439187d4451c856b37816a51f Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Tue, 11 Aug 2026 04:13:53 +0200 Subject: feat: Phase 9 — Web client SPA with WebRTC P2P transport MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Complete browser-based client: Preact SPA with login, group file browser, encrypted download, video playback, group chat, i18n, and dark/light theme. Browser connects P2P to nodes behind residential NAT via WebRTC DataChannel (aiortc). Hub handles signaling only — all data flows E2E. Performance: pipelined downloads (8-chunk sliding window), binary msgpack wire format (no base64), redundant I/O elimination. Large file downloads stream to disk via File System Access API (showSaveFilePicker). Validated on SFR + Orange residential NATs, Chrome + Firefox, IPv4/IPv6. 132 tests passing. Deployed to meshbay.org + Orange node. Co-Authored-By: Claude Opus 4.6 --- packages/meshbay-hub/src/meshbay_hub/api/webapp.py | 73 +++++----------------- 1 file changed, 15 insertions(+), 58 deletions(-) (limited to 'packages/meshbay-hub/src/meshbay_hub/api/webapp.py') diff --git a/packages/meshbay-hub/src/meshbay_hub/api/webapp.py b/packages/meshbay-hub/src/meshbay_hub/api/webapp.py index 6005927..62917f4 100644 --- a/packages/meshbay-hub/src/meshbay_hub/api/webapp.py +++ b/packages/meshbay-hub/src/meshbay_hub/api/webapp.py @@ -1,47 +1,26 @@ """ -Hub web application — serves the MeshBay web client at /. +Hub web application — serves the MeshBay SPA and static assets. -The web client (HTML/JS) is a single-page app that: - - Logs in via the hub API - - Discovers public groups - - Connects to a node URL entered by the user - - Browses the node's file index - - Downloads or streams files via the node HTTP API +The SPA (Preact + htm) handles: + - Authentication (login, register, token refresh) + - Group discovery and browsing + - WebRTC connection to nodes for P2P file transfer + - Dark/light theme with system preference detection -Static files are served from meshbay_hub/static/. -API routes remain at /v1/*. +Static files are served from meshbay_hub/static/ via Starlette StaticFiles. +The root route (/) returns the SPA HTML shell. """ from pathlib import Path from fastapi import APIRouter -from fastapi.responses import FileResponse, HTMLResponse +from fastapi.responses import HTMLResponse STATIC_DIR = Path(__file__).parent.parent / "static" router = APIRouter(tags=["webapp"]) -@router.get("/app.js") -async def app_js(): - return FileResponse(STATIC_DIR / "app.js", media_type="application/javascript") - - -@router.get("/transport.js") -async def transport_js(): - return FileResponse(STATIC_DIR / "transport.js", media_type="application/javascript") - - -@router.get("/crypto.js") -async def crypto_js(): - return FileResponse(STATIC_DIR / "crypto.js", media_type="application/javascript") - - -@router.get("/webrtc-test.html") -async def webrtc_test(): - return FileResponse(STATIC_DIR / "webrtc-test.html", media_type="text/html") - - @router.get("/", response_class=HTMLResponse) async def index(): return HTMLResponse(_HTML) @@ -54,36 +33,14 @@ _HTML = """\ MeshBay - + - -

Loading…

- +
+ + + + """ -- cgit v1.2.3