Skip to main content

Module artifact

Module artifact 

Source
Expand description

AOT compiled-app artifact - the on-disk product of lumenc build.

Today lumenc run parses main.lmn + main.css from source on every launch. The AOT model resolves that work once at build time and bakes the result - a fully cascaded LayoutIR plus the combined script source - into a compact binary blob the runtime deserializes directly, with the markup parser removed from the shipped binary (see the runtime-parse cargo feature).

This mirrors how other toolkits ship compiled UI:

  • Qt precompiles .qml into bytecode via qmlcachegen / the QML disk cache and bakes it into the binary, so the QML parser need not run (or even ship) at launch. This module is the direct analogue: the artifact is Lumen’s “QML cache”.
  • Slint compiles .slint to Rust at build time. We keep Lumen’s model data-driven rather than codegen (an artifact, not generated Rust) so the same runtime consumes it - but the “resolve markup once at build time” principle is identical.

Where these conflict with Lumen philosophy, philosophy wins: the artifact carries the design-token-reachable cascaded stylesheet (LayoutIR::combined_stylesheet) verbatim, so colors/metrics stay CSS-reachable at runtime (the <for> reconciler re-applies it) - the AOT step resolves the cascade, it does not freeze visuals into hardcoded values.

§Container layout

magic  : 4 bytes  b"LMNA"   (Lumen Markup Native Artifact)
version: 2 bytes  u16 LE    (FORMAT_VERSION)
body   : bincode(CompiledApp)

bincode is used over RON/JSON because the artifact is shipped/embedded and binary size is the priority: bincode stores no field names or schema, so a cascaded stylesheet with hundreds of declarations costs a fraction of its textual form. The magic + version prefix lets the loader reject a stale or foreign file cleanly instead of failing deep inside the decoder.

Structs§

CompiledApp
The precompiled application: everything the runtime needs to spawn the UI without touching the markup / CSS parser.
CompiledI18n
The app’s translations, as baked at build time.
CompiledPages
The navigable page set of a compiled multi-page app.
CompiledScript
One language’s whole program, as baked at build time.
UnlinkedCapability
One optional subsystem an app’s engine was linked without.

Enums§

ArtifactError
Errors from (de)serializing or reading/writing an artifact.

Constants§

FORMAT_VERSION
Container format version. Bump on any incompatible change to CompiledApp or the framing. The loader refuses mismatches so a runtime never mis-decodes an artifact built by a different toolchain.
MAGIC
Container magic - “Lumen Markup Native Artifact”.

Functions§

deserialize
Deserialize framed container bytes back into a CompiledApp, validating the magic and version first.
read
Read and decode an artifact from path.
read_bytes
Decode an artifact from an in-memory byte slice: the byte-slice counterpart of read. Used by the link-not-embed launcher path, where the compiler produces LMNA bytes in-process and hands them across the C-ABI (lumen_app_new_from_lmna) instead of writing a file. Thin alias over deserialize; validates magic + version identically.
serialize
Serialize a CompiledApp into the framed container bytes.
write
Write an artifact to path.