ReviewOS

home-lang/home-os

stx → Home: a `home` output format for stx's craft-compiler that emits Craft component trees, signal bindings and event handlers as `.home` source (build-time, zero JS on device)

#89
Open chris opened this 8 days ago ·
8 days ago

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, List with virtualisation hints), props → typed struct fields, @if/@for/@switch → Home control flow in a build() function, slots → child closures/function pointers, signals → Craft state cells with dirty-marking, @click/@keydown → event handler symbols the developer implements in a sibling .home file (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-i18n catalogs compiled to Home string tables; icons collected for #77; classes resolved via #90.
  • bunx stx build --format=home --out apps/tv/generated wired into scripts/build.sh --profile=tv with a drift check (CI fails if generated output differs from committed).
  • Craft side: fill the gaps in kernel/src/lib/craft_lib.home the 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.

Size: L · Depends on: #46, #65 · Blocks: #92, #93, #95

Sign in to comment on this issue.