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;
40pub mod stripe;
41
42pub const VERSION: &str = env!("CARGO_PKG_VERSION");
44
45pub const NAME: &str = env!("CARGO_PKG_NAME");
47
48pub fn generate_request_id() -> String {
50 uuid::Uuid::new_v4().to_string()
51}
52
53pub use browser::controller::BrowserController;
55pub use error::Error;
56pub use extraction::content::ContentExtractor;
57pub use extraction::links::LinkExtractor;
58pub use extraction::metadata::MetadataExtractor;
59pub use mcp::McpServer;
60
61pub mod config {
63 pub const DEFAULT_TIMEOUT_MS: u64 = 30_000;
65
66 pub const DEFAULT_VIEWPORT_WIDTH: u32 = 1920;
68
69 pub const DEFAULT_VIEWPORT_HEIGHT: u32 = 1080;
71}
72
73#[cfg(target_arch = "wasm32")]
75#[wasm_bindgen]
76pub struct WasmBrowserConnector {
77 connected: bool,
78 url: String,
79}
80
81#[cfg(target_arch = "wasm32")]
82#[wasm_bindgen]
83impl WasmBrowserConnector {
84 #[wasm_bindgen(constructor)]
86 pub fn new() -> Self {
87 Self {
88 connected: false,
89 url: String::new(),
90 }
91 }
92
93 #[wasm_bindgen(getter)]
95 pub fn connected(&self) -> bool {
96 self.connected
97 }
98
99 #[wasm_bindgen(getter)]
101 pub fn url(&self) -> String {
102 self.url.clone()
103 }
104
105 pub fn connect(&mut self, url: &str) -> bool {
107 self.url = url.to_string();
108 self.connected = true;
109 true
110 }
111
112 pub fn disconnect(&mut self) {
114 self.connected = false;
115 self.url.clear();
116 }
117}
118
119#[cfg(target_arch = "wasm32")]
120impl Default for WasmBrowserConnector {
121 fn default() -> Self {
122 Self::new()
123 }
124}
125
126#[cfg(test)]
127mod tests {
128 use super::*;
129
130 #[test]
131 fn test_config_defaults() {
132 assert_eq!(config::DEFAULT_TIMEOUT_MS, 30_000);
133 assert_eq!(config::DEFAULT_VIEWPORT_WIDTH, 1920);
134 assert_eq!(config::DEFAULT_VIEWPORT_HEIGHT, 1080);
135 }
136}