Expand description

Millennium Webview is a Cross-platform WebView rendering library.

To build a Window with WebView embedded, we could use application module to create EventLoop and the window. It’s a module that re-exports APIs from millennium-core. Then use webview module to create the WebView from the Window. Here’s a minimum example showing how to create a basic window:

fn main() -> millennium_webview::Result<()> {
	use millennium_webview::{
		application::{
			event::{Event, StartCause, WindowEvent},
			event_loop::{ControlFlow, EventLoop},
			window::WindowBuilder
		},
		webview::WebViewBuilder
	};

	let event_loop = EventLoop::new();
	let window = WindowBuilder::new().with_title("Hello World").build(&event_loop)?;
	let _webview = WebViewBuilder::new(window)?.with_url("https://pyke.io/")?.build()?;

	event_loop.run(move |event, _, control_flow| {
		*control_flow = ControlFlow::Wait;

		match event {
			Event::NewEvents(StartCause::Init) => println!("Millennium Webview has started!"),
			Event::WindowEvent {
				event: WindowEvent::CloseRequested, ..
			} => *control_flow = ControlFlow::Exit,
			_ => ()
		}
	});
}

Feature flags

Millennium Webview uses a set of feature flags to toggle several advanced features. file-drop, protocol, and tray are enabled by default.

  • file-drop: Enables with_file_drop_handler to control the behaviour when there are files interacting with the window. Enabled by default.
  • protocol: Enables with_custom_protocol to define custom URL scheme for handling tasks like loading assets. Enabled by default.
  • tray: Enables system tray and more menu item variants on Linux. This flag is enabled by default. This feature requires either libayatana-appindicator or libappindicator to be installed. You can still create those types if you disable it; they just don’t create the actual objects. We set this flag because some implementations require more installed packages.
  • devtools: Enables devtools in release builds. Devtools are always enabled in debug builds. On macOS, enabling devtools requires calling private functions, so you should avoid using this in release builds if your app needs to be published to the App Store.
  • transparent: Transparent background on macOS requires calling private functions. Avoid this in release build if your app needs to publish to App Store.
  • fullscreen: Fullscreen video and other media on macOS requires calling private functions. Avoid this in release build if your app needs to publish to App Store.
  • dox: Enables this in package.metadata.docs.rs section to skip linking some Linux libraries and prevent from building documentation on doc.rs fails.

Modules

Re-exported Millennium Core APIs

WebView struct and associated types.

Enums

Errors returned by Millennium Webview.

Represents any valid JSON value.

Type Definitions

Convenient type alias of Result type for Millennium Webview.