Skip to main content

Crate bao

Crate bao 

Source
Expand description

§Bao — unified library

Single consumer-facing package. Full stack is always linked: SpiderMonkey (bao_engine) + servo browser (bao_browser) + Node/Bun API (bun_runtime) + CDP (bao_cdp / bao_cdp_client) + Stealth (bao_stealth).

There are no Cargo product features that disable browser, CDP, stealth, or Node API. Runtime knobs (e.g. StealthProfile, permissions) select behaviour without changing the link set.

§Quick start

use bao::{BaoConfig, BaoRuntime, PageConfig, StealthProfile};

fn main() -> Result<(), bao::BrowserError> {
    let runtime = BaoRuntime::new(BaoConfig::default())?;
    let _pool = runtime.page_pool();
    let _ = StealthProfile::firefox_default();
    let _ = PageConfig::default();
    Ok(())
}

§CDP (Playwright-style)

use bao::Browser;

fn main() -> Result<(), bao::ConnectError> {
    let browser = Browser::connect("memory://bao")?;
    let _ = browser;
    Ok(())
}

@trace REQ-LIB-001 [level:library] @trace REQ-LIB-003 [level:library] @trace REQ-BRW-003 [level:library]

Modules§

browser
Browser runtime, PagePool, PageHandle, permissions, screenshots.
cdp
CDP server / router / WS codec surface.
cdp_client
Playwright-style CDP client (Browser::connect, Page, …).
engine
SpiderMonkey engine surface (via bao_engine re-exports).
runtime
Node.js / Bun API compatibility runtime (bun_runtime crate).
stealth
Anti-fingerprint profiles and engine (runtime configuration).
uloop
Event loop (epoll tick shared with FilePoll).

Structs§

AudioProfile
BaoConfig
BaoRuntime
BehaviorConfig
BehaviorSimulator
Browser
CDP Browser 实例。
BrowserConfig
CanvasNoise
CdpRouter
CdpServer
CdpSession
Connection
Connection — CDP JSON-RPC 命令收发 + 事件分发核心。
ConnectionConfig
Connection 配置(超时、重试、session_id 等)。
Cookie
HTTP Cookie 表示(对应 CDP Network.Cookie / Network.setCookie)。
DeviceDescriptor
设备描述符(用于 Page.emulate 设备模拟)。
FontConfig
Font fingerprint protection configuration.
Http2Fingerprint
NavigatorProfile
PageConfig
PageHandle
PagePool
Permission
PermissionDenied
PermissionGuard
ScreenProfile
StealthEngine
StealthHooks
StealthProfile
StealthTlsWireConfig
Wire-level TLS/HTTP2 configuration for servo’s network layer.
TlsFingerprint
Viewport
Viewport(viewport 配置)。
WebGLProfile

Enums§

BackendKind
BrowserError
CdpError
通信阶段错误(Transport 使用,具体实现在 TASK-2)。
ConnectError
连接阶段错误(Browser::connect 入口返回)。
PageState
ScreenshotFormat
WaitUntilState
等待页面就绪的状态(对应 Puppeteer waitUntil 选项)。

Functions§

encode_image
run_browser