apps/web)Owner: ED1 in wave 3 (WP-D before): shell, wiring, panels. ADRs 0025 (React for app UI, engine outside React; supersedes 0016), 0402 (React bindings), 0006 (pages), 0022 (API), 0401 (sync client), 0404 (in-browser demo).
apps/web/
index.html #root only; React renders #shell (account screens) or #app (editor)
demo.html the in-browser demo's page (shipped as dist-demo/index.html, ADR 0404)
vite.config.ts @vitejs/plugin-react; dev/preview proxy /v1 -> API (:8787), so the browser is same-origin;
--mode demo builds demo.html alone into dist-demo/ (relative base, one chunk)
src/main.ts boot: probe GET /v1/me, then createRoot(#root).render(App)
src/shell/
api.ts typed /v1 client from shared/api.ts; CSRF double-submit; 401 -> login
router.ts #/login, #/signup, #/ (projects), #/p/:projectId (files), #/f/:fileId/:pageId?, #/tokens, #/demo
appState.ts HttpApi instance, signed-in user store, app-level notice (notify)
store.ts, useStore.ts ValueStore (framework-free) + useStore(store, select, equal) on useSyncExternalStore
App.tsx route switch; the editor route is a lazy chunk; error boundaries per route; ShellNotice
AuthView, ProjectsView, FilesView (+ members), TokensView, ui.tsx account screens
EditorRoute.tsx lazy chunk: offline demo (createLocalSession) or live file (FileController)
EditorFrame.tsx editor layout; stage element mounted once; host created/disposed in one layout effect
fileController.ts framework-free: sync client, page sessions, page switch + viewport restore,
file/page API actions, status pill (2 Hz), avatars (<= 1 recompute per frame)
EditorChrome.tsx file head (rename, status), pages panel (add/rename/reorder/delete, over PagesHost), avatars (+N, follow)
src/panels/ Toolbar, Zoom, Layers (virtualized tree), Properties, Perf (+ HUD), StageOverlay (toast, empty hint)
src/demo/ in-browser demo (ADR 0404): main.tsx (entry), DemoApp.tsx (banner + EditorFrame),
demoFile.ts (local pages, one createLocalSession each), scene.ts (sample frames), demo.css
src/style/ editor.css (editor chrome), shell.css (account screens, file chrome)
/v1/me answers like the API (200 or 401 JSON), the app runs against the server; otherwise (static build, perf bench, no backend) every route opens the offline canvas on createLocalSession with all panels. #/demo always opens it. The public in-browser demo is a separate entry (below), not this mode.EditorFrame renders the stage and creates its host in a layout effect. Live file: FileController.start(stage) -> getFile -> createSyncClient({docs: docFactory, getRealtimeToken}) -> openPage -> mountEditor({stage, session}). Page switch: save the viewport, open the next session, setSession, restore that page’s viewport, close the previous session; the hash follows with replaceState. file_event refreshes pages and name; file_deleted returns to the project, access_revoked to the projects list; role_changed reconnects with the new role (“view only” in the pill); version_mismatch shows “Reload”.<main id="stage"> and the overlays in it (HUD, toolbar, toast, empty hint); mountEditor creates and removes the canvases and runs its own rAF loop. window.editor is set by mountEditor for tools/bench.Editor handle and reads editor.store (tool, view, ui, selection, layers, perf) through useStore selectors; stores notify at most once per frame. Properties, layer rows and perf stats render through useDeferredValue (transition priority); the selection snapshot is not recomputed while dragging. The layers tree reads LayerTree by index for the visible rows only (28 px rows, slot-keyed, scaled scrolling past 8M px): expand/collapse, rename (double-click), hide/lock, click / cmd-click / shift-click range, reveal on canvas click.PRESENCE_VIEW_MARGIN, which the server stops relaying (ADR 0203).{follow: clientId}, so the server relays the followee’s cursor and viewport every tick;usercamera), Escape, a second click, the peer leaving, or a page switch, and the controller sends {follow: null}.LayerTree.drop, ADR 0521). It stays virtualized, since only the row under the pointer is computed.notify, rendered by ShellNotice above every route), so the message stays visible after the editor route unmounts.online and when the tab becomes visible (visibilitychange), through RemoteSyncClient.retryNow() (DC2), which skips the backoff.GET /v1/me) is preferred. The cookie fallback reads __Host-linora_csrf (production) or linora_csrf (development, and a plain-HTTP LAN origin of the prod-like stack, ADR 0905), per SR-23. Nothing in the app needs a secure context (WebGL2, no crypto.subtle, clipboard API, workers or service workers), so it also runs on http://<lan-ip> (ADR 0905).'unsafe-inline' or 'unsafe-eval'. There are no inline scripts or style attributes; styles are CSS files, and React and the editor set styles through the CSSOM. The required policy is in ADR 0403.The demo at https://pathikdevani.github.io/linora/demo/ is the editor on local in-memory pages, built as static files.
npm run build:demo runs vite build --mode demo and writes apps/web/dist-demo/, with demo.html shipped as index.html.
./), so the files work under /linora/demo/ or any other path; the font loads through new URL(..., import.meta.url).dist-demo into _site/demo/. In development, npm run dev serves it at /demo.html.src/demo/main.tsx) never imports the API client, FileController, the router or the account, token and file screens. The sync client’s network code is tree-shaken. @linorahq/shared is marked "sideEffects": false, so its /v1 route table and the MCP schemas drop out. The demo makes no /v1, WebSocket or third-party request and needs no SharedArrayBuffer or COOP/COEP.DemoFile (src/demo/demoFile.ts) stands in for FileController.
createLocalSession(createDoc(id)), the same offline DocSession the tests and the bench use. Pages switch with setSession, keeping a camera per page.EditorHost and PagesHost, so EditorFrame, the panels and PagesPanel are reused unchanged (add, rename, reorder, delete).src/demo/scene.ts): 58 layers, one non-undoable commit. The camera opens on the Welcome frame.test/demo-build.test.ts (build rules, no-network scan, 200 KB gzip budget) and test/demo.test.ts (scene, pages) run in npm test. node tools/demo/check.ts is the browser check in headless Chrome behind a plain static server under /linora/demo/. It records every request and socket, checks the boot, then clicks both buttons; --perf compares it with the full app.node tools/bench/run.ts --gate --app web --scenario drag-ui --scenes website, React app vs the vanilla app at edf98eb, 682K layers): 99.2 vs 94.1 fps, CPU 0.68 vs 3.26 ms/frame, worst-zoom GPU -1.8%: passed. npm run bench (harness, interleaved vs 44fbb70): all rows within the gate. Memory (npm run bench -- --memory): harness 0.512x / 0.691x of the baseline (website / shapes); the full web app (--app web) 0.502x / 0.700x, with 59K JS objects and a 9.2 MB heap vs 4.3 MB for the harness (unminified build).