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 pub aux_data: Option<ExecutionContextAuxData>,
109}
110
111#[derive(Debug, Clone, Deserialize)]
113#[serde(rename_all = "camelCase")]
114pub struct ExecutionContextAuxData {
115 pub frame_id: Option<String>,
117 pub is_default: Option<bool>,
119 #[serde(rename = "type")]
121 pub context_type: Option<String>,
122}
123
124#[derive(Debug, Clone, Deserialize)]
126#[serde(rename_all = "camelCase")]
127pub struct ExecutionContextDestroyedEvent {
128 pub execution_context_id: ExecutionContextId,
130}
131
132#[derive(Debug, Clone, Serialize)]
138#[serde(rename_all = "camelCase")]
139pub struct CallFunctionOnParams {
140 pub function_declaration: String,
142 #[serde(skip_serializing_if = "Option::is_none")]
144 pub object_id: Option<String>,
145 #[serde(skip_serializing_if = "Option::is_none")]
147 pub arguments: Option<Vec<CallArgument>>,
148 #[serde(skip_serializing_if = "Option::is_none")]
150 pub silent: Option<bool>,
151 #[serde(skip_serializing_if = "Option::is_none")]
153 pub return_by_value: Option<bool>,
154 #[serde(skip_serializing_if = "Option::is_none")]
156 pub generate_preview: Option<bool>,
157 #[serde(skip_serializing_if = "Option::is_none")]
159 pub user_gesture: Option<bool>,
160 #[serde(skip_serializing_if = "Option::is_none")]
162 pub await_promise: Option<bool>,
163 #[serde(skip_serializing_if = "Option::is_none")]
165 pub execution_context_id: Option<ExecutionContextId>,
166 #[serde(skip_serializing_if = "Option::is_none")]
168 pub object_group: Option<String>,
169 #[serde(skip_serializing_if = "Option::is_none")]
171 pub throw_on_side_effect: Option<bool>,
172 #[serde(skip_serializing_if = "Option::is_none")]
174 pub unique_context_id: Option<String>,
175 #[serde(skip_serializing_if = "Option::is_none")]
177 pub serialization_options: Option<serde_json::Value>,
178}
179
180#[derive(Debug, Clone, Serialize)]
182#[serde(rename_all = "camelCase")]
183pub struct CallArgument {
184 #[serde(skip_serializing_if = "Option::is_none")]
186 pub value: Option<serde_json::Value>,
187 #[serde(skip_serializing_if = "Option::is_none")]
189 pub unserializable_value: Option<String>,
190 #[serde(skip_serializing_if = "Option::is_none")]
192 pub object_id: Option<String>,
193}
194
195#[derive(Debug, Clone, Deserialize)]
197#[serde(rename_all = "camelCase")]
198pub struct CallFunctionOnResult {
199 pub result: RemoteObject,
201 pub exception_details: Option<ExceptionDetails>,
203}
204
205#[derive(Debug, Clone, Serialize)]
211#[serde(rename_all = "camelCase")]
212pub struct ReleaseObjectParams {
213 pub object_id: String,
215}
216
217#[derive(Debug, Clone, Serialize)]
219#[serde(rename_all = "camelCase")]
220pub struct ReleaseObjectGroupParams {
221 pub object_group: String,
223}
224
225#[derive(Debug, Clone, Serialize)]
231#[serde(rename_all = "camelCase")]
232pub struct GetPropertiesParams {
233 pub object_id: String,
235 #[serde(skip_serializing_if = "Option::is_none")]
237 pub own_properties: Option<bool>,
238 #[serde(skip_serializing_if = "Option::is_none")]
240 pub accessor_properties_only: Option<bool>,
241 #[serde(skip_serializing_if = "Option::is_none")]
243 pub generate_preview: Option<bool>,
244 #[serde(skip_serializing_if = "Option::is_none")]
246 pub non_indexed_properties_only: Option<bool>,
247}
248
249#[derive(Debug, Clone, Deserialize)]
251#[serde(rename_all = "camelCase")]
252pub struct PropertyDescriptor {
253 pub name: String,
255 pub value: Option<RemoteObject>,
257 pub writable: Option<bool>,
259 pub get: Option<RemoteObject>,
261 pub set: Option<RemoteObject>,
263 pub configurable: bool,
265 pub enumerable: bool,
267 pub was_thrown: Option<bool>,
269 pub is_own: Option<bool>,
271 pub symbol: Option<RemoteObject>,
273}
274
275#[derive(Debug, Clone, Deserialize)]
277#[serde(rename_all = "camelCase")]
278pub struct GetPropertiesResult {
279 pub result: Vec<PropertyDescriptor>,
281 pub internal_properties: Option<Vec<InternalPropertyDescriptor>>,
283 pub private_properties: Option<Vec<PrivatePropertyDescriptor>>,
285 pub exception_details: Option<ExceptionDetails>,
287}
288
289#[derive(Debug, Clone, Deserialize)]
291#[serde(rename_all = "camelCase")]
292pub struct InternalPropertyDescriptor {
293 pub name: String,
295 pub value: Option<RemoteObject>,
297}
298
299#[derive(Debug, Clone, Deserialize)]
301#[serde(rename_all = "camelCase")]
302pub struct PrivatePropertyDescriptor {
303 pub name: String,
305 pub value: Option<RemoteObject>,
307 pub get: Option<RemoteObject>,
309 pub set: Option<RemoteObject>,
311}
312
313#[derive(Debug, Clone, Serialize)]
319#[serde(rename_all = "camelCase")]
320pub struct AddBindingParams {
321 pub name: String,
323 #[serde(skip_serializing_if = "Option::is_none")]
325 pub execution_context_id: Option<ExecutionContextId>,
326 #[serde(skip_serializing_if = "Option::is_none")]
328 pub execution_context_name: Option<String>,
329}
330
331#[derive(Debug, Clone, Serialize)]
333pub struct RemoveBindingParams {
334 pub name: String,
336}
337
338#[derive(Debug, Clone, Deserialize)]
340#[serde(rename_all = "camelCase")]
341pub struct BindingCalledEvent {
342 pub name: String,
344 pub payload: String,
346 pub execution_context_id: ExecutionContextId,
348}
349
350#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
356#[serde(rename_all = "lowercase")]
357pub enum ConsoleApiType {
358 Log,
360 Debug,
362 Info,
364 Error,
366 Warning,
368 Dir,
370 Dirxml,
372 Table,
374 Trace,
376 Clear,
378 Count,
380 Assert,
382 Profile,
384 ProfileEnd,
386 StartGroup,
388 StartGroupCollapsed,
390 EndGroup,
392 TimeEnd,
394}
395
396impl std::fmt::Display for ConsoleApiType {
397 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
398 let s = match self {
399 Self::Log => "log",
400 Self::Debug => "debug",
401 Self::Info => "info",
402 Self::Error => "error",
403 Self::Warning => "warning",
404 Self::Dir => "dir",
405 Self::Dirxml => "dirxml",
406 Self::Table => "table",
407 Self::Trace => "trace",
408 Self::Clear => "clear",
409 Self::Count => "count",
410 Self::Assert => "assert",
411 Self::Profile => "profile",
412 Self::ProfileEnd => "profileEnd",
413 Self::StartGroup => "startGroup",
414 Self::StartGroupCollapsed => "startGroupCollapsed",
415 Self::EndGroup => "endGroup",
416 Self::TimeEnd => "timeEnd",
417 };
418 write!(f, "{s}")
419 }
420}
421
422#[derive(Debug, Clone, Deserialize)]
424#[serde(rename_all = "camelCase")]
425pub struct CallFrame {
426 pub function_name: String,
428 pub script_id: ScriptId,
430 pub url: String,
432 pub line_number: i32,
434 pub column_number: i32,
436}
437
438#[derive(Debug, Clone, Deserialize)]
440#[serde(rename_all = "camelCase")]
441pub struct StackTrace {
442 pub description: Option<String>,
444 pub call_frames: Vec<CallFrame>,
446 pub parent: Option<Box<StackTrace>>,
448 pub parent_id: Option<StackTraceId>,
450}
451
452#[derive(Debug, Clone, Deserialize)]
454#[serde(rename_all = "camelCase")]
455pub struct StackTraceId {
456 pub id: String,
458 pub debugger_id: Option<String>,
460}
461
462#[derive(Debug, Clone, Deserialize)]
466#[serde(rename_all = "camelCase")]
467pub struct ConsoleApiCalledEvent {
468 #[serde(rename = "type")]
470 pub call_type: ConsoleApiType,
471 pub args: Vec<RemoteObject>,
473 pub execution_context_id: ExecutionContextId,
475 pub timestamp: f64,
477 pub stack_trace: Option<StackTrace>,
479 pub context: Option<String>,
482}
483
484#[derive(Debug, Clone, Deserialize)]
492#[serde(rename_all = "camelCase")]
493pub struct ExceptionThrownEvent {
494 pub timestamp: f64,
496 pub exception_details: ExceptionDetails,
498}