diff --git a/Cargo.toml b/Cargo.toml index 00e31a5b..3749435c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -81,6 +81,8 @@ output_progress = [ item_interactions = [ "dep:peace_item_model", "peace_cfg/item_interactions", + "peace_webi?/item_interactions", + "peace_webi_components?/item_interactions", ] item_state_example = [ "peace_cfg/item_state_example", @@ -88,6 +90,8 @@ item_state_example = [ "peace_data/item_state_example", "peace_params/item_state_example", "peace_rt_model/item_state_example", + "peace_webi?/item_state_example", + "peace_webi_components?/item_state_example", ] ssr = [ "peace_webi?/ssr", diff --git a/crate/webi/Cargo.toml b/crate/webi/Cargo.toml index c60ffb89..a2458dc2 100644 --- a/crate/webi/Cargo.toml +++ b/crate/webi/Cargo.toml @@ -26,6 +26,14 @@ peace_webi_output = { workspace = true, optional = true } [features] default = [] +item_interactions = [ + "peace_webi_components/item_interactions", + "peace_webi_output?/item_interactions", +] +item_state_example = [ + "peace_webi_components/item_state_example", + "peace_webi_output?/item_state_example", +] output_progress = [ "peace_webi_model/output_progress", "peace_webi_output?/output_progress", diff --git a/crate/webi_components/Cargo.toml b/crate/webi_components/Cargo.toml index c369b874..c6862387 100644 --- a/crate/webi_components/Cargo.toml +++ b/crate/webi_components/Cargo.toml @@ -26,14 +26,14 @@ gloo-timers = { workspace = true, features = ["futures"] } leptos = { workspace = true } leptos_meta = { workspace = true } leptos_router = { workspace = true } -peace_cmd = { workspace = true, features = ["item_state_example"] } +peace_cmd = { workspace = true } peace_cmd_model = { workspace = true } peace_core = { workspace = true } peace_flow_model = { workspace = true } peace_item_model = { workspace = true } peace_params = { workspace = true } peace_resource_rt = { workspace = true } -peace_rt_model = { workspace = true, features = ["item_interactions", "item_state_example"] } +peace_rt_model = { workspace = true } peace_webi_model = { workspace = true } serde_json = { workspace = true } tokio = { workspace = true, features = ["sync"] } @@ -43,6 +43,16 @@ serde_yaml = { workspace = true } [features] default = [] + +# Technically always needed, but we need to put these in its own feature so that +# these aren't enabled in the underlying crates when `--no-default-features` is +# used. +item_interactions = ["peace_rt_model/item_interactions"] +item_state_example = [ + "peace_cmd/item_state_example", + "peace_rt_model/item_state_example", +] + ssr = [ "dot_ix/ssr", "leptos/ssr", diff --git a/crate/webi_model/Cargo.toml b/crate/webi_model/Cargo.toml index f35dd33f..ddf194f9 100644 --- a/crate/webi_model/Cargo.toml +++ b/crate/webi_model/Cargo.toml @@ -31,6 +31,7 @@ serde = { workspace = true, features = ["derive"] } thiserror = { workspace = true } [features] +default = [] error_reporting = ["dep:miette"] output_progress = [ "dep:peace_item_model", diff --git a/crate/webi_output/Cargo.toml b/crate/webi_output/Cargo.toml index eeb18ea3..f8cae798 100644 --- a/crate/webi_output/Cargo.toml +++ b/crate/webi_output/Cargo.toml @@ -48,6 +48,14 @@ tower-http = { workspace = true, features = ["fs"] } [features] default = [] +item_interactions = [ + "peace_rt_model/item_interactions", + "peace_webi_components/item_interactions", +] +item_state_example = [ + "peace_rt_model/item_state_example", + "peace_webi_components/item_state_example", +] output_progress = [ "peace_cmd_model/output_progress", "peace_core/output_progress", diff --git a/crate/webi_output/src/lib.rs b/crate/webi_output/src/lib.rs index b5e82d6f..e876f3ce 100644 --- a/crate/webi_output/src/lib.rs +++ b/crate/webi_output/src/lib.rs @@ -2,10 +2,12 @@ pub use crate::{ cmd_exec_spawn_ctx::CmdExecSpawnCtx, cmd_exec_to_leptos_ctx::CmdExecToLeptosCtx, - flow_webi_fns::FlowWebiFns, outcome_info_graph_calculator::OutcomeInfoGraphCalculator, - webi_output::WebiOutput, webi_server::WebiServer, + flow_webi_fns::FlowWebiFns, webi_output::WebiOutput, webi_server::WebiServer, }; +#[cfg(feature = "item_interactions")] +pub use crate::outcome_info_graph_calculator::OutcomeInfoGraphCalculator; + #[cfg(feature = "output_progress")] pub use crate::progress_info_graph_calculator::ProgressInfoGraphCalculator; @@ -14,9 +16,11 @@ pub mod assets; mod cmd_exec_spawn_ctx; mod cmd_exec_to_leptos_ctx; mod flow_webi_fns; -mod outcome_info_graph_calculator; mod webi_output; mod webi_server; +#[cfg(feature = "item_interactions")] +mod outcome_info_graph_calculator; + #[cfg(feature = "output_progress")] mod progress_info_graph_calculator; diff --git a/crate/webi_output/src/webi_server.rs b/crate/webi_output/src/webi_server.rs index 3a131601..d8530310 100644 --- a/crate/webi_output/src/webi_server.rs +++ b/crate/webi_output/src/webi_server.rs @@ -7,13 +7,16 @@ use leptos_axum::LeptosRoutes; use peace_cmd_model::CmdExecutionId; use peace_core::FlowId; use peace_webi_components::{ChildrenFn, Home}; -use peace_webi_model::{OutcomeInfoGraphVariant, WebUiUpdate, WebiError}; +use peace_webi_model::{WebUiUpdate, WebiError}; use tokio::{io::AsyncWriteExt, sync::mpsc}; use tower_http::services::ServeDir; -use crate::{ - CmdExecSpawnCtx, CmdExecToLeptosCtx, FlowWebiFns, OutcomeInfoGraphCalculator, WebiOutput, -}; +use crate::{CmdExecSpawnCtx, CmdExecToLeptosCtx, FlowWebiFns, WebiOutput}; + +#[cfg(feature = "item_interactions")] +use crate::OutcomeInfoGraphCalculator; +#[cfg(feature = "item_interactions")] +use peace_webi_model::OutcomeInfoGraphVariant; #[cfg(feature = "output_progress")] use std::collections::HashMap; @@ -113,12 +116,26 @@ impl WebiServer { let flow_outcome_example_info_graph = outcome_info_graph_fn( &mut webi_output_mock, Box::new(|flow, params_specs, resources| { - OutcomeInfoGraphCalculator::calculate::( - flow, - params_specs, - resources, - OutcomeInfoGraphVariant::Example, - ) + #[cfg(all(feature = "item_interactions", feature = "item_state_example"))] + { + OutcomeInfoGraphCalculator::calculate::( + flow, + params_specs, + resources, + OutcomeInfoGraphVariant::Example, + ) + } + + #[cfg(not(all(feature = "item_interactions", feature = "item_state_example")))] + { + use dot_ix_model::info_graph::InfoGraph; + + let _flow = flow; + let _params_specs = params_specs; + let _resources = resources; + + InfoGraph::default() + } }), ) .await; @@ -274,19 +291,33 @@ impl WebiServer { let item_progress_statuses = item_progress_statuses_snapshot.clone(); - OutcomeInfoGraphCalculator::calculate::( - flow, - params_specs, - resources, - OutcomeInfoGraphVariant::Current { - #[cfg(feature = "output_progress")] - cmd_block_item_interaction_type, - #[cfg(feature = "output_progress")] - item_location_states, - #[cfg(feature = "output_progress")] - item_progress_statuses, - }, - ) + #[cfg(feature = "item_interactions")] + { + OutcomeInfoGraphCalculator::calculate::( + flow, + params_specs, + resources, + OutcomeInfoGraphVariant::Current { + #[cfg(feature = "output_progress")] + cmd_block_item_interaction_type, + #[cfg(feature = "output_progress")] + item_location_states, + #[cfg(feature = "output_progress")] + item_progress_statuses, + }, + ) + } + + #[cfg(not(feature = "item_interactions"))] + { + use dot_ix_model::info_graph::InfoGraph; + + let _flow = flow; + let _params_specs = params_specs; + let _resources = resources; + + InfoGraph::default() + } }), ) .await; diff --git a/workspace_tests/Cargo.toml b/workspace_tests/Cargo.toml index 1472e57b..c03033a4 100644 --- a/workspace_tests/Cargo.toml +++ b/workspace_tests/Cargo.toml @@ -40,7 +40,7 @@ tokio = { workspace = true, features = ["rt", "macros"] } tynm = { workspace = true } [features] -default = ["items", "output_in_memory", "webi", "item_interactions", "item_state_example"] +default = ["items", "output_in_memory", "webi"] # `peace` features error_reporting = ["peace/error_reporting"]