Expand description
File-based pages - multi-.lmn discovery, <if>-reconciler page mount,
and the navigation resolver reachable from every embedding surface.
File-based pages - multi-.lmn discovery, registration, and the
runtime navigation resolver.
§The model (Next.js / SvelteKit file-based routing, real-HTML <a>)
Every .lmn file in the app’s src/ directory is a page, keyed by its
filename stem, except layout.lmn, which is the shared layout rather than
a page. The home page is index.lmn (falling back to the [app] entry
stem, then main.lmn for single-file compat). All pages load up front,
and the fragments declared in ANY of the app’s files are merged into one
table every page parses against, so a shared layout.lmn template (with
a <slot>) is usable from every page.
Rendering reuses the existing <if> reconciler with ZERO new machinery:
the assembled tree is the entry <root> holding one synthetic
<if signal="route.path" eq="<page-key>"> gate per page, wrapping that
page’s content. Navigation is a reserved-signal write (route.path); the
reconciler mounts the matching gate and unmounts the rest. This keeps
navigation reactive-only (no per-frame tick) and candela-neutral (the
navigation command rides the shared bus in lumen_core::nav, not a
Rhai builtin).
§Page resolution
The framework does not pattern-match :id segments. A requested path is
resolved by longest existing .lmn prefix (lumen_core::nav::resolve_path):
/settings -> settings.lmn; /user/7 (no user/7.lmn) -> user.lmn
with /7 exposed on the reserved route.segment signal for the page’s
own code to parse.
§Host seams
- Web transpile: [
RouteHistory] is the desktop back/forward stack. The web target binds the same navigation surface to the browser’s ownhistory.pushState/popstateAPI and<a href>to a real DOM anchor- URL, in
lumen-web-dom’snavigationmodule. The reserved-signal surface is unchanged; only the history backend swaps.
- URL, in
- AOT packaging:
lumenc buildbakes ONELayoutIR, and the assembled multi-page IR (this module’s output) already is oneLayoutIR, so the AOT path runs [assemble] at build time and serialises the combined IR. The page keys travel on the artifact asCompiledPages, and a [PageRegistry] is rebuilt from them at load.
Structs§
- Anchor
- Navigation target attached to a spawned
<a href="...">element. A click on the entity navigates the active page. - Location
- One entry on the in-memory history stack.
- Page
File - One discovered page file.
- Page
Plan - The static plan produced by
discover, read by the loader and the runtime. Mirrors whatlumen.toml [pages]describes when explicit. - Page
Registry - Runtime page registry - the resolver’s view of the loaded pages.
- Route
History - In-memory back/forward history. A desktop window steps through this; in a browser the browser’s own history is what answers back and forward, and this records where the app has been without being stepped.
Functions§
- apply_
navigation - The single navigation resolver. Reads the reserved request signal (written
by every surface via
lumen_core::nav::request), resolves the target by longest existing-file prefix, updates the reservedroute.path/route.segmentcells, and maintains the in-memory history stack. - assemble
- Graft every page in
planintoir(parsed from the entry file) as sibling<if signal="route.path" eq="<key>">gates, parsing each page against the app-widefragmentstable and merging every page’s scripts. Returns the extra page-file paths to add to the hot-reload watch set (all non-entry pages). - collect_
fragments - Merge the fragments every one of the app’s
.lmnfiles declares into the one table each page parses against. This is what makes a<template>inlayout.lmnreachable from every page. - discover
- Discover the pages in
src_dir(the app’ssrc/, fromcrate::app_layout::AppLayout), honouring[pages]/[app]config. - install
- Install the page registry, in-memory history, the reserved-signal seeds,
and the navigation systems onto a built app. Called once at boot when
plan.multipageis set. - install_
routing - Install navigation for a known page set: the registry, the in-memory history, the reserved-signal seeds, and the two navigation systems.
- navigate_
on_ anchor_ click - Declarative navigation: a click on a spawned
<a href>navigates the active page. The anchor is a real element; on the web target it is a real DOM<a href>, and under[web] navigation = "soft"the browser’s own anchor navigation is prevented so that this system’s swap is what the click ends at. A host holdingHostFollowsLinksfollows the link itself, and the click raises nothing here.