public sealed record RunicCsWebUiHostOptions : IEquatable<RunicCsWebUiHostOptions> How a RunicCsWebUiHost shows each window. Pass them to RunicCsWebUiHost.Run, which keeps the process main thread in WebUI's wait loop, or to the constructor.
Remarks
return RunicCsWebUiHost.Run(provider, new RunicCsWebUiHostOptions { UseWebView = true }, async host => { ... });Constructors
RunicCsWebUiHostOptions
public RunicCsWebUiHostOptions() 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 its RunicWindowOptions.ContentRoot is set; nothing is extracted to disk. The window's WebUiWindow.SetFileHandler answers each request, and WebUI still serves webui.js. The source must declare RunicWindowOptions.StartPage, or opening the Window throws FileNotFoundException, and must hold everything the build puts in www/, including the host's runic-views.js. Paths resolve as AssetRoutingOptions defaults do, and a path the source does not declare is answered with 404, never from a folder. The build's archive is the entry assembly's manifest resource that the Runic.Application.FrontendArchive runtime option names, read once per process.
WebUI turns its authentication cookie off for the whole process when a window installs a file handler; the host turns it back on after installing its own, so a window stays bound to the first browser that loaded its webui.js, as with a folder. An application that installs a file handler of its own through RunicCsWebUiHostOptions.ConfigureWindow or RunicCsWebUiHostOptions.ShowWindow replaces the host's.
Assets = AssetArchive.ReadEmbedded(typeof(Program).Assembly, "Frontend.runic-assets").Subdirectory("settings")CloseDrain
public RunicCloseDrain? CloseDrain { get; init; } How long each Window stays visible after its close was decided, while its accepted work drains, for Windows whose RunicWindowOptions.CloseDrain is null. null, the default, is RunicCloseDrain.None.
Remarks
A RunicCsWebUiHostOptions.UseWebView window on Windows (WebView2) or Linux (WebKitGTK) stays open after the user's close, or RunicWindow.RequestCloseAsync, was decided, with its page connected, until the Window's operations, awaited commands and drained scopes have ended or the drain's time passed, as Runic Desktop's embedded window does; a second user close meanwhile is ignored. Under RUNIC_APPLICATION_SERVE_ONLY=1 the Windows drain when serving ends, with a line on standard input, before WebUI's wait ends.
A browser window, a macOS WebView and a window that RunicCsWebUiHostOptions.ShowWindow shows close at once and log WindowCloseDrainUnavailable (event 1055); the Window's scope still waits for durable work.
ConfigureWindow
public Action<WebUiWindow>? ConfigureWindow { get; init; } Configures each native window before it is shown, for example its port or kiosk mode.
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.
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.
MenuBar
public IReadOnlyList<DesktopMenu> MenuBar { get; init; } The menus of each window's menu bar, which the page renders, since a CS-WebUI window has no native bar; empty, the default, for none. RunicCsWebUiHost.SetMenuBar replaces them.
Remarks
The menus follow the rules of Runic Desktop's DesktopHostOptions.MenuBar, and the page reads them, as a Runic Desktop window with DesktopMenuBarPresentation.Page does, through createMenuBarController of @runic-artifex/views or the framework adapters' useMenuBar and injectMenuBar, with its own menubar component. Its placement is "page" while there are menus, on every platform.
Each DesktopMenuItem names a command of the Window's root ViewModel (IRunicMenuCommandSource): the item is enabled while its DesktopMenuItem.IsEnabled and the command's CanExecute(CommandParameter) are true, following CanExecuteChanged, and runs Execute(CommandParameter) in the ViewModel's model turn. WebUI reports no keys to .NET, so the page matches the items' shortcuts (shortcuts: "page"). A failing command is logged as event 2102, CsWebUiMenuCommandFailed.
Creating 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 or starting with runic., or a second Application, File or Help menu.
Placement
public Func<IRunicWindow, RunicWindowPlacement?>? 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 shows. It returns the IRunicWindowPresentation.Placement saved when the Window closed, or null for none, and replaces the size of RunicWindowOptions. The bounds are kept on a monitor that exists now: bounds off every monitor's work area move onto the one they are nearest, and bounds larger than it shrink to fit, as on Runic Desktop.
return RunicCsWebUiHost.Run(provider, new RunicCsWebUiHostOptions
{
UseWebView = true,
Placement = window => window is MainWindow ? settings.MainWindowPlacement : null,
}, async host =>
{
await using var window = await host.OpenWindowAsync<MainWindow>();
await window.WaitForCloseAsync();
settings.MainWindowPlacement = window.Presentation.Placement;
return 0;
});A RunicCsWebUiHostOptions.UseWebView window on Windows (WebView2) or Linux (WebKitGTK) takes the whole placement once it is shown, and reports its own in IRunicWindowPresentation.Placement, also when the user closed it; on Wayland it gets the size and maximized state, since the compositor places windows. A browser window, a macOS WebView and a window that RunicCsWebUiHostOptions.ShowWindow shows take only the size and a position WebUI accepts before showing (0 to 3000 × 0 to 1800), and report no placement. Serve-only mode shows no window and does not call it. A placement saved on one machine or operating system is not meant for another. A callback that throws fails the open.
ShowWindow
public Action<WebUiWindow, string>? ShowWindow { get; init; } Shows each native window in place of the presentation RunicCsWebUiHostOptions.UseWebView selects. It receives the configured window and RunicWindowOptions.StartPage, and can show another URL, such as a frontend development server, or only start the server with WebUiWindow.StartServer.
Remarks
The RUNIC_APPLICATION_SERVE_ONLY switch takes precedence. Under RunicCsWebUiHost.Run the window counts as shown, so RunicWindow.WaitForCloseAsync completes when WebUI's wait returns: show the window or start its server here.
UseWebView
public bool UseWebView { get; init; } Whether windows open in the platform WebView (the Edge WebView2 Runtime on Windows, GTK 3 with WebKitGTK 4.1 on Linux, WKWebView on macOS) instead of WebUI's recommended presentation: an installed browser in app mode (Chromium-based browsers first), then the system default browser, then the WebView. The default is false.