test+docs: full-app browser integration test and the isomorphic counter example

The integration test runs the counter through the real browser path in
happy-dom: start(), store events, raf-batched morph, DOM click handlers,
emit coalescing. examples/counter is the Phase 2 exit criterion: one app
module mounted zero-build in a browser via import map and string-rendered
by node examples/counter/render.js.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014NgfSjHE11oFpoSnLVKLXd
This commit is contained in:
Bendik Aagaard Lynghaug
2026-09-08 16:56:54 +02:00
co-authored by Claude Fable 5
parent c696e00d4f
commit 870aa79668
5 changed files with 152 additions and 5 deletions
+22 -5
View File
@@ -19,17 +19,34 @@ everything new lives under `packages/`.
- `packages/html``@choojs/html`: the rendering package.
- `server.js` — server-side tagged template (← nanohtml 1.10.0 server,
transform branches removed; pure runtime)
- `browser.js` — runtime-only cached template tag: each template literal
is parsed once (WeakMap keyed on its strings array) into a <template>
plus hole instructions; renders clone and fill. Values never pass
through innerHTML. Document-level roots (<body> etc.) parse via
DOMParser since <template> drops them. Known limits: no dynamic tag
names, no holes in raw-text elements, SVG fragments need their <svg>
root, and (unlike v7) whitespace is preserved as authored — which is
what makes server and browser output byte-identical.
- `morph.js` — ← nanomorph 5.4.3, consolidated to one module
- `browser.js`**Phase 2**: runtime-only cached template tag (WeakMap
keyed on the template strings array, clone-based instantiation,
hydration that adopts server DOM). Throws until implemented.
- `raw.js` — mark pre-encoded strings
- `raw.js`mark pre-encoded strings (works with both renderers)
- `packages/component``@choojs/component`: ← nanocomponent 6.6.0 +
on-load 3.4.1 as ES classes; the future island/hydration boundary.
- `examples/counter` — the isomorphic proof: one app module, mounted
zero-build in the browser via import map (`index.html`), string-rendered
in Node (`render.js`).
## Status vs the modernization plan
- [x] Phase 1: monorepo scaffold, ESM ports, choo v7 node test suite green
on `node --test` (Node ≥ 24), CI on GitHub Actions
- [ ] Phase 2: browser renderer rewrite + hydration, `@choojs/component`
- [x] URL normalization fix: WHATWG URL parsing, single decode with raw
fallback (no more URIError on '%'), NFC matching, per-segment
wildcard decode, decoded state.href
- [x] Phase 2 (core): browser renderer rewrite, `@choojs/component`,
zero-build counter example, full-app integration test in happy-dom
- [ ] Phase 2 (remaining): adoption-style hydration with mismatch
warnings, Playwright suite in a real browser, benchmarks vs
nanohtml v1 / µhtml
- [ ] Phase 3: v8 wiring (`toStream`, devtools, codemod)
- [ ] Phase 4: bankai v10 (Vite 8/Rolldown shell, SSR middleware,
103 Early Hints, service worker, precompression)