Skip to main content

rosace_widgets/template/
mod.rs

1//! Template descriptor (D103 / D102 Tier 1) — the **data** form of a `view!`
2//! tree, and the runtime that inflates it back into widgets.
3//!
4//! This is the contract at the centre of universal (data-not-code) hot reload:
5//! the `view!` macro *writes* a [`Template`] in dev builds, and a runtime
6//! interpreter *reads* it to reconstruct the widget subtree by calling the same
7//! widget constructors the release builder would (the "inflater, not a
8//! renderer" model — see `.steering/HOT_RELOAD.md`). Because it is pure data —
9//! widget kinds by **name**, literal props as data, dynamic `{expr}` bits as
10//! numbered **holes** — a template can be diffed and swapped at runtime without
11//! recompiling, which is the only reload path that works on iOS device and web.
12//!
13//! # Layers built on this
14//! - Step 2 (this file): the descriptor data model — [`Template`],
15//!   [`TemplateNode`], [`PropValue`], [`StaticValue`], [`TemplateKey`].
16//! - Step 3 (next): the widget registry + interpreter that turn a [`Template`]
17//!   into `Box<dyn Widget>` — that is where `RosaceTrace` inflate events are
18//!   emitted (this data model is inert, so it emits none itself).
19//! - Step 4: the dev watcher diffs templates by [`TemplateKey`] and pushes
20//!   deltas over the control channel.
21//!
22//! # Wire form (named-deferred)
23//! The types are deliberately plain data — `String` widget/prop names, a
24//! primitive-only [`StaticValue`], no borrowed lifetimes — so a
25//! `#[derive(Serialize, Deserialize)]` drops on cleanly the day the SDUI /
26//! external-DevTools transport needs a JSON form (the plan's "design it so it
27//! is not foreclosed"). `serde` is **not** pulled into the workspace here — it
28//! is a named deferral to the transport step (rollout step 4), consistent with
29//! D121 treating a new dependency as its own decision rather than smuggling it
30//! in with an unrelated change.
31
32mod descriptor;
33mod diff;
34mod inflate;
35mod parse;
36mod registry;
37mod reload;
38mod swap;
39
40pub use descriptor::{PropValue, StaticValue, Template, TemplateKey, TemplateNode};
41pub use diff::{diff, EscalationReason, TemplateDiff};
42pub use inflate::{inflate, is_registered, register_widget, FromProp, Handler, InflateError, PropInput};
43pub use parse::{parse_file_templates, parse_template, ParseError};
44pub use registry::{find_running, get, len, register, snapshot};
45pub use reload::{apply_reload, ReloadReport};
46pub use swap::{apply_swap, SwapOutcome};