076914e5b7
- 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.
27 lines
1.0 KiB
Python
27 lines
1.0 KiB
Python
"""Windows namespace: ``b.windows.*``."""
|
|
from __future__ import annotations
|
|
|
|
from browser_cli.sdk.base import Namespace, sdk_command
|
|
|
|
class WindowsNS(Namespace):
|
|
"""List, open, close, and rename browser windows."""
|
|
|
|
def list(self) -> list[dict]:
|
|
"""Return browser windows.
|
|
|
|
In implicit multi-browser mode each window dict includes a ``browser`` key.
|
|
"""
|
|
return self.multi_list("windows.list", {}, self.tag_browser)
|
|
|
|
@sdk_command("windows.open", lambda self, url=None: {"url": url}, default={})
|
|
def open(self, url: str | None = None) -> dict:
|
|
"""Open a new browser window, optionally on a URL."""
|
|
|
|
@sdk_command("windows.close", lambda self, window_id: {"windowId": window_id}, return_result=False)
|
|
def close(self, window_id: int) -> None:
|
|
"""Close a browser window by ID."""
|
|
|
|
@sdk_command("windows.rename", lambda self, window_id, name: {"windowId": window_id, "name": name}, return_result=False)
|
|
def rename(self, window_id: int, name: str) -> None:
|
|
"""Rename a browser window."""
|