Skip to main content

browser_commander/puppeteer/api/
web_mcp_tool.rs

1// @generated by scripts/generate-puppeteer-bindings.mjs from
2// rust/protocol/puppeteer/api.json. Do not edit by hand.
3
4#![allow(clippy::all, missing_docs, unused_imports, non_snake_case)]
5
6use serde_json::Value;
7
8use super::*;
9use crate::puppeteer::bridge::{binary, remote_type, BridgeError, JsFunction, Remote};
10
11remote_type!(
12    /// Puppeteer's `WebMCPTool` (puppeteer-core 25.10.0), a remote object
13    /// served by `browser-commander serve --stdio`.
14    ///
15    /// Extends [`EventEmitter`]; the inherited methods are repeated here.
16    WebMCPTool
17);
18
19impl WebMCPTool {
20    /// `EventEmitter.on`
21    ///
22    /// ```text
23    /// on<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler: Handler<EventsWithWildcard<Events>[Key]>): this
24    /// ```
25    pub async fn on(&self, type_: Value, handler: impl Into<JsFunction>) -> Result<WebMCPTool, BridgeError> {
26        self.remote.call("on", vec![Some(type_), Some(handler.into().to_wire())]).await
27    }
28
29    /// `EventEmitter.off`
30    ///
31    /// ```text
32    /// off<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler?: Handler<EventsWithWildcard<Events>[Key]>): this
33    /// ```
34    pub async fn off(&self, type_: Value, handler: Option<JsFunction>) -> Result<WebMCPTool, BridgeError> {
35        self.remote.call("off", vec![Some(type_), handler.map(|x| x.to_wire())]).await
36    }
37
38    /// `EventEmitter.emit`
39    ///
40    /// ```text
41    /// emit<Key extends keyof EventsWithWildcard<Events>>(type: Key, event: EventsWithWildcard<Events>[Key]): boolean
42    /// ```
43    pub async fn emit(&self, type_: Value, event: Value) -> Result<bool, BridgeError> {
44        self.remote.call("emit", vec![Some(type_), Some(event)]).await
45    }
46
47    /// `EventEmitter.once`
48    ///
49    /// ```text
50    /// once<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler: Handler<EventsWithWildcard<Events>[Key]>): this
51    /// ```
52    pub async fn once(&self, type_: Value, handler: impl Into<JsFunction>) -> Result<WebMCPTool, BridgeError> {
53        self.remote.call("once", vec![Some(type_), Some(handler.into().to_wire())]).await
54    }
55
56    /// `EventEmitter.listenerCount`
57    ///
58    /// ```text
59    /// listenerCount(type: keyof EventsWithWildcard<Events>): number
60    /// ```
61    pub async fn listener_count(&self, type_: Value) -> Result<f64, BridgeError> {
62        self.remote.call("listenerCount", vec![Some(type_)]).await
63    }
64
65    /// `EventEmitter.removeAllListeners`
66    ///
67    /// ```text
68    /// removeAllListeners(type?: keyof EventsWithWildcard<Events>): this
69    /// ```
70    pub async fn remove_all_listeners(&self, type_: Option<Value>) -> Result<WebMCPTool, BridgeError> {
71        self.remote.call("removeAllListeners", vec![type_]).await
72    }
73
74    /// `WebMCPTool.formElement`
75    ///
76    /// ```text
77    /// get formElement(): Promise<ElementHandle<HTMLFormElement> | undefined>
78    /// ```
79    pub async fn form_element(&self) -> Result<Option<ElementHandle>, BridgeError> {
80        self.remote.get("formElement").await
81    }
82
83    /// `WebMCPTool.execute`
84    ///
85    /// ```text
86    /// execute(input?: object, options?: WebMCPToolExecuteOptions): Promise<WebMCPToolCallResult>
87    /// ```
88    pub async fn execute(&self, input: Option<Value>, options: Option<Value>) -> Result<Value, BridgeError> {
89        self.remote.call("execute", vec![input, options]).await
90    }
91}