chromedeveloperprotocol-client 0.1.0__py3-none-any.whl
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.
- cdp/__init__.py +4 -0
- cdp/domains.py +582 -0
- cdp/generator/__init__.py +3 -0
- cdp/generator/client_generator.py +246 -0
- cdp/generator/constant.py +4 -0
- cdp/generator/domain_generator.py +149 -0
- cdp/generator/event_generator.py +202 -0
- cdp/generator/method_generator.py +215 -0
- cdp/generator/service.py +153 -0
- cdp/generator/type_generator.py +231 -0
- cdp/protocol/__init__.py +0 -0
- cdp/protocol/accessibility/__init__.py +0 -0
- cdp/protocol/accessibility/events/__init__.py +0 -0
- cdp/protocol/accessibility/events/service.py +37 -0
- cdp/protocol/accessibility/events/types.py +14 -0
- cdp/protocol/accessibility/methods/__init__.py +0 -0
- cdp/protocol/accessibility/methods/service.py +109 -0
- cdp/protocol/accessibility/methods/types.py +70 -0
- cdp/protocol/accessibility/service.py +21 -0
- cdp/protocol/accessibility/types.py +89 -0
- cdp/protocol/animation/__init__.py +0 -0
- cdp/protocol/animation/events/__init__.py +0 -0
- cdp/protocol/animation/events/service.py +53 -0
- cdp/protocol/animation/events/types.py +20 -0
- cdp/protocol/animation/methods/__init__.py +0 -0
- cdp/protocol/animation/methods/service.py +131 -0
- cdp/protocol/animation/methods/types.py +52 -0
- cdp/protocol/animation/service.py +21 -0
- cdp/protocol/animation/types.py +79 -0
- cdp/protocol/audits/__init__.py +0 -0
- cdp/protocol/audits/events/__init__.py +0 -0
- cdp/protocol/audits/events/service.py +29 -0
- cdp/protocol/audits/events/types.py +10 -0
- cdp/protocol/audits/methods/__init__.py +0 -0
- cdp/protocol/audits/methods/service.py +76 -0
- cdp/protocol/audits/methods/types.py +36 -0
- cdp/protocol/audits/service.py +21 -0
- cdp/protocol/audits/types.py +293 -0
- cdp/protocol/autofill/__init__.py +0 -0
- cdp/protocol/autofill/events/__init__.py +0 -0
- cdp/protocol/autofill/events/service.py +29 -0
- cdp/protocol/autofill/events/types.py +14 -0
- cdp/protocol/autofill/methods/__init__.py +0 -0
- cdp/protocol/autofill/methods/service.py +65 -0
- cdp/protocol/autofill/methods/types.py +22 -0
- cdp/protocol/autofill/service.py +21 -0
- cdp/protocol/autofill/types.py +54 -0
- cdp/protocol/background_service/__init__.py +0 -0
- cdp/protocol/background_service/events/__init__.py +0 -0
- cdp/protocol/background_service/events/service.py +37 -0
- cdp/protocol/background_service/events/types.py +14 -0
- cdp/protocol/background_service/methods/__init__.py +0 -0
- cdp/protocol/background_service/methods/service.py +65 -0
- cdp/protocol/background_service/methods/types.py +17 -0
- cdp/protocol/background_service/service.py +21 -0
- cdp/protocol/background_service/types.py +32 -0
- cdp/protocol/bluetooth_emulation/__init__.py +0 -0
- cdp/protocol/bluetooth_emulation/events/__init__.py +0 -0
- cdp/protocol/bluetooth_emulation/events/service.py +45 -0
- cdp/protocol/bluetooth_emulation/events/types.py +23 -0
- cdp/protocol/bluetooth_emulation/methods/__init__.py +0 -0
- cdp/protocol/bluetooth_emulation/methods/service.py +186 -0
- cdp/protocol/bluetooth_emulation/methods/types.py +81 -0
- cdp/protocol/bluetooth_emulation/service.py +21 -0
- cdp/protocol/bluetooth_emulation/types.py +45 -0
- cdp/protocol/browser/__init__.py +0 -0
- cdp/protocol/browser/events/__init__.py +0 -0
- cdp/protocol/browser/events/service.py +37 -0
- cdp/protocol/browser/events/types.py +28 -0
- cdp/protocol/browser/methods/__init__.py +0 -0
- cdp/protocol/browser/methods/service.py +230 -0
- cdp/protocol/browser/methods/types.py +126 -0
- cdp/protocol/browser/service.py +21 -0
- cdp/protocol/browser/types.py +57 -0
- cdp/protocol/cache_storage/__init__.py +0 -0
- cdp/protocol/cache_storage/events/__init__.py +0 -0
- cdp/protocol/cache_storage/events/service.py +20 -0
- cdp/protocol/cache_storage/events/types.py +3 -0
- cdp/protocol/cache_storage/methods/__init__.py +0 -0
- cdp/protocol/cache_storage/methods/service.py +76 -0
- cdp/protocol/cache_storage/methods/types.py +57 -0
- cdp/protocol/cache_storage/service.py +21 -0
- cdp/protocol/cache_storage/types.py +49 -0
- cdp/protocol/cast/__init__.py +0 -0
- cdp/protocol/cast/events/__init__.py +0 -0
- cdp/protocol/cast/events/service.py +37 -0
- cdp/protocol/cast/events/types.py +12 -0
- cdp/protocol/cast/methods/__init__.py +0 -0
- cdp/protocol/cast/methods/service.py +87 -0
- cdp/protocol/cast/methods/types.py +15 -0
- cdp/protocol/cast/service.py +21 -0
- cdp/protocol/cast/types.py +9 -0
- cdp/protocol/css/__init__.py +0 -0
- cdp/protocol/css/events/__init__.py +0 -0
- cdp/protocol/css/events/service.py +69 -0
- cdp/protocol/css/events/types.py +27 -0
- cdp/protocol/css/methods/__init__.py +0 -0
- cdp/protocol/css/methods/service.py +428 -0
- cdp/protocol/css/methods/types.py +278 -0
- cdp/protocol/css/service.py +21 -0
- cdp/protocol/css/types.py +451 -0
- cdp/protocol/debugger/__init__.py +0 -0
- cdp/protocol/debugger/events/__init__.py +0 -0
- cdp/protocol/debugger/events/service.py +53 -0
- cdp/protocol/debugger/events/types.py +112 -0
- cdp/protocol/debugger/methods/__init__.py +0 -0
- cdp/protocol/debugger/methods/service.py +362 -0
- cdp/protocol/debugger/methods/types.py +250 -0
- cdp/protocol/debugger/service.py +21 -0
- cdp/protocol/debugger/types.py +91 -0
- cdp/protocol/device_access/__init__.py +0 -0
- cdp/protocol/device_access/events/__init__.py +0 -0
- cdp/protocol/device_access/events/service.py +29 -0
- cdp/protocol/device_access/events/types.py +12 -0
- cdp/protocol/device_access/methods/__init__.py +0 -0
- cdp/protocol/device_access/methods/service.py +65 -0
- cdp/protocol/device_access/methods/types.py +16 -0
- cdp/protocol/device_access/service.py +21 -0
- cdp/protocol/device_access/types.py +13 -0
- cdp/protocol/device_orientation/__init__.py +0 -0
- cdp/protocol/device_orientation/events/__init__.py +0 -0
- cdp/protocol/device_orientation/events/service.py +20 -0
- cdp/protocol/device_orientation/events/types.py +3 -0
- cdp/protocol/device_orientation/methods/__init__.py +0 -0
- cdp/protocol/device_orientation/methods/service.py +43 -0
- cdp/protocol/device_orientation/methods/types.py +12 -0
- cdp/protocol/device_orientation/service.py +21 -0
- cdp/protocol/device_orientation/types.py +3 -0
- cdp/protocol/dom/__init__.py +0 -0
- cdp/protocol/dom/events/__init__.py +0 -0
- cdp/protocol/dom/events/service.py +165 -0
- cdp/protocol/dom/events/types.py +97 -0
- cdp/protocol/dom/methods/__init__.py +0 -0
- cdp/protocol/dom/methods/service.py +593 -0
- cdp/protocol/dom/methods/types.py +384 -0
- cdp/protocol/dom/service.py +21 -0
- cdp/protocol/dom/types.py +151 -0
- cdp/protocol/dom_debugger/__init__.py +0 -0
- cdp/protocol/dom_debugger/events/__init__.py +0 -0
- cdp/protocol/dom_debugger/events/service.py +20 -0
- cdp/protocol/dom_debugger/events/types.py +3 -0
- cdp/protocol/dom_debugger/methods/__init__.py +0 -0
- cdp/protocol/dom_debugger/methods/service.py +109 -0
- cdp/protocol/dom_debugger/methods/types.py +51 -0
- cdp/protocol/dom_debugger/service.py +21 -0
- cdp/protocol/dom_debugger/types.py +36 -0
- cdp/protocol/dom_snapshot/__init__.py +0 -0
- cdp/protocol/dom_snapshot/events/__init__.py +0 -0
- cdp/protocol/dom_snapshot/events/service.py +20 -0
- cdp/protocol/dom_snapshot/events/types.py +3 -0
- cdp/protocol/dom_snapshot/methods/__init__.py +0 -0
- cdp/protocol/dom_snapshot/methods/service.py +54 -0
- cdp/protocol/dom_snapshot/methods/types.py +28 -0
- cdp/protocol/dom_snapshot/service.py +21 -0
- cdp/protocol/dom_snapshot/types.py +220 -0
- cdp/protocol/dom_storage/__init__.py +0 -0
- cdp/protocol/dom_storage/events/__init__.py +0 -0
- cdp/protocol/dom_storage/events/service.py +53 -0
- cdp/protocol/dom_storage/events/types.py +22 -0
- cdp/protocol/dom_storage/methods/__init__.py +0 -0
- cdp/protocol/dom_storage/methods/service.py +87 -0
- cdp/protocol/dom_storage/methods/types.py +27 -0
- cdp/protocol/dom_storage/service.py +21 -0
- cdp/protocol/dom_storage/types.py +15 -0
- cdp/protocol/emulation/__init__.py +0 -0
- cdp/protocol/emulation/events/__init__.py +0 -0
- cdp/protocol/emulation/events/service.py +29 -0
- cdp/protocol/emulation/events/types.py +6 -0
- cdp/protocol/emulation/methods/__init__.py +0 -0
- cdp/protocol/emulation/methods/service.py +494 -0
- cdp/protocol/emulation/methods/types.py +261 -0
- cdp/protocol/emulation/service.py +21 -0
- cdp/protocol/emulation/types.py +132 -0
- cdp/protocol/event_breakpoints/__init__.py +0 -0
- cdp/protocol/event_breakpoints/events/__init__.py +0 -0
- cdp/protocol/event_breakpoints/events/service.py +20 -0
- cdp/protocol/event_breakpoints/events/types.py +3 -0
- cdp/protocol/event_breakpoints/methods/__init__.py +0 -0
- cdp/protocol/event_breakpoints/methods/service.py +54 -0
- cdp/protocol/event_breakpoints/methods/types.py +10 -0
- cdp/protocol/event_breakpoints/service.py +21 -0
- cdp/protocol/event_breakpoints/types.py +3 -0
- cdp/protocol/extensions/__init__.py +0 -0
- cdp/protocol/extensions/events/__init__.py +0 -0
- cdp/protocol/extensions/events/service.py +20 -0
- cdp/protocol/extensions/events/types.py +3 -0
- cdp/protocol/extensions/methods/__init__.py +0 -0
- cdp/protocol/extensions/methods/service.py +87 -0
- cdp/protocol/extensions/methods/types.py +46 -0
- cdp/protocol/extensions/service.py +21 -0
- cdp/protocol/extensions/types.py +6 -0
- cdp/protocol/fed_cm/__init__.py +0 -0
- cdp/protocol/fed_cm/events/__init__.py +0 -0
- cdp/protocol/fed_cm/events/service.py +37 -0
- cdp/protocol/fed_cm/events/types.py +18 -0
- cdp/protocol/fed_cm/methods/__init__.py +0 -0
- cdp/protocol/fed_cm/methods/service.py +98 -0
- cdp/protocol/fed_cm/methods/types.py +26 -0
- cdp/protocol/fed_cm/service.py +21 -0
- cdp/protocol/fed_cm/types.py +25 -0
- cdp/protocol/fetch/__init__.py +0 -0
- cdp/protocol/fetch/events/__init__.py +0 -0
- cdp/protocol/fetch/events/service.py +37 -0
- cdp/protocol/fetch/events/types.py +47 -0
- cdp/protocol/fetch/methods/__init__.py +0 -0
- cdp/protocol/fetch/methods/service.py +120 -0
- cdp/protocol/fetch/methods/types.py +85 -0
- cdp/protocol/fetch/service.py +21 -0
- cdp/protocol/fetch/types.py +41 -0
- cdp/protocol/file_system/__init__.py +0 -0
- cdp/protocol/file_system/events/__init__.py +0 -0
- cdp/protocol/file_system/events/service.py +20 -0
- cdp/protocol/file_system/events/types.py +3 -0
- cdp/protocol/file_system/methods/__init__.py +0 -0
- cdp/protocol/file_system/methods/service.py +32 -0
- cdp/protocol/file_system/methods/types.py +14 -0
- cdp/protocol/file_system/service.py +21 -0
- cdp/protocol/file_system/types.py +28 -0
- cdp/protocol/headless_experimental/__init__.py +0 -0
- cdp/protocol/headless_experimental/events/__init__.py +0 -0
- cdp/protocol/headless_experimental/events/service.py +20 -0
- cdp/protocol/headless_experimental/events/types.py +3 -0
- cdp/protocol/headless_experimental/methods/__init__.py +0 -0
- cdp/protocol/headless_experimental/methods/service.py +32 -0
- cdp/protocol/headless_experimental/methods/types.py +22 -0
- cdp/protocol/headless_experimental/service.py +21 -0
- cdp/protocol/headless_experimental/types.py +12 -0
- cdp/protocol/heap_profiler/__init__.py +0 -0
- cdp/protocol/heap_profiler/events/__init__.py +0 -0
- cdp/protocol/heap_profiler/events/service.py +61 -0
- cdp/protocol/heap_profiler/events/types.py +18 -0
- cdp/protocol/heap_profiler/methods/__init__.py +0 -0
- cdp/protocol/heap_profiler/methods/service.py +153 -0
- cdp/protocol/heap_profiler/methods/types.py +73 -0
- cdp/protocol/heap_profiler/service.py +21 -0
- cdp/protocol/heap_profiler/types.py +32 -0
- cdp/protocol/indexed_db/__init__.py +0 -0
- cdp/protocol/indexed_db/events/__init__.py +0 -0
- cdp/protocol/indexed_db/events/service.py +20 -0
- cdp/protocol/indexed_db/events/types.py +3 -0
- cdp/protocol/indexed_db/methods/__init__.py +0 -0
- cdp/protocol/indexed_db/methods/service.py +120 -0
- cdp/protocol/indexed_db/methods/types.py +111 -0
- cdp/protocol/indexed_db/service.py +21 -0
- cdp/protocol/indexed_db/types.py +74 -0
- cdp/protocol/input/__init__.py +0 -0
- cdp/protocol/input/events/__init__.py +0 -0
- cdp/protocol/input/events/service.py +29 -0
- cdp/protocol/input/events/types.py +10 -0
- cdp/protocol/input/methods/__init__.py +0 -0
- cdp/protocol/input/methods/service.py +164 -0
- cdp/protocol/input/methods/types.py +181 -0
- cdp/protocol/input/service.py +21 -0
- cdp/protocol/input/types.py +46 -0
- cdp/protocol/inspector/__init__.py +0 -0
- cdp/protocol/inspector/events/__init__.py +0 -0
- cdp/protocol/inspector/events/service.py +53 -0
- cdp/protocol/inspector/events/types.py +13 -0
- cdp/protocol/inspector/methods/__init__.py +0 -0
- cdp/protocol/inspector/methods/service.py +43 -0
- cdp/protocol/inspector/methods/types.py +3 -0
- cdp/protocol/inspector/service.py +21 -0
- cdp/protocol/inspector/types.py +3 -0
- cdp/protocol/io/__init__.py +0 -0
- cdp/protocol/io/events/__init__.py +0 -0
- cdp/protocol/io/events/service.py +20 -0
- cdp/protocol/io/events/types.py +3 -0
- cdp/protocol/io/methods/__init__.py +0 -0
- cdp/protocol/io/methods/service.py +54 -0
- cdp/protocol/io/methods/types.py +33 -0
- cdp/protocol/io/service.py +21 -0
- cdp/protocol/io/types.py +6 -0
- cdp/protocol/layer_tree/__init__.py +0 -0
- cdp/protocol/layer_tree/events/__init__.py +0 -0
- cdp/protocol/layer_tree/events/service.py +37 -0
- cdp/protocol/layer_tree/events/types.py +18 -0
- cdp/protocol/layer_tree/methods/__init__.py +0 -0
- cdp/protocol/layer_tree/methods/service.py +120 -0
- cdp/protocol/layer_tree/methods/types.py +70 -0
- cdp/protocol/layer_tree/service.py +21 -0
- cdp/protocol/layer_tree/types.py +73 -0
- cdp/protocol/log/__init__.py +0 -0
- cdp/protocol/log/events/__init__.py +0 -0
- cdp/protocol/log/events/service.py +29 -0
- cdp/protocol/log/events/types.py +11 -0
- cdp/protocol/log/methods/__init__.py +0 -0
- cdp/protocol/log/methods/service.py +76 -0
- cdp/protocol/log/methods/types.py +14 -0
- cdp/protocol/log/service.py +21 -0
- cdp/protocol/log/types.py +40 -0
- cdp/protocol/media/__init__.py +0 -0
- cdp/protocol/media/events/__init__.py +0 -0
- cdp/protocol/media/events/service.py +61 -0
- cdp/protocol/media/events/types.py +27 -0
- cdp/protocol/media/methods/__init__.py +0 -0
- cdp/protocol/media/methods/service.py +43 -0
- cdp/protocol/media/methods/types.py +3 -0
- cdp/protocol/media/service.py +21 -0
- cdp/protocol/media/types.py +42 -0
- cdp/protocol/memory/__init__.py +0 -0
- cdp/protocol/memory/events/__init__.py +0 -0
- cdp/protocol/memory/events/service.py +20 -0
- cdp/protocol/memory/events/types.py +3 -0
- cdp/protocol/memory/methods/__init__.py +0 -0
- cdp/protocol/memory/methods/service.py +142 -0
- cdp/protocol/memory/methods/types.py +48 -0
- cdp/protocol/memory/service.py +21 -0
- cdp/protocol/memory/types.py +34 -0
- cdp/protocol/network/__init__.py +0 -0
- cdp/protocol/network/events/__init__.py +0 -0
- cdp/protocol/network/events/service.py +365 -0
- cdp/protocol/network/events/types.py +360 -0
- cdp/protocol/network/methods/__init__.py +0 -0
- cdp/protocol/network/methods/service.py +384 -0
- cdp/protocol/network/methods/types.py +252 -0
- cdp/protocol/network/service.py +21 -0
- cdp/protocol/network/types.py +691 -0
- cdp/protocol/overlay/__init__.py +0 -0
- cdp/protocol/overlay/events/__init__.py +0 -0
- cdp/protocol/overlay/events/service.py +53 -0
- cdp/protocol/overlay/events/types.py +20 -0
- cdp/protocol/overlay/methods/__init__.py +0 -0
- cdp/protocol/overlay/methods/service.py +307 -0
- cdp/protocol/overlay/methods/types.py +144 -0
- cdp/protocol/overlay/service.py +21 -0
- cdp/protocol/overlay/types.py +198 -0
- cdp/protocol/page/__init__.py +0 -0
- cdp/protocol/page/events/__init__.py +0 -0
- cdp/protocol/page/events/service.py +213 -0
- cdp/protocol/page/events/types.py +147 -0
- cdp/protocol/page/methods/__init__.py +0 -0
- cdp/protocol/page/methods/service.py +560 -0
- cdp/protocol/page/methods/types.py +346 -0
- cdp/protocol/page/service.py +21 -0
- cdp/protocol/page/types.py +379 -0
- cdp/protocol/performance/__init__.py +0 -0
- cdp/protocol/performance/events/__init__.py +0 -0
- cdp/protocol/performance/events/service.py +29 -0
- cdp/protocol/performance/events/types.py +13 -0
- cdp/protocol/performance/methods/__init__.py +0 -0
- cdp/protocol/performance/methods/service.py +54 -0
- cdp/protocol/performance/methods/types.py +18 -0
- cdp/protocol/performance/service.py +21 -0
- cdp/protocol/performance/types.py +10 -0
- cdp/protocol/performance_timeline/__init__.py +0 -0
- cdp/protocol/performance_timeline/events/__init__.py +0 -0
- cdp/protocol/performance_timeline/events/service.py +29 -0
- cdp/protocol/performance_timeline/events/types.py +10 -0
- cdp/protocol/performance_timeline/methods/__init__.py +0 -0
- cdp/protocol/performance_timeline/methods/service.py +32 -0
- cdp/protocol/performance_timeline/methods/types.py +7 -0
- cdp/protocol/performance_timeline/service.py +21 -0
- cdp/protocol/performance_timeline/types.py +46 -0
- cdp/protocol/preload/__init__.py +0 -0
- cdp/protocol/preload/events/__init__.py +0 -0
- cdp/protocol/preload/events/service.py +69 -0
- cdp/protocol/preload/events/types.py +49 -0
- cdp/protocol/preload/methods/__init__.py +0 -0
- cdp/protocol/preload/methods/service.py +43 -0
- cdp/protocol/preload/methods/types.py +3 -0
- cdp/protocol/preload/service.py +21 -0
- cdp/protocol/preload/types.py +56 -0
- cdp/protocol/profiler/__init__.py +0 -0
- cdp/protocol/profiler/events/__init__.py +0 -0
- cdp/protocol/profiler/events/service.py +45 -0
- cdp/protocol/profiler/events/types.py +30 -0
- cdp/protocol/profiler/methods/__init__.py +0 -0
- cdp/protocol/profiler/methods/service.py +120 -0
- cdp/protocol/profiler/methods/types.py +45 -0
- cdp/protocol/profiler/service.py +21 -0
- cdp/protocol/profiler/types.py +65 -0
- cdp/protocol/pwa/__init__.py +0 -0
- cdp/protocol/pwa/events/__init__.py +0 -0
- cdp/protocol/pwa/events/service.py +20 -0
- cdp/protocol/pwa/events/types.py +3 -0
- cdp/protocol/pwa/methods/__init__.py +0 -0
- cdp/protocol/pwa/methods/service.py +98 -0
- cdp/protocol/pwa/methods/types.py +43 -0
- cdp/protocol/pwa/service.py +21 -0
- cdp/protocol/pwa/types.py +15 -0
- cdp/protocol/py.typed +0 -0
- cdp/protocol/runtime/__init__.py +0 -0
- cdp/protocol/runtime/events/__init__.py +0 -0
- cdp/protocol/runtime/events/service.py +85 -0
- cdp/protocol/runtime/events/types.py +55 -0
- cdp/protocol/runtime/methods/__init__.py +0 -0
- cdp/protocol/runtime/methods/service.py +274 -0
- cdp/protocol/runtime/methods/types.py +226 -0
- cdp/protocol/runtime/service.py +21 -0
- cdp/protocol/runtime/types.py +194 -0
- cdp/protocol/security/__init__.py +0 -0
- cdp/protocol/security/events/__init__.py +0 -0
- cdp/protocol/security/events/service.py +29 -0
- cdp/protocol/security/events/types.py +11 -0
- cdp/protocol/security/methods/__init__.py +0 -0
- cdp/protocol/security/methods/service.py +54 -0
- cdp/protocol/security/methods/types.py +9 -0
- cdp/protocol/security/service.py +21 -0
- cdp/protocol/security/types.py +102 -0
- cdp/protocol/service_worker/__init__.py +0 -0
- cdp/protocol/service_worker/events/__init__.py +0 -0
- cdp/protocol/service_worker/events/service.py +45 -0
- cdp/protocol/service_worker/events/types.py +16 -0
- cdp/protocol/service_worker/methods/__init__.py +0 -0
- cdp/protocol/service_worker/methods/service.py +153 -0
- cdp/protocol/service_worker/methods/types.py +36 -0
- cdp/protocol/service_worker/service.py +21 -0
- cdp/protocol/service_worker/types.py +38 -0
- cdp/protocol/storage/__init__.py +0 -0
- cdp/protocol/storage/events/__init__.py +0 -0
- cdp/protocol/storage/events/service.py +141 -0
- cdp/protocol/storage/events/types.py +139 -0
- cdp/protocol/storage/methods/__init__.py +0 -0
- cdp/protocol/storage/methods/service.py +428 -0
- cdp/protocol/storage/methods/types.py +184 -0
- cdp/protocol/storage/service.py +21 -0
- cdp/protocol/storage/types.py +236 -0
- cdp/protocol/system_info/__init__.py +0 -0
- cdp/protocol/system_info/events/__init__.py +0 -0
- cdp/protocol/system_info/events/service.py +20 -0
- cdp/protocol/system_info/events/types.py +3 -0
- cdp/protocol/system_info/methods/__init__.py +0 -0
- cdp/protocol/system_info/methods/service.py +54 -0
- cdp/protocol/system_info/methods/types.py +27 -0
- cdp/protocol/system_info/service.py +21 -0
- cdp/protocol/system_info/types.py +71 -0
- cdp/protocol/target/__init__.py +0 -0
- cdp/protocol/target/events/__init__.py +0 -0
- cdp/protocol/target/events/service.py +77 -0
- cdp/protocol/target/events/types.py +38 -0
- cdp/protocol/target/methods/__init__.py +0 -0
- cdp/protocol/target/methods/service.py +219 -0
- cdp/protocol/target/methods/types.py +148 -0
- cdp/protocol/target/service.py +21 -0
- cdp/protocol/target/types.py +44 -0
- cdp/protocol/tethering/__init__.py +0 -0
- cdp/protocol/tethering/events/__init__.py +0 -0
- cdp/protocol/tethering/events/service.py +29 -0
- cdp/protocol/tethering/events/types.py +9 -0
- cdp/protocol/tethering/methods/__init__.py +0 -0
- cdp/protocol/tethering/methods/service.py +43 -0
- cdp/protocol/tethering/methods/types.py +10 -0
- cdp/protocol/tethering/service.py +21 -0
- cdp/protocol/tethering/types.py +3 -0
- cdp/protocol/tracing/__init__.py +0 -0
- cdp/protocol/tracing/events/__init__.py +0 -0
- cdp/protocol/tracing/events/service.py +45 -0
- cdp/protocol/tracing/events/types.py +28 -0
- cdp/protocol/tracing/methods/__init__.py +0 -0
- cdp/protocol/tracing/methods/service.py +87 -0
- cdp/protocol/tracing/methods/types.py +54 -0
- cdp/protocol/tracing/service.py +21 -0
- cdp/protocol/tracing/types.py +34 -0
- cdp/protocol/web_audio/__init__.py +0 -0
- cdp/protocol/web_audio/events/__init__.py +0 -0
- cdp/protocol/web_audio/events/service.py +125 -0
- cdp/protocol/web_audio/events/types.py +56 -0
- cdp/protocol/web_audio/methods/__init__.py +0 -0
- cdp/protocol/web_audio/methods/service.py +54 -0
- cdp/protocol/web_audio/methods/types.py +17 -0
- cdp/protocol/web_audio/service.py +21 -0
- cdp/protocol/web_audio/types.py +66 -0
- cdp/protocol/web_authn/__init__.py +0 -0
- cdp/protocol/web_authn/events/__init__.py +0 -0
- cdp/protocol/web_authn/events/service.py +53 -0
- cdp/protocol/web_authn/events/types.py +21 -0
- cdp/protocol/web_authn/methods/__init__.py +0 -0
- cdp/protocol/web_authn/methods/service.py +164 -0
- cdp/protocol/web_authn/methods/types.py +61 -0
- cdp/protocol/web_authn/service.py +21 -0
- cdp/protocol/web_authn/types.py +54 -0
- cdp/py.typed +0 -0
- cdp/service.py +184 -0
- chromedeveloperprotocol_client-0.1.0.dist-info/METADATA +15 -0
- chromedeveloperprotocol_client-0.1.0.dist-info/RECORD +476 -0
- chromedeveloperprotocol_client-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
from jinja2_strcase import StrcaseExtension
|
|
2
|
+
from jinja2 import Environment
|
|
3
|
+
import inflection
|
|
4
|
+
|
|
5
|
+
METHOD_IMPLEMENTATION_TEMPLATE = """\
|
|
6
|
+
async def {{ method_name | to_snake }}(self, params: {% if parameters|length > 0 %}Optional[{{ method_name }}Parameters]{% else %}None{% endif %}=None,session_id: Optional[str] = None) -> {% if return_parameters|length > 0 %}{{ method_name }}Returns{% else %}Dict[str, Any]{% endif %}:
|
|
7
|
+
\"\"\"
|
|
8
|
+
{% if method_description %}{{ method_description | replace("\\n", " ") }}{% else %}No description available for {{ method_name }}.{% endif %}
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
params ({% if parameters|length > 0 %}{{ method_name }}Parameters{% else %}None{% endif %}, optional): Parameters for the {{ method_name }} method.
|
|
12
|
+
session_id (str, optional): Target session ID for flat protocol usage.
|
|
13
|
+
|
|
14
|
+
Returns:
|
|
15
|
+
{% if return_parameters|length > 0 %}{{ method_name }}Returns{% else %}Dict[str, Any]{% endif %}: The result of the {{ method_name }} call.
|
|
16
|
+
\"\"\"
|
|
17
|
+
return await self.client.send(method="{{ domain_name }}.{{ method_name }}", params=params,session_id=session_id)
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
METHOD_TYPES_TEMPLATE = """\
|
|
21
|
+
\"\"\"CDP {{ domain_name }} Methods Types\"\"\"
|
|
22
|
+
|
|
23
|
+
{% for import_ in imports %}
|
|
24
|
+
{{ import_ }}
|
|
25
|
+
{% endfor %}
|
|
26
|
+
{% if type_checking_imports %}
|
|
27
|
+
|
|
28
|
+
from typing import TYPE_CHECKING
|
|
29
|
+
if TYPE_CHECKING:
|
|
30
|
+
{% for type_checking_import in type_checking_imports %}
|
|
31
|
+
{{ type_checking_import }}
|
|
32
|
+
{% endfor %}
|
|
33
|
+
{% endif %}
|
|
34
|
+
|
|
35
|
+
{% for definition in parameter_definitions_code %}
|
|
36
|
+
{{ definition }}
|
|
37
|
+
{% endfor %}
|
|
38
|
+
{% for definition in return_definitions_code %}
|
|
39
|
+
{{ definition }}
|
|
40
|
+
{% endfor %}
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
PARAMETER_DEFINITION_TEMPLATE = """\
|
|
44
|
+
class {{ method_name }}Parameters(TypedDict, total={{ total }}):
|
|
45
|
+
{% if not required_parameters and not optional_parameters %}
|
|
46
|
+
pass
|
|
47
|
+
{% else %}
|
|
48
|
+
{% if required_parameters %}
|
|
49
|
+
{% for parameter in required_parameters %}
|
|
50
|
+
{{ parameter['name'] }}: '{{ parameter['type'] }}'
|
|
51
|
+
{% if parameter['description'] %}
|
|
52
|
+
\"\"\"{{ parameter['description'] | replace('\\n', ' ') | replace('`', '') }}\"\"\"
|
|
53
|
+
{% endif %}
|
|
54
|
+
{% endfor %}
|
|
55
|
+
{% endif %}
|
|
56
|
+
{% if optional_parameters %}
|
|
57
|
+
{% for parameter in optional_parameters %}
|
|
58
|
+
{{ parameter['name'] }}: NotRequired['{{ parameter['type'] }}']
|
|
59
|
+
{% if parameter['description'] %}
|
|
60
|
+
\"\"\"{{ parameter['description'] | replace('\\n', ' ') | replace('`', '') }}\"\"\"
|
|
61
|
+
{% endif %}
|
|
62
|
+
{% endfor %}
|
|
63
|
+
{% endif %}
|
|
64
|
+
{% endif %}
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
RETURN_DEFINITION_TEMPLATE = """\
|
|
68
|
+
class {{ method_name }}Returns(TypedDict):
|
|
69
|
+
{% if not return_parameters %}
|
|
70
|
+
pass
|
|
71
|
+
{% else %}
|
|
72
|
+
{% for return_parameter in return_parameters %}
|
|
73
|
+
{{ return_parameter['name'] }}: '{{ return_parameter['type'] }}'
|
|
74
|
+
{% if return_parameter['description'] %}
|
|
75
|
+
\"\"\"{{ return_parameter['description'] | replace('\\n', ' ') | replace('`', '') }}\"\"\"
|
|
76
|
+
{% endif %}
|
|
77
|
+
{% endfor %}
|
|
78
|
+
{% endif %}
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
class MethodGenerator:
|
|
82
|
+
def __init__(self,path, protocol_package:str):
|
|
83
|
+
self.path = path
|
|
84
|
+
self.protocol_package = protocol_package
|
|
85
|
+
self.current_domain:str=None
|
|
86
|
+
self.env=Environment(trim_blocks=True,lstrip_blocks=True,extensions=[StrcaseExtension])
|
|
87
|
+
self.imports = set()
|
|
88
|
+
self.generated_methods = set()
|
|
89
|
+
self.type_checking_imports = set()
|
|
90
|
+
|
|
91
|
+
def clear(self):
|
|
92
|
+
self.imports.clear()
|
|
93
|
+
self.generated_methods.clear()
|
|
94
|
+
self.type_checking_imports.clear()
|
|
95
|
+
|
|
96
|
+
def generate_method_implementation(self,method:dict):
|
|
97
|
+
method_name=method.get('name')
|
|
98
|
+
method_description=method.get('description','')
|
|
99
|
+
parameters=method.get('parameters',[])
|
|
100
|
+
return_parameters=method.get('returns',[])
|
|
101
|
+
template = self.env.from_string(METHOD_IMPLEMENTATION_TEMPLATE)
|
|
102
|
+
code = template.render(
|
|
103
|
+
domain_name=self.current_domain,
|
|
104
|
+
method_name=method_name,
|
|
105
|
+
method_description=method_description,
|
|
106
|
+
parameters=parameters,
|
|
107
|
+
return_parameters=return_parameters,
|
|
108
|
+
)
|
|
109
|
+
return code.strip()
|
|
110
|
+
|
|
111
|
+
def generate_method_types(self,domain:dict):
|
|
112
|
+
self.current_domain=domain.get('domain')
|
|
113
|
+
methods=domain.get('commands',[])
|
|
114
|
+
self.clear()
|
|
115
|
+
self.imports.add("from typing import TypedDict, NotRequired, Required, Literal, Any, Dict, Union, Optional, List, Set, Tuple")
|
|
116
|
+
for method in methods:
|
|
117
|
+
self.generated_methods.add(method.get('name'))
|
|
118
|
+
|
|
119
|
+
parameter_definitions_code=[self.generate_parameter_definition(method) for method in methods if not method.get('deprecated',False)]
|
|
120
|
+
return_definitions_code=[self.generate_return_definition(method) for method in methods if not method.get('deprecated',False)]
|
|
121
|
+
|
|
122
|
+
template = self.env.from_string(METHOD_TYPES_TEMPLATE)
|
|
123
|
+
code = template.render(
|
|
124
|
+
domain_name=self.current_domain,
|
|
125
|
+
parameter_definitions_code=parameter_definitions_code,
|
|
126
|
+
return_definitions_code=return_definitions_code,
|
|
127
|
+
imports=sorted(filter(lambda x: not x.startswith(f'from {self.protocol_package}.{self.current_domain}.types import'),self.imports)),
|
|
128
|
+
type_checking_imports=sorted(self.type_checking_imports),
|
|
129
|
+
)
|
|
130
|
+
return code.strip()
|
|
131
|
+
|
|
132
|
+
def generate_parameter_definition(self, method_definition:dict):
|
|
133
|
+
method_name=method_definition.get('name')
|
|
134
|
+
parameters=method_definition.get('parameters',[])
|
|
135
|
+
if not parameters:
|
|
136
|
+
return ''
|
|
137
|
+
required_parameters=[]
|
|
138
|
+
optional_parameters=[]
|
|
139
|
+
for parameter in parameters:
|
|
140
|
+
parameter['type'] = self.resolve_parameter_type(parameter)
|
|
141
|
+
if parameter.get('optional',False):
|
|
142
|
+
optional_parameters.append(parameter)
|
|
143
|
+
else:
|
|
144
|
+
required_parameters.append(parameter)
|
|
145
|
+
total = not (optional_parameters and not required_parameters)
|
|
146
|
+
template = self.env.from_string(PARAMETER_DEFINITION_TEMPLATE)
|
|
147
|
+
code = template.render(
|
|
148
|
+
total=total,
|
|
149
|
+
method_name=method_name,
|
|
150
|
+
required_parameters=required_parameters,
|
|
151
|
+
optional_parameters=optional_parameters,
|
|
152
|
+
)
|
|
153
|
+
self.generated_methods.add(method_name)
|
|
154
|
+
return code.strip()
|
|
155
|
+
|
|
156
|
+
def generate_return_definition(self, method_definition:dict):
|
|
157
|
+
method_name=method_definition.get('name')
|
|
158
|
+
return_parameters=method_definition.get('returns',[])
|
|
159
|
+
if not return_parameters:
|
|
160
|
+
return ""
|
|
161
|
+
for return_parameter in return_parameters:
|
|
162
|
+
return_parameter['type']=self.resolve_parameter_type(return_parameter)
|
|
163
|
+
template = self.env.from_string(RETURN_DEFINITION_TEMPLATE)
|
|
164
|
+
code = template.render(
|
|
165
|
+
method_name=method_name,
|
|
166
|
+
return_parameters=return_parameters
|
|
167
|
+
)
|
|
168
|
+
self.generated_methods.add(method_name)
|
|
169
|
+
return code.strip()
|
|
170
|
+
|
|
171
|
+
def resolve_parameter_type(self, parameter:dict):
|
|
172
|
+
if "$ref" in parameter:
|
|
173
|
+
return self.resolve_type_reference(parameter)
|
|
174
|
+
parameter_type=parameter.get("type","any")
|
|
175
|
+
match parameter_type:
|
|
176
|
+
case 'object':
|
|
177
|
+
return "Dict[str, Any]"
|
|
178
|
+
case 'array':
|
|
179
|
+
items=parameter.get('items',{})
|
|
180
|
+
return f"List[{self.resolve_type_reference(items) if '$ref' in items else self.map_primitive_type(items.get('type'))}]"
|
|
181
|
+
case 'string':
|
|
182
|
+
if 'enum' in parameter:
|
|
183
|
+
return f"Literal[{', '.join(f'\"{v}\"' for v in parameter.get('enum'))}]"
|
|
184
|
+
else:
|
|
185
|
+
return "str"
|
|
186
|
+
case _:
|
|
187
|
+
return self.map_primitive_type(parameter_type)
|
|
188
|
+
|
|
189
|
+
def resolve_type_reference(self, type_ref:dict):
|
|
190
|
+
ref=type_ref.get('$ref')
|
|
191
|
+
if '.' in ref:
|
|
192
|
+
parts=ref.split('.')
|
|
193
|
+
type_name=parts[1]
|
|
194
|
+
domain=inflection.underscore(parts[0])
|
|
195
|
+
self.type_checking_imports.add(f"from {self.protocol_package}.{domain}.types import {type_name}")
|
|
196
|
+
return type_name
|
|
197
|
+
else:
|
|
198
|
+
domain=inflection.underscore(self.current_domain)
|
|
199
|
+
self.type_checking_imports.add(f"from {self.protocol_package}.{domain}.types import {ref}")
|
|
200
|
+
return ref
|
|
201
|
+
|
|
202
|
+
def map_primitive_type(self, type_name: str):
|
|
203
|
+
match type_name:
|
|
204
|
+
case "string":
|
|
205
|
+
return "str"
|
|
206
|
+
case "object":
|
|
207
|
+
return "Dict[str, Any]"
|
|
208
|
+
case "number":
|
|
209
|
+
return "float"
|
|
210
|
+
case "integer":
|
|
211
|
+
return "int"
|
|
212
|
+
case "boolean":
|
|
213
|
+
return "bool"
|
|
214
|
+
case _:
|
|
215
|
+
return "Any"
|
cdp/generator/service.py
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
from .constant import BROWSER_PROTOCOL_URL, JS_PROTOCOL_URL
|
|
2
|
+
from .method_generator import MethodGenerator
|
|
3
|
+
from .event_generator import EventGenerator
|
|
4
|
+
from .type_generator import TypeGenerator
|
|
5
|
+
from .client_generator import ClientGenerator
|
|
6
|
+
from .domain_generator import DomainGenerator
|
|
7
|
+
from jinja2_strcase import StrcaseExtension
|
|
8
|
+
from jinja2 import Environment
|
|
9
|
+
from textwrap import dedent
|
|
10
|
+
from functools import cache
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Any, Optional
|
|
13
|
+
import inflection
|
|
14
|
+
import httpx
|
|
15
|
+
|
|
16
|
+
class CDPGenerator:
|
|
17
|
+
def __init__(self, src_path: Optional[Path] = None):
|
|
18
|
+
if src_path is None:
|
|
19
|
+
self.root_path = Path(__file__).parent.parent.parent.parent
|
|
20
|
+
self.src_path = self.root_path / "src"
|
|
21
|
+
else:
|
|
22
|
+
self.src_path = src_path
|
|
23
|
+
self.root_path = src_path.parent
|
|
24
|
+
|
|
25
|
+
self.cdp_path = self.src_path / "cdp"
|
|
26
|
+
self.protocol_path = self.cdp_path / "protocol"
|
|
27
|
+
self.client_path = self.cdp_path
|
|
28
|
+
|
|
29
|
+
self.protocol_package = "cdp.protocol"
|
|
30
|
+
self.package_name = "cdp"
|
|
31
|
+
|
|
32
|
+
self.method_generator = MethodGenerator(self.protocol_path, self.protocol_package)
|
|
33
|
+
self.event_generator = EventGenerator(self.protocol_path, self.protocol_package)
|
|
34
|
+
self.type_generator = TypeGenerator(self.protocol_path, self.protocol_package)
|
|
35
|
+
self.domain_generator = DomainGenerator(self.method_generator, self.event_generator, self.package_name)
|
|
36
|
+
self.client_generator = ClientGenerator(self.protocol_package, self.package_name)
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
@cache
|
|
40
|
+
def domains(self):
|
|
41
|
+
domains = []
|
|
42
|
+
for url in [BROWSER_PROTOCOL_URL, JS_PROTOCOL_URL]:
|
|
43
|
+
try:
|
|
44
|
+
protocol = httpx.get(url).json()
|
|
45
|
+
domains.extend(protocol.get('domains', []))
|
|
46
|
+
except Exception as e:
|
|
47
|
+
print(f"Failed to load protocol from {url}: {e}")
|
|
48
|
+
return domains
|
|
49
|
+
|
|
50
|
+
def generate(self):
|
|
51
|
+
# Create base directories and __init__.py files
|
|
52
|
+
self.cdp_path.mkdir(parents=True, exist_ok=True)
|
|
53
|
+
self.protocol_path.mkdir(parents=True, exist_ok=True)
|
|
54
|
+
|
|
55
|
+
self.ensure_init(self.cdp_path)
|
|
56
|
+
self.ensure_init(self.protocol_path)
|
|
57
|
+
|
|
58
|
+
# Add py.typed to both cdp and cdp.protocol
|
|
59
|
+
(self.cdp_path / "py.typed").write_text("")
|
|
60
|
+
(self.protocol_path / "py.typed").write_text("")
|
|
61
|
+
|
|
62
|
+
self.generate_protocol()
|
|
63
|
+
self.generate_client()
|
|
64
|
+
|
|
65
|
+
def ensure_init(self, path: Path):
|
|
66
|
+
init_file = path / "__init__.py"
|
|
67
|
+
if not init_file.exists():
|
|
68
|
+
init_file.write_text("")
|
|
69
|
+
|
|
70
|
+
def generate_protocol(self):
|
|
71
|
+
for domain in self.domains:
|
|
72
|
+
if not domain.get('deprecated', False):
|
|
73
|
+
self.generate_domain_types(domain)
|
|
74
|
+
self.generate_domain_services(domain)
|
|
75
|
+
|
|
76
|
+
def generate_client(self):
|
|
77
|
+
client_dir = self.client_path
|
|
78
|
+
domains = list(filter(lambda x: not x.get('deprecated', False), self.domains))
|
|
79
|
+
|
|
80
|
+
# Generate domains.py with Domains class
|
|
81
|
+
domains_content = self.client_generator.generate_domains(domains)
|
|
82
|
+
self.write_file(client_dir / "domains.py", domains_content)
|
|
83
|
+
|
|
84
|
+
# Generate service.py with Client class
|
|
85
|
+
service_content = self.client_generator.generate_service()
|
|
86
|
+
self.write_file(client_dir / "service.py", service_content)
|
|
87
|
+
|
|
88
|
+
# Generate cdp/__init__.py
|
|
89
|
+
init_content = dedent("""
|
|
90
|
+
from .domains import Domains
|
|
91
|
+
from .service import Client
|
|
92
|
+
|
|
93
|
+
__all__ = ["Domains", "Client"]
|
|
94
|
+
""").strip()
|
|
95
|
+
self.write_file(client_dir / "__init__.py", init_content)
|
|
96
|
+
|
|
97
|
+
def generate_domain_services(self, domain: dict):
|
|
98
|
+
domain_name_snake = inflection.underscore(domain['domain'])
|
|
99
|
+
domain_dir = self.protocol_path / domain_name_snake
|
|
100
|
+
|
|
101
|
+
methods_dir = domain_dir / "methods"
|
|
102
|
+
events_dir = domain_dir / "events"
|
|
103
|
+
|
|
104
|
+
domain_dir.mkdir(parents=True, exist_ok=True)
|
|
105
|
+
methods_dir.mkdir(parents=True, exist_ok=True)
|
|
106
|
+
events_dir.mkdir(parents=True, exist_ok=True)
|
|
107
|
+
|
|
108
|
+
self.ensure_init(domain_dir)
|
|
109
|
+
self.ensure_init(methods_dir)
|
|
110
|
+
self.ensure_init(events_dir)
|
|
111
|
+
|
|
112
|
+
# Generate methods service
|
|
113
|
+
methods_content = self.domain_generator.generate_methods_service(domain)
|
|
114
|
+
self.write_file(methods_dir / "service.py", methods_content)
|
|
115
|
+
|
|
116
|
+
# Generate events service
|
|
117
|
+
events_content = self.domain_generator.generate_events_service(domain)
|
|
118
|
+
self.write_file(events_dir / "service.py", events_content)
|
|
119
|
+
|
|
120
|
+
# Generate main service
|
|
121
|
+
service_content = self.domain_generator.generate_domain_service(domain)
|
|
122
|
+
self.write_file(domain_dir / "service.py", service_content)
|
|
123
|
+
|
|
124
|
+
def generate_domain_types(self, domain: dict):
|
|
125
|
+
domain_name_snake = inflection.underscore(domain['domain'])
|
|
126
|
+
domain_dir = self.protocol_path / domain_name_snake
|
|
127
|
+
|
|
128
|
+
methods_dir = domain_dir / "methods"
|
|
129
|
+
events_dir = domain_dir / "events"
|
|
130
|
+
|
|
131
|
+
domain_dir.mkdir(parents=True, exist_ok=True)
|
|
132
|
+
methods_dir.mkdir(parents=True, exist_ok=True)
|
|
133
|
+
events_dir.mkdir(parents=True, exist_ok=True)
|
|
134
|
+
|
|
135
|
+
self.ensure_init(domain_dir)
|
|
136
|
+
self.ensure_init(methods_dir)
|
|
137
|
+
self.ensure_init(events_dir)
|
|
138
|
+
|
|
139
|
+
# Generate types
|
|
140
|
+
types_content = self.type_generator.generate_types(domain)
|
|
141
|
+
self.write_file(domain_dir / "types.py", types_content)
|
|
142
|
+
|
|
143
|
+
# Generate method types
|
|
144
|
+
method_types_content = self.method_generator.generate_method_types(domain)
|
|
145
|
+
self.write_file(methods_dir / "types.py", method_types_content)
|
|
146
|
+
|
|
147
|
+
# Generate event types
|
|
148
|
+
event_types_content = self.event_generator.generate_event_types(domain)
|
|
149
|
+
self.write_file(events_dir / "types.py", event_types_content)
|
|
150
|
+
|
|
151
|
+
def write_file(self, path: Path, content: str):
|
|
152
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
153
|
+
path.write_text(content, encoding='utf-8')
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
from jinja2 import Environment
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import inflection
|
|
4
|
+
|
|
5
|
+
TYPES_TEMPLATE = """\
|
|
6
|
+
\"\"\"CDP {{ current_domain }} Types\"\"\"
|
|
7
|
+
|
|
8
|
+
{% for import_ in imports %}
|
|
9
|
+
{{ import_ }}
|
|
10
|
+
{% endfor %}
|
|
11
|
+
{% if type_checking_imports %}
|
|
12
|
+
|
|
13
|
+
from typing import TYPE_CHECKING
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
{% for type_checking_import in type_checking_imports %}
|
|
16
|
+
{{ type_checking_import }}
|
|
17
|
+
{% endfor %}
|
|
18
|
+
{% endif %}
|
|
19
|
+
|
|
20
|
+
{% for definition in type_definitions_code %}
|
|
21
|
+
{{ definition }}
|
|
22
|
+
{% endfor %}
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
ARRAY_TYPE_TEMPLATE = """\
|
|
26
|
+
{{ type_name }} = List['{{ type_type }}']
|
|
27
|
+
{% if type_description %}
|
|
28
|
+
\"\"\"{{ type_description | replace('\\n', ' ') | replace('`', '') }}\"\"\"
|
|
29
|
+
{% endif %}
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
PRIMITIVE_TYPE_TEMPLATE = """\
|
|
33
|
+
{{ type_name }} = {{ type_type }}
|
|
34
|
+
{% if type_description %}
|
|
35
|
+
\"\"\"{{ type_description | replace('\\n', ' ') | replace('`', '') }}\"\"\"
|
|
36
|
+
{% endif %}
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
LITERAL_TYPE_TEMPLATE = """\
|
|
40
|
+
{{ type_name }} = Literal[{{ enum_values }}]
|
|
41
|
+
{% if type_description %}
|
|
42
|
+
\"\"\"{{ type_description | replace('\\n', ' ') }}\"\"\"
|
|
43
|
+
{% endif %}
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
OBJECT_TYPE_TEMPLATE = """\
|
|
47
|
+
class {{ type_name }}(TypedDict, total={{ total }}):
|
|
48
|
+
{% if type_description %}
|
|
49
|
+
\"\"\"{{ type_description | replace('\\n', ' ') | replace('`', '') }}\"\"\"
|
|
50
|
+
{% endif %}
|
|
51
|
+
{% if not required_properties and not optional_properties %}
|
|
52
|
+
pass
|
|
53
|
+
{% else %}
|
|
54
|
+
{% if required_properties %}
|
|
55
|
+
{% for property in required_properties %}
|
|
56
|
+
{{ property['name'] }}: '{{ property['type'] }}'
|
|
57
|
+
{% if property.get('description') %}
|
|
58
|
+
\"\"\"{{ property['description'] | replace('\\n', ' ') | replace('\\\"', '') | replace('`','') }}\"\"\"
|
|
59
|
+
{% endif %}
|
|
60
|
+
{% endfor %}
|
|
61
|
+
{% endif %}
|
|
62
|
+
{% if optional_properties %}
|
|
63
|
+
{% for property in optional_properties %}
|
|
64
|
+
{{ property['name'] }}: NotRequired['{{ property['type'] }}']
|
|
65
|
+
{% if property.get('description') %}
|
|
66
|
+
\"\"\"{{ property['description'] | replace('\\n', ' ') | replace('`', '') }}\"\"\"
|
|
67
|
+
{% endif %}
|
|
68
|
+
{% endfor %}
|
|
69
|
+
{% endif %}
|
|
70
|
+
{% endif %}
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
class TypeGenerator:
|
|
74
|
+
def __init__(self,path:Path, protocol_package:str):
|
|
75
|
+
self.path = path
|
|
76
|
+
self.protocol_package = protocol_package
|
|
77
|
+
self.current_domain:str = None
|
|
78
|
+
self.env=Environment(trim_blocks=True,lstrip_blocks=True)
|
|
79
|
+
self.imports = set()
|
|
80
|
+
self.generated_types = set()
|
|
81
|
+
self.type_checking_imports = set()
|
|
82
|
+
|
|
83
|
+
def clear(self):
|
|
84
|
+
self.imports.clear()
|
|
85
|
+
self.generated_types.clear()
|
|
86
|
+
self.type_checking_imports.clear()
|
|
87
|
+
|
|
88
|
+
def generate_types(self, domain: dict):
|
|
89
|
+
self.current_domain = domain.get('domain')
|
|
90
|
+
type_definitions = domain.get('types', [])
|
|
91
|
+
self.clear()
|
|
92
|
+
self.imports.add("from typing import TypedDict, NotRequired, Required, Literal, Any, Dict, Union, Optional, List, Set, Tuple")
|
|
93
|
+
for type_definition in type_definitions:
|
|
94
|
+
self.generated_types.add(type_definition.get('id'))
|
|
95
|
+
|
|
96
|
+
type_definitions_code=[self.generate_type_definition(type_definition) for type_definition in type_definitions]
|
|
97
|
+
template = self.env.from_string(TYPES_TEMPLATE)
|
|
98
|
+
code = template.render(
|
|
99
|
+
current_domain=self.current_domain,
|
|
100
|
+
type_definitions_code=type_definitions_code,
|
|
101
|
+
imports=sorted(filter(lambda x: not x.startswith(f'from {self.protocol_package}.{inflection.underscore(self.current_domain)}.types import'),self.imports)),
|
|
102
|
+
type_checking_imports=sorted(self.type_checking_imports),
|
|
103
|
+
)
|
|
104
|
+
return code.strip()
|
|
105
|
+
|
|
106
|
+
def generate_type_definition(self, type_definition: dict):
|
|
107
|
+
type_type = type_definition.get('type')
|
|
108
|
+
if type_type == "string" and "enum" in type_definition:
|
|
109
|
+
return self.generate_literal_type(type_definition)
|
|
110
|
+
elif type_type == "object":
|
|
111
|
+
return self.generate_object_type(type_definition)
|
|
112
|
+
elif type_type == "array":
|
|
113
|
+
return self.generate_array_type(type_definition)
|
|
114
|
+
elif type_type in ["string", "number", "integer", "boolean"]:
|
|
115
|
+
return self.generate_primitive_type(type_definition)
|
|
116
|
+
|
|
117
|
+
def generate_array_type(self, type_definition: dict):
|
|
118
|
+
type_name = type_definition.get('id')
|
|
119
|
+
type_description = type_definition.get('description')
|
|
120
|
+
items = type_definition.get('items', {})
|
|
121
|
+
template = self.env.from_string(ARRAY_TYPE_TEMPLATE)
|
|
122
|
+
code = template.render(
|
|
123
|
+
type_name=type_name,
|
|
124
|
+
type_type=self.resolve_type_reference(items) if '$ref' in items else self.map_primitive_type(items.get('type')),
|
|
125
|
+
type_description=type_description,
|
|
126
|
+
)
|
|
127
|
+
self.generated_types.add(type_name)
|
|
128
|
+
return code.strip()
|
|
129
|
+
|
|
130
|
+
def generate_primitive_type(self, type_definition: dict):
|
|
131
|
+
type_name=type_definition.get('id')
|
|
132
|
+
type_description=type_definition.get('description')
|
|
133
|
+
type_type=type_definition.get('type')
|
|
134
|
+
template = self.env.from_string(PRIMITIVE_TYPE_TEMPLATE)
|
|
135
|
+
code = template.render(
|
|
136
|
+
type_name=type_name,
|
|
137
|
+
type_type=self.map_primitive_type(type_type),
|
|
138
|
+
type_description=type_description,
|
|
139
|
+
)
|
|
140
|
+
self.generated_types.add(type_name)
|
|
141
|
+
return code.strip()
|
|
142
|
+
|
|
143
|
+
def generate_literal_type(self, type_definition: dict):
|
|
144
|
+
type_name = type_definition.get('id')
|
|
145
|
+
type_description = type_definition.get('description')
|
|
146
|
+
enum_values = type_definition.get('enum', [])
|
|
147
|
+
template = self.env.from_string(LITERAL_TYPE_TEMPLATE)
|
|
148
|
+
code = template.render(
|
|
149
|
+
type_name=type_name,
|
|
150
|
+
enum_values=",".join(f"'{v}'" for v in enum_values),
|
|
151
|
+
type_description=type_description,
|
|
152
|
+
)
|
|
153
|
+
self.generated_types.add(type_name)
|
|
154
|
+
return code.strip()
|
|
155
|
+
|
|
156
|
+
def generate_object_type(self, type_definition: dict):
|
|
157
|
+
type_name = type_definition.get('id')
|
|
158
|
+
type_description = type_definition.get('description', '')
|
|
159
|
+
properties = type_definition.get('properties', [])
|
|
160
|
+
required_properties = []
|
|
161
|
+
optional_properties = []
|
|
162
|
+
for property in properties:
|
|
163
|
+
is_optional = property.get('optional', False)
|
|
164
|
+
if property.get('deprecated', False):
|
|
165
|
+
continue
|
|
166
|
+
property['type'] = self.resolve_property_type(property)
|
|
167
|
+
if is_optional:
|
|
168
|
+
optional_properties.append(property)
|
|
169
|
+
else:
|
|
170
|
+
required_properties.append(property)
|
|
171
|
+
total = not (optional_properties and not required_properties)
|
|
172
|
+
template = self.env.from_string(OBJECT_TYPE_TEMPLATE)
|
|
173
|
+
code = template.render(
|
|
174
|
+
type_name=type_name,
|
|
175
|
+
total=total,
|
|
176
|
+
type_description=type_description,
|
|
177
|
+
required_properties=required_properties,
|
|
178
|
+
optional_properties=optional_properties,
|
|
179
|
+
)
|
|
180
|
+
self.generated_types.add(type_name)
|
|
181
|
+
return code.strip()
|
|
182
|
+
|
|
183
|
+
def resolve_property_type(self, property: dict):
|
|
184
|
+
if '$ref' in property:
|
|
185
|
+
return self.resolve_type_reference(property)
|
|
186
|
+
property_type = property.get('type','any')
|
|
187
|
+
match property_type:
|
|
188
|
+
case 'object':
|
|
189
|
+
return "Dict[str, Any]"
|
|
190
|
+
case 'array':
|
|
191
|
+
items=property.get('items',{})
|
|
192
|
+
return f"List[{self.resolve_type_reference(items) if '$ref' in items else self.map_primitive_type(items.get('type'))}]"
|
|
193
|
+
case 'string':
|
|
194
|
+
if 'enum' in property:
|
|
195
|
+
return f"Literal[{', '.join(f'\"{v}\"' for v in property.get('enum'))}]"
|
|
196
|
+
else:
|
|
197
|
+
return "str"
|
|
198
|
+
case _:
|
|
199
|
+
return self.map_primitive_type(property_type)
|
|
200
|
+
|
|
201
|
+
def resolve_type_reference(self, type_ref:dict):
|
|
202
|
+
ref = type_ref.get('$ref')
|
|
203
|
+
if '.' in ref:
|
|
204
|
+
parts=ref.split('.')
|
|
205
|
+
type_name=parts[1]
|
|
206
|
+
current_domain=self.current_domain.lower()
|
|
207
|
+
domain=parts[0].lower()
|
|
208
|
+
if (current_domain!=domain) or (type_name not in self.generated_types):
|
|
209
|
+
domain=inflection.underscore(domain)
|
|
210
|
+
self.type_checking_imports.add(f"from {self.protocol_package}.{domain}.types import {type_name}")
|
|
211
|
+
return type_name
|
|
212
|
+
else:
|
|
213
|
+
if ref not in self.generated_types:
|
|
214
|
+
domain=inflection.underscore(self.current_domain)
|
|
215
|
+
self.imports.add(f"from {self.protocol_package}.{domain}.types import {ref}")
|
|
216
|
+
return ref
|
|
217
|
+
|
|
218
|
+
def map_primitive_type(self, type_name: str):
|
|
219
|
+
match type_name:
|
|
220
|
+
case "string":
|
|
221
|
+
return "str"
|
|
222
|
+
case "object":
|
|
223
|
+
return "Dict[str, Any]"
|
|
224
|
+
case "number":
|
|
225
|
+
return "float"
|
|
226
|
+
case "integer":
|
|
227
|
+
return "int"
|
|
228
|
+
case "boolean":
|
|
229
|
+
return "bool"
|
|
230
|
+
case _:
|
|
231
|
+
return "Any"
|
cdp/protocol/__init__.py
ADDED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""CDP Accessibility Domain Events"""
|
|
2
|
+
from ..types import *
|
|
3
|
+
from .types import *
|
|
4
|
+
from typing import Optional, Dict, Any, Callable, TYPE_CHECKING
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from ....service import Client
|
|
8
|
+
|
|
9
|
+
class AccessibilityEvents:
|
|
10
|
+
"""
|
|
11
|
+
Events for the Accessibility domain.
|
|
12
|
+
"""
|
|
13
|
+
def __init__(self, client: "Client"):
|
|
14
|
+
"""
|
|
15
|
+
Initialize the Accessibility events.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
client ("Client"): The parent CDP client instance.
|
|
19
|
+
"""
|
|
20
|
+
self.client = client
|
|
21
|
+
|
|
22
|
+
def on_load_complete(self, callback: Callable[[loadCompleteEvent,Optional[str]], None]=None) -> None:
|
|
23
|
+
"""
|
|
24
|
+
The loadComplete event mirrors the load complete event sent by the browser to assistive technology when the web page has finished loading.
|
|
25
|
+
Args:
|
|
26
|
+
callback (callable, optional): Function called when the event is fired.
|
|
27
|
+
The callback receives (params: loadCompleteEvent, session_id: Optional[str]).
|
|
28
|
+
"""
|
|
29
|
+
self.client.on('Accessibility.loadComplete', callback)
|
|
30
|
+
def on_nodes_updated(self, callback: Callable[[nodesUpdatedEvent,Optional[str]], None]=None) -> None:
|
|
31
|
+
"""
|
|
32
|
+
The nodesUpdated event is sent every time a previously requested node has changed the in tree.
|
|
33
|
+
Args:
|
|
34
|
+
callback (callable, optional): Function called when the event is fired.
|
|
35
|
+
The callback receives (params: nodesUpdatedEvent, session_id: Optional[str]).
|
|
36
|
+
"""
|
|
37
|
+
self.client.on('Accessibility.nodesUpdated', callback)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""CDP Accessibility Events"""
|
|
2
|
+
|
|
3
|
+
from typing import TypedDict, NotRequired, Required, Literal, Any, Dict, Union, Optional, List, Set, Tuple
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from cdp.protocol.accessibility.types import AXNode
|
|
8
|
+
|
|
9
|
+
class loadCompleteEvent(TypedDict, total=True):
|
|
10
|
+
root: 'AXNode'
|
|
11
|
+
"""New document root node."""
|
|
12
|
+
class nodesUpdatedEvent(TypedDict, total=True):
|
|
13
|
+
nodes: 'List[AXNode]'
|
|
14
|
+
"""Updated node data."""
|
|
File without changes
|