browser-ctl 0.2.1__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/PKG-INFO +1 -1
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/browser_ctl/cli.py +45 -1
- browser_ctl-0.2.3/browser_ctl/extension/background.js +1253 -0
- browser_ctl-0.2.3/browser_ctl/extension/icon-128.png +0 -0
- browser_ctl-0.2.3/browser_ctl/extension/icon-16.png +0 -0
- browser_ctl-0.2.3/browser_ctl/extension/icon-32.png +0 -0
- browser_ctl-0.2.3/browser_ctl/extension/icon-48.png +0 -0
- browser_ctl-0.2.3/browser_ctl/extension/manifest.json +25 -0
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/browser_ctl.egg-info/PKG-INFO +1 -1
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/browser_ctl.egg-info/SOURCES.txt +7 -1
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/pyproject.toml +2 -2
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/LICENSE +0 -0
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/README.md +0 -0
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/browser_ctl/SKILL.md +0 -0
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/browser_ctl/__init__.py +0 -0
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/browser_ctl/__main__.py +0 -0
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/browser_ctl/client.py +0 -0
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/browser_ctl/server.py +0 -0
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/browser_ctl.egg-info/dependency_links.txt +0 -0
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/browser_ctl.egg-info/entry_points.txt +0 -0
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/browser_ctl.egg-info/requires.txt +0 -0
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/browser_ctl.egg-info/top_level.txt +0 -0
- {browser_ctl-0.2.1 → browser_ctl-0.2.3}/setup.cfg +0 -0
|
@@ -421,8 +421,18 @@ def handle_serve(args):
|
|
|
421
421
|
|
|
422
422
|
|
|
423
423
|
def _get_extension_source_dir() -> str | None:
|
|
424
|
-
"""Locate the extension source directory
|
|
424
|
+
"""Locate the extension source directory.
|
|
425
|
+
|
|
426
|
+
Looks in two places:
|
|
427
|
+
1. Inside the package (works for pip install)
|
|
428
|
+
2. Project root (works for editable/dev install)
|
|
429
|
+
"""
|
|
425
430
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
|
431
|
+
# 1. Bundled inside the package (pip install browser-ctl)
|
|
432
|
+
ext_dir = os.path.join(pkg_dir, "extension")
|
|
433
|
+
if os.path.isdir(ext_dir) and os.path.exists(os.path.join(ext_dir, "manifest.json")):
|
|
434
|
+
return ext_dir
|
|
435
|
+
# 2. Project root (pip install -e . / dev checkout)
|
|
426
436
|
project_root = os.path.dirname(pkg_dir)
|
|
427
437
|
ext_dir = os.path.join(project_root, "extension")
|
|
428
438
|
if os.path.isdir(ext_dir) and os.path.exists(os.path.join(ext_dir, "manifest.json")):
|
|
@@ -430,6 +440,28 @@ def _get_extension_source_dir() -> str | None:
|
|
|
430
440
|
return None
|
|
431
441
|
|
|
432
442
|
|
|
443
|
+
def _get_package_version() -> str:
|
|
444
|
+
"""Get the package version. Tries pyproject.toml first (dev), then importlib.metadata (pip)."""
|
|
445
|
+
# 1. Read from pyproject.toml (always up-to-date in source checkouts)
|
|
446
|
+
try:
|
|
447
|
+
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
|
448
|
+
toml_path = os.path.join(os.path.dirname(pkg_dir), "pyproject.toml")
|
|
449
|
+
if os.path.exists(toml_path):
|
|
450
|
+
with open(toml_path) as f:
|
|
451
|
+
for line in f:
|
|
452
|
+
if line.strip().startswith("version"):
|
|
453
|
+
return line.split("=", 1)[1].strip().strip('"').strip("'")
|
|
454
|
+
except Exception:
|
|
455
|
+
pass
|
|
456
|
+
# 2. importlib.metadata (works for pip-installed packages)
|
|
457
|
+
try:
|
|
458
|
+
from importlib.metadata import version
|
|
459
|
+
return version("browser-ctl")
|
|
460
|
+
except Exception:
|
|
461
|
+
pass
|
|
462
|
+
return "0.0.0"
|
|
463
|
+
|
|
464
|
+
|
|
433
465
|
def _install_extension() -> str | None:
|
|
434
466
|
"""Copy extension to ~/.browser-ctl/extension/ and try to open Chrome extensions page."""
|
|
435
467
|
src = _get_extension_source_dir()
|
|
@@ -441,6 +473,18 @@ def _install_extension() -> str | None:
|
|
|
441
473
|
shutil.rmtree(dest)
|
|
442
474
|
shutil.copytree(src, dest)
|
|
443
475
|
|
|
476
|
+
# Sync manifest.json version with the Python package version
|
|
477
|
+
manifest_path = os.path.join(dest, "manifest.json")
|
|
478
|
+
try:
|
|
479
|
+
with open(manifest_path, "r") as f:
|
|
480
|
+
manifest = json.load(f)
|
|
481
|
+
manifest["version"] = _get_package_version()
|
|
482
|
+
with open(manifest_path, "w") as f:
|
|
483
|
+
json.dump(manifest, f, indent=2)
|
|
484
|
+
f.write("\n")
|
|
485
|
+
except Exception:
|
|
486
|
+
pass # Non-fatal: extension still works with mismatched version
|
|
487
|
+
|
|
444
488
|
# Try to open Chrome extensions page
|
|
445
489
|
system = platform.system()
|
|
446
490
|
try:
|