# Changelog

## Unreleased

### Performance

- `hit_stack_next` is now linear in the op count. The previous version copied
  the whole stack on every move-to-top and re-scanned the drawn set when
  filtering, so a frame with N drawables cost O(N²). Measured on Chrome 158 /
  macOS (M5), 5000 piled cards went from 154 ms to 8.1 ms per frame and 10000
  from 966 ms to 182 ms. Semantics (auto push, `preserveHitTestOrder` keeps its
  slot, `clearElementGeometry` removes) are unchanged; all 51 tests pass.
- `cmd/bench` gains `?spread=1`, which lays the cards out as a wide board
  instead of the 5x4 pile. It separates per-draw cost from overdraw: 10k
  cards = 13.4 ms, 20k = 29.9 ms, 50k = 87.6 ms per frame on the same setup.

### Demos

- `cmd/whiteboard`: infinite whiteboard built on the 0.1 API — notes, shapes
  and text stay real DOM inside the canvas. Marquee/group drag, handle resize,
  rotation, double-click editing, undo/redo, z-order, tones and localStorage
  persistence. `?selftest=1` runs 26 headless checks (hit, drag, handle
  geometry, resize, rotate, delete/restore, text edit, persistence, pan and
  cursor-anchored zoom); `e2e/accept.mjs` and CI run it with the rest of the
  matrix.

## 0.1.0 — 2026-11-24

Initial release: a type-safe HTML-in-Canvas scene graph for MoonBit with a
pure scheduler and two runners.

### Core

- `SceneNode` with `Html`, `Group` and `Clip`; named groups
  (`group_named` / `clip_named`) can be moved, hidden and faded after build.
- `plan_paint(Scene, Viewport) -> PaintPlan` with a scene camera, stable
  z-order, dirty-set driven `UpdateGeometry`, and a preserve-aware hit stack
  model (`hit_stack_next`).
- `HtmlProps` updates land in an O(1) override table; `replace_props_many`
  applies a whole selection with one repaint.
- Rotation/skew emit `DrawElementTransformed` with the full matrix; AABB is
  only used where the transform is axis-aligned.
- Clip groups emit `PushClip`/`PopClip`, and clipped elements also get a
  `canvasClip` so native hit testing and a11y stop at the clip boundary.
- Group visibility clears the browser geometry of hidden elements; group
  opacity emits `PushOpacity`/`PopOpacity` (per-element alpha on canvas).

### Runners

- `stage::Stage`: HTML-in-Canvas 2D runner with pointer/wheel bridges,
  element-size observation, rotation, clips, camera, `set_props_many`,
  visibility/opacity and `unmount`.
- `fallback::OverlayStage`: the same plans executed as a DOM overlay
  (CSS transforms, `clip-path`, visibility, opacity).
- `fallback::mount_any`: picks canvas or overlay automatically; `Mounted`
  forwards the whole scene API so callers never branch on the backend.

### Demos

- `hello`, `drag`, `kanban` (camera, column groups, selection, fit/reset,
  visibility/opacity), `camera`, `fallback`, `bench`, `glass`.

### Verification

- 48 pure MoonBit tests (property tests in `geom`, scheduler/hit-stack tests
  in `core`) plus the README doc tests.
- `e2e/accept.mjs`: 19 headless checks over CDP (I4–I20), skipping canvas
  checks when `drawElementImage` is absent and always exercising the overlay.
- `.github/workflows/ci.yml`: `moon check --deny-warn`, `moon test`, JS build
  and the acceptance suite on push/PR.

### Known limitations

- `extern "js"` is js-backend only; `geom`/`core` compile under wasm-gc.
- Rotation paints the element snapshot through the CTM (no re-rasterisation).
- Opacity uses per-element alpha, not offscreen group compositing.
- Hit testing is a local model; the browser remains the source of truth for
  native events, and `preserveHitTestOrder` keeps a slot rather than moving it.
