Skip to main content

Module pages

Module pages 

Source
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 own history.pushState / popstate API and <a href> to a real DOM anchor
    • URL, in lumen-web-dom’s navigation module. The reserved-signal surface is unchanged; only the history backend swaps.
  • AOT packaging: lumenc build bakes ONE LayoutIR, and the assembled multi-page IR (this module’s output) already is one LayoutIR, so the AOT path runs [assemble] at build time and serialises the combined IR. The page keys travel on the artifact as CompiledPages, 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.
PageFile
One discovered page file.
PagePlan
The static plan produced by discover, read by the loader and the runtime. Mirrors what lumen.toml [pages] describes when explicit.
PageRegistry
Runtime page registry - the resolver’s view of the loaded pages.
RouteHistory
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 reserved route.path / route.segment cells, and maintains the in-memory history stack.
assemble
Graft every page in plan into ir (parsed from the entry file) as sibling <if signal="route.path" eq="<key>"> gates, parsing each page against the app-wide fragments table 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 .lmn files declares into the one table each page parses against. This is what makes a <template> in layout.lmn reachable from every page.
discover
Discover the pages in src_dir (the app’s src/, from crate::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.multipage is 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 holding HostFollowsLinks follows the link itself, and the click raises nothing here.