use super::*;
#[derive(Clone, Copy, Data, Debug, Default, Deserialize, PartialEq, Serialize)]
#[serde(default)]
pub struct DynamicStyleSpec {
#[get(skip)]
pub(crate) width: Option<f32>,
#[get(skip)]
pub(crate) height: Option<f32>,
#[get(type(copy))]
pub(crate) full_width: bool,
#[get(skip)]
pub(crate) padding: Option<f32>,
#[get(skip)]
pub(crate) gap: Option<f32>,
#[get(skip)]
pub(crate) radius: Option<f32>,
#[get(skip)]
pub(crate) font_size: Option<f32>,
#[get(type(copy))]
pub(crate) bold: bool,
#[get(skip)]
pub(crate) background_hex: Option<u32>,
#[get(skip)]
pub(crate) color_hex: Option<u32>,
#[get(skip)]
pub(crate) border_width: Option<f32>,
#[get(skip)]
pub(crate) border_hex: Option<u32>,
#[get(type(copy))]
pub(crate) columns: u16,
#[get(type(copy))]
pub(crate) flex_grow: f32,
}
#[derive(Clone, Data, Debug, Default, Deserialize, New, PartialEq, Serialize)]
#[serde(default)]
pub struct DynamicNodeSpec {
#[get(type(copy))]
pub(crate) kind: DynamicNodeKind,
#[new(skip)]
pub(crate) text: String,
#[new(skip)]
#[get(skip)]
pub(crate) action: Option<String>,
#[new(skip)]
pub(crate) payload: String,
#[new(skip)]
#[get(type(copy))]
pub(crate) style: DynamicStyleSpec,
#[new(skip)]
pub(crate) children: Vec<DynamicNodeSpec>,
}
#[derive(Clone, Data, Debug, Deserialize, New, PartialEq, Serialize)]
pub struct DynamicComponentUpdate {
pub(crate) id: String,
#[get(type(copy))]
pub(crate) version: u64,
pub(crate) spec: DynamicNodeSpec,
#[new(skip)]
#[serde(default)]
#[get(type(copy))]
pub(crate) checksum: u64,
#[new(skip)]
#[serde(default)]
#[get(type(copy))]
pub(crate) allow_downgrade: bool,
}
#[derive(Clone, Data, Debug, Deserialize, New, PartialEq, Serialize)]
pub struct DynamicPageUpdate {
pub(crate) route: String,
pub(crate) title: String,
#[get(type(copy))]
pub(crate) version: u64,
pub(crate) spec: DynamicNodeSpec,
#[new(skip)]
#[serde(default)]
#[get(type(copy))]
pub(crate) checksum: u64,
#[new(skip)]
#[serde(default)]
#[get(type(copy))]
pub(crate) preserve_state: bool,
#[new(skip)]
#[serde(default)]
#[get(type(copy))]
pub(crate) allow_downgrade: bool,
}
#[derive(Clone, Data, Debug, Default, Deserialize, New, PartialEq, Serialize)]
pub struct DynamicUpdateBundle {
pub(crate) bundle_id: String,
#[get(type(copy))]
pub(crate) version: u64,
#[new(skip)]
#[serde(default)]
pub(crate) components: Vec<DynamicComponentUpdate>,
#[new(skip)]
#[serde(default)]
pub(crate) pages: Vec<DynamicPageUpdate>,
}
#[derive(Clone, Data, Debug, Eq, Hash, New, PartialEq)]
pub struct DynamicActionEvent {
pub(crate) source_id: String,
pub(crate) action: String,
pub(crate) payload: String,
}
#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
pub struct DynamicTelemetry {
#[get(type(copy))]
pub(crate) components_applied: u64,
#[get(type(copy))]
pub(crate) pages_applied: u64,
#[get(type(copy))]
pub(crate) rollbacks: u64,
#[get(type(copy))]
pub(crate) rejected: u64,
#[get(type(copy))]
pub(crate) actions_dispatched: u64,
}
#[derive(Clone, CustomDebug)]
pub(crate) struct DynamicSlotRecord {
pub(crate) version: u64,
pub(crate) title: String,
pub(crate) checksum: u64,
pub(crate) payload: DynamicPayload,
}
#[derive(CustomDebug)]
pub(crate) struct DynamicHubState {
pub(crate) components: HashMap<String, Vec<DynamicSlotRecord>>,
pub(crate) component_signals: HashMap<String, Signal<u64>>,
pub(crate) pages: HashMap<String, Vec<DynamicSlotRecord>>,
pub(crate) page_signals: HashMap<String, Signal<u64>>,
pub(crate) routes_signal: Signal<u64>,
pub(crate) telemetry_signal: Signal<DynamicTelemetry>,
pub(crate) last_action: Signal<Option<DynamicActionEvent>>,
#[debug(skip)]
pub(crate) action_handlers: Vec<DynamicActionCallback>,
pub(crate) runtime_epoch: u64,
}
pub(crate) struct PageApplyCommit {
pub(crate) page_sig: Signal<u64>,
pub(crate) routes_sig: Signal<u64>,
pub(crate) tel_sig: Signal<DynamicTelemetry>,
pub(crate) tel: DynamicTelemetry,
pub(crate) is_new_route: bool,
}
pub(crate) struct PageRollbackCommit {
pub(crate) next_ver: u64,
pub(crate) page_sig: Signal<u64>,
pub(crate) routes_sig: Signal<u64>,
pub(crate) tel_sig: Signal<DynamicTelemetry>,
pub(crate) tel: DynamicTelemetry,
pub(crate) route_removed: bool,
}
pub(crate) struct BundleApplyCommit {
pub(crate) dirty_signals: Vec<Signal<u64>>,
pub(crate) added_route: bool,
pub(crate) routes_sig: Signal<u64>,
pub(crate) tel_sig: Signal<DynamicTelemetry>,
pub(crate) tel: DynamicTelemetry,
}
#[derive(Clone, CustomDebug)]
pub struct DynamicUpdateHub {
pub(crate) inner: Rc<RefCell<DynamicHubState>>,
}
#[derive(CustomDebug, Data, New)]
pub struct DynamicComponentSlot {
pub(crate) id: String,
#[debug(skip)]
#[get(skip)]
pub(crate) fallback: Rc<dyn Fn() -> NodeId>,
#[new(skip)]
#[get(skip)]
pub(crate) hub: Option<DynamicUpdateHub>,
#[new(skip)]
#[get(type(copy))]
pub(crate) style: Style,
}
#[derive(CustomDebug, Data, New)]
pub struct DynamicPageSlot {
pub(crate) route: String,
#[debug(skip)]
#[get(skip)]
pub(crate) fallback: Rc<dyn Fn() -> NodeId>,
#[new(skip)]
#[get(skip)]
pub(crate) hub: Option<DynamicUpdateHub>,
#[new(skip)]
#[get(type(copy))]
pub(crate) style: Style,
}
#[derive(CustomDebug, Data, New)]
pub struct DynamicPageOutlet {
#[get(type(copy))]
pub(crate) route: Signal<String>,
#[debug(skip)]
#[get(skip)]
pub(crate) fallback: Rc<dyn Fn(&str) -> NodeId>,
#[new(skip)]
#[get(skip)]
pub(crate) hub: Option<DynamicUpdateHub>,
#[new(skip)]
#[get(type(copy))]
pub(crate) style: Style,
}