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;
85pub mod vnode_ffi; // FFI for Windjammer components to construct VNodes
86#[cfg(target_arch = "wasm32")]
87pub mod wasm_events;
88
89#[cfg(target_arch = "wasm32")]
90pub mod examples_wasm;
91
92#[cfg(test)]
93mod reactivity_tests;
94
95/// Prelude module with commonly used types and traits
96pub mod prelude {
97    pub use crate::app::App;
98    pub use crate::component::{Component, ComponentProps};
99    pub use crate::component_runtime;
100    pub use crate::events::{Event, EventHandler};
101    pub use crate::platform::{Event as PlatformEvent, GestureEvent, SwipeDirection, Target};
102    pub use crate::reactivity::{Computed, Effect, Signal};
103    pub use crate::renderer::WebRenderer;
104    pub use crate::routing::{Route, Router};
105    pub use crate::simple_vnode::{VAttr, VNode};
106    pub use crate::to_vnode::ToVNode;
107    pub use crate::vnode_ffi; // VNode FFI for cross-platform components
108
109    pub use crate::vdom::{VElement, VText};
110
111    // Reactive app (all platforms)
112    #[cfg(all(not(target_arch = "wasm32"), feature = "desktop"))]
113    pub use crate::app_docking::DockingApp;
114    #[cfg(target_arch = "wasm32")]
115    pub use crate::app_reactive::{trigger_rerender, ReactiveApp};
116    #[cfg(all(not(target_arch = "wasm32"), feature = "desktop"))]
117    pub use crate::app_reactive_eframe::{trigger_rerender, ReactiveApp};
118
119    // Re-export the component macro
120    pub use crate::component;
121
122    // Re-export common components (explicit imports due to symbol conflicts)
123    pub use crate::components::alert::{Alert, AlertVariant};
124    pub use crate::components::button::{Button, ButtonSize, ButtonVariant};
125    pub use crate::components::container::Container;
126    pub use crate::components::flex::{Flex, FlexDirection};
127    pub use crate::components::input::Input;
128    pub use crate::components::text::{Text, TextSize, TextWeight};
129}
130
131/// Mount a component to the DOM (WASM only)
132#[cfg(target_arch = "wasm32")]
133pub use renderer::mount;
134
135#[cfg(test)]
136mod tests {
137    #[test]
138    fn test_prelude_imports() {
139        // Just verify prelude compiles
140        use crate::prelude::*;
141        let _ = Signal::new(42);
142    }
143}