Skip to main content

Crate plexus_ui_engine

Crate plexus_ui_engine 

Source
Expand description

UI-6: the engine — the host interface engine/1 of UI-4’s contract.

The engine owns what lives across swaps: the socket, the cache, the signals, the registry. A component owns only its tree and its folds; it never touches the DOM, the socket or another component.

modulewhat it holds
signalsa signal runtime: signals::Signal, bindings re-run only when a signal they read changes
treethe compiled view tree (UI-4’s schema), its interpreter over a tree::Renderer; the recording renderer (native tests) and, with dom, the DOM one
livelive(): a collection { rows, status } folded from a snapshot and a changes stream, shared by method and params, kept 5 s past its last reader
foldsa component’s handlers in Rhai — (state, event) → state, only call and navigate registered, call held to the component’s uses
swapthe bundle’s manifest, the module registry (name → hashes), mounting, hot-swap, and the sections (slots and their assignments)
htmlUI-10: {@html} and markdown() — an allow-list sanitizer to a tree the renderer draws
routermanifest.routes: a hash route to a component, its :name segments the props
transportthe wire seam (transport::Wire): the one socket on wasm32, a fake for the tests
busFRAME-12: what every mounted component is handed — call and live held to its uses, emit / on, navigate, slots_set
keysFRAME-36: every mounted component’s shortcuts — chords and sequences, matched on the window’s capture phase, the ? overlay
marksFRAME-17: the host’s steps on the page’s clock, performance.mark plexus-ui:*
moduleFRAME-12: the module contract every profile implements, mount(target, { props, bus }) → { update, destroy }

FRAME-12 cuts it in two: the host — transport, live, swap (versions, hot-swap, sections), router, bus, module and the signals they publish on — and the rhx runtime, the first profile (rhx/1): tree, folds, html. A module of any other profile is an ES module the page imports; js/host.js is the host’s JS face, beside engine.js in every bundle.

The wasm entry (boot) is [entry], behind the dom feature.

Modules§

bus
FRAME-12: the bus — what the host hands every mounted component, whatever drew it (the rhx runtime, a module written by hand, FRAME-13’s Svelte): one Bus per page, one Member per mounted component.
folds
UI-6: the folds — a component’s handlers, components/<name>.rhai, run in Rhai: every fn name(state, ev) returns the new state.
html
UI-10: HTML the page may hold — {@html expr} draws the expression’s text as HTML, and markdown(text) makes HTML of markdown; both go through sanitize first.
keys
FRAME-36: keys — a component’s shortcuts, the host’s to handle.
live
UI-6: live() — a component’s collection bound to Plexus streams: { rows, status }.
marks
FRAME-17: the host’s marks — its steps on the page’s clock, each a performance.mark named plexus-ui:<step> (CONTRACT.md’s host chapter), read by a probe with performance.getEntriesByType("mark"):
module
FRAME-12: the module contract — what every profile implements and the host mounts: mount(target, { props, bus }) → { update(props), destroy() }. In the page a module is an ES module (esm/1 written by hand, svelte/1 from FRAME-13) the host imports from its version’s components/<name>.js and wraps ([crate::entry]’s JsModule); the rhx runtime (rhx/1, the tree and the folds) is the host’s own arm of the same lifecycle in crate::swap — mounted, updated, swapped, fallen back and destroyed by the same rules.
router
UI-6: the router — manifest.routes: a hash route (#/ticket/T-1) to the component drawn (a layout too) and its props, each :name segment of the pattern a prop. The most specific pattern wins: one with fewer : segments over one with more (#/ticket/new over #/ticket/:id).
signals
UI-6: the signal runtime — no framework. A Signal<T> holds a value; a binding (Runtime::bind) is a closure that is run once, its reads of signals tracked, and run again exactly when one of the signals it read last time is set to a different value. Nothing else re-runs.
swap
UI-6: the module registry, hot-swap and the sections.
transport
UI-6: the wire seam — every Plexus call the engine makes goes through one Wire: on wasm32 the page’s one WebSocket ([ws], v1’s WsTransport over plexus-client’s ws-web, with its 1 s reconnect loop); in the native tests FakeWire, which records what was opened and lets the test feed each stream.
tree
UI-6: the view tree — UI-4’s compiled components/<name>.json, and its interpreter over a Renderer.

Constants§

ABI
The host interface this engine implements; a manifest’s abi.