windjammer_ui/
lib.rs

1//! Windjammer UI Framework
2//!
3//! A cross-platform UI framework for building web, desktop, and mobile applications.
4//!
5//! # Features
6//!
7//! - **Reactive State Management** - Signal, Computed, Effect
8//! - **Virtual DOM** - Efficient diffing and patching
9//! - **Component Model** - Clean, composable components
10//! - **Cross-Platform** - Web (WASM), Desktop (Tauri), Mobile
11//! - **Server-Side Rendering** - SSR with hydration
12//! - **Routing** - Client-side navigation
13//!
14//! # Example
15//!
16//! ```rust,no_run
17//! use windjammer_ui::prelude::*;
18//! use windjammer_ui::vdom::{VElement, VNode, VText};
19//! use windjammer_ui::reactivity::Signal;
20//!
21
22// Allow clippy warnings for generated code
23#![allow(clippy::new_without_default)]
24#![allow(clippy::len_zero)]
25#![allow(clippy::useless_conversion)]
26#![allow(clippy::comparison_to_empty)]
27#![allow(clippy::write_with_newline)]
28#![allow(clippy::to_string_in_format_args)]
29#![allow(clippy::collapsible_else_if)]
30#![allow(clippy::useless_format)]
31//! struct Counter {
32//!     count: Signal<i32>,
33//! }
34//!
35//! impl Counter {
36//!     fn new() -> Self {
37//!         Self { count: Signal::new(0) }
38//!     }
39//!     
40//!     fn increment(&self) {
41//!         self.count.update(|c| *c += 1);
42//!     }
43//! }
44//! ```
45
46#![allow(clippy::module_inception)]
47
48// Re-export the proc macro
49pub use windjammer_ui_macro::component;
50pub use windjammer_ui_macro::Props;
51
52pub mod app;
53#[cfg(all(not(target_arch = "wasm32"), feature = "desktop"))]
54pub mod app_docking;
55#[cfg(target_arch = "wasm32")]
56pub mod app_reactive;
57#[cfg(all(not(target_arch = "wasm32"), feature = "desktop"))]
58pub mod app_reactive_eframe;
59pub mod event_handler;
60#[cfg(all(not(target_arch = "wasm32"), feature = "desktop"))]
61// pub mod scene_gizmos; // TODO: Implement scene gizmos module
62pub mod undo_redo; // Available on all platforms
63
64// Component trait (used by renderer, runtime, ssr)
65pub mod component;
66pub mod component_runtime;
67pub mod components; // Component library
68pub mod events;
69pub mod platform;
70pub mod reactivity;
71
72#[cfg(all(not(target_arch = "wasm32"), feature = "desktop"))]
73pub mod desktop_app_context;
74#[cfg(all(not(target_arch = "wasm32"), feature = "desktop"))]
75pub mod desktop_renderer;
76pub mod reactivity_optimized;
77pub mod renderer;
78pub mod routing;
79pub mod runtime;
80pub mod simple_renderer;
81pub mod simple_vnode;
82pub mod ssr;
83pub mod to_vnode;
84pub mod vdom;
85#[cfg(target_arch = "wasm32")]
86pub mod wasm_events;
87
88#[cfg(target_arch = "wasm32")]
89pub mod examples_wasm;
90
91#[cfg(test)]
92mod reactivity_tests;
93
94/// Prelude module with commonly used types and traits
95pub mod prelude {
96    pub use crate::app::App;
97    pub use crate::component::{Component, ComponentProps};
98    pub use crate::component_runtime;
99    pub use crate::events::{Event, EventHandler};
100    pub use crate::platform::{Event as PlatformEvent, GestureEvent, SwipeDirection, Target};
101    pub use crate::reactivity::{Computed, Effect, Signal};
102    pub use crate::renderer::WebRenderer;
103    pub use crate::routing::{Route, Router};
104    pub use crate::simple_vnode::{VAttr, VNode};
105    pub use crate::to_vnode::ToVNode;
106
107    pub use crate::vdom::{VElement, VText};
108
109    // Reactive app (all platforms)
110    #[cfg(all(not(target_arch = "wasm32"), feature = "desktop"))]
111    pub use crate::app_docking::DockingApp;
112    #[cfg(target_arch = "wasm32")]
113    pub use crate::app_reactive::{trigger_rerender, ReactiveApp};
114    #[cfg(all(not(target_arch = "wasm32"), feature = "desktop"))]
115    pub use crate::app_reactive_eframe::{trigger_rerender, ReactiveApp};
116
117    // Re-export the component macro
118    pub use crate::component;
119
120    // Re-export common components
121    pub use crate::components::{
122        Alert, AlertVariant, Button, ButtonSize, ButtonVariant, Container, Flex, FlexDirection,
123        Input, Text, TextSize, TextWeight,
124    };
125}
126
127/// Mount a component to the DOM (WASM only)
128#[cfg(target_arch = "wasm32")]
129pub use renderer::mount;
130
131#[cfg(test)]
132mod tests {
133    #[test]
134    fn test_prelude_imports() {
135        // Just verify prelude compiles
136        use crate::prelude::*;
137        let _ = Signal::new(42);
138    }
139}