Skip to content

Commit f2c7add

Browse files
committed
Merge branch 'dev'
2 parents bba0ab5 + b1cc780 commit f2c7add

28 files changed

Lines changed: 838 additions & 66 deletions

File tree

README.en.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ interactive components that need browser APIs.
1919
- **Universal WC Engine** (v0.18.0) — auto-detect third-party WC packages, 4-tier compatibility (ssr-capable / client-only / rejected / experimental-dom)
2020
- **validate-manifest CLI** (v0.18.1) — validate CEM manifests before install
2121
- **less add safe install** (v0.18.2) — dry-run + validation gate + plan generation
22+
- **DOM simulation experiment** (v0.18.3) — Happy DOM-driven SSR experiment for client-only components
2223
- **Renderer Protocol** — structured render output, error taxonomy, DSD metrics
2324
- **Multi-adapter** — Lit / React / Vanilla adapters
2425
- **Deno workspace** — pure ESM, no `package.json`
@@ -73,18 +74,19 @@ node_modules/*/custom-elements.json → CEM Parser → 4-tier classifier → SSR
7374

7475
## Roadmap
7576

76-
| Version | Target | Status |
77-
| ------- | ----------------------------------- | ----------- |
78-
| v0.15 | Renderer Kernel Protocol | ✅ Done |
79-
| v0.16 | WC Package Protocol | ✅ Done |
80-
| v0.17 | Ecosystem Entry + SSR Boundary | ✅ Done |
81-
| v0.18 | **Universal WC Engine** | **Current** |
82-
| v0.18.0 | CEM parser + 4-tier + auto-detect | ✅ Done |
83-
| v0.18.1 | validate-manifest CLI | ✅ Done |
84-
| v0.18.2 | less add safe install flow | ✅ Done |
85-
| v0.18.3 | DOM simulation experiment (planned) | 📋 Planned |
86-
| v0.19 | Registry Hub + Platform | 📋 Planned |
87-
| v1.0 | API Freeze | 🚀 Far term |
77+
| Version | Target | Status |
78+
| ------- | ------------------------------------- | ----------- |
79+
| v0.15 | Renderer Kernel Protocol | ✅ Done |
80+
| v0.16 | WC Package Protocol | ✅ Done |
81+
| v0.17 | Ecosystem Entry + SSR Boundary | ✅ Done |
82+
| v0.18 | **Universal WC Engine** | **Current** |
83+
| v0.18.0 | CEM parser + 4-tier + auto-detect | ✅ Done |
84+
| v0.18.1 | validate-manifest CLI | ✅ Done |
85+
| v0.18.2 | less add safe install flow | ✅ Done |
86+
| v0.18.3 | DOM simulation experiment (Happy DOM) | ✅ Done |
87+
| v0.19 | Registry Hub + Platform | 📋 Planned |
88+
| v1.0 | API Freeze | 🚀 Far term |
89+
| v1.0 | API Freeze | 🚀 Far term |
8890

8991
See [ADR docs](docs/adr/) and [lessjs.org](https://lessjs.org) for details.
9092

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Deno-first Web Components 框架。基于 **Declarative Shadow DOM SSR/SSG + Isl
1717
- **Universal WC Engine** (v0.18.0) — 自动检测第三方 Web Component,4 级兼容性分类(ssr-capable / client-only / rejected / experimental-dom)
1818
- **validate-manifest CLI** (v0.18.1) — 安装前验证 CEM manifest 兼容性
1919
- **less add 安全安装** (v0.18.2) — dry-run + 验证门禁 + 计划生成
20+
- **DOM 模拟实验** (v0.18.3) — Happy DOM 驱动的 client-only 组件 SSR 实验
2021
- **Renderer Protocol** — 结构化渲染输出 + 错误分类 + DSD 指标
2122
- **多适配器** — Lit / React / Vanilla 适配器
2223
- **Deno workspace** — 纯 ESM,零 `package.json`
@@ -80,7 +81,7 @@ node_modules/*/custom-elements.json → CEM Parser → 4级分类器 → SSR adm
8081
| v0.18.0 | CEM 解析器 + 4级分类 + 自动检测 | ✅ 完成 |
8182
| v0.18.1 | validate-manifest CLI | ✅ 完成 |
8283
| v0.18.2 | less add 安全安装流 | ✅ 完成 |
83-
| v0.18.3 | DOM 模拟实验(计划 | 📋 计划中 |
84+
| v0.18.3 | DOM 模拟实验(Happy DOM| ✅ 完成 |
8485
| v0.19 | Registry Hub + Platform | 📋 计划中 |
8586
| v1.0 | API Freeze | 🚀 远期 |
8687

deno.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"@lessjs/content/sitemap": "./packages/content/src/sitemap/index.ts",
4848
"@lessjs/i18n": "./packages/i18n/src/index.ts",
4949
"@lessjs/app": "./packages/app/src/index.ts",
50+
"happy-dom": "npm:happy-dom@^20.8.9",
5051
"lit": "npm:lit@^3.2.0",
5152
"@lit/reactive-element": "npm:@lit/reactive-element@^2",
5253
"lit-element": "npm:lit-element@^4",

deno.lock

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# ADR-0029: Happy DOM for v0.18.3 DOM Simulation
2+
3+
- Status: Proposed
4+
- Date: 2026-05-17
5+
- Target: v0.18.3
6+
7+
## Context
8+
9+
v0.18.3 adds an experimental DOM simulation path for client-only Web Components.
10+
The goal is to evaluate whether selected browser-dependent components can be
11+
server-rendered through an isolated environment without weakening the core
12+
admission model.
13+
14+
The key challenge: Web Components often access browser-only DOM APIs during
15+
`connectedCallback()``childNodes`, `querySelector`, slot state, layout info.
16+
Without these APIs, components like Shoelace cannot render during SSR.
17+
18+
Three implementation approaches were evaluated:
19+
20+
1. **Self-implement** — write a minimal DOM shim covering only the APIs that
21+
LessJS components actually need (HTMLElement, connectedCallback, slot).
22+
2. **Happy DOM** — reuse an existing, maintained pure-JS DOM implementation
23+
with broad Web Component support.
24+
3. **JSDOM** — the oldest and most widely-known DOM-in-JS library.
25+
26+
## Decision
27+
28+
**Use Happy DOM as the underlying DOM environment for v0.18.3 DOM simulation.**
29+
30+
Rationale:
31+
32+
| Criterion | Self-implement | Happy DOM | JSDOM |
33+
| ---------------------- | ---------------------------- | -------------------------- | ------------------------------------- |
34+
| WC support maturity | Unknown (will discover bugs) | Good — Lit/Shoelace tested | Poor — customElements.define unstable |
35+
| Maintenance burden | High — we own every bug | Medium — active community | Low — but community nearly dead |
36+
| Bloat for our use case | Minimal (only needed APIs) | Moderate — treeshakable | High — full window object |
37+
| Startup cost | Lowest | Medium | Highest |
38+
| Long-term viability | N/A | Active (2024-2026 commits) | Stagnant (last release 2023) |
39+
40+
**JSDOM** was ruled out because its `customElements.define` support requires
41+
explicit flags and remains unreliable — a showstopper for Web Component SSR.
42+
43+
**Self-implement** is attractive for its minimal footprint but would require
44+
us to re-discover and fix the same edge cases that Happy DOM has already
45+
solved (e.g., slot assignment, composed paths, attribute reflection). The
46+
cost of reinventing a well-known wheel outweighs the bundle savings for an
47+
experimental feature.
48+
49+
**Happy DOM** provides the best balance:
50+
51+
- It supports `customElements.define`, `connectedCallback`,
52+
`attributeChangedCallback`, and Lit's rendering lifecycle out of the box.
53+
- It is treeshakable — we can import only `HTMLElement`, `customElements`,
54+
`Document`, and `window` without pulling in unused APIs like `fetch` or
55+
`Canvas`.
56+
- The community is active and responsive to Web Component issues.
57+
- The performance profile (5-20ms per render) is acceptable for an
58+
opt-in experimental feature with timeout guards.
59+
60+
### Integration Architecture
61+
62+
```
63+
lessjs({ ssr: { domSimulation: 'explicit' } })
64+
65+
66+
v0.18.3 creates isolated DOM environment
67+
68+
69+
Happy DOM provides: window, document, HTMLElement,
70+
customElements.define, connectedCallback, slots
71+
72+
73+
Admitted tags registered and rendered
74+
75+
76+
Timeout guard (500ms default) → success/failure
77+
78+
79+
Results written to dsd-report.json
80+
81+
82+
Failure → degrade to client-only, continue build
83+
```
84+
85+
## Consequences
86+
87+
### Positive
88+
89+
- Faster path to a working DOM simulation than self-implementing.
90+
- Happy DOM's existing WC support reduces the risk of missing edge cases.
91+
- We stay focused on the integration layer (config, isolation, timeout,
92+
reporting, fallback) rather than debugging DOM API quirks.
93+
- The decision is reversible — if Happy DOM proves unsuitable, we can
94+
swap it out without changing the public API.
95+
96+
### Negative
97+
98+
- Happy DOM adds a third-party dependency with its own release cadence and
99+
potential breaking changes.
100+
- Bundle size increases (~50KB gzipped) for the simulation path, though
101+
it is only loaded when `domSimulation !== 'off'`.
102+
- Happy DOM's behavior may diverge from real browsers in subtle ways
103+
(e.g., event dispatch timing, slot reassignment order).
104+
105+
### Neutral
106+
107+
- The v0.18.3 integration is designed to abstract the DOM environment
108+
behind an interface, so switching to a different implementation later
109+
is possible.
110+
- Happy DOM's treeshakable exports mean we can start with a minimal
111+
import set and expand only as needed.
112+
113+
## References
114+
115+
- [SOP v0.18.3](../sop/v0.18.3-dom-simulation-experiment.md)
116+
- [ADR-0028](./0028-universal-ssr-via-dom-simulation.md) — Conservative
117+
Third-Party WC SSR Admission (proposes the overall DOM simulation
118+
strategy)
119+
- [Happy DOM](https://github.com/capricorn86/happy-dom) — GitHub
120+
repository

docs/adr/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ architectural decision, its context, and consequences.
3737
| 0026 | Structured Render Pipeline (v0.16) | Proposed |
3838
| 0027 | Roadmap Reorder: Engine Before Hub | Accepted |
3939
| 0028 | Conservative Third-Party WC SSR Admission | Proposed |
40+
| 0029 | Happy DOM for v0.18.3 DOM Simulation | Proposed |
4041

4142
## Superseded / Historical
4243

docs/changelog/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ One file per version: `vX.Y.Z.md`
3030

3131
| Version | Date | File |
3232
| ------------- | ---------- | ------------------------------------------------ |
33+
| 0.18.3 | 2026-05-17 | [v0.18.3.md](./v0.18.3.md) |
3334
| 0.18.2 | 2026-05-17 | [v0.18.2.md](./v0.18.2.md) |
3435
| 0.18.1 | 2026-05-17 | [v0.18.1.md](./v0.18.1.md) |
3536
| 0.18.0 | 2026-05-17 | [v0.18.0.md](./v0.18.0.md) |

0 commit comments

Comments
 (0)