public sealed record DesktopSurfaceOptions : IEquatable<DesktopSurfaceOptions> Configures one isolated presentation surface.
Constructors
DesktopSurfaceOptions
public DesktopSurfaceOptions() No documentation.
Properties
Content
public DesktopContent Content { get; init; } Gets what the surface serves: a local Directory, an Html document, an ExternalUrl, or a request Handler.
Remarks
Defaults to the current directory with index discovery.
ContentSecurityPolicy
public string? ContentSecurityPolicy { get; init; } Gets the Content-Security-Policy that the surface sends with the HTML of its content, or null, the default, for none.
Exceptions
ArgumentExceptionThe value is empty or contains a character that a header cannot carry.
Remarks
The policy applies to text/html responses of Directory, Html and Handler content and of DesktopSurfaceOptions.Resources. It is sent as a header of its own next to the surface's frame-ancestors policy, and next to a policy that a content handler sets: the browser or WebView enforces every one, so a page can do only what all of them allow. Every embedded WebView and installed browser applies it, since content is served over the surface's loopback listener. The surface's document-start scripts are not subject to page policies. The Bridge needs only 'self': its script is served by the surface, its WebSocket is a same-origin connection, and the Views Bridge's state arrives as data that the script parses. Only DesktopSurface.ExecuteJavaScriptAsync evaluates a string in the page, with the Function constructor, so it fails under a policy whose script-src (or default-src) lacks 'unsafe-eval'. The value must be printable ASCII: a carriage return, line feed, NUL or other control character throws ArgumentException.
ContentSecurityPolicy = "default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'"Path
public string? Path { get; init; } Gets the optional single-segment listener path; an opaque path is generated when omitted.
Resources
public ContentHandler? Resources { get; init; } Gets a handler for the requests that DesktopSurfaceOptions.Content does not serve, such as application files outside the frontend build, or null, the default, for none.
Remarks
The surface asks the handler for a GET or HEAD request only when DesktopSurfaceOptions.Content has no file or response for it, before it responds 404 Not Found; a null response is 404. The resources are served from the surface's own URL, so a page shown in a window and the same page served to a browser load them alike, for example as <img src="icons/org.example.App.png">. ContentRequest.Path is decoded and can contain .. segments: never pass it to the file system unchecked.
Security
public DesktopSecurityPolicy? Security { get; init; } Gets a surface-specific security policy, or the host default when omitted.
UseIsolatedListener
public bool UseIsolatedListener { get; init; } Gets whether this surface owns a separate listener.