Skip to main content

Module web_host

Module web_host 

Source
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§

ShellTheme
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 --token on :root, so a user overrides one line to reskin — and the tokens are the ones largo new --web scaffolds into static/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 is BigInt, an even one the integer t >> 1, an odd one a slot of exactHeld that a dropped handle gives back to exactFree. The arithmetic is BigInt’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. Number of a BigInt is the nearest binary64, ties to even, as an Int widens to a Real. The node shim interpolates it and runtime.js carries 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_f64 defines, byte for byte. ECMAScript’s Number.prototype.toString gives 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 in BigInt) moves up. The digits are spelled without exponent notation, an integral value bare, and NaN, inf, -inf and -0 as Rust spells them. The node shim interpolates it and runtime.js carries the same text (wasm_float_display_lock).

Functions§

assemble_preview
Assemble a self-contained, sandboxable iframe srcdoc that 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 own document, and the default theme makes it beautiful. Powers the Studio’s live “Web” preview. On a build failure returns the ParseError (render it with error_overlay_html).
assemble_preview_painted
assemble_preview with the page’s first_paint already 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 as assemble_preview previews 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-color so 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_themed with ShellTheme::Default.
browser_host_js
The browser host: the production analog of the test MockDom. 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. Loading the emitted .wasm and calling main() 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_client embedded so fixing the source snaps the page back to green. Reuses ParseError::diagnostic_parts so 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 build writes it into the document it ships, and assemble_preview_painted into 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 every env.* import the backend can emit (the display sinks, the float display FMT_F64_JS, the scalar→Text formatters, parse_int, pow, and an args host that materializes process.argv as a Seq of Text in the module’s linear memory). Running it needs only a wasm engine (node/V8).
with_csrf_meta
document carrying the visitor’s CSRF token in 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’s requestHeaders) sends back as x-csrf-token on the page’s state-changing requests to its own server. The meta opens the head; a page’s own Head: merges over it by identity like every other head element. A document with no <head> is returned as it is.