modcdp 0.0.2__tar.gz → 0.0.4__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.
- modcdp-0.0.4/PKG-INFO +78 -0
- modcdp-0.0.4/README.md +69 -0
- {modcdp-0.0.2 → modcdp-0.0.4}/modcdp/ModCDPClient.py +6 -1
- modcdp-0.0.4/modcdp/extension.zip +0 -0
- {modcdp-0.0.2 → modcdp-0.0.4}/pyproject.toml +5 -1
- {modcdp-0.0.2 → modcdp-0.0.4}/uv.lock +1 -1
- modcdp-0.0.2/PKG-INFO +0 -12
- modcdp-0.0.2/README.md +0 -3
- {modcdp-0.0.2 → modcdp-0.0.4}/.gitignore +0 -0
- {modcdp-0.0.2 → modcdp-0.0.4}/demo.py +0 -0
- {modcdp-0.0.2 → modcdp-0.0.4}/modcdp/__init__.py +0 -0
- {modcdp-0.0.2 → modcdp-0.0.4}/modcdp/translate.py +0 -0
- {modcdp-0.0.2 → modcdp-0.0.4}/modcdp/types.py +0 -0
modcdp-0.0.4/PKG-INFO
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: modcdp
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: Python client for ModCDP.
|
|
5
|
+
Project-URL: Repository, https://github.com/pirate/ModCDP
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: websocket-client>=1.8.0
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
# ModCDP
|
|
11
|
+
|
|
12
|
+
ModCDP is a small Chrome DevTools Protocol client and extension bridge. It connects to Chrome over CDP, discovers or injects the ModCDP extension service worker, and routes normal CDP commands, custom commands, and custom events through the same client API.
|
|
13
|
+
|
|
14
|
+
This package contains the Python client. It mirrors the JavaScript and Go clients so SDKs can use the same option names and behavior across languages.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
pip install modcdp
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Basic Usage
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from modcdp import ModCDPClient
|
|
26
|
+
|
|
27
|
+
cdp = ModCDPClient().connect()
|
|
28
|
+
version = cdp.send("Browser.getVersion")
|
|
29
|
+
print(version)
|
|
30
|
+
cdp.close()
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
When no `cdp_url` is provided, the client can launch a local browser and load the bundled ModCDP extension. The package includes the extension zip used for automatic injection.
|
|
34
|
+
|
|
35
|
+
## Options
|
|
36
|
+
|
|
37
|
+
The Python constructor mirrors the JavaScript and Go clients:
|
|
38
|
+
|
|
39
|
+
- `cdp_url`: upstream CDP HTTP or websocket URL.
|
|
40
|
+
- `extension_path`: extension directory or zip. Defaults to the bundled extension zip.
|
|
41
|
+
- `routes`: client-side route map such as `{ "Mod.*": "service_worker", "*.*": "direct_cdp" }`.
|
|
42
|
+
- `server`: service-worker server config, including `loopback_cdp_url` and `routes`.
|
|
43
|
+
- `custom_commands`: custom commands registered during connect.
|
|
44
|
+
- `custom_events`: custom events registered during connect.
|
|
45
|
+
- `custom_middlewares`: custom request/response/event middleware registered during connect.
|
|
46
|
+
- `service_worker_url_includes` and `service_worker_url_suffixes`: service-worker discovery filters.
|
|
47
|
+
- `scan_for_existing_localhost_9222`: attach to localhost Chrome before launching a new browser.
|
|
48
|
+
- `mirror_upstream_events`: mirror upstream CDP events through the ModCDP service worker.
|
|
49
|
+
- `*_timeout_ms` and `*_interval_ms`: override CDP send, websocket connect, service-worker probe, event wait, and polling timings.
|
|
50
|
+
|
|
51
|
+
## Custom Commands And Events
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from modcdp import ModCDPClient
|
|
55
|
+
|
|
56
|
+
cdp = ModCDPClient(
|
|
57
|
+
custom_commands=[
|
|
58
|
+
{
|
|
59
|
+
"name": "Custom.echo",
|
|
60
|
+
"expression": "(params) => ({ value: params.value })",
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
custom_events=[
|
|
64
|
+
{
|
|
65
|
+
"name": "Custom.ready",
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
).connect()
|
|
69
|
+
|
|
70
|
+
print(cdp.send("Custom.echo", {"value": "hello"}))
|
|
71
|
+
cdp.close()
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Repository
|
|
75
|
+
|
|
76
|
+
Source, examples, JavaScript client, Go client, and extension implementation live at:
|
|
77
|
+
|
|
78
|
+
https://github.com/pirate/ModCDP
|
modcdp-0.0.4/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# ModCDP
|
|
2
|
+
|
|
3
|
+
ModCDP is a small Chrome DevTools Protocol client and extension bridge. It connects to Chrome over CDP, discovers or injects the ModCDP extension service worker, and routes normal CDP commands, custom commands, and custom events through the same client API.
|
|
4
|
+
|
|
5
|
+
This package contains the Python client. It mirrors the JavaScript and Go clients so SDKs can use the same option names and behavior across languages.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pip install modcdp
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Basic Usage
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from modcdp import ModCDPClient
|
|
17
|
+
|
|
18
|
+
cdp = ModCDPClient().connect()
|
|
19
|
+
version = cdp.send("Browser.getVersion")
|
|
20
|
+
print(version)
|
|
21
|
+
cdp.close()
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
When no `cdp_url` is provided, the client can launch a local browser and load the bundled ModCDP extension. The package includes the extension zip used for automatic injection.
|
|
25
|
+
|
|
26
|
+
## Options
|
|
27
|
+
|
|
28
|
+
The Python constructor mirrors the JavaScript and Go clients:
|
|
29
|
+
|
|
30
|
+
- `cdp_url`: upstream CDP HTTP or websocket URL.
|
|
31
|
+
- `extension_path`: extension directory or zip. Defaults to the bundled extension zip.
|
|
32
|
+
- `routes`: client-side route map such as `{ "Mod.*": "service_worker", "*.*": "direct_cdp" }`.
|
|
33
|
+
- `server`: service-worker server config, including `loopback_cdp_url` and `routes`.
|
|
34
|
+
- `custom_commands`: custom commands registered during connect.
|
|
35
|
+
- `custom_events`: custom events registered during connect.
|
|
36
|
+
- `custom_middlewares`: custom request/response/event middleware registered during connect.
|
|
37
|
+
- `service_worker_url_includes` and `service_worker_url_suffixes`: service-worker discovery filters.
|
|
38
|
+
- `scan_for_existing_localhost_9222`: attach to localhost Chrome before launching a new browser.
|
|
39
|
+
- `mirror_upstream_events`: mirror upstream CDP events through the ModCDP service worker.
|
|
40
|
+
- `*_timeout_ms` and `*_interval_ms`: override CDP send, websocket connect, service-worker probe, event wait, and polling timings.
|
|
41
|
+
|
|
42
|
+
## Custom Commands And Events
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from modcdp import ModCDPClient
|
|
46
|
+
|
|
47
|
+
cdp = ModCDPClient(
|
|
48
|
+
custom_commands=[
|
|
49
|
+
{
|
|
50
|
+
"name": "Custom.echo",
|
|
51
|
+
"expression": "(params) => ({ value: params.value })",
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
custom_events=[
|
|
55
|
+
{
|
|
56
|
+
"name": "Custom.ready",
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
).connect()
|
|
60
|
+
|
|
61
|
+
print(cdp.send("Custom.echo", {"value": "hello"}))
|
|
62
|
+
cdp.close()
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Repository
|
|
66
|
+
|
|
67
|
+
Source, examples, JavaScript client, Go client, and extension implementation live at:
|
|
68
|
+
|
|
69
|
+
https://github.com/pirate/ModCDP
|
|
@@ -165,6 +165,11 @@ def _json_object(value: JsonValue | None) -> ProtocolResult:
|
|
|
165
165
|
return value if isinstance(value, dict) else {}
|
|
166
166
|
|
|
167
167
|
|
|
168
|
+
def default_extension_path() -> str | None:
|
|
169
|
+
bundled_extension = Path(__file__).resolve().parent / "extension.zip"
|
|
170
|
+
return str(bundled_extension) if bundled_extension.exists() else None
|
|
171
|
+
|
|
172
|
+
|
|
168
173
|
def modcdp_server_path(extension_path: str) -> Path:
|
|
169
174
|
candidates = [Path(extension_path) / "ModCDPServer.js"]
|
|
170
175
|
for parent in Path(__file__).resolve().parents:
|
|
@@ -224,7 +229,7 @@ class ModCDPClient:
|
|
|
224
229
|
launch_options: LaunchOptions | None = None,
|
|
225
230
|
) -> None:
|
|
226
231
|
self.cdp_url: str | None = cdp_url
|
|
227
|
-
self.extension_path: str | None = extension_path
|
|
232
|
+
self.extension_path: str | None = extension_path or default_extension_path()
|
|
228
233
|
self.routes: ModCDPRoutes = {**DEFAULT_CLIENT_ROUTES, **dict(routes or {})}
|
|
229
234
|
if server is DEFAULT_SERVER:
|
|
230
235
|
self.server: ModCDPServerConfig | None = {}
|
|
Binary file
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "modcdp"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.4"
|
|
8
8
|
description = "Python client for ModCDP."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -15,6 +15,10 @@ Repository = "https://github.com/pirate/ModCDP"
|
|
|
15
15
|
|
|
16
16
|
[tool.hatch.build.targets.wheel]
|
|
17
17
|
packages = ["modcdp"]
|
|
18
|
+
artifacts = ["modcdp/extension.zip"]
|
|
19
|
+
|
|
20
|
+
[tool.hatch.build.targets.sdist]
|
|
21
|
+
artifacts = ["modcdp/extension.zip"]
|
|
18
22
|
|
|
19
23
|
[dependency-groups]
|
|
20
24
|
dev = [
|
modcdp-0.0.2/PKG-INFO
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: modcdp
|
|
3
|
-
Version: 0.0.2
|
|
4
|
-
Summary: Python client for ModCDP.
|
|
5
|
-
Project-URL: Repository, https://github.com/pirate/ModCDP
|
|
6
|
-
Requires-Python: >=3.10
|
|
7
|
-
Requires-Dist: websocket-client>=1.8.0
|
|
8
|
-
Description-Content-Type: text/markdown
|
|
9
|
-
|
|
10
|
-
# ModCDP Python Client
|
|
11
|
-
|
|
12
|
-
Python client for ModCDP.
|
modcdp-0.0.2/README.md
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|