hojicha_runtime/
lib.rs

1//! # Hojicha Runtime
2//!
3//! Event handling and async runtime for Hojicha TUI applications.
4//!
5//! This crate provides the runtime infrastructure for handling events,
6//! managing async operations, and running the main application loop.
7//!
8//! ## Core Components
9//!
10//! - **Program**: Main application runtime and event loop
11//! - **Event Processing**: Priority-based event handling with backpressure
12//! - **Async Support**: Tokio-based async command execution
13//! - **Subscriptions**: Stream-based event sources
14//! - **Error Resilience**: Panic recovery and error handling
15//!
16//! ## Features
17//!
18//! - Priority event queue with automatic scaling
19//! - Resilient input handling with panic recovery
20//! - Safe mutex operations that recover from poison
21//! - Metrics and monitoring support
22//! - Terminal management and restoration
23
24#![warn(missing_docs)]
25
26// Note: Event types are in hojicha-core since they're fundamental to the Model trait
27
28// Program and runtime
29pub mod program;
30pub use program::{MouseMode, Program, ProgramOptions};
31
32// Async support
33pub mod async_handle;
34pub mod stream_builders;
35pub mod subscription;
36
37// Event processing infrastructure
38pub mod metrics;
39pub mod priority_queue;
40pub mod queue_scaling;
41
42// Testing utilities
43pub mod safe_priority;
44pub mod testing;
45
46// Error resilience
47pub mod panic_handler;
48pub mod panic_recovery;
49pub mod panic_utils;
50pub mod resilient_input;
51pub mod resource_limits;
52pub mod safe_mutex;
53
54// Re-export from core
55pub use hojicha_core::event::{Event, Key, KeyEvent, KeyModifiers, MouseEvent, WindowSize};
56
57// Re-export runtime types
58pub use async_handle::AsyncHandle;
59pub use subscription::Subscription;
60
61// Re-export program components
62pub use program::{
63    CommandExecutor, EventProcessor, EventStats, FpsLimiter, PriorityConfig,
64    PriorityEventProcessor, TerminalConfig, TerminalManager,
65};
66
67// Re-export differential rendering
68pub use hojicha_rendering::DifferentialRenderer;
69
70/// Prelude for convenient imports
71///
72/// This module provides the essential runtime types for Hojicha applications.
73/// Import everything with:
74///
75/// ```
76/// use hojicha_runtime::prelude::*;
77/// ```
78///
79/// ## Included Items
80///
81/// ### Program & Configuration
82/// - [`Program`] - The main application runtime
83/// - [`ProgramOptions`] - Configuration for the program
84/// - [`MouseMode`] - Mouse tracking options
85///
86/// ### Async Support
87/// - [`AsyncHandle`] - Handle for cancellable async operations
88/// - [`Subscription`] - Stream subscription handle
89///
90/// ### Stream Builders
91/// - [`interval_stream()`] - Create periodic event streams
92/// - [`timeout_stream()`] - Create timeout streams
93/// - [`delayed_stream()`] - Create delayed streams
94pub mod prelude {
95    // Program and configuration
96    pub use crate::program::{MouseMode, Program, ProgramOptions};
97
98    // Async support
99    pub use crate::async_handle::AsyncHandle;
100    pub use crate::subscription::Subscription;
101
102    // Stream builders for common patterns
103    pub use crate::stream_builders::{delayed_stream, interval_stream, timeout_stream};
104
105    // Re-export essential event types from core
106    pub use hojicha_core::event::{Event, Key, KeyEvent, KeyModifiers, MouseEvent, WindowSize};
107}