1pub mod Activation;
35pub mod APIBridge;
36pub mod ExtensionHost;
37pub mod ExtensionManager;
38pub mod Lifecycle;
39
40pub use Activation::{ActivationEngine, ActivationEvent};
42pub use Lifecycle::{LifecycleEvent, LifecycleManager};
43#[derive(Debug, Clone)]
47pub struct HostConfig {
48 pub max_extensions:usize,
50 pub lazy_activation:bool,
52 pub hot_reload:bool,
54 pub discovery_paths:Vec<String>,
56 pub api_logging:bool,
58 pub activation_timeout_ms:u64,
60}
61
62impl Default for HostConfig {
63 fn default() -> Self {
64 Self {
65 max_extensions:100,
66 lazy_activation:true,
67 hot_reload:false,
68 discovery_paths:vec!["~/.vscode/extensions".to_string(), "~/.grove/extensions".to_string()],
69 api_logging:false,
70 activation_timeout_ms:30000,
71 }
72 }
73}
74
75impl HostConfig {
76 pub fn new() -> Self { Self::default() }
78
79 pub fn with_max_extensions(mut self, max:usize) -> Self {
81 self.max_extensions = max;
82 self
83 }
84
85 pub fn with_lazy_activation(mut self, enabled:bool) -> Self {
87 self.lazy_activation = enabled;
88 self
89 }
90
91 pub fn with_hot_reload(mut self, enabled:bool) -> Self {
93 self.hot_reload = enabled;
94 self
95 }
96
97 pub fn with_activation_timeout(mut self, timeout_ms:u64) -> Self {
99 self.activation_timeout_ms = timeout_ms;
100 self
101 }
102
103 pub fn add_discovery_path(mut self, path:String) -> Self {
105 self.discovery_paths.push(path);
106 self
107 }
108}
109
110#[derive(Debug, Clone)]
112pub struct ActivationResult {
113 pub extension_id:String,
115 pub success:bool,
117 pub time_ms:u64,
119 pub error:Option<String>,
121 pub contributes:Vec<String>,
123}
124
125#[cfg(test)]
126mod tests {
127 use super::*;
128
129 #[test]
130 fn test_host_config_default() {
131 let config = HostConfig::default();
132 assert_eq!(config.max_extensions, 100);
133 assert_eq!(config.lazy_activation, true);
134 }
135
136 #[test]
137 fn test_host_config_builder() {
138 let config = HostConfig::default()
139 .with_max_extensions(50)
140 .with_lazy_activation(false)
141 .with_activation_timeout(60000);
142
143 assert_eq!(config.max_extensions, 50);
144 assert_eq!(config.lazy_activation, false);
145 assert_eq!(config.activation_timeout_ms, 60000);
146 }
147
148 #[test]
149 fn test_activation_result() {
150 let result = ActivationResult {
151 extension_id:"test.ext".to_string(),
152 success:true,
153 time_ms:100,
154 error:None,
155 contributes:vec!["command.test".to_string()],
156 };
157
158 assert_eq!(result.extension_id, "test.ext");
159 assert!(result.success);
160 assert_eq!(result.contributes.len(), 1);
161 }
162}