Skip to main content

strata/
lib.rs

1//! Strata: Universal High-Performance Frontend Engine & Framework in Pure Rust.
2//!
3//! # Examples
4//!
5//! ```rust
6//! use strata::prelude::*;
7//!
8//! let counter = Signal::new(10);
9//! counter.set(25);
10//! assert_eq!(counter.get(), 25);
11//! ```
12
13#![allow(
14    clippy::too_many_arguments,
15    clippy::type_complexity,
16    clippy::field_reassign_with_default,
17    clippy::collapsible_match
18)]
19
20pub use strata_a11y;
21pub use strata_a11y as a11y;
22pub use strata_dom;
23pub use strata_dom as dom;
24pub use strata_gpu_path as gpu_path;
25pub use strata_js;
26pub use strata_js as js;
27pub use strata_layout as layout;
28pub use strata_macro::*;
29pub use strata_platform as platform;
30pub use strata_platform::dialog;
31pub use strata_platform::vibrancy;
32pub use strata_platform::{HoverTooltipStyle, WindowConfig};
33pub use strata_primitives as primitives;
34pub use strata_render as render;
35pub use strata_storage as storage;
36pub use strata_style as style;
37pub use strata_vfs as fs;
38pub use strata_web_api as web_api;
39
40#[cfg(feature = "audio")]
41pub use strata_audio as audio;
42#[cfg(feature = "codegen-js")]
43pub use strata_codegen_js as codegen_js;
44#[cfg(feature = "device")]
45pub use strata_device as device;
46#[cfg(feature = "devtools")]
47pub use strata_devtools as devtools;
48#[cfg(feature = "icons")]
49pub use strata_icons as icons;
50#[cfg(feature = "mobile-test")]
51pub use strata_mobile_test as mobile_test;
52#[cfg(feature = "parallel")]
53pub use strata_parallel as parallel;
54#[cfg(feature = "sim")]
55pub use strata_sim as sim;
56#[cfg(feature = "tui")]
57pub use strata_tui as tui;
58#[cfg(feature = "ui")]
59pub use strata_ui as ui;
60
61#[cfg(feature = "agent-ui")]
62pub use strata_agent_ui as agent_ui;
63#[cfg(feature = "aria")]
64pub use strata_aria as aria;
65#[cfg(feature = "charts")]
66pub use strata_charts as charts;
67#[cfg(feature = "crdt")]
68pub use strata_crdt as crdt;
69#[cfg(feature = "editor")]
70pub use strata_editor as editor;
71#[cfg(feature = "form")]
72pub use strata_form as form;
73#[cfg(feature = "i18n")]
74pub use strata_i18n as i18n;
75#[cfg(feature = "motion")]
76pub use strata_motion as motion;
77#[cfg(feature = "query")]
78pub use strata_query as query;
79#[cfg(feature = "router")]
80pub use strata_router as router;
81#[cfg(feature = "store")]
82pub use strata_store as store;
83#[cfg(feature = "table")]
84pub use strata_table as table;
85#[cfg(feature = "toast")]
86pub use strata_toast as toast;
87#[cfg(feature = "virtual")]
88pub use strata_virtual as virtualizer;
89
90pub mod benchmarks;
91pub mod low_level;
92#[cfg(unix)]
93pub mod mcp_bridge;
94pub mod runtime;
95pub mod view_transition;
96#[cfg(unix)]
97pub use mcp_bridge::{default_dev_socket_path, start_mcp_dev_listener};
98
99#[cfg(not(unix))]
100pub mod mcp_bridge {
101    use std::path::PathBuf;
102    pub fn default_dev_socket_path() -> PathBuf {
103        PathBuf::from("/tmp/strata-dev.sock")
104    }
105    pub fn start_mcp_dev_listener(_path: Option<PathBuf>) -> Result<(), std::io::Error> {
106        Ok(())
107    }
108}
109pub use benchmarks::{BenchmarkHarness, BenchmarkReport};
110pub use low_level::{LowLevelRenderer, OffscreenBuffer, RawSurfaceHandle};
111#[cfg(not(unix))]
112pub use mcp_bridge::{default_dev_socket_path, start_mcp_dev_listener};
113pub use runtime::{
114    app, launch, launch_auto, launch_headless, launch_headless_pump, launch_window,
115    launch_with_config, launch_with_events, launch_with_frame, queue_edit_command, AppFrameInfo,
116    AppLifecycleHooks, AppRuntime, DynamicTextBinding, EditCommand, FrameOutcome,
117    KeyDispatchResult, MatchMode, NodeQuery, PointerDownAction, PointerMoveAction, PointerUpAction,
118    StrataApp, StrataAppBuilder,
119};
120#[cfg(target_os = "linux")]
121pub use runtime::{
122    launch_gtk, launch_gtk_with_events, launch_gtk_with_frame, launch_wayland,
123    launch_wayland_with_events, launch_x11, launch_x11_with_events,
124};
125#[cfg(target_os = "macos")]
126pub use runtime::{launch_macos, launch_macos_with_events};
127#[cfg(windows)]
128pub use runtime::{launch_win32, launch_win32_with_events};
129#[cfg(target_os = "linux")]
130pub use strata_platform::{
131    gtk_begin_window_drag, gtk_close, gtk_current_modifiers, gtk_get_clipboard_text,
132    gtk_is_closing, gtk_is_maximized, gtk_minimize, gtk_set_clipboard_text, gtk_toggle_maximize,
133};
134pub use strata_dom::{
135    get_scroll_offset, scroll_into_view, scroll_to, scroll_to_bottom, scroll_to_top,
136    ProgrammaticScrollCommand,
137};
138pub use view_transition::{ViewTransitionManager, ViewTransitionSnapshot};
139
140pub mod prelude {
141    pub use strata_dom;
142    pub use strata_dom::{
143        clear_cursor_override, clear_persistent_signals, create_anchored_portal, create_context,
144        create_dropdown_portal, create_portal, current_cursor, dispatch_click_outside,
145        dispatch_global_keydown, get_scroll_offset, provide_context, reset_component_hooks,
146        scroll_into_view, scroll_to, scroll_to_bottom, scroll_to_top, set_current_cursor,
147        set_system_color_scheme, set_system_contrast, set_system_reduced_motion,
148        set_viewport_dimensions, use_active, use_callback, use_click_outside, use_clipboard,
149        use_color_scheme, use_context, use_contrast, use_cursor, use_effect, use_effect_with_deps,
150        use_focus, use_focus_within, use_hover, use_id, use_keyboard_shortcut, use_media_query,
151        use_memo, use_persistent_signal, use_press, use_reduced_motion, use_reducer,
152        use_reducer_init, use_ref, use_signal, use_state, with_component_key, AnchorPlacement,
153        Attribute, ClickOutsideHandle, ClipboardHandle, ColorScheme, Context, ContrastPreference,
154        CursorIcon, Effect, EffectGuard, ErrorBoundary, ErrorBoundaryBuilder, ErrorBoundaryInfo,
155        Event, EventType, FocusHandlers, HoverHandlers, IntoNodeBlueprint, KeyChord, Memo,
156        NodeBlueprint, Portal, PortalBuilder, PressHandlers, ProgrammaticScrollCommand,
157        ReadSignal, Ref, SetSignal, ShortcutHandle, Signal, Tag, View, WriteSignal,
158    };
159    pub use strata_js;
160    pub use strata_js::{
161        json::{parse_json, stringify_json},
162        promise::{
163            drain_microtasks, pending_microtasks_count, queue_microtask, JsPromise, PromiseState,
164        },
165        web::{
166            advance_timers_by, clear_interval, clear_timeout, local_storage, session_storage,
167            set_interval, set_timeout, tick_timers, Storage, TimerId, URLSearchParams,
168        },
169        JsObject, JsValue,
170    };
171    pub use strata_macro::{component, dynamic, rsx};
172    pub use strata_platform::prelude::*;
173    pub use strata_primitives::prelude::*;
174    pub use strata_render::scene3d::{
175        AmbientLight, BoxGeometry, Camera3D, Canvas3D, DirectionalLight, Geometry3D, Light3D,
176        Material3D, Mesh, Mesh3D, PerspectiveCamera, Scene3D, ShaderMaterial, ShaderSource,
177        SphereGeometry, StandardMaterial, Transform3D,
178    };
179    pub use strata_storage::prelude::*;
180    pub use strata_style::ComputedStyle;
181    pub use strata_vfs::prelude::*;
182    pub use strata_web_api::prelude::*;
183
184    #[cfg(feature = "aria")]
185    pub use strata_aria::floating::Placement as AriaPlacement;
186    #[cfg(feature = "aria")]
187    pub use strata_aria::focus_trap::FocusTrap as AriaFocusTrap;
188    #[cfg(feature = "aria")]
189    pub use strata_aria::roving_tabindex::{Orientation as AriaOrientation, RovingTabIndex};
190    #[cfg(feature = "aria")]
191    pub use strata_aria::{
192        compute_position, use_accordion, use_dialog, use_tooltip, AccordionState, AccordionType,
193        Alignment, ComputePositionOptions, ComputePositionResult, DialogConfig, DialogState,
194        FloatRect, Side, TooltipConfig, TooltipState,
195    };
196    #[cfg(feature = "charts")]
197    pub use strata_charts::prelude::*;
198    #[cfg(feature = "codegen-js")]
199    pub use strata_codegen_js::prelude::*;
200    #[cfg(feature = "crdt")]
201    pub use strata_crdt::{
202        CrdtCounterStore, CrdtSignalStore, LamportClock, LwwRegister, OrSet, PnCounter,
203        ReplicatedSignal, RgaSequence, SyncMessage, VectorClock,
204    };
205    #[cfg(feature = "device")]
206    pub use strata_device::prelude::*;
207    #[cfg(feature = "devtools")]
208    pub use strata_devtools::*;
209    #[cfg(feature = "editor")]
210    pub use strata_editor::prelude::*;
211    #[cfg(feature = "form")]
212    pub use strata_form::field::FormField as FormFieldState;
213    #[cfg(feature = "form")]
214    pub use strata_form::{use_field_array, use_form, FieldArray, Form, ValidationRule};
215    #[cfg(feature = "i18n")]
216    pub use strata_i18n::prelude::*;
217    #[cfg(feature = "icons")]
218    pub use strata_icons::Icons;
219    #[cfg(feature = "mobile-test")]
220    pub use strata_mobile_test::*;
221    #[cfg(feature = "motion")]
222    pub use strata_motion::prelude::*;
223    #[cfg(feature = "parallel")]
224    pub use strata_parallel::prelude::*;
225    #[cfg(feature = "query")]
226    pub use strata_query::prelude::*;
227    #[cfg(feature = "router")]
228    pub use strata_router::prelude::*;
229    #[cfg(feature = "sim")]
230    pub use strata_sim as sim;
231    #[cfg(feature = "sim")]
232    pub use strata_sim::{
233        AppMetadata, DeviceFormFactor, DeviceManufacturer, DeviceOrientation, DevicePosture,
234        DeviceProfile, DynamicAlertKind, DynamicIslandOscillator, DynamicIslandState,
235        FoldableState, GeometrySolver, MobileSimulatorWorkspace, MultiAppSandbox, NavAction,
236        ScreenProfile, ThreeButtonNavBar, VirtualHalBus,
237    };
238    #[cfg(feature = "store")]
239    pub use strata_store::prelude::*;
240    #[cfg(feature = "table")]
241    pub use strata_table::table::Table as DataTableState;
242    #[cfg(feature = "table")]
243    pub use strata_table::{use_table, ColumnDef, ColumnPin, SortDirection};
244    #[cfg(feature = "toast")]
245    pub use strata_toast::toast::ToastKind as SonnerToastKind;
246    #[cfg(feature = "toast")]
247    pub use strata_toast::{
248        compute_stack_layout, toast_dismiss, toast_error, toast_info, toast_success, toast_warning,
249        StackedToastVisual, ToastAction, ToastItem, ToastManager, ToastPosition,
250    };
251    #[cfg(feature = "tui")]
252    pub use strata_tui::prelude::*;
253    #[cfg(feature = "ui")]
254    pub use strata_ui::prelude::*;
255    #[cfg(feature = "virtual")]
256    pub use strata_virtual::prelude::*;
257
258    pub use crate::benchmarks::{BenchmarkHarness, BenchmarkReport};
259    pub use crate::runtime::{
260        app, launch, launch_auto, launch_headless, launch_headless_pump, launch_window,
261        launch_with_config, launch_with_events, launch_with_frame, queue_edit_command,
262        AppFrameInfo, AppLifecycleHooks, AppRuntime, DynamicTextBinding, EditCommand, FrameOutcome,
263        KeyDispatchResult, PointerDownAction, PointerMoveAction, PointerUpAction, StrataApp,
264        StrataAppBuilder,
265    };
266    #[cfg(target_os = "linux")]
267    pub use crate::runtime::{
268        launch_gtk, launch_gtk_with_events, launch_gtk_with_frame, launch_wayland,
269        launch_wayland_with_events, launch_x11, launch_x11_with_events,
270    };
271    #[cfg(target_os = "macos")]
272    pub use crate::runtime::{launch_macos, launch_macos_with_events};
273    #[cfg(windows)]
274    pub use crate::runtime::{launch_win32, launch_win32_with_events};
275    #[cfg(target_os = "linux")]
276    pub use strata_platform::{
277        gtk_begin_window_drag, gtk_close, gtk_get_clipboard_text, gtk_is_maximized, gtk_minimize,
278        gtk_set_clipboard_text, gtk_toggle_maximize,
279    };
280    pub use strata_platform::{HoverTooltipStyle, WindowAnchor, WindowConfig};
281}