Skip to main content

tpt_appfront_core/
lib.rs

1pub mod agent;
2pub mod component;
3pub mod components;
4pub mod context;
5pub mod devtools;
6pub mod error_boundary;
7pub mod form;
8pub mod plugin;
9pub mod reconcile;
10pub mod resource;
11pub mod router;
12pub mod signal;
13pub mod static_tree;
14pub mod store;
15pub mod styling;
16pub mod suspense;
17pub mod ui_tree;
18pub mod virtual_scroll;
19
20pub use context::{provide_context, use_context, Context};
21pub use resource::{Resource, ResourceState};
22pub use store::{instrument_store, Persistence, Store, StoreSubscription};
23pub use suspense::Suspense;
24pub use router::{Route, RouteTable, Router};
25
26/// Tailwind-style utility-class macro.
27///
28/// ```ignore
29/// ui.class(class!("bg-blue-500", "p-4", "rounded-lg"));
30/// ```
31///
32/// Emits a `String` of space-separated, `af-u-`-prefixed utility names and
33/// **validates each name at compile time** against
34/// [`styling::UTILITIES`] — an unknown utility is a build error, not
35/// silently-unstyled output. The `af-u-` prefix matches the rules produced
36/// by [`styling::style_sheet`] (embed once in a page `<head>`), or use
37/// [`styling::inline_style`] / the `tpt-appfront-html` SSR backend to have the
38/// CSS applied directly.
39#[macro_export]
40macro_rules! class {
41    ($($u:literal),* $(,)?) => {{
42        // Compile-time validation: each literal must be a known utility.
43        $( $crate::styling::class_macro_check($u); )*
44        let mut __appfront_class = ::std::string::String::new();
45        $(
46            __appfront_class.push_str("af-u-");
47            __appfront_class.push_str($u);
48            __appfront_class.push(' ');
49        )*
50        __appfront_class.truncate(__appfront_class.trim_end().len());
51        __appfront_class
52    }};
53}
54
55pub use agent::{current_route, navigate_to, query_state, route_signal, trigger_event, AgentState, ElementSummary};
56pub use tpt_appfront_macros::component;
57pub use tpt_appfront_macros::rsx;
58pub use tpt_appfront_macros::view;
59pub use devtools::{inspect_state, inspect_tree, render, to_html, DevtoolsReport};
60pub use error_boundary::{error_boundary, recover_or, BoundaryResult};
61pub use form::FormState;
62pub use plugin::{context_for_plugin, Plugin, PluginCtx, PluginRegistry};
63pub use reconcile::{
64    apply_edits, diff_summary, edit_description, reconcile_keys, History, KeyedDiff, ListEdit,
65};
66pub use signal::{
67    batch, create_effect, create_memo, reset_signal_activity, set_hydration_state, signal_activity,
68    take_hydration_state, EffectHandle, Signal,
69};
70pub use static_tree::static_node;
71pub use styling::{
72    class_macro_check, class_value, inline_style, is_utility, lookup, style_sheet, UTILITIES,
73};
74pub use ui_tree::{AiMeta, ContainerBuilder, HydrationPayload, NodeKind, NodeMeta, NodeRef, UITree};
75pub use virtual_scroll::{VirtualScroll, VisibleRange};
76pub use component::{memoize, Children};
77pub use components::{
78    announce_resource_status, date_picker, dropdown, live_region, modal, move_focus,
79    sortable_table, tabs,
80};