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