1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// @generated by scripts/generate-puppeteer-bindings.mjs from
// rust/protocol/puppeteer/api.json. Do not edit by hand.
#![allow(clippy::all, missing_docs, unused_imports, non_snake_case)]
use serde_json::Value;
use super::*;
use crate::puppeteer::bridge::{binary, remote_type, BridgeError, JsFunction, Remote};
remote_type!(
/// Puppeteer's `CDPSession` (puppeteer-core 25.10.0), a remote object
/// served by `browser-commander serve --stdio`.
///
/// Extends [`EventEmitter`]; the inherited methods are repeated here.
CDPSession
);
impl CDPSession {
/// `EventEmitter.on`
///
/// ```text
/// on<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler: Handler<EventsWithWildcard<Events>[Key]>): this
/// ```
pub async fn on(&self, type_: Value, handler: impl Into<JsFunction>) -> Result<CDPSession, BridgeError> {
self.remote.call("on", vec![Some(type_), Some(handler.into().to_wire())]).await
}
/// `EventEmitter.off`
///
/// ```text
/// off<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler?: Handler<EventsWithWildcard<Events>[Key]>): this
/// ```
pub async fn off(&self, type_: Value, handler: Option<JsFunction>) -> Result<CDPSession, BridgeError> {
self.remote.call("off", vec![Some(type_), handler.map(|x| x.to_wire())]).await
}
/// `EventEmitter.emit`
///
/// ```text
/// emit<Key extends keyof EventsWithWildcard<Events>>(type: Key, event: EventsWithWildcard<Events>[Key]): boolean
/// ```
pub async fn emit(&self, type_: Value, event: Value) -> Result<bool, BridgeError> {
self.remote.call("emit", vec![Some(type_), Some(event)]).await
}
/// `EventEmitter.once`
///
/// ```text
/// once<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler: Handler<EventsWithWildcard<Events>[Key]>): this
/// ```
pub async fn once(&self, type_: Value, handler: impl Into<JsFunction>) -> Result<CDPSession, BridgeError> {
self.remote.call("once", vec![Some(type_), Some(handler.into().to_wire())]).await
}
/// `EventEmitter.listenerCount`
///
/// ```text
/// listenerCount(type: keyof EventsWithWildcard<Events>): number
/// ```
pub async fn listener_count(&self, type_: Value) -> Result<f64, BridgeError> {
self.remote.call("listenerCount", vec![Some(type_)]).await
}
/// `EventEmitter.removeAllListeners`
///
/// ```text
/// removeAllListeners(type?: keyof EventsWithWildcard<Events>): this
/// ```
pub async fn remove_all_listeners(&self, type_: Option<Value>) -> Result<CDPSession, BridgeError> {
self.remote.call("removeAllListeners", vec![type_]).await
}
/// `CDPSession.connection`
///
/// ```text
/// connection(): Connection | undefined
/// ```
pub async fn connection(&self) -> Result<Option<Connection>, BridgeError> {
self.remote.call("connection", vec![]).await
}
/// `CDPSession.detached`
///
/// ```text
/// get detached(): boolean
/// ```
pub async fn detached(&self) -> Result<bool, BridgeError> {
self.remote.get("detached").await
}
/// `CDPSession.send`
///
/// ```text
/// send<T extends keyof ProtocolMapping.Commands>(method: T, params?: ProtocolMapping.Commands[T]['paramsType'][0], options?: CommandOptions): Promise<ProtocolMapping.Commands[T]['returnType']>
/// ```
pub async fn send(&self, method: Value, params: Option<Value>, options: Option<Value>) -> Result<Value, BridgeError> {
self.remote.call("send", vec![Some(method), params, options]).await
}
/// `CDPSession.detach`
///
/// ```text
/// detach(): Promise<void>
/// ```
pub async fn detach(&self) -> Result<(), BridgeError> {
self.remote.call("detach", vec![]).await
}
/// `CDPSession.id`
///
/// ```text
/// id(): string
/// ```
pub async fn id(&self) -> Result<String, BridgeError> {
self.remote.call("id", vec![]).await
}
}