Skip to main content

incular_runtime/
lib.rs

1//! Controlled BUILD → LAYOUT → PAINT coordination and local reactive state.
2
3mod app_log;
4mod application;
5mod application_activations;
6mod application_shell;
7mod application_types;
8mod context;
9#[cfg(feature = "devtools")]
10mod devtools_inspection;
11mod environment;
12mod executor;
13pub use executor::sleep;
14mod file_dialogs;
15mod frame;
16mod global_shortcuts;
17mod profiling;
18mod reactive;
19mod request_admission;
20mod request_channel;
21mod request_registry;
22mod restoration;
23mod route_focus;
24mod route_outlet;
25mod route_tasks;
26mod simulation;
27mod tasks;
28mod text_shortcuts;
29mod transient_presentation;
30mod undo;
31mod window_commands;
32mod window_state;
33
34pub use app_log::{
35    LOG_MESSAGE_LIMIT, LOG_QUEUE_CAPACITY, LogBatch, LogLevel, LogQueue, LogRecord, log,
36};
37#[cfg(feature = "devtools")]
38pub use app_log::{drain_logs, logs_pending, set_log_wake};
39pub use application::{Application, PERFORMANCE_OVERLAY_KEY};
40pub use application_activations::{
41    ActivationRouteBridge, ApplicationActivationListener, ApplicationActivationService,
42    ApplicationActivationSubscription,
43};
44pub use application_shell::{
45    ApplicationShellRequestId, ApplicationShellService, MemoryApplicationShellAdapter,
46    NativeApplicationShellApplyResult, NativeApplicationShellCompletion,
47    NativeApplicationShellEvent, NativeApplicationShellOperation, NativeApplicationShellRequest,
48    NotificationHandle, TrayItemHandle,
49};
50pub use application_types::{
51    ApplicationLifecycle, LastWindowPolicy, LifecycleTransition, RestorableWindowFactory,
52    RuntimeErrorReport, WindowError, WindowRestorationId,
53};
54pub use context::BuildContext;
55#[cfg(feature = "devtools")]
56pub use environment::devtools_registry;
57pub use environment::{EditableSignalKind, Signal, SignalRegistration};
58pub use file_dialogs::{
59    FileDialogCompletionStatus, FileDialogRequest, FileDialogService, MemoryFileDialogAdapter,
60    NativeFileDialogCompletion, NativeFileDialogRequest,
61};
62pub use frame::{EditingDiagnostics, EventTarget, FocusDiagnostics, FrameStats, Runtime};
63pub use global_shortcuts::{
64    GlobalShortcutCompletionStatus, GlobalShortcutRegistration, GlobalShortcutRegistrationRequest,
65    GlobalShortcutRequestId, GlobalShortcutService, GlobalShortcutUnregistrationRequest,
66    MemoryGlobalShortcutAdapter, NativeGlobalShortcutCompletion, NativeGlobalShortcutOperation,
67    NativeGlobalShortcutRequest,
68};
69pub use incular_accessibility::AccessibilityDiagnostics;
70#[cfg(feature = "hot-reload")]
71pub use incular_core::hot_reload::{HotPatch, HotPatchError, aslr_reference};
72pub use profiling::{
73    AccessibilitySnapshot, BudgetStatistics, FrameHistory, FrameRecord, FrameStatistics,
74    FrameTimings, FrameWork, GpuResourceSummary, GpuSample, PerformanceHub, PerformanceProfiler,
75    PerformanceSnapshot, ProfilerMode, RenderFrameMetrics, SchedulerCounters, TextCacheSnapshot,
76    WidgetWorkSnapshot, WindowPerformance,
77};
78pub use reactive::{Action, ActionDispatchError, ActionError, ActionState, Effect, Memo};
79#[cfg(target_arch = "wasm32")]
80pub use restoration::BrowserRestorationStore;
81pub use restoration::{
82    ClaimedRestorationScope, DEFAULT_RESTORATION_DEBOUNCE, DEFAULT_RESTORATION_SNAPSHOT_LIMIT,
83    FRAMEWORK_RESTORATION_FORMAT_VERSION, FileRestorationStore, InMemoryRestorationStore,
84    MAX_RESTORATION_SAVE_RETRIES, RESTORATION_RETRY_BACKOFF, Restorable, RestorableBool,
85    RestorableBoolN, RestorableDouble, RestorableDoubleN, RestorableInt, RestorableIntN,
86    RestorableString, RestorableStringN, RestorationConfig, RestorationDiagnostics,
87    RestorationHandle, RestorationMigration, RestorationStore, RestorationStoreError,
88};
89pub use route_focus::{RouteFocusOwner, RouteFocusState};
90pub use route_outlet::{OutletAttachError, OutletError, OutletId, OutletPlacement, RouteOutlet};
91pub use route_tasks::RouteTaskBinding;
92pub use simulation::{Screenshot, Simulation, SimulationError};
93#[cfg(not(target_arch = "wasm32"))]
94pub use tasks::TokioHandle;
95pub use tasks::{
96    AsyncState, AsyncValue, RuntimeDiagnostics, RuntimeSpawner, RuntimeWake, Task, TaskFailure,
97    TaskHandle, TaskScope, UiDispatcher,
98};
99pub use text_shortcuts::TextShortcutPlatform;
100pub use transient_presentation::{
101    ResolvedTransientPresentation, TransientFallbackReason, TransientPresentationResolution,
102};
103pub use undo::{UndoHistoryController, UndoHistoryState};
104pub use window_commands::{
105    NativeOperationCompletionStatus, NativeOperationRequest, NativeWindowCommand,
106    WindowCommandEnqueueError, WindowHandle, WindowOpener, WindowPlacementError,
107};
108pub use window_state::{ApplicationDiagnostics, WindowDiagnostics};
109
110// Compatibility imports for the existing implementation submodules. These
111// remain private to the facade while preserving their original super:: paths.
112pub(crate) use environment::{
113    BUILD_SCOPE, BuildScope, Dependency, NEXT_REACTIVE_NODE, ReactiveNode, ReactiveNodeId,
114    ReactiveQueue, ReactiveRootId, TrackedDependency,
115};
116pub(crate) use frame::diagnostic_input_trigger;
117
118/// Process-wide scheduler/reactivity counters. Relaxed atomics on the UI
119/// thread cost a single increment per event and never allocate.
120mod scheduler_counters {
121    use std::sync::atomic::{AtomicU64, Ordering};
122    pub static SIGNAL_READS: AtomicU64 = AtomicU64::new(0);
123    pub static SIGNAL_WRITES: AtomicU64 = AtomicU64::new(0);
124    pub static DEPENDENTS_ENQUEUED: AtomicU64 = AtomicU64::new(0);
125    pub static RUNTIME_WAKES: AtomicU64 = AtomicU64::new(0);
126    pub static REDRAW_REQUESTS: AtomicU64 = AtomicU64::new(0);
127    pub static FRAMES_STARTED: AtomicU64 = AtomicU64::new(0);
128    pub static FRAMES_PRESENTED: AtomicU64 = AtomicU64::new(0);
129    pub static FRAMES_SKIPPED: AtomicU64 = AtomicU64::new(0);
130    #[must_use]
131    pub fn load(counter: &AtomicU64) -> u64 {
132        counter.load(Ordering::Relaxed)
133    }
134}
135
136#[must_use]
137pub fn scheduler_counters() -> SchedulerCounters {
138    SchedulerCounters {
139        signal_reads: scheduler_counters::load(&scheduler_counters::SIGNAL_READS),
140        signal_writes: scheduler_counters::load(&scheduler_counters::SIGNAL_WRITES),
141        dependents_enqueued: scheduler_counters::load(&scheduler_counters::DEPENDENTS_ENQUEUED),
142        runtime_wakes: scheduler_counters::load(&scheduler_counters::RUNTIME_WAKES),
143        redraw_requests: scheduler_counters::load(&scheduler_counters::REDRAW_REQUESTS),
144        frames_started: scheduler_counters::load(&scheduler_counters::FRAMES_STARTED),
145        frames_presented: scheduler_counters::load(&scheduler_counters::FRAMES_PRESENTED),
146        frames_skipped: scheduler_counters::load(&scheduler_counters::FRAMES_SKIPPED),
147    }
148}