1use serde::{Deserialize, Serialize};
6
7pub type ScriptId = String;
9
10pub type ExecutionContextId = i64;
12
13#[derive(Debug, Clone, Deserialize)]
15#[serde(rename_all = "camelCase")]
16pub struct RemoteObject {
17 #[serde(rename = "type")]
19 pub object_type: String,
20 pub subtype: Option<String>,
22 pub class_name: Option<String>,
24 pub value: Option<serde_json::Value>,
26 pub description: Option<String>,
28 pub object_id: Option<String>,
30}
31
32#[derive(Debug, Clone, Deserialize)]
34#[serde(rename_all = "camelCase")]
35pub struct ExceptionDetails {
36 pub exception_id: i64,
38 pub text: String,
40 pub line_number: i64,
42 pub column_number: i64,
44 pub script_id: Option<ScriptId>,
46 pub url: Option<String>,
48 pub exception: Option<RemoteObject>,
50 pub execution_context_id: Option<ExecutionContextId>,
52}
53
54#[derive(Debug, Clone, Serialize)]
56#[serde(rename_all = "camelCase")]
57pub struct EvaluateParams {
58 pub expression: String,
60 #[serde(skip_serializing_if = "Option::is_none")]
62 pub object_group: Option<String>,
63 #[serde(skip_serializing_if = "Option::is_none")]
65 pub include_command_line_api: Option<bool>,
66 #[serde(skip_serializing_if = "Option::is_none")]
68 pub silent: Option<bool>,
69 #[serde(skip_serializing_if = "Option::is_none")]
71 pub context_id: Option<ExecutionContextId>,
72 #[serde(skip_serializing_if = "Option::is_none")]
74 pub return_by_value: Option<bool>,
75 #[serde(skip_serializing_if = "Option::is_none")]
77 pub await_promise: Option<bool>,
78}
79
80#[derive(Debug, Clone, Deserialize)]
82#[serde(rename_all = "camelCase")]
83pub struct EvaluateResult {
84 pub result: RemoteObject,
86 pub exception_details: Option<ExceptionDetails>,
88}
89
90#[derive(Debug, Clone, Deserialize)]
92pub struct ExecutionContextCreatedEvent {
93 pub context: ExecutionContextDescription,
95}
96
97#[derive(Debug, Clone, Deserialize)]
99#[serde(rename_all = "camelCase")]
100pub struct ExecutionContextDescription {
101 pub id: ExecutionContextId,
103 pub origin: String,
105 pub name: String,
107}
108
109#[derive(Debug, Clone, Deserialize)]
111#[serde(rename_all = "camelCase")]
112pub struct ExecutionContextDestroyedEvent {
113 pub execution_context_id: ExecutionContextId,
115}
116
117#[derive(Debug, Clone, Serialize)]
123#[serde(rename_all = "camelCase")]
124pub struct CallFunctionOnParams {
125 pub function_declaration: String,
127 #[serde(skip_serializing_if = "Option::is_none")]
129 pub object_id: Option<String>,
130 #[serde(skip_serializing_if = "Option::is_none")]
132 pub arguments: Option<Vec<CallArgument>>,
133 #[serde(skip_serializing_if = "Option::is_none")]
135 pub silent: Option<bool>,
136 #[serde(skip_serializing_if = "Option::is_none")]
138 pub return_by_value: Option<bool>,
139 #[serde(skip_serializing_if = "Option::is_none")]
141 pub generate_preview: Option<bool>,
142 #[serde(skip_serializing_if = "Option::is_none")]
144 pub user_gesture: Option<bool>,
145 #[serde(skip_serializing_if = "Option::is_none")]
147 pub await_promise: Option<bool>,
148 #[serde(skip_serializing_if = "Option::is_none")]
150 pub execution_context_id: Option<ExecutionContextId>,
151 #[serde(skip_serializing_if = "Option::is_none")]
153 pub object_group: Option<String>,
154 #[serde(skip_serializing_if = "Option::is_none")]
156 pub throw_on_side_effect: Option<bool>,
157 #[serde(skip_serializing_if = "Option::is_none")]
159 pub unique_context_id: Option<String>,
160 #[serde(skip_serializing_if = "Option::is_none")]
162 pub serialization_options: Option<serde_json::Value>,
163}
164
165#[derive(Debug, Clone, Serialize)]
167#[serde(rename_all = "camelCase")]
168pub struct CallArgument {
169 #[serde(skip_serializing_if = "Option::is_none")]
171 pub value: Option<serde_json::Value>,
172 #[serde(skip_serializing_if = "Option::is_none")]
174 pub unserializable_value: Option<String>,
175 #[serde(skip_serializing_if = "Option::is_none")]
177 pub object_id: Option<String>,
178}
179
180#[derive(Debug, Clone, Deserialize)]
182#[serde(rename_all = "camelCase")]
183pub struct CallFunctionOnResult {
184 pub result: RemoteObject,
186 pub exception_details: Option<ExceptionDetails>,
188}
189
190#[derive(Debug, Clone, Serialize)]
196#[serde(rename_all = "camelCase")]
197pub struct ReleaseObjectParams {
198 pub object_id: String,
200}
201
202#[derive(Debug, Clone, Serialize)]
204#[serde(rename_all = "camelCase")]
205pub struct ReleaseObjectGroupParams {
206 pub object_group: String,
208}
209
210#[derive(Debug, Clone, Serialize)]
216#[serde(rename_all = "camelCase")]
217pub struct GetPropertiesParams {
218 pub object_id: String,
220 #[serde(skip_serializing_if = "Option::is_none")]
222 pub own_properties: Option<bool>,
223 #[serde(skip_serializing_if = "Option::is_none")]
225 pub accessor_properties_only: Option<bool>,
226 #[serde(skip_serializing_if = "Option::is_none")]
228 pub generate_preview: Option<bool>,
229 #[serde(skip_serializing_if = "Option::is_none")]
231 pub non_indexed_properties_only: Option<bool>,
232}
233
234#[derive(Debug, Clone, Deserialize)]
236#[serde(rename_all = "camelCase")]
237pub struct PropertyDescriptor {
238 pub name: String,
240 pub value: Option<RemoteObject>,
242 pub writable: Option<bool>,
244 pub get: Option<RemoteObject>,
246 pub set: Option<RemoteObject>,
248 pub configurable: bool,
250 pub enumerable: bool,
252 pub was_thrown: Option<bool>,
254 pub is_own: Option<bool>,
256 pub symbol: Option<RemoteObject>,
258}
259
260#[derive(Debug, Clone, Deserialize)]
262#[serde(rename_all = "camelCase")]
263pub struct GetPropertiesResult {
264 pub result: Vec<PropertyDescriptor>,
266 pub internal_properties: Option<Vec<InternalPropertyDescriptor>>,
268 pub private_properties: Option<Vec<PrivatePropertyDescriptor>>,
270 pub exception_details: Option<ExceptionDetails>,
272}
273
274#[derive(Debug, Clone, Deserialize)]
276#[serde(rename_all = "camelCase")]
277pub struct InternalPropertyDescriptor {
278 pub name: String,
280 pub value: Option<RemoteObject>,
282}
283
284#[derive(Debug, Clone, Deserialize)]
286#[serde(rename_all = "camelCase")]
287pub struct PrivatePropertyDescriptor {
288 pub name: String,
290 pub value: Option<RemoteObject>,
292 pub get: Option<RemoteObject>,
294 pub set: Option<RemoteObject>,
296}
297
298#[derive(Debug, Clone, Serialize)]
304#[serde(rename_all = "camelCase")]
305pub struct AddBindingParams {
306 pub name: String,
308 #[serde(skip_serializing_if = "Option::is_none")]
310 pub execution_context_id: Option<ExecutionContextId>,
311 #[serde(skip_serializing_if = "Option::is_none")]
313 pub execution_context_name: Option<String>,
314}
315
316#[derive(Debug, Clone, Serialize)]
318pub struct RemoveBindingParams {
319 pub name: String,
321}
322
323#[derive(Debug, Clone, Deserialize)]
325#[serde(rename_all = "camelCase")]
326pub struct BindingCalledEvent {
327 pub name: String,
329 pub payload: String,
331 pub execution_context_id: ExecutionContextId,
333}
334
335#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
341#[serde(rename_all = "lowercase")]
342pub enum ConsoleApiType {
343 Log,
345 Debug,
347 Info,
349 Error,
351 Warning,
353 Dir,
355 Dirxml,
357 Table,
359 Trace,
361 Clear,
363 Count,
365 Assert,
367 Profile,
369 ProfileEnd,
371 StartGroup,
373 StartGroupCollapsed,
375 EndGroup,
377 TimeEnd,
379}
380
381impl std::fmt::Display for ConsoleApiType {
382 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
383 let s = match self {
384 Self::Log => "log",
385 Self::Debug => "debug",
386 Self::Info => "info",
387 Self::Error => "error",
388 Self::Warning => "warning",
389 Self::Dir => "dir",
390 Self::Dirxml => "dirxml",
391 Self::Table => "table",
392 Self::Trace => "trace",
393 Self::Clear => "clear",
394 Self::Count => "count",
395 Self::Assert => "assert",
396 Self::Profile => "profile",
397 Self::ProfileEnd => "profileEnd",
398 Self::StartGroup => "startGroup",
399 Self::StartGroupCollapsed => "startGroupCollapsed",
400 Self::EndGroup => "endGroup",
401 Self::TimeEnd => "timeEnd",
402 };
403 write!(f, "{s}")
404 }
405}
406
407#[derive(Debug, Clone, Deserialize)]
409#[serde(rename_all = "camelCase")]
410pub struct CallFrame {
411 pub function_name: String,
413 pub script_id: ScriptId,
415 pub url: String,
417 pub line_number: i32,
419 pub column_number: i32,
421}
422
423#[derive(Debug, Clone, Deserialize)]
425#[serde(rename_all = "camelCase")]
426pub struct StackTrace {
427 pub description: Option<String>,
429 pub call_frames: Vec<CallFrame>,
431 pub parent: Option<Box<StackTrace>>,
433 pub parent_id: Option<StackTraceId>,
435}
436
437#[derive(Debug, Clone, Deserialize)]
439#[serde(rename_all = "camelCase")]
440pub struct StackTraceId {
441 pub id: String,
443 pub debugger_id: Option<String>,
445}
446
447#[derive(Debug, Clone, Deserialize)]
451#[serde(rename_all = "camelCase")]
452pub struct ConsoleApiCalledEvent {
453 #[serde(rename = "type")]
455 pub call_type: ConsoleApiType,
456 pub args: Vec<RemoteObject>,
458 pub execution_context_id: ExecutionContextId,
460 pub timestamp: f64,
462 pub stack_trace: Option<StackTrace>,
464 pub context: Option<String>,
467}
468
469#[derive(Debug, Clone, Deserialize)]
477#[serde(rename_all = "camelCase")]
478pub struct ExceptionThrownEvent {
479 pub timestamp: f64,
481 pub exception_details: ExceptionDetails,
483}