moleculekit.viewer.molstar.cdp module#
Minimal Chrome DevTools Protocol client over a raw WebSocket.
Only the standard library is used. This exists so headless rendering needs no browser-automation dependency: the sandbox images moleculekit runs in ship a chromium binary but neither playwright nor node.
- class moleculekit.viewer.molstar.cdp.WS(url, timeout=300.0)#
Bases:
objectA CDP session over one WebSocket connection.
- call(method, params=None)#
Send a CDP command and return its result, ignoring unrelated events.
- Parameters:
- Returns:
result – The result object from the CDP response.
- Return type:
- Raises:
RuntimeError – If the CDP endpoint returns an error.
- evaluate(expression, timeout_ms=300000)#
Evaluate JavaScript in the page and return its value.
Promises are awaited. A JavaScript exception is re-raised here rather than returning a value, so a failed render cannot masquerade as a successful one.
- moleculekit.viewer.molstar.cdp.encode_frame(payload)#
Encode a payload as a masked client-to-server WebSocket text frame.
- moleculekit.viewer.molstar.cdp.page_target_url(port, timeout=30.0)#
Wait for devtools to come up and return the first page target’s ws url.
- Parameters:
- Returns:
url – The websocket debugger url of the first page target.
- Return type:
- Raises:
TimeoutError – If no page target appears within
timeout.