feat(api): streamline generated app authoring

Move the canonical examples toward generated component-root helpers, typed form decoding, async/state handler registration, and derive-driven app/component registry wiring. Tighten requirements and diagnostics for the server-first, selectorless authoring path.

Verified with cargo run -p slhx-xtask -- test, cargo check --workspace, redgate list, redgate refs, redgate health --strict, and git diff --check.

req: canonical/001

req: canonical/003

req: canonical/004

req: dx/002

req: derive_app/001

req: component/003

req: form/004

req: axum_integration/003
This commit is contained in:
slhx agent
2026-06-05 06:33:41 +02:00
parent eb6086616c
commit d4e865ef92
34 changed files with 4573 additions and 1156 deletions
+13 -10
View File
@@ -6,7 +6,7 @@ mod tests {
use super::ui::{board, board_card};
use hemplate::Hemplate;
use scraper::{Html, Selector};
use slhx::{Effect, IntoEffect, Payload};
use slhx::IntoEffect;
use slhx_test::inspect;
#[derive(Hemplate)]
@@ -27,12 +27,11 @@ mod tests {
#[test]
fn kanban_board_updates_generated_slot() {
fn render_board() -> impl IntoEffect {
board::targets::board.put(&empty_board())
board::board.put(&empty_board())
}
let effect = inspect(render_board());
assert!(effect.has_slot(board::slots::board));
assert!(matches!(effect.ops(), [Effect::Put { payload: Payload::Html(_), .. }]));
assert!(effect.updates_html(board::board));
}
// req: html_safety/002 req: view/001 req: test/005
@@ -45,7 +44,9 @@ mod tests {
fn empty_board() -> BoardColumns {
// req: html_safety/002 req: view/001
BoardColumns { columns: Vec::new() }
BoardColumns {
columns: Vec::new(),
}
}
fn selector(value: &str) -> Selector {
@@ -57,19 +58,21 @@ mod tests {
fn kanban_form_handler_is_checked_against_hemplate_form() {
#[slhx::handler]
fn create_card(_form: slhx::Form<CreateCard>) -> impl IntoEffect {
board::slots::notice.text("queued")
board::notice.text("queued")
}
let effect = inspect(create_card(CreateCard::FORM));
assert!(effect.has_slot(board::slots::notice));
assert!(matches!(effect.ops(), [Effect::Put { payload: Payload::Text(_), .. }]));
assert!(effect.updates_text(board::notice));
}
// req: examples/001 req: form/002 req: codegen/003
#[test]
fn kanban_template_exports_form_and_card_handles() {
assert_ne!(board::handles::create_card.id(), board_card::handles::move_right.id());
assert_eq!(board::forms::create_card.field("title").resource, board::forms::create_card.id());
assert_ne!(board::create_card.id(), board_card::move_right.id());
assert_eq!(
board::create_card_form.field("title").resource,
board::create_card_form.id()
);
}
}