camoufox_juggler/lib.rs
1//! # camoufox-juggler
2//!
3//! Native Rust client for Firefox's Juggler automation protocol.
4//!
5//! Camoufox embeds the Juggler protocol (the Firefox automation layer
6//! Playwright uses). This crate closes the automation loop with zero
7//! Playwright dependency:
8//!
9//! - [`launch_with_juggler`] prepares the launch (fingerprint, env, prefs)
10//! through the `camoufox` facade and spawns the browser with the Juggler
11//! pipe connected (FDs 3/4 on Unix, `PW_PIPE_READ`/`PW_PIPE_WRITE`
12//! inheritable handles on Windows)
13//! - [`JugglerBrowser`] manages contexts, pages, cookies, downloads and
14//! the credentials-aware proxy configuration
15//! - [`JugglerPage`] navigates, evaluates JS, screenshots, captures
16//! cookies/local storage, dispatches input events (mouse, keyboard,
17//! touch, wheel), exposes network events, intercepts requests and file
18//! choosers, injects WebSocket frames, streams screencasts and tracks
19//! web workers
20//! - [`verify_fingerprint`] asserts the running browser's spoofed surfaces
21//! match the generated fingerprint
22//! - [`Orchestrator`] runs a pool of persona-driven browser sessions with
23//! rotation policies and persistent rotation state
24//!
25//! ## Example
26//!
27//! ```no_run
28//! # async fn demo() -> camoufox_juggler::Result<()> {
29//! use camoufox::builder::{HeadlessMode, LaunchOptions};
30//! use camoufox_core::os::SupportedOs;
31//!
32//! let options = LaunchOptions {
33//! os: vec![SupportedOs::Linux],
34//! headless: HeadlessMode::On,
35//! ..Default::default()
36//! };
37//! let mut browser = camoufox_juggler::launch_with_juggler(&options).await?;
38//! let page = browser.new_page().await?;
39//! page.goto("https://example.com").await?;
40//! let title = page.evaluate("document.title").await?;
41//! println!("title: {title:?}");
42//! browser.close().await?;
43//! # Ok(())
44//! # }
45//! ```
46//!
47//! ## Network events & interception
48//!
49//! ```no_run
50//! # async fn demo() -> camoufox_juggler::Result<()> {
51//! # let browser: camoufox_juggler::JugglerBrowser = todo!();
52//! # let page: std::sync::Arc<camoufox_juggler::JugglerPage> = todo!();
53//! // Observe traffic
54//! let mut events = page.network_events();
55//! page.set_request_interception(true).await?;
56//! while let Some(event) = events.next().await? {
57//! if let camoufox_juggler::NetworkEvent::RequestWillBeSent(request) = event {
58//! if request.is_intercepted && request.url.contains("ads.example") {
59//! page.take_intercepted_request(&request).abort().await?;
60//! }
61//! }
62//! }
63//! # Ok(())
64//! # }
65//! ```
66
67pub mod binding;
68pub mod browser;
69pub mod cloudflare;
70pub mod connection;
71pub mod console;
72pub mod dom;
73pub mod download;
74pub mod driver;
75pub mod emulation;
76pub mod error;
77pub mod har;
78pub mod input;
79pub mod network;
80pub mod orchestrator;
81pub mod page;
82pub mod permission;
83pub mod process;
84pub mod protocol;
85pub mod screencast;
86pub mod transport;
87pub mod verify;
88pub mod worker;
89
90pub use binding::{BindingCall, BindingCalls};
91pub use browser::JugglerBrowser;
92pub use cloudflare::{ChallengeKind, CloudflareOptions, CloudflareOutcome};
93pub use connection::{Connection, DEFAULT_COMMAND_TIMEOUT};
94pub use console::{ConsoleEvents, ConsoleLevel, ConsoleMessage};
95pub use dom::{NodeDescription, Point, Quad};
96pub use download::{
97 DownloadBehavior, DownloadCreated, DownloadEvent, DownloadEvents, DownloadFinished,
98};
99pub use driver::{core_error, into_core, launch_with_juggler};
100pub use emulation::{ColorScheme, Contrast, EmulatedMedia, ForcedColors, MediaType, ReducedMotion};
101pub use error::{JugglerError, Result};
102pub use har::HarLog;
103pub use input::{KeyDescriptor, Modifiers, MouseButton, TouchEventType, TouchPoint};
104pub use network::{
105 FulfillResponse, InterceptedRequest, NetworkEvent, NetworkEvents, NetworkRequest,
106 NetworkRequestFailed, NetworkRequestFinished, NetworkResponseInfo, RouteOverrides,
107 WebSocketFrame, WebSocketInfo,
108};
109pub use orchestrator::{OrchestratedSession, Orchestrator, OrchestratorOptions};
110pub use page::{Dialog, FileChooser, JugglerPage};
111pub use permission::Permission;
112pub use screencast::{ScreencastFrame, ScreencastFrames};
113pub use verify::{verify_fingerprint, SurfaceCheck, VerificationReport};
114pub use worker::{WorkerEvent, WorkerEvents, WorkerInfo};