refactor: reorganize client transport and extension internals
- Split client, native, remote, serve, markdown, and SDK internals into focused packages with direct imports. - Move local and remote transport framing/protocol helpers behind clearer module boundaries. - Break up the extension injected DOM logic into a separate content dispatch bundle and dedicated content modules. - Add explicit client handling for passive remote discovery without noisy PQ warnings. - Keep behavior covered with updated unit, integration, and extension tests.
This commit is contained in:
@@ -2,17 +2,15 @@
|
||||
|
||||
Pure helpers (no sockets, no I/O) for turning user-facing ``host[:port]``
|
||||
strings into the canonical forms the rest of the client uses, and back into the
|
||||
short forms shown to humans. Re-exported from :mod:`browser_cli.client` for
|
||||
backward compatibility.
|
||||
short forms shown to humans.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
from browser_cli.constants import DEFAULT_REMOTE_PORT
|
||||
from browser_cli.errors import BrowserNotConnected
|
||||
|
||||
_DEFAULT_REMOTE_PORT = 443
|
||||
|
||||
def _looks_like_domain(host: str) -> bool:
|
||||
"""True if host looks like a domain name rather than an IP address or localhost."""
|
||||
if host in {"localhost", "127.0.0.1", "::1"}:
|
||||
@@ -35,7 +33,7 @@ def _resolve_connect_endpoint(endpoint: str) -> str:
|
||||
_, sep, _ = endpoint.rpartition(":")
|
||||
if not sep:
|
||||
if _looks_like_domain(endpoint):
|
||||
return f"{endpoint}:{_DEFAULT_REMOTE_PORT}"
|
||||
return f"{endpoint}:{DEFAULT_REMOTE_PORT}"
|
||||
raise BrowserNotConnected(
|
||||
f"Invalid remote endpoint '{endpoint}': expected host:port"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user