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 = "PascalCase")]
16pub struct WebviewContentOptionsDTO {
17	/// Enables the use of `vscode:command:` URIs within the Webview.
18	pub EnableCommandURIs:Option<bool>,
19
20	/// Enables the execution of scripts within the Webview.
21	pub EnableScripts:Option<bool>,
22
23	/// Enables the use of HTML forms within the Webview.
24	pub EnableForms:Option<bool>,
25
26	/// An optional array of port mappings for forwarding traffic from the
27	/// Webview to the extension host. Serialized
28	/// `Vec<{ webviewPort: number, extensionHostPort: number }>`.
29	#[serde(skip_serializing_if = "Option::is_none")]
30	pub PortMapping:Option<Value>,
31
32	/// An optional array of URIs that define the root paths from which the
33	/// Webview is allowed to load local resources. Serialized
34	/// `Vec<UriComponents>`.
35	#[serde(skip_serializing_if = "Option::is_none")]
36	pub LocalResourceRoots:Option<Value>,
37}