Skip to main content

CommonLibrary/Webview/DTO/
WebviewContentOptionsDTO.rs

1//! # WebviewContentOptionsDTO
2//!
3//! Defines the Data Transfer Object for a Webview's content and security
4//! settings.
5
6use serde::{Deserialize, Serialize};
7use serde_json::Value;
8
9/// A serializable struct that represents the options controlling the content
10/// within a Webview, including script enablement and local resource access.
11///
12/// This DTO is sent from `Cocoon` to `Mountain` when a Webview is created to
13/// configure its security sandbox and capabilities.
14#[derive(Serialize, Deserialize, Debug, Clone)]
15#[serde(rename_all = "camelCase")]
16pub struct WebviewContentOptionsDTO {
17	/// Enables the use of `vscode:command:` URIs within the Webview.
18	#[serde(rename = "enableCommandUris")]
19	pub EnableCommandURIs:Option<bool>,
20
21	/// Enables the execution of scripts within the Webview.
22	pub EnableScripts:Option<bool>,
23
24	/// Enables the use of HTML forms within the Webview.
25	pub EnableForms:Option<bool>,
26
27	/// An optional array of port mappings for forwarding traffic from the
28	/// Webview to the extension host. Serialized
29	/// `Vec<{ webviewPort: number, extensionHostPort: number }>`.
30	#[serde(skip_serializing_if = "Option::is_none")]
31	pub PortMapping:Option<Value>,
32
33	/// An optional array of URIs that define the root paths from which the
34	/// Webview is allowed to load local resources. Serialized
35	/// `Vec<UriComponents>`.
36	#[serde(skip_serializing_if = "Option::is_none")]
37	pub LocalResourceRoots:Option<Value>,
38}