Skip to main content

Module lgx_lower

Module lgx_lower 

Source
Expand description

Lowering a component’s View: into the DOM calls every tier already runs.

The tree-walker renders an LGX component from its first-class AST, with the whole runtime behind it: instances, transactional turns, the journal. That is the REFERENCE semantics, and it stays.

The bytecode VM — and therefore WebAssembly, and therefore a browser — reaches the same page by a different road. A component’s view is compiled ONCE, here, into ordinary LOGOS: a ## To __render_<Name> (parent): function whose body is the createElement / setAttribute / appendChild calls the retiring dialect has always lowered to. Those builtins are already compiled by the VM and already lowered to wasm, so the frontend reaches the browser with NO new ISA surface — no opcode to classify in six device catalogs, no wasm_aot_lock bucket that would have to lie about a lowering that does not exist.

Both forms are emitted. The interpreter reads the ComponentDef and ignores the function; the VM compiles the function and treats the definition as a declaration. Mount App. means “render the instance” on one tier and “call __render_App” on the other, and lgx_vm_parity_lock holds the two to the same bytes.

What is NOT here is everything that needs the runtime rather than the DOM: actions, turns, rollback, the journal, stores, directives. Those need a host that can catch a trap, which the VM has no way to express — so a component using them has no render function, and the VM refuses it LOUDLY rather than rendering half a page.

Split by concern across this directory’s modules: naming/binding conventions (naming), the lowerability/refusal gate every construct passes through before compiling (gate), the derived JSON codec (json), sessions, ## Routes and server rendering (server), the per-component driver (components), DOM events and dispatch (events), patchable sites and per-instance state (sites), the page clock and the unmount sweep (sweep), typed fetch (fetch), ## Store lowering (stores), element/localStorage commands (elements), Mount (mount), turn wrapping and its epilogue (turns), and the view-tree walk that builds a render function (render). Every item this module used to export at the flat lgx_lower:: path still does, through the pub use lines below — this split is a pure reorganization, not a change to what any other file may call.

Structs§

HostEntry
A function a host enters a compiled program by name.
NotLowerable
Why a component cannot be lowered — the message the VM refuses a Mount with, and WHERE.
VdomFeature
A vdom.lg path only some pages take: every vdom.lg function named with prefix runs only on a tape holding records one of writers laid down, so the module’s dead-code analysis follows a call into it once a writer is reached (vm::reach) — a page that never calls a writer ships none of the feature. A new function of the feature is pruned by being named for it.

Enums§

EntryHost
Who enters an LGX_ENTRIES function by name.
ListenerSite
One attached listener, as the dispatcher needs to call it back.
ParamFrom
Where a route parameter’s value comes from at dispatch.
SessionFieldKind
★ components IS NOT OPTIONAL CONTEXT — IT DECIDES THE ANSWER.

Constants§

