baobab/core/actor/src/main.rs
2025-08-06 12:48:32 +02:00

39 lines
1.4 KiB
Rust

#[cfg(feature = "wasm")]
use baobab_actor::ui::App;
#[cfg(feature = "wasm")]
use yew::prelude::*;
#[cfg(feature = "wasm")]
fn main() {
console_log::init_with_level(log::Level::Debug).expect("Failed to initialize logger");
// Get configuration from URL parameters or local storage
let window = web_sys::window().expect("No global window exists");
let location = window.location();
let search = location.search().unwrap_or_default();
// Parse URL parameters for actor configuration
let url_params = web_sys::UrlSearchParams::new_with_str(&search).unwrap();
let actor_id = url_params.get("id").unwrap_or_else(|| "default_actor".to_string());
let actor_path = url_params.get("path").unwrap_or_else(|| "/path/to/actor".to_string());
let example_dir = url_params.get("example_dir");
let redis_url = url_params.get("redis_url").unwrap_or_else(|| "redis://localhost:6379".to_string());
log::info!("Starting Baobab Actor UI with actor_id: {}", actor_id);
yew::Renderer::<App>::with_props(baobab_actor::ui::app::AppProps {
actor_id,
actor_path,
example_dir,
redis_url,
}).render();
}
#[cfg(not(feature = "wasm"))]
fn main() {
eprintln!("This binary is only available with the 'wasm' feature enabled.");
eprintln!("Please compile with: cargo build --features wasm --target wasm32-unknown-unknown");
std::process::exit(1);
}