1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//! Plugin system for extending Revue applications
//!
//! Plugins provide a modular way to extend app functionality with lifecycle hooks,
//! custom styles, and shared state.
//!
//! # Features
//!
//! | Feature | Description |
//!|---------|-------------|
//! | **Lifecycle Hooks** | Init, tick, event, shutdown callbacks |
//! | **Shared State** | Global state accessible to all plugins |
//! | **Custom Styles** | Add CSS variables and rules |
//! | **Event Handling** | Subscribe to and emit events |
//! | **Async Support** | Async lifecycle operations |
//!
//! # Quick Start
//!
//! ## Create a Plugin
//!
//! ```rust,ignore
//! use revue::plugin::{Plugin, PluginContext};
//! use std::time::Duration;
//!
//! struct LoggerPlugin {
//! event_count: usize,
//! }
//!
//! impl Plugin for LoggerPlugin {
//! fn name(&self) -> &str { "logger" }
//!
//! fn on_init(&mut self, ctx: &mut PluginContext) -> revue::Result<()> {
//! println!("[{}] Plugin initialized", self.name());
//! Ok(())
//! }
//!
//! fn on_tick(&mut self, _ctx: &mut PluginContext, delta: Duration) -> revue::Result<()> {
//! self.event_count += 1;
//! Ok(())
//! }
//! }
//! ```
//!
//! ## Register a Plugin
//!
//! ```rust,ignore
//! use revue::App;
//!
//! let app = App::builder()
//! .plugin(LoggerPlugin { event_count: 0 })
//! .build();
//! ```
//!
//! # Lifecycle Hooks
//!
//! | Hook | When Called | Use Case |
//!|------|-------------|----------|
//! | `on_init` | After app creation | Setup, initialization |
//! | `on_mount` | When view is mounted | UI setup, subscriptions |
//! | `on_tick` | Every frame | Update logic, animation |
//! | `on_event` | On input event | Event handling |
//! | `on_shutdown` | Before app exit | Cleanup, saving |
//!
//! # Plugin Context
//!
//! The [`PluginContext`] provides access to:
//!
//! ```rust,ignore
//! impl Plugin for MyPlugin {
//! fn on_init(&mut self, ctx: &mut PluginContext) -> Result<()> {
//! // Access app state
//! let state = ctx.state();
//!
//! // Emit events
//! ctx.emit("my_event", data);
//!
//! // Subscribe to events
//! ctx.subscribe("other_event", |data| {
//! println!("Got event: {:?}", data);
//! });
//!
//! Ok(())
//! }
//! }
//! ```
//!
//! # Built-in Plugins
//!
//! ## LoggerPlugin
//!
//! Logs app lifecycle events and errors:
//!
//! ```rust,ignore
//! use revue::plugin::LoggerPlugin;
//!
//! let app = App::builder()
//! .plugin(LoggerPlugin::new())
//! .build();
//! ```
//!
//! ## PerformancePlugin
//!
//! Tracks FPS, frame time, and memory usage:
//!
//! ```rust,ignore
//! use revue::plugin::PerformancePlugin;
//!
//! let app = App::builder()
//! .plugin(PerformancePlugin::new())
//! .build();
//! ```
//!
//! # Plugin Registry
//!
//! Access and manage plugins:
//!
//! ```rust,ignore
//! use revue::plugin::PluginRegistry;
//!
//! // Get plugin by name
//! if let Some(logger) = registry.get("logger") {
//! // Use plugin...
//! }
//!
//! // List all plugins
//! for name in registry.plugin_names() {
//! println!("{}", name);
//! }
//! ```
pub use PluginContext;
pub use PluginRegistry;
pub use Plugin;
// Built-in plugins
pub use ;