Epic: #113 · Milestone: MC7 — TV shell
Why
ADR #46: author in stx, ship Home. ~/Code/Tools/stx/packages/stx/src/craft-compiler.ts (1,422 lines) already turns stx templates into a Craft native component tree with CompilationFormat = 'zig' | 'typescript' | 'json' | 'binary'. Adding 'home' targets HomeOS's Craft (docs/design/craft.md v0.3: widget/event/layout/draw/text/theme modules, retained draw lists). The generated code is committed under apps/tv/generated/ so the OS repo stays pure Home and reviewable.
Tasks
- In stx:
CompilationFormat = 'home'; emitter maps stx nodes → Craft widgets (Stack,Row,Grid,Text,Image,Focusable,Listwith virtualisation hints), props → typed struct fields,@if/@for/@switch→ Home control flow in abuild()function, slots → child closures/function pointers, signals → Craft state cells with dirty-marking,@click/@keydown→ event handler symbols the developer implements in a sibling.homefile (apps/tv/screens/home.stx+home.handlers.home). - Unsupported stx features produce compile errors with locations (no silent drop): DOM-only directives, inline
<script>JS, arbitrary expressions beyond a whitelisted expression grammar (compiled to Home expressions). - i18n:
ts-i18ncatalogs compiled to Home string tables; icons collected for #77; classes resolved via #90. bunx stx build --format=home --out apps/tv/generatedwired intoscripts/build.sh --profile=tvwith a drift check (CI fails if generated output differs from committed).- Craft side: fill the gaps in
kernel/src/lib/craft_lib.homethe emitter needs (virtualised list, image widget, focus attributes); golden-frame tests in QEMU x86. - Hot-iteration on the Mac: stx dev server rendering the same components to HTML for layout previews (no fidelity guarantee, speed only).
Acceptance
apps/tv/screens/home.stx compiles to Home, builds into the x86 QEMU image, renders in the golden test; drift check enforced; unsupported-feature errors covered by tests in stx.