[ui] PlanetGarden: Analysis, review, lessons and the tablet smoke that always stops Chrome

This commit is contained in:
2026-11-17 19:56:24 +01:00
parent 1ff00b0e3f
commit f0cb6750c4
13 changed files with 467 additions and 8 deletions
+13
View File
@@ -50,3 +50,16 @@ hands out Proxies wherever state is deep.
**How to apply it.** At every storage or messaging boundary, write a plain copy built
field by field (in `@rosea/storage`, the same shape check used on reading). Keep lists
that are only passed along as `$state.raw`. Test the boundary with `new Proxy(value, {})`.
## `svelte/motion` reads `matchMedia` when it is imported
**What happened.** On 2026-11-17 the gardener's walk used `Tween` from `svelte/motion`. Every UI
test file failed at import: jsdom has no `window.matchMedia`, and the module reads it at load (for
its reduced-motion store), not when a tween runs.
**Why it bit.** An import with side effects breaks every file that imports it, even transitively,
and the error points at the module, not at the component that needed it.
**How to apply it.** In `packages/ui`, animate with a small `setInterval` easing inside an
`$effect` (`packages/ui/src/scene/Planet.svelte`), reading reduced motion once through a guarded
`matchMedia` call. If `svelte/motion` is wanted later, stub `matchMedia` in the test setup first.