Sign in

    mizchi/crater-browser/cdp does not have a README file

    CdpBoxModel

    pub struct CdpBoxModel {
    content : Array[Double]
    padding : Array[Double]
    border : Array[Double]
    margin : Array[Double]
    width : Int
    height : Int
    } derive(
    Debug
    )

    CDP Box Model

    CdpContext

    pub struct CdpContext {
    id : String
    target_id : String?
    session_id : String?
    session : CdpSession
    url : String
    title : String
    }

    CDP Context - equivalent to lightpanda's BrowserContext

    CdpContext::clear_target

    fn CdpContext::clear_target(self : CdpContext) -> Unit

    Clear target (close)

    CdpContext::detach

    fn CdpContext::detach(self : CdpContext) -> Unit

    Detach session

    CdpContext::get_id

    fn CdpContext::get_id(self : CdpContext) -> String

    Get context ID

    CdpContext::get_session

    fn CdpContext::get_session(self : CdpContext) -> CdpSession

    Get underlying session

    CdpContext::get_session_id

    fn CdpContext::get_session_id(self : CdpContext) -> String?

    Get session ID

    CdpContext::get_target_id

    fn CdpContext::get_target_id(self : CdpContext) -> String?

    Get target ID

    CdpContext::get_title

    fn CdpContext::get_title(self : CdpContext) -> String

    Get page title

    CdpContext::get_url

    fn CdpContext::get_url(self : CdpContext) -> String

    Get current URL

    CdpContext::is_attached

    fn CdpContext::is_attached(self : CdpContext) -> Bool

    Check if target is attached

    CdpContext::navigate

    fn CdpContext::navigate(self : CdpContext, url : String) -> Result[CdpNavigateResult, CdpError]

    Navigate to URL

    CdpContext::new

    fn CdpContext::new(id : String) -> CdpContext

    Create new CDP context

    CdpContext::set_session_id

    fn CdpContext::set_session_id(self : CdpContext, session_id : String) -> Unit

    Set session ID

    CdpContext::set_target_id

    fn CdpContext::set_target_id(self : CdpContext, target_id : String) -> Unit

    Set target ID

    CdpContext::set_title

    fn CdpContext::set_title(self : CdpContext, title : String) -> Unit

    Set page title

    CdpError

    pub struct CdpError {
    code : Int
    message : String
    } derive(
    Debug
    )

    CDP Error

    CdpError::from_code

    fn CdpError::from_code(code : CdpErrorCode, message : String) -> CdpError

    Create CDP error from code

    CdpErrorCode

    pub enum CdpErrorCode {
    InvalidParams
    InternalError
    NodeNotFound
    NoSuchElement
    } derive(
    Debug
    )

    CDP Error codes (subset)

    CdpEvent

    pub struct CdpEvent {
    event_method : String
    params : Json?
    session_id : String?
    }

    CDP Event message (no id)

    CdpEvent::new

    fn CdpEvent::new(event_method : String, params : Json?, session_id : String?) -> CdpEvent

    Create new CDP event

    CdpFrameInfo

    pub struct CdpFrameInfo {
    id : String
    parent_id : String?
    loader_id : String
    name : String
    url : String
    security_origin : String
    mime_type : String
    } derive(
    Debug
    )

    CDP Frame Info

    CdpNavigateResult

    pub struct CdpNavigateResult {
    frame_id : String
    loader_id : String
    error_text : String?
    } derive(
    Debug
    )

    Navigate result

    CdpNavigationEntry

    pub struct CdpNavigationEntry {
    id : Int
    url : String
    title : String
    transition_type : String
    } derive(
    Debug
    )

    CDP Navigation Entry

    CdpNavigationHistory

    pub struct CdpNavigationHistory {
    current_index : Int
    entries : Array[CdpNavigationEntry]
    } derive(
    Debug
    )

    Navigation history

    CdpNode

    pub struct CdpNode {
    node_id : Int
    backend_node_id : Int
    node_type : Int
    node_name : String
    local_name : String
    node_value : String
    child_node_count : Int?
    children : Array[CdpNode]?
    attributes : Array[String]?
    shadow_roots : Array[CdpNode]?
    shadow_root_type : String?
    } derive(
    Debug
    )

    CDP Node - representation of a DOM node in CDP

    CdpOutMessage

    pub enum CdpOutMessage {
    Response(CdpResponse)
    Event(CdpEvent)
    }

    Message types that can be sent to clients

    CdpOutMessage::event

    Create Event message

    CdpOutMessage::response

    fn CdpOutMessage::response(resp : CdpResponse) -> CdpOutMessage

    Create Response message

    CdpOutMessage::to_json

    fn CdpOutMessage::to_json(self : CdpOutMessage) -> String

    Serialize outgoing message to JSON

    CdpProtocol

    pub struct CdpProtocol {
    target : TargetDomain
    network :
    NetworkManager

    outbox : Array[CdpOutMessage]
    lifecycle_events : Bool
    }

    CDP Protocol handler

    CdpProtocol::create_network_request

    fn CdpProtocol::create_network_request(self : CdpProtocol, url : String, resource_type :
    ResourceType
    , document_url : String, frame_id : String) ->
    RequestId

    Create a new network request (returns request ID for tracking)

    CdpProtocol::create_network_request_with_loader

    fn CdpProtocol::create_network_request_with_loader(self : CdpProtocol, url : String, resource_type :
    ResourceType
    , document_url : String, frame_id : String, loader_id : String) ->
    RequestId

    Create a new network request with explicit loader ID

    CdpProtocol::flush_network_events

    fn CdpProtocol::flush_network_events(self : CdpProtocol, session_id : String?) -> Unit

    Process pending network events and add them to outbox

    CdpProtocol::get_network_manager

    Get network manager for direct access

    CdpProtocol::has_pending_network_events

    fn CdpProtocol::has_pending_network_events(self : CdpProtocol) -> Bool

    Check if there are pending network events

    CdpProtocol::new

    Create new protocol handler

    CdpProtocol::notify_loading_failed

    fn CdpProtocol::notify_loading_failed(self : CdpProtocol, request_id :
    RequestId
    , error : String) -> Unit

    Notify loading failed

    CdpProtocol::notify_loading_finished

    fn CdpProtocol::notify_loading_finished(self : CdpProtocol, request_id :
    RequestId
    , encoded_data_length : Int) -> Unit

    Notify loading finished

    CdpProtocol::notify_response_received

    fn CdpProtocol::notify_response_received(self : CdpProtocol, request_id :
    RequestId
    , url : String, status : Int, mime_type : String, headers : Map[String, String]) -> Unit

    Notify response received

    CdpProtocol::notify_response_received_with_loader

    fn CdpProtocol::notify_response_received_with_loader(self : CdpProtocol, request_id :
    RequestId
    , url : String, status : Int, mime_type : String, headers : Map[String, String], loader_id : String) -> Unit

    Notify response received with explicit loader ID

    CdpProtocol::process_message

    fn CdpProtocol::process_message(self : CdpProtocol, json_str : String) -> Result[Unit, String]

    Process incoming JSON message

    CdpProtocol::take_messages

    fn CdpProtocol::take_messages(self : CdpProtocol) -> Array[CdpOutMessage]

    Take all pending outgoing messages

    CdpRequest

    pub struct CdpRequest {
    id : Int?
    request_method : String
    params : Json?
    session_id : String?
    }

    CDP Request message

    CdpResponse

    pub struct CdpResponse {
    id : Int?
    result : Json?
    error : CdpResponseError?
    session_id : String?
    }

    CDP Response message

    CdpResponse::new

    fn CdpResponse::new(id : Int?, result : Json?, error : CdpResponseError?, session_id : String?) -> CdpResponse

    Create new CDP response

    CdpResponseError

    pub struct CdpResponseError {
    code : Int
    message : String
    }

    CDP Response error

    CdpSession

    pub struct CdpSession {
    tree :
    DomTree

    dom : DomDomain
    input : InputDomain
    page : PageDomain
    session_id : String
    target_id : String
    }

    CDP Session - combines all domains

    CdpSession::click_element

    fn CdpSession::click_element(self : CdpSession, node_id : Int) -> Result[Unit, CdpError]

    Click element by node ID

    CdpSession::focus_element

    fn CdpSession::focus_element(self : CdpSession, node_id : Int) -> Result[Unit, CdpError]

    Focus element

    CdpSession::get_dom

    fn CdpSession::get_dom(self : CdpSession) -> DomDomain

    Get DOM domain

    CdpSession::get_input

    fn CdpSession::get_input(self : CdpSession) -> InputDomain

    Get Input domain

    CdpSession::get_page

    fn CdpSession::get_page(self : CdpSession) -> PageDomain

    Get Page domain

    CdpSession::get_session_id

    fn CdpSession::get_session_id(self : CdpSession) -> String

    Get session ID

    CdpSession::get_target_id

    fn CdpSession::get_target_id(self : CdpSession) -> String

    Get target ID

    CdpSession::get_title

    fn CdpSession::get_title(self : CdpSession) -> String

    Get page title

    CdpSession::get_tree

    Get underlying DOM tree for direct manipulation

    CdpSession::get_url

    fn CdpSession::get_url(self : CdpSession) -> String

    Get current URL

    CdpSession::load_html

    fn CdpSession::load_html(self : CdpSession, html : String) -> Unit

    Load HTML content into the DOM tree

    CdpSession::navigate_to

    fn CdpSession::navigate_to(self : CdpSession, url : String) -> Result[CdpNavigateResult, CdpError]

    Navigate to URL (combines Page.navigate with state update)

    CdpSession::new

    fn CdpSession::new(session_id : String) -> CdpSession

    Create new CDP session

    CdpSession::query_selector

    fn CdpSession::query_selector(self : CdpSession, selector : String) -> Result[Int?, CdpError]

    Find element by selector

    CdpSession::query_selector_all

    fn CdpSession::query_selector_all(self : CdpSession, selector : String) -> Result[Array[Int], CdpError]

    Find all elements by selector

    CdpSession::set_title

    fn CdpSession::set_title(self : CdpSession, title : String) -> Unit

    Set page title

    CdpSession::type_text

    fn CdpSession::type_text(self : CdpSession, text : String) -> Result[Unit, CdpError]

    Type text into focused element

    DomDomain

    pub struct DomDomain {
    tree :
    DomTree

    }

    DOM Domain handler

    DomDomain::get_attributes

    fn DomDomain::get_attributes(self : DomDomain, node_id : Int) -> Result[Array[String], CdpError]

    DOM.getAttributes - Returns attributes for the given node

    DomDomain::get_box_model

    fn DomDomain::get_box_model(self : DomDomain, node_id : Int) -> Result[CdpBoxModel, CdpError]

    DOM.getBoxModel - Returns box model for the given node

    DomDomain::get_document

    fn DomDomain::get_document(self : DomDomain, depth : Int?) -> Result[CdpNode, CdpError]

    DOM.getDocument - Returns the root DOM node

    DomDomain::get_outer_html

    fn DomDomain::get_outer_html(self : DomDomain, node_id : Int) -> Result[String, CdpError]

    DOM.getOuterHTML - Returns node's outer HTML

    DomDomain::new

    Create new DOM domain

    DomDomain::query_selector

    fn DomDomain::query_selector(self : DomDomain, node_id : Int, selector : String) -> Result[Int?, CdpError]

    DOM.querySelector - Executes querySelector on a given node

    DomDomain::query_selector_all

    fn DomDomain::query_selector_all(self : DomDomain, node_id : Int, selector : String) -> Result[Array[Int], CdpError]

    DOM.querySelectorAll - Executes querySelectorAll on a given node

    DomDomain::remove_attribute

    fn DomDomain::remove_attribute(self : DomDomain, node_id : Int, name : String) -> Result[Unit, CdpError]

    DOM.removeAttribute - Removes attribute

    DomDomain::remove_node

    fn DomDomain::remove_node(self : DomDomain, node_id : Int) -> Result[Unit, CdpError]

    DOM.removeNode - Removes node from the tree

    DomDomain::request_child_nodes

    fn DomDomain::request_child_nodes(self : DomDomain, node_id : Int, depth : Int?) -> Result[Array[CdpNode], CdpError]

    DOM.requestChildNodes - Requests child nodes for the given node

    DomDomain::set_attribute_value

    fn DomDomain::set_attribute_value(self : DomDomain, node_id : Int, name : String, value : String) -> Result[Unit, CdpError]

    DOM.setAttributeValue - Sets attribute value

    DomDomain::set_node_value

    fn DomDomain::set_node_value(self : DomDomain, node_id : Int, value : String) -> Result[Unit, CdpError]

    DOM.setNodeValue - Sets node value (for text nodes)

    InputDomain

    pub struct InputDomain {
    tree :
    DomTree

    mouse_x : Double
    mouse_y : Double
    button_pressed : Bool
    }

    Input Domain handler

    InputDomain::dispatch_key_event

    fn InputDomain::dispatch_key_event(self : InputDomain, type_ : String, key : String, code : String, text : String?) -> Result[Unit, CdpError]

    Input.dispatchKeyEvent

    InputDomain::dispatch_mouse_event

    fn InputDomain::dispatch_mouse_event(self : InputDomain, type_ : String, x : Double, y : Double, button : String, click_count : Int) -> Result[Unit, CdpError]

    Input.dispatchMouseEvent

    InputDomain::insert_text

    fn InputDomain::insert_text(self : InputDomain, text : String) -> Result[Unit, CdpError]

    Input.insertText - Insert text at current cursor position

    InputDomain::new

    Create new Input domain

    PageDomain

    pub struct PageDomain {
    tree :
    DomTree

    current_url : String
    title : String
    frame_id : String
    loader_id : Int
    history : Array[CdpNavigationEntry]
    history_index : Int
    }

    Page Domain handler

    PageDomain::get_frame_tree

    fn PageDomain::get_frame_tree(self : PageDomain) -> Result[CdpFrameInfo, CdpError]

    Page.getFrameTree - Returns frame tree

    PageDomain::get_navigation_history

    fn PageDomain::get_navigation_history(self : PageDomain) -> Result[CdpNavigationHistory, CdpError]

    Page.getNavigationHistory - Returns navigation history

    PageDomain::get_title

    fn PageDomain::get_title(self : PageDomain) -> String

    Get page title

    PageDomain::get_url

    fn PageDomain::get_url(self : PageDomain) -> String

    Get current URL

    PageDomain::go_back

    fn PageDomain::go_back(self : PageDomain) -> Result[Bool, CdpError]

    Page.goBack - Goes back in history

    PageDomain::go_forward

    fn PageDomain::go_forward(self : PageDomain) -> Result[Bool, CdpError]

    Page.goForward - Goes forward in history

    PageDomain::navigate

    fn PageDomain::navigate(self : PageDomain, url : String) -> Result[CdpNavigateResult, CdpError]

    Page.navigate - Navigates to URL Note: Actual fetching is done externally, this just updates state

    PageDomain::new

    Create new Page domain

    PageDomain::push_history_url

    fn PageDomain::push_history_url(self : PageDomain, url : String) -> Unit

    Update URL/history for History API pushState without full navigation.

    PageDomain::reload

    fn PageDomain::reload(self : PageDomain) -> Result[Unit, CdpError]

    Page.reload - Reloads the current page

    PageDomain::replace_history_url

    fn PageDomain::replace_history_url(self : PageDomain, url : String) -> Unit

    Update URL/history for History API replaceState without adding an entry.

    PageDomain::set_title

    fn PageDomain::set_title(self : PageDomain, title : String) -> Unit

    Set page title (called when document is loaded)

    TargetDomain

    pub struct TargetDomain {
    contexts : Map[String, CdpContext]
    active_context_id : String?
    next_context_id : Int
    next_target_id : Int
    next_session_id : Int
    auto_attach : Bool
    discover_targets : Bool
    }

    Target domain handler

    TargetDomain::attach_to_target

    fn TargetDomain::attach_to_target(self : TargetDomain, target_id : String) -> Result[String, CdpError]

    Target.attachToTarget

    TargetDomain::close_target

    fn TargetDomain::close_target(self : TargetDomain, target_id : String) -> Result[Unit, CdpError]

    Target.closeTarget

    TargetDomain::create_browser_context

    fn TargetDomain::create_browser_context(self : TargetDomain) -> Result[String, CdpError]

    Target.createBrowserContext

    TargetDomain::create_target

    fn TargetDomain::create_target(self : TargetDomain, url : String, browser_context_id : String?) -> Result[String, CdpError]

    Target.createTarget

    TargetDomain::detach_from_target

    fn TargetDomain::detach_from_target(self : TargetDomain, session_id : String?, target_id : String?) -> Result[Unit, CdpError]

    Target.detachFromTarget

    TargetDomain::dispose_browser_context

    fn TargetDomain::dispose_browser_context(self : TargetDomain, browser_context_id : String) -> Result[Unit, CdpError]

    Target.disposeBrowserContext

    TargetDomain::get_active_context

    fn TargetDomain::get_active_context(self : TargetDomain) -> CdpContext?

    Get active browser context

    TargetDomain::get_browser_contexts

    fn TargetDomain::get_browser_contexts(self : TargetDomain) -> Array[String]

    Target.getBrowserContexts

    TargetDomain::get_context

    fn TargetDomain::get_context(self : TargetDomain, id : String) -> CdpContext?

    Get browser context by ID

    TargetDomain::get_target_info

    fn TargetDomain::get_target_info(self : TargetDomain, target_id : String?) -> Result[TargetInfo, CdpError]

    Target.getTargetInfo

    TargetDomain::get_targets

    fn TargetDomain::get_targets(self : TargetDomain) -> Array[TargetInfo]

    Target.getTargets

    TargetDomain::is_auto_attach

    fn TargetDomain::is_auto_attach(self : TargetDomain) -> Bool

    Check if auto-attach is enabled

    TargetDomain::new

    Create new Target domain

    TargetDomain::set_auto_attach

    fn TargetDomain::set_auto_attach(self : TargetDomain, auto_attach : Bool, _wait_for_debugger_on_start : Bool) -> Unit

    Target.setAutoAttach

    TargetDomain::set_discover_targets

    fn TargetDomain::set_discover_targets(self : TargetDomain, discover : Bool) -> Unit

    Target.setDiscoverTargets

    TargetInfo

    pub struct TargetInfo {
    target_id : String
    target_type : String
    title : String
    url : String
    attached : Bool
    browser_context_id : String?
    } derive(
    Debug
    )

    Target info structure (for CDP responses)

    TestContext

    pub struct TestContext {
    session : CdpSession
    }

    Test context for CDP operations

    TestContext::doc_id

    fn TestContext::doc_id(self : TestContext) -> Int

    Get document root node ID

    TestContext::dom

    fn TestContext::dom(self : TestContext) -> DomDomain

    Get DOM domain from test context

    TestContext::input

    fn TestContext::input(self : TestContext) -> InputDomain

    Get Input domain from test context

    TestContext::new

    Create a new test context

    TestContext::page

    fn TestContext::page(self : TestContext) -> PageDomain

    Get Page domain from test context

    TestContext::tree

    Get the underlying DOM tree

    TestContext::with_html

    fn TestContext::with_html(html : String) -> TestContext

    Create test context with HTML content

    core_to_cdp_error

    Convert core error to CDP error