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 = "device")]
41pub use strata_device as device;
42#[cfg(feature = "audio-dsp")]
43pub use strata_audio as audio;
44#[cfg(feature = "media")]
45pub use strata_media as media;
46#[cfg(feature = "hardware")]
47pub use strata_hardware as hardware;
48#[cfg(feature = "tui")]
49pub use strata_tui as tui;
50#[cfg(feature = "devtools")]
51pub use strata_devtools as devtools;
52#[cfg(feature = "hot-reload")]
53pub use strata_hot_reload as hot_reload;
54#[cfg(feature = "parallel")]
55pub use strata_parallel as parallel;
56
57/// Installs cycle-free runtime sensor provider bridges connecting enabled `crates/io/*`
58/// subsystems (`strata-audio` A-weighted SPL and `strata-hardware` BLE Heart Rate `0x180D`)
59/// into `strata-device` reactive sensor hooks (`use_ambient_spl`, `use_heart_rate`).
60pub fn register_universal_io_bridges() {
61    #[cfg(all(feature = "device", feature = "audio-dsp"))]
62    {
63        strata_device::register_ambient_spl_provider(Some(strata_audio::latest_ambient_spl_dba));
64    }
65    #[cfg(all(feature = "device", feature = "hardware"))]
66    {
67        strata_device::register_heart_rate_provider(Some(
68            strata_hardware::latest_ble_heart_rate_bpm,
69        ));
70    }
71}
72
73pub mod low_level;
74pub mod mcp_bridge;
75pub mod runtime;
76pub mod view_transition;
77pub use low_level::{LowLevelRenderer, OffscreenBuffer, RawSurfaceHandle};
78pub use mcp_bridge::{default_dev_socket_path, start_mcp_dev_listener};
79#[cfg(feature = "hot-reload")]
80pub use runtime::{HmrPatchOutcome, HmrRuntimeController};
81pub use runtime::{
82    app, launch, launch_auto, launch_headless, launch_headless_pump, launch_window,
83    launch_with_config, launch_with_events, launch_with_frame, queue_edit_command, AppFrameInfo,
84    AppLifecycleHooks, AppRuntime, DynamicTextBinding, EditCommand, FrameOutcome, FrameProfile,
85    FrameProfileRecord, KeyDispatchResult, MatchMode, NodeQuery, PerfPercentileStats,
86    PerfProfileSummary, PointerDownAction, PointerMoveAction, PointerUpAction, ProfilingAllocator,
87    RebuildReason, ReconcileStats, StrataApp, StrataAppBuilder,
88};
89#[cfg(target_os = "linux")]
90pub use runtime::{
91    launch_gtk, launch_gtk_with_events, launch_gtk_with_frame, launch_wayland,
92    launch_wayland_with_events, launch_x11, launch_x11_with_events,
93};
94#[cfg(target_os = "macos")]
95pub use runtime::{launch_macos, launch_macos_with_events};
96#[cfg(windows)]
97pub use runtime::{launch_win32, launch_win32_with_events};
98#[cfg(target_os = "linux")]
99pub use strata_platform::{
100    gtk_begin_window_drag, gtk_close, gtk_current_modifiers, gtk_get_clipboard_text,
101    gtk_is_closing, gtk_is_maximized, gtk_minimize, gtk_set_clipboard_text, gtk_toggle_maximize,
102};
103pub use strata_dom::{
104    get_scroll_offset, scroll_into_view, scroll_to, scroll_to_bottom, scroll_to_top,
105    ProgrammaticScrollCommand,
106};
107pub use view_transition::{ViewTransitionManager, ViewTransitionSnapshot};
108
109pub mod prelude {
110    pub use strata_dom;
111    pub use strata_dom::{
112        clear_cursor_override, clear_hmr_signals, clear_persistent_signals, create_anchored_portal,
113        create_context, create_dropdown_portal, create_portal, current_cursor,
114        dispatch_click_outside, dispatch_global_keydown, export_hmr_signals, get_scroll_offset,
115        import_hmr_signals, provide_context, reset_component_hooks, scroll_into_view, scroll_to,
116        scroll_to_bottom, scroll_to_top, set_current_cursor, set_system_color_scheme,
117        set_system_contrast, set_system_reduced_motion, set_viewport_dimensions, use_active,
118        use_callback, use_click_outside, use_clipboard, use_color_scheme, use_context,
119        use_contrast, use_cursor, use_effect, use_effect_with_deps, use_focus, use_focus_within,
120        use_hmr_signal, use_hover, use_id, use_keyboard_shortcut, use_media_query, use_memo,
121        use_memo_with_deps, use_persistent_signal, use_press, use_reduced_motion, use_reducer,
122        use_reducer_init, use_ref, use_shortcut, use_signal, use_state, with_component_key,
123        with_root_component_scope, AnchorPlacement, Attribute, ClickOutsideHandle, ClipboardHandle,
124        ColorScheme, Context, ContrastPreference, CursorIcon, Effect, EffectGuard, ErrorBoundary,
125        ErrorBoundaryBuilder, ErrorBoundaryInfo, Event, EventType, FocusHandlers, HmrCodec,
126        HoverHandlers, IntoChildren, IntoEffectCleanup, IntoNodeBlueprint, KeyChord, Memo,
127        NodeBlueprint, Portal, PortalBuilder, PressHandlers, ProgrammaticScrollCommand, ReadSignal,
128        Ref, SetSignal, ShortcutHandle, Signal, Tag, View, WriteSignal,
129    };
130    pub use strata_js;
131    pub use strata_js::{
132        json::{parse_json, stringify_json},
133        promise::{
134            drain_microtasks, pending_microtasks_count, queue_microtask, JsPromise, PromiseState,
135        },
136        web::{
137            advance_timers_by, clear_interval, clear_timeout, local_storage, session_storage,
138            set_interval, set_timeout, tick_timers, Storage, TimerId, URLSearchParams,
139        },
140        JsObject, JsValue,
141    };
142    pub use strata_macro::{component, dynamic, rsx};
143    pub use strata_platform::prelude::*;
144    pub use strata_primitives::prelude::*;
145    pub use strata_render::scene3d::{
146        AmbientLight, BoxGeometry, Camera3D, Canvas3D, DirectionalLight, Geometry3D, Light3D,
147        Material3D, Mesh, Mesh3D, PerspectiveCamera, Scene3D, ShaderMaterial, ShaderSource,
148        SphereGeometry, StandardMaterial, Transform3D,
149    };
150    pub use strata_storage::prelude::*;
151    pub use strata_style::ComputedStyle;
152    pub use strata_vfs::prelude::*;
153    pub use strata_web_api::prelude::*;
154
155    #[cfg(feature = "device")]
156    pub use strata_device::prelude::*;
157    #[cfg(feature = "devtools")]
158    pub use strata_devtools::*;
159    #[cfg(feature = "hot-reload")]
160    pub use strata_hot_reload::prelude::*;
161    #[cfg(feature = "parallel")]
162    pub use strata_parallel::{
163        reset_thread_local_arena, translate_draw_command, with_thread_local_arena,
164        AdaptivePartitioner, ContainmentClassifier, DirtySignalQueue, DisplayListChunk,
165        LayoutConstraints, LayoutPartition, ParallelEngine, PartitionBoundary, PartitionId,
166    };
167
168    pub use crate::runtime::{
169        app, launch, launch_auto, launch_headless, launch_headless_pump, launch_window,
170        launch_with_config, launch_with_events, launch_with_frame, queue_edit_command,
171        AppFrameInfo, AppLifecycleHooks, AppRuntime, DynamicTextBinding, EditCommand, FrameOutcome,
172        KeyDispatchResult, PointerDownAction, PointerMoveAction, PointerUpAction, StrataApp,
173        StrataAppBuilder,
174    };
175    #[cfg(target_os = "linux")]
176    pub use crate::runtime::{
177        launch_gtk, launch_gtk_with_events, launch_gtk_with_frame, launch_wayland,
178        launch_wayland_with_events, launch_x11, launch_x11_with_events,
179    };
180    #[cfg(target_os = "macos")]
181    pub use crate::runtime::{launch_macos, launch_macos_with_events};
182    #[cfg(windows)]
183    pub use crate::runtime::{launch_win32, launch_win32_with_events};
184    #[cfg(target_os = "linux")]
185    pub use strata_platform::{
186        gtk_begin_window_drag, gtk_close, gtk_get_clipboard_text, gtk_is_maximized, gtk_minimize,
187        gtk_set_clipboard_text, gtk_toggle_maximize,
188    };
189    pub use strata_platform::{HoverTooltipStyle, WindowAnchor, WindowConfig};
190}