| 6 | dark theme, reference mode (`?reference=1`, native rendering of the same file |
| 7 | for comparison — never for `corpus/attacks`), renderer toggles (Shadow DOM, |
| 8 | Blitz, litehtml wasm, compare all), stats / diagnostics / bridge / console |
| 9 | panels. Exposes `window.__tw` — the Playwright suites in `tests/` drive it. |
| 10 | - `src/mock-bot.ts` — the **Bot (mock)** panel (the widget's state and requests): |
| 11 | the widget's chat state (`chatData`) and shared state (`publicData`) per file as a server would |
| 12 | keep them, the bot's edits of them (`setData`; `edit by id` changes a shared widget's shared state without a push, and the dev |
| 13 | app polls it only while the widget watches, `watchPublicData()`, at the panel's period), built-in bots that answer requests (a widget |
| 14 | picks one with `<meta name="tw-bot" content="poll">`; echo, poll, tictactoe, |
| 15 | ticker, promo), manual answers and client failures, and the context a client |
| 16 | passes: the kind of message and so the server's flags (private, group, |
| 17 | via-bot, no-queries, live-copy, copy, preview; the bubble's header shows the network |
| 18 | marker where the message has `canQuery`), the chat type, the viewer |
| 19 | (`?message=group&chat=supergroup&viewer=42&botmode=TIMEOUT`). `__tw.bot`, |
| 20 | `__tw.setContext`; `corpus/interactive` uses it. |
| 21 | - `src/feed.ts` + `src/feed-bench.ts` — the chat feed (`?feed=1`): 72 bubbles |
| 22 | with the list's own lifecycle, the worker pool on/off, a live renderer |
| 23 | switch, one hostile bubble, a metrics overlay and the bench panel |
| 24 | (`?bench=1`, `scripts/feed-report.ts` runs it headless). `docs/chat-feed-web.md`. |
| 25 | - `src/renderers/` — the Blitz and litehtml wasm renderers plugged into the |
| 26 | `Renderer` seam (need `pnpm build:blitz-web` / `build:litehtml-web`). |
| 27 | - `bench/feed.html` — the raw renderer bench behind `scripts/feed-bench.ts`. |
| 28 | - `vite.config.ts` — the package's plugin plus dev middleware: `/api/corpus`, |
| 29 | `/corpus/*`, `/reference/*`, `/blitz/*`, `/litehtml/*`. |
| 30 | - `tests/unit/` — the wasm renderers through the validator (skipped until built). |
| 31 |
| 32 | ## From a fresh clone |
| 33 |
| 34 | Checked from a fresh `git clone` on macOS (Apple silicon), 2026-10-14; Windows |
| 35 | not tried. Clone into a path without spaces or non-ASCII characters: the |
| 36 | scripts derive the repo root from `new URL(import.meta.url).pathname`, which |
| 37 | percent-encodes them (on Windows it yields `/C:/…`). |
| 38 |
| 39 | Node ≥ 22.12 with corepack (bundled up to Node 24; on Node 25+ |
| 40 | `npm install -g corepack`); pnpm itself comes from the `packageManager` pin. |
| 41 |
| 42 | ```bash |
| 43 | corepack pnpm install |
| 44 | corepack pnpm dev # from the repo root; http://127.0.0.1:5173/?file=compat/tabs.html |
| 45 | corepack pnpm dev --port 5174 |
| 46 | ``` |
| 47 |
| 48 | Open `127.0.0.1`, not `localhost`: Vite listens on 127.0.0.1 only, and the |
| 49 | port is strict (`--port` when 5173 is taken). The chat feed is `?feed=1`. |
| 50 |
| 51 | The Blitz and litehtml toggles (the dev app's checkboxes, the feed's renderer |
| 52 | switch, compare all) are frozen prototypes since 2026-10-30 (no runner or bench |
| 53 | uses them by default, their unit tests run only with `TW_NATIVE_RENDERERS=1`) and need their wasm builds in `apps/renderer-*/pkg-web/` |
| 54 | (gitignored); the dev server reads them from disk, no restart. The toolchain, |
| 55 | once (`--version` = the `wasm-bindgen` version in |
| 56 | `apps/renderer-blitz/Cargo.lock`; the build script says so when they differ): |
| 57 |
| 58 | ```bash |
| 59 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh |
| 60 | cargo install wasm-bindgen-cli --version 0.2.129 --locked |
| 61 | brew install emscripten # Linux: emsdk, with emcc on PATH |
| 62 | ``` |
| 63 |
| 64 | Then, and again after a pull that touches `apps/renderer-*`: |
| 65 |
| 66 | ```bash |
| 67 | corepack pnpm build:blitz-web # cargo, adds the wasm32 target on first run; ~2 min → 8 MB wasm |
| 68 | corepack pnpm build:litehtml-web # em++; ~30 s → 1.4 MB wasm |
| 69 | ``` |
| 70 |
| 71 | Editing `packages/core/src` or this directory while a Playwright suite runs |
| 72 | reloads Vite and breaks the run. |
| 73 |