sema-cdp 0.1.1

API reference · 17 exports

Source declarations and literal docstrings from this release. Package code was not executed.

cdp/attach!

(cdp/attach! conn target-id)
Attach to a target (flat protocol) and return a session map. Pass the session to cdp/send / cdp/wait-event to address commands to that target.

Source: package.sema:281

cdp/browser-candidates

(cdp/browser-candidates)
Return the browser binary paths cdp/find-chrome probes on this machine, in priority order (Chrome, Chromium, Brave, Edge). Entries are candidates — most will not exist.

Source: package.sema:62

cdp/clear-events!

(cdp/clear-events! target . method-rest)
Drop buffered events — all of them, or only a given method name. Scoped to the session when `target` is one.

Source: package.sema:338

cdp/close!

(cdp/close! conn)
Close the browser: ask it to shut down via Browser.close, close the websocket, kill the spawned process if this connection launched it, and delete the temp profile dir if cdp/launch created it.

Source: package.sema:161

cdp/connect

(cdp/connect url)
Connect to an already-running browser. Accepts a ws:// debugger URL, or an http:// devtools address (e.g. "http://localhost:9222") whose /json/version endpoint is used to discover it.

Source: package.sema:151

cdp/detach!

(cdp/detach! session)
Detach a session created by cdp/attach!.

Source: package.sema:287

cdp/events

(cdp/events target)
Return the buffered events for this connection (or, for a session, only that session's), oldest first.

Source: package.sema:330

cdp/find-chrome

(cdp/find-chrome)
Return the path of a Chrome-compatible browser binary, or nil if none is found. Checks the SEMA_CHROME env var first, then well-known install locations on macOS, Linux, and Windows (see cdp/browser-candidates).

Source: package.sema:76

cdp/launch

(cdp/launch . opts-rest)
Launch a Chrome-compatible browser with remote debugging and return a connection. Options map: :headless (default #t), :chrome (binary path), :args (extra CLI args), :user-data-dir (default: fresh dir under the system temp dir).

Source: package.sema:116

cdp/new-target!

(cdp/new-target! conn url)
Create a new page target navigated to url and return its target id.

Source: package.sema:277

cdp/off!

(cdp/off! target handler-id)
Remove an event handler registered by cdp/on!, by its returned id.

Source: package.sema:311

cdp/on!

(cdp/on! target method handler)
Register a handler called with each matching event map as it arrives, and return a handler id for cdp/off!. Events are only received while a cdp/send, cdp/wait-event, or cdp/pump is pumping the connection. Scoped to the session when `target` is one, otherwise connection-wide. Handlers may call cdp/send themselves.

Source: package.sema:300

cdp/pump

(cdp/pump target duration-ms)
Receive and dispatch events for up to duration-ms without sending anything — use it to let cdp/on! handlers run while otherwise idle.

Source: package.sema:319

cdp/send

(cdp/send target method . extra)
Send a CDP command and return its result map. `target` is a connection or a session (from cdp/attach!). Optional: params map, then options map {:timeout ms}. Raises on a CDP error response, including the method, code, and message.

Source: package.sema:248

cdp/targets

(cdp/targets conn)
List the browser's targets (pages, workers, extensions) as maps with :targetId, :type, :url, :title.

Source: package.sema:273

cdp/version

(cdp/version conn)
Return browser version info: :product, :revision, :userAgent, :jsVersion, :protocolVersion.

Source: package.sema:269

cdp/wait-event

(cdp/wait-event target method . opts-rest)
Wait for an event, consuming it from the buffer, and return the event map. Checks already-buffered events first. Options: :timeout ms (default 30000), :pred (event map -> bool). Scoped to the session when `target` is one.

Source: package.sema:358