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