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::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, create_anchored_portal, create_dropdown_portal, create_portal,
144        current_cursor, dispatch_click_outside, dispatch_global_keydown, get_scroll_offset,
145        scroll_into_view, scroll_to, scroll_to_bottom, scroll_to_top, set_current_cursor,
146        set_system_color_scheme, set_system_contrast, set_system_reduced_motion,
147        set_viewport_dimensions, use_active, use_click_outside, use_clipboard, use_color_scheme,
148        use_contrast, use_cursor, use_effect, use_focus, use_focus_within, use_hover,
149        use_keyboard_shortcut, use_media_query, use_memo, use_press, use_reduced_motion,
150        use_signal, use_state, AnchorPlacement, Attribute, ClickOutsideHandle, ClipboardHandle,
151        ColorScheme, ContrastPreference, CursorIcon, Event, EventType, FocusHandlers,
152        HoverHandlers, IntoNodeBlueprint, KeyChord, NodeBlueprint, Portal, PortalBuilder,
153        PressHandlers, ProgrammaticScrollCommand, ShortcutHandle, Signal, Tag, View,
154    };
155    pub use strata_js;
156    pub use strata_js::{
157        json::{parse_json, stringify_json},
158        promise::{
159            drain_microtasks, pending_microtasks_count, queue_microtask, JsPromise, PromiseState,
160        },
161        web::{
162            advance_timers_by, clear_interval, clear_timeout, local_storage, session_storage,
163            set_interval, set_timeout, tick_timers, Storage, TimerId, URLSearchParams,
164        },
165        JsObject, JsValue,
166    };
167    pub use strata_macro::{component, dynamic, rsx};
168    pub use strata_platform::prelude::*;
169    pub use strata_primitives::prelude::*;
170    pub use strata_render::scene3d::{
171        AmbientLight, BoxGeometry, Camera3D, Canvas3D, DirectionalLight, Geometry3D, Light3D,
172        Material3D, Mesh, Mesh3D, PerspectiveCamera, Scene3D, ShaderMaterial, ShaderSource,
173        SphereGeometry, StandardMaterial, Transform3D,
174    };
175    pub use strata_storage::prelude::*;
176    pub use strata_style::ComputedStyle;
177    pub use strata_vfs::prelude::*;
178    pub use strata_web_api::prelude::*;
179
180    #[cfg(feature = "aria")]
181    pub use strata_aria::floating::Placement as AriaPlacement;
182    #[cfg(feature = "aria")]
183    pub use strata_aria::focus_trap::FocusTrap as AriaFocusTrap;
184    #[cfg(feature = "aria")]
185    pub use strata_aria::roving_tabindex::{Orientation as AriaOrientation, RovingTabIndex};
186    #[cfg(feature = "aria")]
187    pub use strata_aria::{
188        compute_position, use_accordion, use_dialog, use_tooltip, AccordionState, AccordionType,
189        Alignment, ComputePositionOptions, ComputePositionResult, DialogConfig, DialogState,
190        FloatRect, Side, TooltipConfig, TooltipState,
191    };
192    #[cfg(feature = "charts")]
193    pub use strata_charts::prelude::*;
194    #[cfg(feature = "codegen-js")]
195    pub use strata_codegen_js::prelude::*;
196    #[cfg(feature = "crdt")]
197    pub use strata_crdt::{
198        CrdtCounterStore, CrdtSignalStore, LamportClock, LwwRegister, OrSet, PnCounter,
199        ReplicatedSignal, RgaSequence, SyncMessage, VectorClock,
200    };
201    #[cfg(feature = "device")]
202    pub use strata_device::prelude::*;
203    #[cfg(feature = "devtools")]
204    pub use strata_devtools::*;
205    #[cfg(feature = "editor")]
206    pub use strata_editor::prelude::*;
207    #[cfg(feature = "form")]
208    pub use strata_form::field::FormField as FormFieldState;
209    #[cfg(feature = "form")]
210    pub use strata_form::{use_field_array, use_form, FieldArray, Form, ValidationRule};
211    #[cfg(feature = "i18n")]
212    pub use strata_i18n::prelude::*;
213    #[cfg(feature = "icons")]
214    pub use strata_icons::Icons;
215    #[cfg(feature = "mobile-test")]
216    pub use strata_mobile_test::*;
217    #[cfg(feature = "motion")]
218    pub use strata_motion::prelude::*;
219    #[cfg(feature = "parallel")]
220    pub use strata_parallel::prelude::*;
221    #[cfg(feature = "query")]
222    pub use strata_query::prelude::*;
223    #[cfg(feature = "router")]
224    pub use strata_router::prelude::*;
225    #[cfg(feature = "sim")]
226    pub use strata_sim as sim;
227    #[cfg(feature = "sim")]
228    pub use strata_sim::{
229        AppMetadata, DeviceFormFactor, DeviceManufacturer, DeviceOrientation, DevicePosture,
230        DeviceProfile, DynamicAlertKind, DynamicIslandOscillator, DynamicIslandState,
231        FoldableState, GeometrySolver, MobileSimulatorWorkspace, MultiAppSandbox, NavAction,
232        ScreenProfile, ThreeButtonNavBar, VirtualHalBus,
233    };
234    #[cfg(feature = "store")]
235    pub use strata_store::prelude::*;
236    #[cfg(feature = "table")]
237    pub use strata_table::table::Table as DataTableState;
238    #[cfg(feature = "table")]
239    pub use strata_table::{use_table, ColumnDef, ColumnPin, SortDirection};
240    #[cfg(feature = "toast")]
241    pub use strata_toast::toast::ToastKind as SonnerToastKind;
242    #[cfg(feature = "toast")]
243    pub use strata_toast::{
244        compute_stack_layout, toast_dismiss, toast_error, toast_info, toast_success, toast_warning,
245        StackedToastVisual, ToastAction, ToastItem, ToastManager, ToastPosition,
246    };
247    #[cfg(feature = "tui")]
248    pub use strata_tui::prelude::*;
249    #[cfg(feature = "ui")]
250    pub use strata_ui::prelude::*;
251    #[cfg(feature = "virtual")]
252    pub use strata_virtual::prelude::*;
253
254    pub use crate::benchmarks::{BenchmarkHarness, BenchmarkReport};
255    pub use crate::runtime::{
256        app, launch, launch_auto, launch_headless, launch_headless_pump, launch_window,
257        launch_with_config, launch_with_events, launch_with_frame, queue_edit_command,
258        AppFrameInfo, AppLifecycleHooks, AppRuntime, DynamicTextBinding, EditCommand, FrameOutcome,
259        KeyDispatchResult, PointerDownAction, PointerMoveAction, PointerUpAction, StrataApp,
260        StrataAppBuilder,
261    };
262    #[cfg(target_os = "linux")]
263    pub use crate::runtime::{
264        launch_gtk, launch_gtk_with_events, launch_gtk_with_frame, launch_wayland,
265        launch_wayland_with_events, launch_x11, launch_x11_with_events,
266    };
267    #[cfg(target_os = "macos")]
268    pub use crate::runtime::{launch_macos, launch_macos_with_events};
269    #[cfg(windows)]
270    pub use crate::runtime::{launch_win32, launch_win32_with_events};
271    #[cfg(target_os = "linux")]
272    pub use strata_platform::{
273        gtk_begin_window_drag, gtk_close, gtk_get_clipboard_text, gtk_is_maximized, gtk_minimize,
274        gtk_set_clipboard_text, gtk_toggle_maximize,
275    };
276    pub use strata_platform::{WindowAnchor, WindowConfig};
277}