public sealed record RunicDesktopHostOptions : IEquatable<RunicDesktopHostOptions> The options of a RunicDesktopHost's Windows: their Desktop window and surface options, resources and saved placement. Pass them to RunicDesktopHost.Run or the constructor.
Remarks
return RunicDesktopHost.Run(provider, new DesktopHostOptions(), new RunicDesktopHostOptions
{
Placement = window => window is MainWindow ? settings.MainWindowPlacement : null,
}, async host => { ... });The host reads the options when it is created. Application menu bar commands are application-wide, not per host: see RunicDesktopHost.UseApplicationMenu.
Constructors
RunicDesktopHostOptions
public RunicDesktopHostOptions() No documentation.
Properties
Assets
public IAssetSource? Assets { get; init; } The frontend every Window serves in place of its web root, or null, the default, for the archive that the build embedded with RunicApplicationFrontendDelivery=Embedded, if any.
Remarks
A Window serves this source, or the build's archive, unless RunicDesktopHostOptions.SurfaceOptions are set, its RunicWindowOptions.ContentRoot is set, or dotnet runic dev serves the frontend output live. The root serves RunicWindowOptions.StartPage, which the source must declare, and paths resolve as AssetRoutingOptions defaults do. The source must hold everything the build puts in www/, including the host's runic-views.js. The build's archive is the entry assembly's manifest resource that the Runic.Application.FrontendArchive runtime option names, read once per process.
Assets = await AssetArchive.ReadAsync(File.OpenRead("frontend.runic-assets"))CloseDrain
public RunicCloseDrain? CloseDrain { get; init; } How long Windows whose RunicWindowOptions.CloseDrain is null stay visible after their close was decided, while their accepted work drains. null, the default, is RunicCloseDrain.None: the window closes at once, as before 0.19. The host reads it when each Window opens.
Remarks
With a drain, a user close that the Window's guards approved, RequestCloseAsync and a quit leave the embedded window open and its page connected until the Window's operations, its awaited commands and the scopes it drains (IRunicWindowContext.DrainOnClose) have ended or the drain's timeout passed (DesktopWindowOptions.CloseDrainAsync). A Ctrl+C, SIGTERM or quit drains the same way, for up to DesktopHostOptions.ShutdownDrainTimeout. An installed browser, serve-only mode and a hosted application's region keep no window of their own open: they log WindowCloseDrainUnavailable (event 1055), and the process still waits for durable work before the Window's scope is released. A hosted application's Window drains before it reports window-closed, and the host keeps its window until then.
ContentSecurityPolicy
public string? ContentSecurityPolicy { get; init; } The Content-Security-Policy that every Window's surface sends with its HTML (DesktopSurfaceOptions.ContentSecurityPolicy), or null, the default, for none.
Exceptions
ArgumentExceptionThe value is empty or contains a character that a header cannot carry.
Remarks
It applies to the default surface options and to RunicDesktopHostOptions.SurfaceOptions that set no policy of their own. The policy is a header of its own next to the surface's frame-ancestors policy; both are enforced. The Bridge needs 'self' scripts and connections and no 'unsafe-eval': state arrives as data that the served bridge script parses. DesktopSurface.ExecuteJavaScriptAsync evaluates a string, so it still needs 'unsafe-eval'.
ContentSecurityPolicy = "default-src 'self'; script-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'"FlowCultureFromLocale
public bool? FlowCultureFromLocale { get; init; } Whether the bridged invocations of Windows whose RunicWindowOptions.FlowCultureFromLocale is null run in the culture of the Window's locale (WindowContentSessionOptions.FlowCultureFromLocale). null, the default, keeps the process's cultures. The host reads it when each Window opens.
Guest
public RunicGuestOptions? Guest { get; init; } Runs the application in hosted mode, shown in the windows of a host application that started it, or null, the default, to show its own windows. See RunicGuestOptions.
Remarks
Only RunicDesktopHost.Run starts hosted mode: before the body runs, it completes the host's handshake or throws RunicHostedApplicationException. Hosted mode takes precedence over RunicDesktopHostOptions.ServeOnly, RUNIC_APPLICATION_SERVE_ONLY and RUNIC_APPLICATION_CLOSE_AFTER_OPEN.
IncludeFailureDetail
public bool? IncludeFailureDetail { get; init; } Whether the Bridge error replies of a Window carry the exception type, message and stack, for Windows whose RunicWindowOptions.IncludeFailureDetail is null. null, the default, includes them only in a Development environment.
Remarks
The application-wide default; a Window's own RunicWindowOptions.IncludeFailureDetail takes precedence. Detail can contain file paths and application data. The host reads it when each Window opens.
MaximumInputBytes
public int? MaximumInputBytes { get; init; } The largest Bridge input, in UTF-8 bytes, of Windows whose RunicWindowOptions.MaximumInputBytes is null (WindowContentSessionOptions.MaximumInputBytes), between 1 KiB and 64 MiB. null, the default, is 1 MiB. The host reads it when each Window opens.
MaximumPendingUploadBytes
public long? MaximumPendingUploadBytes { get; init; } The most bytes that unclaimed uploads may take at once in Windows whose RunicWindowOptions.MaximumPendingUploadBytes is null (WindowContentSessionOptions.MaximumPendingUploadBytes), at least 1 KiB. null, the default, is 1 GiB. The host reads it when each Window opens.
MaximumUploadBytes
public long? MaximumUploadBytes { get; init; } The largest file the page may upload to Windows whose RunicWindowOptions.MaximumUploadBytes is null (WindowContentSessionOptions.MaximumUploadBytes), at least 1 KiB. null, the default, is 256 MiB. The host reads it when each Window opens.
Placement
public Func<IRunicWindow, DesktopWindowPlacement?>? Placement { get; init; } Chooses the saved placement each Window restores: its size, position and maximized state from the last time it closed. null, the default, restores none.
Remarks
Called with each Window as it opens, once its ViewModel is set, before its native window opens. It returns the placement saved from DesktopPlatformServices.GetWindowState, or null for none, and it becomes DesktopWindowOptions.Placement of the Window, replacing the size of RunicDesktopHostOptions.WindowOptions and RunicWindowOptions. The embedded window keeps a restored placement on a monitor that exists now; see DesktopWindowOptions.Placement.
return RunicDesktopHost.Run(provider, new DesktopHostOptions(), new RunicDesktopHostOptions
{
Placement = window => window is MainWindow ? settings.MainWindowPlacement : null,
}, async host =>
{
await using var window = await host.OpenWindowAsync<MainWindow>();
await window.WaitForCloseAsync();
if (DesktopPlatformServices.GetWindowState(window) is PlatformResult<DesktopWindowState>.Success { Value: var state })
settings.MainWindowPlacement = state.Placement;
return 0;
});A placement saved on one machine or operating system is not meant for another; see DesktopWindowPlacement. A callback that throws fails the open.
Resources
public Func<IRunicWindow, ContentHandler?>? Resources { get; init; } Chooses the resources of each Window: application files outside the frontend build, such as icons from a cache, that the Window's page loads from its own address. null, the default, serves none.
Remarks
Called with each Window as it opens, once its ViewModel is set (RunicWindow.ViewModel) and before its surface is created. It returns the handler for the requests the Window's content does not serve, or null for none, and it becomes DesktopSurfaceOptions.Resources of the Window's surface, replacing the one of RunicDesktopHostOptions.SurfaceOptions. The resources are served whether the Window is shown or served to a browser under RUNIC_APPLICATION_SERVE_ONLY, for as long as the Window is open.
new RunicDesktopHostOptions
{
Resources = window => window is DashboardWindow ? icons.ServeAsync : null,
}A handler that throws fails the request with 500, and a callback that throws fails the open.
ServeOnly
public bool ServeOnly { get; init; } Whether the host's Windows are served to a browser instead of shown, as with RUNIC_APPLICATION_SERVE_ONLY=1, without setting an environment variable that child processes inherit. The default, false, follows that variable.
Remarks
A serve-only Window creates its surface, writes RUNIC_APPLICATION_URL=<url> to standard output and serves until a line is read from standard input, shutdown is requested or the process ends; see RunicDesktopHost. With RunicDesktopHost.Run the window toolkit's event loop does not start either, so a headless machine reports no gtk4-display-unavailable. Open a served Window in the user's browser with the application's launcher, DesktopPlatformServices.ForApplication, which needs no window:
await DesktopPlatformServices.ForApplication().FileLauncher.LaunchUriAsync(RunicDesktopHost.GetSurface(window)!.Url);SurfaceOptions
public DesktopSurfaceOptions? SurfaceOptions { get; init; } The surface options of every window, or null, the default, to serve RunicWindowOptions.ContentRoot and open RunicWindowOptions.StartPage.
WindowOptions
public DesktopWindowOptions WindowOptions { get; init; } The Desktop options of every window; RunicDesktopHost.DefaultWindowOptions by default. RunicWindowOptions.Width and RunicWindowOptions.Height replace their width and height when set.