CSRF_FIELD
The form field and the header a token may arrive in. _csrf is the one csrf_lock already requires of every state-changing <form>; the header is how a scripted fetch sends one.
CSRF_FN
What a page calls to get its own token: value={csrf()}.
CSRF_HEADER
CSRF_TOKEN_PATH
Where a server with a ## Session answers the visitor’s own CSRF token — the value a page composed around it (<meta name="csrf-token">) hands its scripted requests. The path is the router’s own, never a route an author declares.
DROP_TARGET_CANCELS
The drag events a When a file is dropped on "<sel>": target cancels at registration. A browser makes an element a drop target only while dragenter and dragover are cancelled on it, and performs its own default for an uncancelled drop (it opens the file in the tab).
LGX_ENTRIES
★ EVERY FUNCTION A HOST ENTERS BY NAME, ONCE. A page’s wasm module exports its page entries under these names and nothing else of the lowering’s, the dead-code walk roots at them, runtime.js enters the module only through them and the in-process page host calls only them — lgx_entry_abi_lock reads each of those sides against this table.
PRERENDERED_ATTR
The attribute a pre-rendered document’s <body> carries: its markup is the page’s own first paint, which the mount adopts (vdHydrate) rather than clearing and drawing again. Written by the build’s pre-render, read by the mount, and taken off by the host as the hydration opens.
ROUTE_BODY_WALK
The three walks over the route table. Each takes the WHOLE Request — see the wrappers at the end of lower_lgx_routes for why the three-argument conveniences are built on top of these rather than the other way around.
ROUTE_CTYPE_WALK
ROUTE_HANDLER
The function one of a component’s actions lowers to. The Request -> Response the route table synthesizes, and what a bare Serve on port N. serves with. Named here so the parser and the lowering cannot spell it differently.
ROUTE_HEADERS_WALK
The FOURTH walk: the headers of the response the matched route answered.
ROUTE_RESPONSE_WALK
★ THE SERVING WALK — the ONE __lgx_route_handler runs, answering a whole Response.
ROUTE_STATUS_WALK
SESSION_COOKIE
The one cookie. See lower_session for why there is exactly one.
SESSION_LOADED_VAR
SESSION_LOAD_FN
SESSION_NONCE_FIELD
The hidden field every session carries, whether the author declared it or not: the value a visitor’s CSRF token is derived from.
SESSION_PAYLOAD_FN
SESSION_SAVE_FN
SESSION_SECRET_VAR
SESSION_VAR
The module global a ## Session lives in. Named session on purpose: it makes the session's user an ordinary possessive rather than a sentence form of its own.
SHARED_AREA
The storage area a shared on store’s fields live in, keyed "<topic>.<field>": the topics every page on them shares.
UNUSED_LOOKUP
The lookup no listener ever has: the seed entry of every map keyed by lookup, which types the map’s key and is never looked up.
VDOM_CALLS
Every vdom.lg function a lowered page calls — the tape it writes, the commit, the sites and fragments it finds its nodes by. None of them appears in the author’s source, so the prelude splices vdom.lg for a page and the pruner keeps exactly these as roots (loader.rs); vdom_calls_lock holds this list to the calls the lowering writes.
VDOM_FEATURES
Every VdomFeature: firm-key checks, matching by key, range resolution, hydration.

Functions§

