1#![cfg_attr(docsrs, feature(doc_cfg))]
27#![warn(missing_docs)]
28#![warn(clippy::all)]
29
30pub mod browser;
31pub mod buffer;
32pub mod cors;
33pub mod error;
34pub mod extraction;
35pub mod handlers;
36pub mod mcp;
37pub mod metrics;
38pub mod processing;
39pub mod shutdown;
40
41pub const VERSION: &str = env!("CARGO_PKG_VERSION");
43
44pub const NAME: &str = env!("CARGO_PKG_NAME");
46
47pub fn generate_request_id() -> String {
49 uuid::Uuid::new_v4().to_string()
50}
51
52pub use browser::controller::BrowserController;
54pub use error::Error;
55pub use extraction::content::ContentExtractor;
56pub use extraction::links::LinkExtractor;
57pub use extraction::metadata::MetadataExtractor;
58pub use mcp::McpServer;
59
60pub mod config {
62 pub const DEFAULT_TIMEOUT_MS: u64 = 30_000;
64
65 pub const DEFAULT_VIEWPORT_WIDTH: u32 = 1920;
67
68 pub const DEFAULT_VIEWPORT_HEIGHT: u32 = 1080;
70}
71
72#[cfg(target_arch = "wasm32")]
74#[wasm_bindgen]
75pub struct WasmBrowserConnector {
76 connected: bool,
77 url: String,
78}
79
80#[cfg(target_arch = "wasm32")]
81#[wasm_bindgen]
82impl WasmBrowserConnector {
83 #[wasm_bindgen(constructor)]
85 pub fn new() -> Self {
86 Self {
87 connected: false,
88 url: String::new(),
89 }
90 }
91
92 #[wasm_bindgen(getter)]
94 pub fn connected(&self) -> bool {
95 self.connected
96 }
97
98 #[wasm_bindgen(getter)]
100 pub fn url(&self) -> String {
101 self.url.clone()
102 }
103
104 pub fn connect(&mut self, url: &str) -> bool {
106 self.url = url.to_string();
107 self.connected = true;
108 true
109 }
110
111 pub fn disconnect(&mut self) {
113 self.connected = false;
114 self.url.clear();
115 }
116}
117
118#[cfg(target_arch = "wasm32")]
119impl Default for WasmBrowserConnector {
120 fn default() -> Self {
121 Self::new()
122 }
123}
124
125#[cfg(test)]
126mod tests {
127 use super::*;
128
129 #[test]
130 fn test_config_defaults() {
131 assert_eq!(config::DEFAULT_TIMEOUT_MS, 30_000);
132 assert_eq!(config::DEFAULT_VIEWPORT_WIDTH, 1920);
133 assert_eq!(config::DEFAULT_VIEWPORT_HEIGHT, 1080);
134 }
135}