public sealed record DesktopHostOptions : IEquatable<DesktopHostOptions> Configures a Desktop host before its listener starts.
Constructors
DesktopHostOptions
public DesktopHostOptions() No documentation.
Properties
BrowserFolder
public string? BrowserFolder { get; init; } Gets an optional folder searched before system browser locations.
BrowserLaunchAttempts
public int BrowserLaunchAttempts { get; init; } Gets how many times a browser presentation is launched when the browser starts but requests nothing.
Remarks
Each attempt waits the whole DesktopHostOptions.ConnectionTimeout. A browser that is still running but has not requested its page by then is stopped and launched again, with a fresh profile unless the window configures one, and a browser-launch-stalled diagnostic is reported. A page that was requested, a browser that exited and embedded WebViews are never relaunched. Defaults to 2; 1 disables relaunching. Values outside 1 to 5 make building the host throw ArgumentOutOfRangeException.
ConfigureServices
public Action<IServiceCollection>? ConfigureServices { get; init; } Gets an optional service-registration callback run once while the host is built.
ConfirmQuitAsync
public Func<DesktopQuitRequest, CancellationToken, ValueTask<bool>>? ConfirmQuitAsync { get; init; } Gets the application's decision whether to quit, or null, the default, to quit without asking. Returning false keeps the application running.
Remarks
On macOS every quit takes one path, also with no window open: Quit in the application menu (Command and Q) or another sender of terminate: (DesktopQuitSource.Menu), Quit in the Dock or a script's quit Apple event (DesktopQuitSource.Dock), and logging out, restarting or shutting down (DesktopQuitSource.System). Runic first asks this callback, then each window's close guard (DesktopWindowOptions.ConfirmCloseAsync) one at a time; a window whose guard agrees closes. When all agree, DesktopHost.ShutdownRequested is cancelled and the remaining windows close without asking, as for a signal, and AppKit's reply to the system waits until the application's work returns. A refusal at any step keeps the application running and, for a logout or restart, cancels it. Save documents here, or ask the user whether to; the callback runs on the thread pool.
With DesktopHostOptions.HandleShutdownSignals, Ctrl+C, SIGTERM and SIGHUP ask it too (DesktopQuitSource.Signal), on every platform, before the shutdown that closes the windows without close guards; a refusal keeps the application running and a later signal asks again. A second Ctrl+C at least a second after the first still ends the process at once, also while the callback runs. On Windows a closed console, a logoff or a shutdown ends the process when Windows' own timeout expires, whatever the callback answers.
The token is cancelled when the host shuts down for another reason while the callback runs, such as a signal; the shutdown then goes ahead. A callback that throws counts as a refusal and is logged as event 3019, DesktopQuitConfirmationFailed. Requests that arrive while the callback runs share its answer.
ConnectionTimeout
public TimeSpan ConnectionTimeout { get; init; } Gets the bridge authentication deadline.
Remarks
The deadline counts from the launch while the page has requested nothing, and from its first request once it has, so a slow browser start that reaches the server just before the deadline still gets the whole timeout to finish authentication.
Only the page's requests count: those that carry the window's client cookie, which the page's first response sets, or the launch code of the browser the window started. A program that probes the listener, such as a development tool or a security scanner, gets its usual answer but neither moves the deadline nor keeps a browser that stalled before its first request from being relaunched.
An embedded WebView that has requested nothing yet but is still loading the page extends the deadline: it does not run out while the WebView's first navigation is in progress, and not within a whole timeout of the last startup step the WebView reported, up to four times this timeout from the launch (60 seconds with the default). A fresh WebView2 profile can take many seconds to start while Windows services the disk. The Windows WebView2 windows report this progress; the other embedded windows and browsers keep the plain deadline. An extension logs event 3021, and a timeout at the limit says how long the WebView was still loading.
A launch therefore waits at most twice this timeout, and an embedded WebView that requests its page just before the extended limit at most five times it.
DevToolsExtensions
public IReadOnlyList<string> DevToolsExtensions { get; init; } Gets the full paths of unpacked browser extensions, such as React DevTools or Vue DevTools, that the WebView2 windows load in Development; empty, the default, for none.
Remarks
Only when DOTNET_ENVIRONMENT, or else ASPNETCORE_ENVIRONMENT, is Development, as under dotnet runic dev, does a window's WebView2 environment enable browser extensions (AreBrowserExtensionsEnabled). A window whose developer tools are on (DesktopWebContentPolicy.DevTools) then installs each folder into its profile before its first page loads, once per profile and process. Outside Development the option is ignored and extensions stay off, also those an earlier development run installed into the same profile.
The RUNIC_DESKTOP_DEVTOOLS_EXTENSIONS environment variable adds folders for a development session, separated by Path.PathSeparator; entries that are not full paths are skipped. A folder named twice loads once.
Extensions belong to the WebView2 profile, so every window of a profile (DesktopWindowOptions.ProfilePath) runs them, also one whose developer tools are off. WebView2 keeps an installed extension in the profile until its files change. In Development, Runic removes from the profile the extensions it installed whose folders are no longer listed, once per profile and process; it records them in Runic.DevToolsExtensions.json in the user data folder and never removes an extension it did not install. Hosted windows load none. WKWebView, WebKitGTK and installed browsers ignore the option. A folder that WebView2 cannot install, or a runtime without extensions, is reported to DesktopHostOptions.DiagnosticSink as devtools-extension-failed and the window opens without it; so does an installation that takes longer than 15 seconds, and a profile folder that another process holds with extensions off, whose window then opens without extensions. Building the host throws ArgumentException for an entry that is not a full path.
DiagnosticSink
public Action<DesktopDiagnostic>? DiagnosticSink { get; init; } Gets an optional sink for redacted host diagnostics.
HandleShutdownSignals
public bool HandleShutdownSignals { get; init; } Gets whether DesktopEventLoop.Run handles Ctrl+C, SIGTERM and SIGHUP (a closed Windows console) by shutting the application down in order. Defaults to true.
Remarks
The first signal cancels DesktopHost.ShutdownRequested and closes every open window without close confirmation, as if the user had closed them; the application then returns, its window and services release their work, and the host is disposed. A second Ctrl+C, at least a second after the first signal, keeps its default action and ends the process at once; other repeats are ignored. While the host has no surface (no window and no page served at a surface URL), the first signal also keeps its default action unless DesktopHostOptions.HandlesShutdownWithoutWindow is set: nothing would end the application. Set to false when the application handles these signals itself. Hosts created with DesktopHost.StartAsync never register signal handlers.
HandlesShutdownWithoutWindow
public bool HandlesShutdownWithoutWindow { get; init; } Gets whether the application ends its work when DesktopHost.ShutdownRequested is cancelled, also while no window is open. Defaults to false.
Remarks
Set it for an application that runs without a window, such as one behind a status icon, and end its loop on DesktopHost.ShutdownRequested. Then the first Ctrl+C, SIGTERM or SIGHUP shuts it down in order whether or not a window is open. When it is false and the host has no surface, neither a native or browser window nor a page served at a surface URL, the first signal keeps its default action and ends the process, because the host has nothing to close and nothing else would end the application. Has no effect when DesktopHostOptions.HandleShutdownSignals is false.
Linux
public LinuxDesktopOptions Linux { get; init; } Gets explicit Linux embedded-backend selection.
LoggerFactory
public ILoggerFactory? LoggerFactory { get; init; } Gets an optional logger factory for host and window messages, such as a shutdown request or a failed close confirmation. RunicDesktopHost.Run lends it the application's registered ILoggerFactory when it is not set, until Run returns; a later message goes to Trace. When omitted, they are written to Trace.
MacOS
public MacOSDesktopOptions MacOS { get; init; } Gets the macOS application options: the Dock menu and an application delegate of the application's own.
MenuBar
public IReadOnlyList<DesktopMenu> MenuBar { get; init; } Gets the application's menus for the menu bar: on macOS beside the standard application, File, Edit, View and Window menus, in a Windows window on their own; empty by default. The GTK windows show no native menu bar in this release.
Remarks
Each DesktopMenuItem names a command that the key window's DesktopWindow.MenuCommands runs, or else DesktopHost.MenuCommands; an item is enabled while its DesktopMenuItem.IsEnabled is true and one of them can run it, and shows DesktopMenuItem.IsChecked as declared. Titles are user-visible text, so take them from the application's translations, and call DesktopHost.SetMenuBar to show the bar again after the language changes. Building the host throws ArgumentException for a blank title or one longer than 128 characters, a command id outside 1 to 64 ASCII letters, digits, dots, underscores or hyphens, a command id starting with the reserved runic., or a second Application, File or Help menu. See DesktopHost.Validate for the shortcuts it does not apply.
NetworkExposure
public DesktopNetworkExposure NetworkExposure { get; init; } Gets the listener exposure policy.
Port
public int Port { get; init; } Gets the TCP port, where zero selects an ephemeral port.
Security
public DesktopSecurityPolicy Security { get; init; } Gets the default security policy copied by newly created surfaces.
Remarks
DesktopNetworkExposure.AllInterfaces requires assigning this property explicitly.
ShutdownDrainTimeout
public TimeSpan ShutdownDrainTimeout { get; init; } Gets how long a shutdown keeps the windows that drain (DesktopWindowOptions.CloseDrainAsync) open and visible before it closes them. Defaults to 30 seconds; Timeout.InfiniteTimeSpan waits until every drain has returned.
Remarks
A shutdown is Ctrl+C, SIGTERM, SIGHUP or a closed Windows console (DesktopHostOptions.HandleShutdownSignals), and a quit once DesktopHostOptions.ConfirmQuitAsync and the windows' close guards agreed. It cancels DesktopHost.ShutdownStarting, closes the windows without a drain at once and lets the others drain in parallel, then, when all have returned or this time has passed, closes the rest and cancels DesktopHost.ShutdownRequested. Without a window that drains, both tokens are cancelled together, as before 0.19. The time runs from the start of the shutdown; a window's own, shorter drain still applies.
Runic cancels none of the application's work at this limit; only the visible windows close. The process ends earlier only through the operating system or a second Ctrl+C: Windows ends a process about 5 seconds after its console was closed and at logoff or shutdown, systemd sends SIGKILL after TimeoutStopSec (90 seconds by default), docker stop after 10 seconds, and a hosting application after its stop timeout. Keep those limits above this one.
Zero closes the draining windows at once.
SpellCheckingLanguages
public IReadOnlyList<string> SpellCheckingLanguages { get; init; } Gets the BCP 47 languages that the embedded windows' spell checker checks, such as de-CH and en; empty, the default, for the user's languages.
Remarks
The spell checkers of WebKitGTK and macOS belong to the process, not to a window, so the languages are the application's: every window checks with them, and DesktopHost.SetSpellCheckingLanguagesAsync changes them for all, for example when the language of the open document changes. A word is correct when one of the languages accepts it; the page's lang attribute does not choose a dictionary on any platform. DesktopWindowOptions.SpellChecking turns the checker off in a window.
- Linux (WebKitGTK): each language selects an installed hunspell dictionary through enchant.
de-CHselectsde_CH, or else a dictionary fordealone, never one for another region. A language without a region selects the region of the user's locale when it has the same language, such asen_GBforenwithLANG=en_GB.UTF-8, else the language's most common region, else any installed region of it. Without languages, the dictionaries of the user'sLANGUAGE,LC_ALL,LC_MESSAGESandLANGare used, and WebKitGTK chooses one when none of them is installed. A language without a dictionary is not checked, and the window reportsspell-checking-dictionary-missingonce. A desktop may have no dictionaries at all: install them with the distribution's hunspell packages, or with Nix throughbuildRunicApplication'sspellingDictionaries. - macOS: WKWebView checks with the application's
NSSpellChecker. One language selects that language (setLanguage:), matched againstavailableLanguagesas on Linux. With several languages, or none, macOS identifies each paragraph's language among the user's spelling languages (System Settings › Keyboard › Text Input), becauseNSSpellCheckercannot be limited to a set of languages. - Windows: WebView2 has no setting for its spelling languages; it checks in its own language, which
DesktopWindowOptions.Languagesets. It ignores the option, andDesktopHost.Validatereportswindow-option-unsupported.
Installed browsers use their own settings. Two hosts in one process share the platform's checker, so the languages set last apply. Building the host throws ArgumentException for a value that is not a BCP 47 language tag.
StandardMenuTitles
public DesktopStandardMenuTitles? StandardMenuTitles { get; init; } Gets the titles of the standard macOS menus and their items (application, File, Edit, View and Window), or null, the default, for the English titles.
Remarks
Take the titles from the application's own translations, for example from its Runic Translations catalog for the user's language, as for DesktopHostOptions.MenuBar, or from the optional Runic.Application.Views.Translations package (English and German). They apply when the first window opens and to the menus Runic adds to an empty main menu; an application that builds its own main menu keeps its titles. DesktopHost.SetStandardMenuTitles changes them while the application runs. Windows and Linux show no standard menus. Building the host throws ArgumentException for an invalid title, and DesktopHost.Validate reports it as menu-title-invalid; see DesktopStandardMenuTitles.
WaitForConnection
public bool WaitForConnection { get; init; } Gets whether opening a window waits for bridge authentication.
WindowHostFactory
public IDesktopWindowHostFactory? WindowHostFactory { get; init; } Gets the embedded-window factory, or the platform default when omitted.