Expand description
The browser host for a LOGOS→WASM DOM app — shared by the CLI (largo emit wasm-dom / largo serve) and the web Studio’s live preview so both render a
LOGOS app identically. It supplies the real DOM behind the dom_* imports,
allocates host Text into linear memory, and fires event/fetch callbacks through
the exported __logos_call_closure trampoline (the production analog of the test
MockDom). It also carries the default theme, the favicon, and the build-error
overlay so a fresh LOGOS web app is beautiful — and legible when it breaks — with
zero CSS written.
Enums§
- Shell
Theme - Whether a page’s shell carries the built-in theme (
DEFAULT_THEME_CSS).
Constants§
- BROWSER_
RUNTIME_ JS - The browser host runtime, verbatim. Kept as a file so it can be executed by a test rather
than only string-matched — see
runtime_js_lock. - DEFAULT_
THEME_ CSS - The default theme — a small, opinionated design system in Claude’s language: a warm
cream surface, a clay accent, ink text, generous spacing, rounded controls, and an
automatic dark mode via
prefers-color-scheme. Every value is a--tokenon:root, so a user overrides one line to reskin — and the tokens are the oneslargo new --webscaffolds intostatic/theme.css(--paper,--ink,--accent,--muted,--border,--radius,--shadow), so a project’s theme file reskins these styles too. Ships in every generated page so a LOGOS web app looks designed with zero CSS written, unless the site opts out (ShellTheme::None). - EXACT_
INT_ JS - The host’s half of a module’s exact integers (
exact_*,vm::wasm::module::exact), as JavaScript: a tagged word isBigInt, an even one the integert >> 1, an odd one a slot ofexactHeldthat a dropped handle gives back toexactFree. The arithmetic isBigInt’s, which truncates a quotient and gives a remainder the dividend’s sign as the reference tier does; a floored quotient corrects the truncated one.Numberof aBigIntis the nearest binary64, ties to even, as anIntwidens to a Real. The node shim interpolates it andruntime.jscarries the same text (exact_int_every_tier_lock). - FAVICON_
DATA_ URI - A clay-λ favicon (an inline SVG data-URI) so a fresh LOGOS app is branded in the
tab bar with no asset file.
#is%23-encoded (a#is a URI fragment marker). - FMT_
F64_ JS - A float as LOGOS shows it, in the JavaScript every WebAssembly host runs: the display
logicaffeine_data::fmt::fmt_f64defines, byte for byte. ECMAScript’sNumber.prototype.toStringgives the shortest digits that read back to the same bits, as Rust’s{}does, except where the double lies exactly halfway between two shortest candidates: ECMAScript takes the even one and Rust the larger, so an exact tie (screened by parsing, settled with the double’s exact binary value inBigInt) moves up. The digits are spelled without exponent notation, an integral value bare, andNaN,inf,-infand-0as Rust spells them. The node shim interpolates it andruntime.jscarries the same text (wasm_float_display_lock).
Functions§
- assemble_
preview - Assemble a self-contained, sandboxable iframe
srcdocthat COMPILES-and-RUNS an LGX app entirely in the browser — the wasm module is embedded inline (no file to fetch), the shared DOM runtime drives the iframe’s owndocument, and the default theme makes it beautiful. Powers the Studio’s live “Web” preview. On a build failure returns theParseError(render it witherror_overlay_html). - assemble_
preview_ painted assemble_previewwith the page’sfirst_paintalready in the frame’s body, marked for the page’s mount to adopt, so the frame shows the page the moment its document parses rather than once its module has run, and a frame that reloads with the same page shows it throughout. A program with no first paint is previewed asassemble_previewpreviews it.- browser_
host_ html - The HTML shell that loads a LOGOS→WASM DOM app in a browser — carrying the default
theme, the clay-λ favicon, and a light/dark
theme-colorso a fresh app is beautiful out of the box. - browser_
host_ html_ themed - The HTML shell that loads a LOGOS→WASM DOM app, with a page’s own
Head:merged over the defaults. - browser_
host_ html_ with_ head - The HTML shell that loads a LOGOS→WASM DOM app, with a page’s own
Head:merged over the defaults, carrying the built-in theme —browser_host_html_themedwithShellTheme::Default. - browser_
host_ js - The browser host: the production analog of the test
MockDom. It supplies the real DOM behind thedom_*imports, allocates host Text into linear memory, and fires event/fetch callbacks through the exported__logos_call_closuretrampoline. Loading the emitted.wasmand callingmain()builds the page. - error_
overlay_ html - Render a build error as a themed HTML overlay — the SAME source line + caret +
Socratic message + spelling suggestion the terminal shows, in the Claude palette,
with
reload_clientembedded so fixing the source snaps the page back to green. ReusesParseError::diagnostic_partsso the terminal and browser never drift. - error_
overlay_ html_ in - The same overlay, told WHICH FILE it is drawing.
- first_
paint - The page’s markup: the first paint of the page’s own lowered program, the one its module runs,
drawn in process, or the reason it cannot be rendered without a browser.
largo buildwrites it into the document it ships, andassemble_preview_paintedinto a preview’s frame; either way the page’s mount adopts it (data-logos-prerendered) rather than drawing it again. - wasm_
host_ shim - The JavaScript host shim written beside an emitted
.wasm— supplies everyenv.*import the backend can emit (the display sinks, the float displayFMT_F64_JS, the scalar→Text formatters,parse_int,pow, and anargshost that materializesprocess.argvas aSeq of Textin the module’s linear memory). Running it needs only a wasm engine (node/V8). - with_
csrf_ meta documentcarrying the visitor’s CSRFtokenin its head, as<meta name="csrf-token">— what the server writes into every page it composes under a## Session, and what the browser host (runtime.js’srequestHeaders) sends back asx-csrf-tokenon the page’s state-changing requests to its own server. The meta opens the head; a page’s ownHead:merges over it by identity like every other head element. A document with no<head>is returned as it is.