Skip to main content

freya_webview/
lib.rs

1//! WebView support for Freya using WRY.
2//!
3//! This crate provides WebView integration for Freya applications using the WRY library.
4//! WebViews can be embedded in your Freya UI as regular elements.
5//!
6//! # Registering the plugin
7//!
8//! WebViews are managed by [`WebViewPlugin`](plugin::WebViewPlugin), so it must be registered in your
9//! `LaunchConfig` with `with_plugin` before any [`WebView`](component::WebView) is rendered. Without
10//! it the [`WebView`](component::WebView) component will panic, as it has no plugin to drive its
11//! lifecycle.
12//!
13//! # Platform compatibility
14//!
15//! WebViews rely on each platform's native web engine, so support is limited to:
16//!
17//! - **Windows**: WebView2.
18//! - **macOS**: WKWebView.
19//! - **Linux (x11)**: WebKitGTK.
20//! - **Linux (Wayland)**: Not supported**.
21//! - **Android**: **Not supported**.
22//!
23//! # Example
24//!
25//! ```rust,no_run
26//! use freya::prelude::*;
27//! use freya_webview::prelude::*;
28//!
29//! fn main() {
30//!     launch(
31//!         LaunchConfig::new()
32//!             // The plugin must be registered for WebViews to work.
33//!             .with_plugin(WebViewPlugin::new())
34//!             .with_window(WindowConfig::new(app)),
35//!     )
36//! }
37//!
38//! fn app() -> impl IntoElement {
39//!     WebView::new("https://example.com").expanded()
40//! }
41//! ```
42
43pub mod component;
44mod element;
45pub mod lifecycle;
46pub mod plugin;
47pub mod registry;
48
49/// Prelude module for convenient imports.
50pub mod prelude {
51    pub use crate::{
52        component::WebView,
53        lifecycle::WebViewManager,
54        plugin::WebViewPlugin,
55        registry::{
56            WebViewConfig,
57            WebViewId,
58        },
59    };
60}