AWESOME-OS ENGINEERING BLOG
12 — Native HTML5, CSS Flexbox & Reactive JS Without Forking WebKit (b8g-html)
12 — Native HTML5, CSS Flexbox & Reactive JS Without Forking WebKit (b8g-html)
Anchored Code:
- Portable HTML5/CSS ->b8g-layoutCore (zeronode:*):intersections/b8g-html/index.mts
- Reactive Isolated JS DOM Runtime: intersections/b8g-html/runtime.host.mts
- Unified Host CLI (bin\b8g-html.ps1, pre-wrapped withhost-debug-facade):intersections/b8g-html/cli.host.mts
- Run this post live: .\bin\notebook.ps1 run 12
1. Why We Chose Projection Over a 20M-LOC WebKit Fork
Forking full WebKit would mean maintaining 15–20 million lines of C++, ICU, HarfBuzz, Cairo/Skia, GStreamer, libxml2, and JavaScriptCore — duplicating our own faster b8g-abi-v8, $O(N)$ @awesome-os/b8g-layout, and native wgpu + glyphon b8g-gfx-host.
Instead, intersections/b8g-html/ projects real HTML5 + <style> CSS Flexbox + <script> / onclick directly onto Awesome-OS primitives in ~500 lines of zero-dependency TypeScript:
- Streaming HTML5 Tokenizer & DOM Tree (
parseHtmlToDom): Handles nested elements, void tags, attributes,<style>,<script>, and<title>. - CSS Rule & Specificity Resolver: Maps
display: flex,flex-direction,gap,padding,flex-grow,align-items,width/height,background,color,border-radius, andfont-sizeonto@awesome-os/b8g-layout. - Reactive Isolated JS Sandbox (
B8gHtmlRuntime): Providesdocument.getElementById,querySelectorAll,textContent,style,onclick, andaddEventListener('click', fn)— mutating DOM nodes and re-projecting 48 B/quad GPU scenes in sub-millisecond time. - Damped Legacy Host Chart (
host-debug-facade): Launches safely via.\bin\host-debug.ps1 run --profile diagnostic -- b8g-html.
2. Live Executable alg Cell (.\bin\notebook.ps1 run 12)
blade HtmlDom @sab-ring { nodeCount: int32, quadCount: int32 }
blade HtmlEvents @sab-ring { interactionCount: int32, lastHitId: string(64) }
manifold NativeHtmlApp = HtmlDom ^ HtmlEvents
chart NativeHtmlGpu = NativeHtmlApp |> host(diagnostic, 8000ms) -> wgpu