viewpoint_cdp/protocol/
runtime.rs

1//! Runtime domain types.
2//!
3//! The Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects.
4
5use serde::{Deserialize, Serialize};
6
7/// Unique script identifier.
8pub type ScriptId = String;
9
10/// Unique execution context identifier.
11pub type ExecutionContextId = i64;
12
13/// Remote object value.
14#[derive(Debug, Clone, Deserialize)]
15#[serde(rename_all = "camelCase")]
16pub struct RemoteObject {
17    /// Object type.
18    #[serde(rename = "type")]
19    pub object_type: String,
20    /// Object subtype hint.
21    pub subtype: Option<String>,
22    /// Object class name.
23    pub class_name: Option<String>,
24    /// Remote object value.
25    pub value: Option<serde_json::Value>,
26    /// String representation of the object.
27    pub description: Option<String>,
28    /// Unique object identifier.
29    pub object_id: Option<String>,
30}
31
32/// Exception details.
33#[derive(Debug, Clone, Deserialize)]
34#[serde(rename_all = "camelCase")]
35pub struct ExceptionDetails {
36    /// Exception id.
37    pub exception_id: i64,
38    /// Exception text.
39    pub text: String,
40    /// Line number of the exception location.
41    pub line_number: i64,
42    /// Column number of the exception location.
43    pub column_number: i64,
44    /// Script ID of the exception location.
45    pub script_id: Option<ScriptId>,
46    /// URL of the exception location.
47    pub url: Option<String>,
48    /// Exception object if available.
49    pub exception: Option<RemoteObject>,
50    /// Execution context ID.
51    pub execution_context_id: Option<ExecutionContextId>,
52}
53
54/// Parameters for Runtime.evaluate.
55#[derive(Debug, Clone, Serialize)]
56#[serde(rename_all = "camelCase")]
57pub struct EvaluateParams {
58    /// Expression to evaluate.
59    pub expression: String,
60    /// Object group for the result.
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub object_group: Option<String>,
63    /// Whether to include command line API.
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub include_command_line_api: Option<bool>,
66    /// Whether to disable side effects.
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub silent: Option<bool>,
69    /// Execution context ID.
70    #[serde(skip_serializing_if = "Option::is_none")]
71    pub context_id: Option<ExecutionContextId>,
72    /// Whether to return by value.
73    #[serde(skip_serializing_if = "Option::is_none")]
74    pub return_by_value: Option<bool>,
75    /// Whether to await the promise.
76    #[serde(skip_serializing_if = "Option::is_none")]
77    pub await_promise: Option<bool>,
78}
79
80/// Result of Runtime.evaluate.
81#[derive(Debug, Clone, Deserialize)]
82#[serde(rename_all = "camelCase")]
83pub struct EvaluateResult {
84    /// Evaluation result.
85    pub result: RemoteObject,
86    /// Exception details if the evaluation threw.
87    pub exception_details: Option<ExceptionDetails>,
88}
89
90/// Event: Runtime.executionContextCreated
91#[derive(Debug, Clone, Deserialize)]
92pub struct ExecutionContextCreatedEvent {
93    /// Newly created execution context.
94    pub context: ExecutionContextDescription,
95}
96
97/// Execution context description.
98#[derive(Debug, Clone, Deserialize)]
99#[serde(rename_all = "camelCase")]
100pub struct ExecutionContextDescription {
101    /// Unique execution context id.
102    pub id: ExecutionContextId,
103    /// Execution context origin.
104    pub origin: String,
105    /// Human readable name describing given context.
106    pub name: String,
107}
108
109/// Event: Runtime.executionContextDestroyed
110#[derive(Debug, Clone, Deserialize)]
111#[serde(rename_all = "camelCase")]
112pub struct ExecutionContextDestroyedEvent {
113    /// ID of the destroyed context.
114    pub execution_context_id: ExecutionContextId,
115}