action_fn_name
answer_fn_name
__lgx_answer(lookup, value) -> Bool — run the listener one listener-table entry names, for the instance that registered it; the node dispatcher asks it for the entry waiting for the pressed key and for the one waiting for any.
appear_at_binding
__LGX_APPEAR_AT — the next owed entry appear_fn_name runs.
appear_fn_name
__lgx_appear() — every owed When this component appears:, first drawn first, each a turn of its own; run where a paint ends, never inside one.
appear_key_binding
__LGX_APPEAR_KEY — the instance each owed When this component appears: belongs to.
appear_who_binding
__LGX_APPEAR_WHO — which component each owed When this component appears: belongs to, as its place (from 1) among the components that have one; beside appear_key_binding, one entry per instance a paint drew for the first time, in the order it drew them.
authored_construct
The construct an author wrote that the compiler-written function name was lowered from, named as the author knows it: `## Route GET /agent`, the `add` action of `## Component Counter`, `## Directive focus`, or the `## Route` table for the walks that serve every route. Built on the forward helpers above over the constructs the program declares, so there is no inverse mapping to keep in step. None for a name no construct owns — a synthesized name never becomes text an author reads.
bind_fn_name
The binding holding where a component last rendered, so a turn can repaint it. __bind_<Component>_<field>(v) — the write-back a bound input performs.
block_slot_param
The parameter a layout’s render reads its {block <name>} out of: the node holding what the extending view drew for that block in its own scope, or 0 when it filled none and the layout draws its default.
callback_arg_binding
Where a callback prop’s own declared parameters are kept, per instance — the twin of listener_arg_binding for a handler whose target varies by placement instead of being fixed at the component’s own declaration. Typed by the prop’s own function type, which every action bound to it is required to match exactly, so one map serves every target the tag can name.
callback_key_binding
The twin of callback_tag_binding: whose own instance the tag’s action runs against — the placing component’s key, recorded beside the tag so the two travel together.
callback_tag_binding
The module binding holding a CALLBACK PROP’s own identity, per instance: which (component, action) pair to run when the prop is called, as that pair’s tag (events.rs::action_tag) — never the pair itself, because the two scalars a map CAN hold are an index and a key, never a function reference.
callback_trampoline_fn_name
__cb_<Component>_<prop>(key, a…) — the one function every call of a callback prop goes through: it reads the instance’s recorded identity and runs the action it names.
cascade_binding
__LGX_CASCADE — how many rounds of store watchers are running inside one another: a round that has watchers to run enters before they run and leaves after, and a round past crate::ast::component::STORE_CASCADE_LIMIT fails the page as one that never settles.
commit_fn_name
__lgx_commit(node) — commits the tape into node’s retained children and hands the stream to the host, or fails the turn with the commit’s refusal and the document untouched.
construct_heading
How an LGX construct is named in a refusal: by the header its author wrote.
declares_session
Whether a lowered program declares a ## Session — read off the program itself, because the session’s loader is defined exactly when one is. A serving tier that composes page documents asks the router for the visitor’s token (CSRF_TOKEN_PATH) only then: without a session there is no token to ask for, and asking would run the handler for every page served.
descends_fn_name
__lgx_descends(k, under) — whether instance key k was placed inside the instance keyed by under (a key and its trailing /); what a repaint of a placed component sweeps within.
directive_fn_name
The function a ## Directive lowers to. A directive is behavior attached to an element, and on this tier that is exactly what a function call is.
directive_keys_binding
__DIRK_<name> — every attached occurrence of a directive with a When removed: block, by its identity (the instance key, \u{1}, its static site, and its row in every enclosing loop).
directive_node_binding
__DIRN_<name> — the element each attached occurrence was last drawn on.
directive_queue_key_binding
__DIRQK_<d> — the identity of each queued occurrence of a directive with When removed:.
directive_queue_site_binding
__DIRQS_<d> — the sites of the elements directive d sits on, queued by the render for the commit.
directive_queue_value_binding
__DIRQV_<d> — the value each queued occurrence of directive d is drawn with.
directive_removed_fn_name
__dir_<name>__removed — a directive’s When removed: block, run with the element and value its occurrence was last attached with, once that occurrence is no longer drawn.
directive_stamp_binding
__DIRS_<name> — the paint pass each attached occurrence was last drawn in.
directive_value_binding
__DIRV_<name> — the value each attached occurrence was last drawn with.
dispatch_fn_name
The program-wide event dispatcher: __lgx_dispatch(selector, event). A driving verb on the bytecode tier calls it, and it routes to the action the view attached — decided here, as data, because a page has no way to call a closure it found at run time.
dispatch_node_fn_name
The dispatcher’s node half: __lgx_dispatch_node(node, event, value) — a host that already holds the element (a focus change: the element that lost focus, the one that gained it) raises an event on it without a selector naming it.
drain_directives_fn_name
__lgx_drain_directives() — runs every directive occurrence the committed paint drew.
draw_depth_param
The parameter a drawing takes how deep it is nested in its own kind in: a template among templates (__view_<f>), a served component among served components (__serve_<C>). Past RENDER_DEPTH_LIMIT the drawing fails in the render-depth words.
due_binding
__DUE_<C>_<i> — the page time (__LGX_NOW’s clock) at which handler i of C next fires, per instance. -1 is “not running”, which is what a Stop the … timer. writes and what a one-shot leaves behind.
empty_view_variant_name
__View_none — the empty view: what a View prop holds before anything is handed to it.
failing_component_binding
__LGX_FAIL_C / __LGX_FAIL_K — WHICH turn is running right now: a component id and an instance key, written at the top of every turn.
failing_key_binding
failure_context_binding
__LGX_CONTEXT — what the page is doing that a trap should be named by (a directive’s block), in the words every tier puts in front of the trap’s message; "" outside any.
failure_context_fn_name
__lgx_failure_context() -> Text — the context a trap left open, taken (the page is back outside any once a host has read it).
forget_listener_fn_name
__lgx_forget_listener(lookup) — retire one registration: its entry in every map keyed by lookup and its place in a spilled slot’s list; or, while a delivery holds it, mark it to go when the delivery lets go.
forwarded_binding
__LGX_HEARD_<C>_<i> — whether the page already forwards what handler i of C waits for (a window event, a relay topic) to its dispatcher; the forwarder is attached once per page.
frag_key_binding
__LGX_FRAGK — the instance key each fragment id is drawn for.
frag_owner_binding
__LGX_FRAGC — the component (its position among the lowered components, from 1) each fragment id is an instance of; 0 for an id no instance holds.
gone_fn_name
__lgx_gone() — the unmount sweep: every instance whose fragment the last commit removed loses its registries, tells its When this component disappears: handler, and hands its sites back.
host_entry_of
The LGX_ENTRIES row name enters by: its own row, or its family’s.
html_fn_name
__html_<C>() — component C’s markup, as html of C asks for it: C drawn by its server render into a root no host holds, serialized, and the root discarded.
instance_key_param
The module-level binding a component’s state field lives in. Prefixed with the component’s name so two components’ n are two different bindings. The parameter every instance-aware synthesized function carries: WHICH instance it is acting for. A component’s state is a map from this key to that instance’s value, so two placements of one component keep separate records, each instance addressed by its key path.
is_browser_only_lowering
★ WHICH SYNTHESIZED FUNCTIONS NEED A DOCUMENT — the one place the answer lives.
is_compiler_written
Is this a name the COMPILER wrote, rather than one the author typed?
json_bare_scalar_name
Why a ## Route cannot be lowered to a plain function yet.
keeps_instance_registry
Whether this component keeps a live-instance registry (__KEYS_<C> / __SEEN_<C>).
keys_binding
__KEYS_<C> — every instance key of C that has ever rendered, in first-render order.
listener_arg_binding
Where a registered listener’s ARGUMENTS are kept, per instance.
listener_fn_binding
__LISTENER_FN — the site each registered listener runs, by its lookup: its slot for the first listener waiting there, a spilled lookup (listener_spill_binding) for each one after it.
listener_held_binding
__LISTENER_HELD — how many deliveries in flight hold each lookup. A delivery fixes the listeners it will run before running any, as a browser does, so a listener whose element an earlier listener’s turn redrew still answers: retiring a held lookup waits for its last holder.
listener_key_binding
The instance key each registered listener belongs to — the twin of listener_fn_binding.
listener_left_binding
__LISTENER_LEFT — the held lookups retired while held, forgotten when their last holder lets go.
listener_once_binding
__LISTENER_ONCE — the .once identity of each registered listener, keyed like listener_fn_binding, so the dispatcher can spend the listener it resolved.
listener_sites_binding
__LISTENER_SITES_<C> — every listener lookup THIS instance registered in its LAST paint.
listener_space_binding
__LISTENER_SPACE — how many listener entries (event names, and event-and-key pairs) the program registers. A listener’s SLOT is node * __LISTENER_SPACE + code, so every (element, entry) pair has a slot of its own however many entries the program has; declared once every entry is known.
listener_spill_binding
__LISTENER_MORE — the lookups of every listener past the first waiting on one slot, in the order they registered: one element can wait for one event several times over (a directive and a sentence, two sentences, two instances naming it), and each answers. Empty unless a slot has several listeners, so the common slot costs nothing here.
listener_spill_count_binding
__LISTENER_SPILLED — how many listeners have ever spilled. The n-th spilled listener’s lookup is -1 - n: below every slot (slots are never negative), never reused, and never UNUSED_LOOKUP, which the listener maps are seeded with.
listener_spill_slot_binding
__LISTENER_MORE_AT — the slot each spilled listener waits on, so retiring it finds its list.
loop_placed_components
lowerable
Whether this component’s view is expressible as plain DOM calls.
mount_binding
mount_fn_name
The entry point a Mount calls: record where the component renders, run its load handlers once, then paint. Distinct from the render function, which runs again on every repaint — a load handler that ran on each repaint would not be a load handler.
moved_binding
__LGX_MOVED — set when a turn moved the location within the page, and taken by that turn’s epilogue, which delivers the move to the page’s route listeners.
now_binding
__LGX_NOW — the page’s own clock, in milliseconds since the page started, moved only by __lgx_tick(ms).
on_failure_fn_name
__lgx_on_failure(message) — run the failure handler of whichever component was mid-turn. The browser host calls it from the one place that catches.
once_record_binding
__ONCE_<C> — every .once identity an instance of C has spent, per instance key, so the unmount sweep can forget them when the instance leaves and a remount starts with its listeners armed.
once_spent_binding
__LGX_ONCE — the identity of every .once listener that has answered, mapped to true. An identity is the listener’s author-level address — its instance key, its static site, and its row in every enclosing {for each} — so it survives a repaint that draws the element again with a fresh node, and a spent listener stays spent however its element is redrawn.
open_keys_binding
__LGX_OPEN_KEYS — the journal instance of each open turn, beside its name in open_turns_binding.
open_turns_binding
__LGX_OPEN_TURNS — the journal names of the turns in progress, innermost last: a turn pushes its name first and pops it just before it journals itself, so a trap leaves exactly the turns it interrupted here, for the failure door to journal innermost-first.
outbox_count_binding
The page’s OUTBOX: the element events turns have asked for and not yet had delivered — how many (outbox_count_binding) and, at positions 1..=count, three parallel Int-keyed maps of selector, event and carried value — appended where the asking statement RUNS and emptied by the flush that follows a turn’s write-back.
outbox_event_binding
outbox_flush_event
The reserved event a turn’s epilogue dispatches to flush the outbox (lower_lgx_dispatcher’s first arm).
outbox_selector_binding
outbox_value_binding
own_frag_fn_name
__lgx_own_frag(frag, who, key) — records which instance a fresh fragment id is drawn for.
owns_fn_name
__lgx_owns(path) -> Bool — whether this module’s ## Page serves path (its query and fragment set aside): the one rule deciding whether a move to path stays in the page (navigate, a pushState) or loads another document (assignLocation). Navigate to branches on it, and a host’s link-following asks it.
pass_binding
The paint-pass counter every instance stamps itself with. One per program.
patch_fn_name
The per-turn patcher: __patch_<Component>_<turn>.
period_binding
__PERIOD_<C>_<i> — handler i of C’s period in milliseconds on each instance, as its sentence read when the instance was drawn: what a repeating timer re-arms by and what Start the timer … restarts it from.
place_view_fn_name
__lgx_place_view(view, scope, depth) — draw whichever template a View value is a call of.
placed_components
prop_binding
The module binding holding a component’s PROP values, per instance.
raise_fn_name
Raise "offline". on the bytecode tier.
rearm_fn_name
__lgx_rearm() — ask the host to wake the page when its earliest running timer comes due (wakeAfter), or to wake it for none. Called after every arming, stop and start, and at the end of every tick.
render_depth_binding
__LGX_RENDER_DEPTH — how many renders of components that can be drawn inside themselves are running inside one another; one past crate::ast::component::RENDER_DEPTH_LIMIT fails the paint as one with no finite rendering.
render_fn_name
The name of a component’s render function: __render_<Name>. The VM builds the same name from a Mount, so the two sides agree without a table between them.
render_frag_param
The render function’s parameter holding the fragment its instance is drawn as — what the sites its paint hands out are kept against (vdAnchor).
render_slot_param
__html_<Component>() — the server-rendered markup of a component’s view. The parameter a rendered component reads its {children} out of in a BROWSER: the node holding the caller’s children, or 0 for a placement that gave none.
repaint_root_fn_name
__lgx_repaint_root() — repaint the page from its root (the instance keyed ""), the answer to a change any component may show: what a turn that moved a store paints, and what a shared store runs when another replica’s write arrives.
route_changed_fn_name
__lgx_route_changed() — deliver a move of the location to every live instance of every component with a When the route changes: handler. The page registers it with the host once, at start (onRoute), and a turn whose own Navigate to moved the location calls it at its epilogue, so a placed component hears the move exactly as a mounted one does.
route_fn_name
__route_<METHOD>_<slug> — the function a ## Route becomes.
route_heading
A route’s own heading, as its author wrote it — the one place a route names itself in a refusal, called by both the tree-walker and the VM compiler so the wording cannot diverge.
route_lowerable
route_refusals
Every ## Route this program cannot lower, and why — computed ONCE where the whole program is visible, for the tiers whose per-statement walk cannot see it.
scope_class
seed_key
The key the per-instance maps are SEEDED with, purely to give themselves a type.
seen_binding
__SEEN_<C> — the key of every instance of C that has ever rendered, mapped to the PAINT PASS it last rendered in.
seq_binding
__SEQ_<C>_<i> — when handler i of C was armed on each instance, in arming order across the page: two timers due at one moment fire in the order they were armed.
serve_fn_name
__serve_<C>(props…, slot, blocks…) — component C drawn onto the tape to be serialized: the same walk as its __render_<C> over its initial state, writing only the records its markup is made of (LowerTrail::serving).
shared_arrival_fn_name
__lgx_shared(topic, key, frame) — the relay’s entry: a frame another page published.
shared_base_binding
The plain value a convergent field of shared store store last adopted — what the next action’s change to field is read against.
shared_clock_binding
This page’s Lamport clock for its shared stores.
shared_ids_binding
The node id behind each element of shared sequence field of store, in its order.
shared_join_fn_name
__join_<S>() — the replica joins its topic: it adopts what the topic holds and publishes the rest. Runs before the first statement that reads one of its fields.
shared_joined_binding
Whether the shared-store replica store has joined its topic.
shared_publish_fn_name
__publish_<S>() — publish every field the replica’s action moved, then refresh the topic’s other joined replicas.
shared_refresh_fn_name
__refresh_<S>() — a joined replica adopts what its topic holds.
shared_replica_binding
This page’s replica id, drawn once per page load by a page with a convergent shared field: the part of every tag and node id that no other page’s can share.
site_binding
The module binding that remembers WHERE one updatable site’s node landed.
state_binding
stateful
store_area
Whether a store’s state can be given a record type here. A derived field or a field whose type cannot be named from its annotation or its initializer means it cannot. The storage AREA a store keeps its state in between page loads, or None for one that keeps nothing there. The area is the lifetime the author asked for, spelled the way the browser spells it — the one decision every tier reads, so every tier puts a persisted store in the same place.
store_moved_binding
__MOVED_<Store>_<field> — set by a store action whose commit moved a field some component watches, and taken by the next store-watcher round (wake_stores_fn_name).
store_type_name
The record type a ## Store lowers to. A store is a singleton with named fields, which is what a record is — so Session's name stays an ORDINARY field access on both tiers and no expression anywhere needs rewriting.
stores_dirty_binding
__LGX_STORES_DIRTY — set by every store action’s commit and cleared by every repaint from the page root: whether the page may still show a store as it was before a commit. A turn that moved a store repaints from the root; one that trapped first never did, and the failure door repaints for it.
styled_binding
The class a component’s Style: is scoped to, and which its own elements carry. The server walk stamps the same class, or the two would render the same page with different class lists. The module binding holding whether this component’s stylesheet has been emitted in the CURRENT paint. A Style: block is one <style> per component TYPE per render pass, however many instances render: the first instance to render claims it, and a new paint clears the claims.
tick_fn_name
__lgx_tick(ms) — the page’s clock moves forward by ms, and every timer that time makes due fires, in due order.
timer_seq_binding
__LGX_TIMER_SEQ — how many timers the page has armed, the next arming’s order.
unkeyed_stateful_loop
A {for each …:} with NO keyed by whose body reaches a component that owns State:.
view_draw_fn_name
__view_<f>(depth, scope, params…) — template f’s nodes drawn onto the tape, depth views deep.
view_html_fn_name
The function a -> View function’s served half lowers to: the same view as HTML text.
view_html_lowerable
Which view nodes the server-side HTML walk covers.
view_html_lowerable_with
view_html_lowerable with the component list, so a CHILD COMPONENT can be checked: a <TodoRow todo={t}/> is server-renderable exactly when the child’s own view is.
view_scope_param
The parameter a template’s drawing takes the placing component’s scope class in ("" when that component has no Style:).
view_type_name
__View — the enum a page program’s View values are: one variant per -> View template, carrying that template’s arguments (lgx_lower::views). Registered by the discovery pass, so every engine is handed it.
view_value_param
The parameter place_view_fn_name takes the View value in.
view_variant_name
__View_<f> — the variant a call of template f is.
wake_stores_fn_name
__lgx_wake_stores() — one store-watcher round: take every moved-field flag, and run each watcher of a field that moved once per live instance. Every turn ends with one.
watch_changes_binding
__LGX_WATCH_CHANGES — the changes the watching turn’s action committed, as noteTurn takes them: what the failure door journals for that turn when one of its handlers traps.
watch_depth_binding
watch_key_binding
watching_binding
__LGX_WATCHING — which component’s When <field> changes: handlers are running (its id among the components that have them, 0 for none): its action has committed, so a trap there is absorbed rather than undoing it. __LGX_WATCH_K is that instance’s key, and __LGX_WATCH_DEPTH how many turns were open when the handlers began (the watching turn’s own entry the last of them).