feat(build): type generated event constants

Generate EventName constants for data-slhx-on metadata and exercise them through typed event emission in techdemo.

req: codegen/006
This commit is contained in:
slhx agent
2026-05-26 00:09:07 +02:00
parent 0b6ad64d98
commit 5364135c5e
5 changed files with 45 additions and 6 deletions
+35
View File
@@ -186,6 +186,41 @@ impl core::fmt::Display for CssClass {
}
}
/// A generated, checked event token.
/// req: codegen/006
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub struct EventName {
name: &'static str,
}
impl EventName {
pub const fn new(name: &'static str) -> Self {
Self { name }
}
pub const fn as_str(self) -> &'static str {
self.name
}
}
impl AsRef<str> for EventName {
fn as_ref(&self) -> &str {
self.name
}
}
impl From<EventName> for String {
fn from(event: EventName) -> Self {
event.name.to_string()
}
}
impl core::fmt::Display for EventName {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.write_str(self.name)
}
}
/// A small displayable list of generated CSS class tokens for hemplate `+class`.
/// req: style/003
#[derive(Clone, Debug, Eq, PartialEq, Hash)]