use serde::{Deserialize, Serialize};
pub type ScriptId = String;
pub type ExecutionContextId = i64;
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RemoteObject {
#[serde(rename = "type")]
pub object_type: String,
pub subtype: Option<String>,
pub class_name: Option<String>,
pub value: Option<serde_json::Value>,
pub description: Option<String>,
pub object_id: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExceptionDetails {
pub exception_id: i64,
pub text: String,
pub line_number: i64,
pub column_number: i64,
pub script_id: Option<ScriptId>,
pub url: Option<String>,
pub exception: Option<RemoteObject>,
pub execution_context_id: Option<ExecutionContextId>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct EvaluateParams {
pub expression: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub object_group: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub include_command_line_api: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub silent: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub context_id: Option<ExecutionContextId>,
#[serde(skip_serializing_if = "Option::is_none")]
pub return_by_value: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub await_promise: Option<bool>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EvaluateResult {
pub result: RemoteObject,
pub exception_details: Option<ExceptionDetails>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ExecutionContextCreatedEvent {
pub context: ExecutionContextDescription,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExecutionContextDescription {
pub id: ExecutionContextId,
pub origin: String,
pub name: String,
pub aux_data: Option<ExecutionContextAuxData>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExecutionContextAuxData {
pub frame_id: Option<String>,
pub is_default: Option<bool>,
#[serde(rename = "type")]
pub context_type: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExecutionContextDestroyedEvent {
pub execution_context_id: ExecutionContextId,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CallFunctionOnParams {
pub function_declaration: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub object_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub arguments: Option<Vec<CallArgument>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub silent: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub return_by_value: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub generate_preview: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_gesture: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub await_promise: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub execution_context_id: Option<ExecutionContextId>,
#[serde(skip_serializing_if = "Option::is_none")]
pub object_group: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub throw_on_side_effect: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unique_context_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub serialization_options: Option<serde_json::Value>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CallArgument {
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<serde_json::Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unserializable_value: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub object_id: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CallFunctionOnResult {
pub result: RemoteObject,
pub exception_details: Option<ExceptionDetails>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ReleaseObjectParams {
pub object_id: String,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ReleaseObjectGroupParams {
pub object_group: String,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct GetPropertiesParams {
pub object_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub own_properties: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub accessor_properties_only: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub generate_preview: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub non_indexed_properties_only: Option<bool>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PropertyDescriptor {
pub name: String,
pub value: Option<RemoteObject>,
pub writable: Option<bool>,
pub get: Option<RemoteObject>,
pub set: Option<RemoteObject>,
pub configurable: bool,
pub enumerable: bool,
pub was_thrown: Option<bool>,
pub is_own: Option<bool>,
pub symbol: Option<RemoteObject>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetPropertiesResult {
pub result: Vec<PropertyDescriptor>,
pub internal_properties: Option<Vec<InternalPropertyDescriptor>>,
pub private_properties: Option<Vec<PrivatePropertyDescriptor>>,
pub exception_details: Option<ExceptionDetails>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InternalPropertyDescriptor {
pub name: String,
pub value: Option<RemoteObject>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PrivatePropertyDescriptor {
pub name: String,
pub value: Option<RemoteObject>,
pub get: Option<RemoteObject>,
pub set: Option<RemoteObject>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AddBindingParams {
pub name: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub execution_context_id: Option<ExecutionContextId>,
#[serde(skip_serializing_if = "Option::is_none")]
pub execution_context_name: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct RemoveBindingParams {
pub name: String,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BindingCalledEvent {
pub name: String,
pub payload: String,
pub execution_context_id: ExecutionContextId,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ConsoleApiType {
Log,
Debug,
Info,
Error,
Warning,
Dir,
Dirxml,
Table,
Trace,
Clear,
Count,
Assert,
Profile,
ProfileEnd,
StartGroup,
StartGroupCollapsed,
EndGroup,
TimeEnd,
}
impl std::fmt::Display for ConsoleApiType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let s = match self {
Self::Log => "log",
Self::Debug => "debug",
Self::Info => "info",
Self::Error => "error",
Self::Warning => "warning",
Self::Dir => "dir",
Self::Dirxml => "dirxml",
Self::Table => "table",
Self::Trace => "trace",
Self::Clear => "clear",
Self::Count => "count",
Self::Assert => "assert",
Self::Profile => "profile",
Self::ProfileEnd => "profileEnd",
Self::StartGroup => "startGroup",
Self::StartGroupCollapsed => "startGroupCollapsed",
Self::EndGroup => "endGroup",
Self::TimeEnd => "timeEnd",
};
write!(f, "{s}")
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CallFrame {
pub function_name: String,
pub script_id: ScriptId,
pub url: String,
pub line_number: i32,
pub column_number: i32,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StackTrace {
pub description: Option<String>,
pub call_frames: Vec<CallFrame>,
pub parent: Option<Box<StackTrace>>,
pub parent_id: Option<StackTraceId>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StackTraceId {
pub id: String,
pub debugger_id: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConsoleApiCalledEvent {
#[serde(rename = "type")]
pub call_type: ConsoleApiType,
pub args: Vec<RemoteObject>,
pub execution_context_id: ExecutionContextId,
pub timestamp: f64,
pub stack_trace: Option<StackTrace>,
pub context: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExceptionThrownEvent {
pub timestamp: f64,
pub exception_details: ExceptionDetails,
}