Skip to main content

webui_desktop/
lib.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT license.
3
4//! Native desktop SDK for WebUI applications.
5//!
6//! Bundle loading, rendering, and frame configuration are available without
7//! native dependencies. Enable `application-ipc` for application IPC,
8//! `native` for the platform webview, `source` for
9//! development compilation, and `cli` for the `webui-desktop` tooling binary.
10//! Enable `packaging` to lay out an already-compiled host without source compilation.
11//! Enable `verified-update` for host-only, staged-file byte integrity checks.
12//! Enable `startup-failure` for an explicit host-only pre-frame error alert.
13
14#[cfg(test)]
15extern crate self as webui_desktop;
16
17#[cfg(all(test, feature = "application-ipc"))]
18#[path = "../tests/support/echo.rs"]
19mod ipc_test_support;
20
21#[cfg(all(test, feature = "application-ipc"))]
22#[path = "../tests/ipc_contract.rs"]
23mod ipc_contract_tests;
24
25mod app;
26#[cfg(any(feature = "native", test))]
27mod app_identity;
28mod asset_file;
29#[cfg(any(all(windows, feature = "native"), test))]
30mod browser_profile;
31mod bundle;
32#[cfg(feature = "native-capture")]
33mod capture;
34#[cfg(feature = "native-clipboard")]
35mod clipboard;
36#[cfg(all(feature = "native", feature = "application-ipc"))]
37mod document;
38mod error;
39mod event;
40#[cfg(any(feature = "native", test))]
41mod execution;
42mod frame;
43#[cfg(feature = "local-server")]
44mod frame_policy;
45mod hydration;
46#[cfg(any(test, all(feature = "native", target_os = "macos")))]
47mod icon_path;
48#[cfg(feature = "application-ipc")]
49pub mod ipc;
50#[cfg(test)]
51#[path = "../runtime/ipc_asset_build.rs"]
52mod ipc_asset_build_tests;
53#[cfg(feature = "application-ipc")]
54mod ipc_assets;
55#[cfg(feature = "local-server")]
56mod local_server;
57#[cfg(feature = "native-dialogs")]
58mod native_dialogs;
59#[cfg(all(feature = "native", feature = "application-ipc"))]
60mod native_ipc;
61#[cfg(feature = "native-services")]
62mod native_services;
63#[cfg(all(
64    feature = "native",
65    any(
66        feature = "application-ipc",
67        target_os = "macos",
68        target_os = "windows"
69    )
70))]
71mod native_tasks;
72#[cfg(feature = "native-services")]
73mod native_theme;
74mod navigation;
75#[cfg(any(feature = "source", feature = "packaging"))]
76mod package;
77#[cfg(feature = "packaging")]
78mod package_precompiled;
79mod path;
80mod protocol;
81mod response_content;
82mod routes;
83mod runtime;
84#[cfg(feature = "startup-failure")]
85mod startup_failure;
86#[cfg(feature = "verified-update")]
87pub mod verified_update;
88mod window;
89mod window_state;
90
91#[cfg(all(feature = "native", target_os = "linux"))]
92#[allow(unsafe_code)]
93pub mod linux;
94#[cfg(all(feature = "native", target_os = "macos"))]
95#[allow(unsafe_code)]
96pub mod macos;
97#[cfg(all(feature = "native", target_os = "windows"))]
98#[allow(unsafe_code)]
99pub mod windows;
100
101#[cfg(feature = "native")]
102pub use app::run_packaged_app;
103pub use app::{DesktopApp, DesktopAppBuilder};
104#[cfg(feature = "source")]
105pub use bundle::{build_desktop_bundle, DesktopBundleOptions};
106pub use bundle::{
107    BundleAsset, BundleIntegrity, DesktopBundleManifest, DesktopMenu, DesktopMenuItem,
108    DesktopPackageTarget, DesktopShellConfig, TrayConfig,
109};
110#[cfg(feature = "native-capture")]
111pub use capture::{
112    CaptureError, CaptureOptions, CaptureRequest, CapturedContent, CapturedContentChunk,
113    MAX_WEB_CAPTURE_CHUNK_BYTES, MAX_WEB_CAPTURE_HEIGHT, MAX_WEB_CAPTURE_PNG_BYTES,
114    MAX_WEB_CAPTURE_RASTER_BYTES, MAX_WEB_CAPTURE_WIDTH,
115};
116#[cfg(feature = "native-clipboard")]
117pub use clipboard::{ClipboardError, ClipboardRequest};
118pub use error::{DesktopError, Result, WebsiteDataError};
119pub use event::{
120    DesktopEvent, DesktopHostMessage, DesktopHostMessageError, EventHandler, EventJavascriptError,
121    EventRegistrationError, EventRegistry, EventResponse, EventSubscription, WindowCommand,
122    WindowCommandError, WindowHandle, WindowId, DRAG_REGION_SCRIPT, MAX_EVENT_HANDLERS,
123    MAX_HOST_MESSAGE_BYTES, MAX_QUEUED_WINDOW_COMMANDS, MAX_QUEUED_WINDOW_TITLE_BYTES,
124    MAX_WINDOW_TITLE_BYTES,
125};
126pub use frame::{
127    find_packaged_resources_dir, run_frame_with, validate_frame_capabilities, DesktopFrame,
128    DesktopFrameBackend, DesktopFrameCapabilities,
129};
130#[cfg(feature = "native")]
131pub use frame::{run_frame, run_runtime, PlatformFrameBackend};
132#[cfg(feature = "local-server")]
133pub use frame_policy::{FrameGrant, FramePolicyHandle, HttpFrameOrigin};
134#[cfg(feature = "application-ipc")]
135pub use ipc::{IpcRegistry, DEFAULT_MAX_IPC_PAYLOAD_BYTES, IPC_VERSION};
136#[cfg(feature = "local-server")]
137pub use local_server::bind_owned_local_server;
138#[cfg(all(
139    feature = "local-server",
140    feature = "application-ipc",
141    any(target_os = "macos", target_os = "windows", target_os = "linux")
142))]
143pub use local_server::{local_ipc_runtime_asset, LOCAL_IPC_RUNTIME_PATH};
144#[cfg(feature = "local-server")]
145pub use local_server::{
146    run_local_server_frame, HostCloseError, HostLifetime, HostLifetimeOwner, LocalServerAppBuilder,
147    LocalServerFrame, LocalServerOptions, LoopbackOrigin,
148};
149#[cfg(feature = "native-url-activation")]
150pub use local_server::{
151    UrlActivation, UrlActivationRegistrationError, MAX_URL_ACTIVATIONS_PER_BATCH,
152    MAX_URL_ACTIVATION_BYTES,
153};
154#[cfg(feature = "native-dialogs")]
155pub use native_dialogs::{
156    ConfirmDialog, DialogError, DialogOutcome, DialogRequest, ErrorDialog, MAX_DIALOG_LABEL_BYTES,
157    MAX_DIALOG_MESSAGE_BYTES, MAX_DIALOG_TITLE_BYTES,
158};
159#[cfg(feature = "native-services")]
160pub use native_services::{
161    ContentGeometry, GeometryRequest, NativeOpen, NativeServiceError, NativeServices,
162    ScreenRectPoints, MAX_NATIVE_DOCUMENT_PATH_BYTES, MAX_NATIVE_URL_BYTES,
163};
164#[cfg(feature = "native-picker")]
165pub use native_services::{
166    DirectoryPick, DirectoryPickerOptions, DirectorySelection, MAX_DIRECTORY_PICKER_TITLE_BYTES,
167};
168#[cfg(feature = "native-services")]
169pub use native_theme::{ThemeMode, ThemeRequest, ThemeState};
170pub use navigation::is_allowed_navigation_url;
171#[cfg(feature = "source")]
172pub use package::{package_desktop_bundle, DesktopPackageOptions, DesktopPackageResult};
173#[cfg(feature = "packaging")]
174pub use package_precompiled::{
175    package_precompiled_host, PrecompiledHostOptions, PrecompiledPackageResult,
176    PrecompiledResource, ResourceKind,
177};
178#[cfg(feature = "application-ipc")]
179pub use protocol::IPC_ENDPOINT;
180pub use protocol::{
181    DesktopHttpMethod, DesktopProtocolRequest, DesktopProtocolResponse, DesktopResponseBody,
182    DesktopResponseLease, DEFAULT_MAX_ASSET_BYTES, DEFAULT_MAX_REQUEST_BYTES,
183};
184pub use response_content::{DesktopResponseContent, DesktopResponseFile};
185pub use routes::{ApiContext, ApiRouteRegistry, RouteContext, RouteStateRegistry};
186#[cfg(feature = "source")]
187pub use runtime::DesktopSourceConfig;
188pub use runtime::{DesktopBundleConfig, DesktopRuntime};
189#[cfg(feature = "startup-failure")]
190pub use startup_failure::{
191    present_startup_failure, StartupFailure, StartupFailureError, StartupPresentationError,
192    MAX_STARTUP_HELP_BYTES, MAX_STARTUP_SUMMARY_BYTES, MAX_STARTUP_TITLE_BYTES,
193};
194pub use window::{
195    apply_window_css, window_css_block, window_css_block_with_nonce, CaptionButtonSize,
196    DesktopPlatform, Rgba, RgbaParseError, TitlebarStyle, WindowCssNonceError, WindowEffect,
197    WindowInsets, WindowOptions,
198};
199pub use window_state::{DisplayBounds, WindowState, WindowStateError, WindowStateStore};
200
201#[cfg(feature = "source")]
202pub use webui::{
203    BuildOptions, CssStrategy, DomStrategy, LegalComments, Plugin, DEFAULT_CSS_FILE_NAME_TEMPLATE,
204};