Windows, pages, and menus
Vmux keeps ECS as the single authority for application state while rendering Dioxus pages inside lightweight native WebViews (vmux_page + wry), without requiring Chromium (bevy_cef).
WindowHostPlugin
WindowHostPlugin (vmux_app::window) is the one-line reactive desktop window shell:
App::new().add_plugins(WindowHostPlugin::new(
WindowHostConfig::new("My App")
.size(1024, 720)
.appearance(PageAppearance::Dark)
.page(&MY_PAGE),
));
It composes:
WindowPluginwith centered primary window and IME enabled.- Reactive
WinitSettings::desktop_app()andWinitWakePlugin(neverUpdateMode::Continuous). ShutdownPluginandDisplayRelocationPlugin(recenters windows when monitors disconnect).PageHostPlugin(vmux_page/host) and automatic attachment ofstartup_pageas a full-windowPageRoot.- Multi-window messages:
OpenWindowRequest,CloseWindowRequest, andHideAllWindowsRequest.
Call .headless() on WindowHostConfig to run the same plugin graph in tests or CI without opening an OS window.
Page hosting and static assets
PageHostPlugin (vmux_app::page) manages HostedPage entities:
- Single-page apps: attach
PageRootalongsideHostedPage::new(&PAGE)andChildOf(window)to automatically fill the window viewport. - Multi-pane apps: omit
PageRootand pairHostedPagewithvmux_flex::Node/ComputedNodeandvmux_layout::Pane.PageHostPluginsynchronizes each page's native bounds afterLayoutSystems::Layout. - Static assets: attach
PageStylesheet(css)and/or sharedvmux_ecs::FilePathdirectly to aHostedPageentity (or viaWindowHostConfig::stylesheet/.asset_directory). The native Wry driver serves files over the page's custom scheme (app://...,vmux://...) with path-traversal protection and a minimal fallback stylesheet. - Appearance and scripts: mutate
PageAppearance(Light,Dark,System) on a page entity, or triggerPageScriptRequest { page, script }for targeted DOM evaluation.
UiPlugin, UiState, and UiEvent contracts
UI IPC in vmux_ecs::ui is completely renderer-agnostic. Register states and UI events together with UiPlugin<States, Events>:
app.add_plugins(UiPlugin::<MyUiState, (SaveEvent, DeleteEvent)>::default());
UiPlugin accepts single types or tuples for both States and Events (UiPlugin::<MyUiState>::default() for state-only, UiPlugin::events::<(EventA, EventB)>() for events-only, UiPlugin::default() for base IPC, and UiPlugin::<...>::with_post_update_flush() for PostUpdate flushing). Under the hood it composes:
- Host → UI (
UiStatePlugin<S>): write updates throughUiStateWriter<S>orUiStateWrite<S>.UiStatePlugin<S>batches same-frame updates, enforcesUiEventPermissionsand authority (UiIpcGeneration,UiIpcNavigationRevision,UiIpcEpoch), emitsUiEmitEvent, tracks delivery receipts with bounded retries, and replays the latest snapshot onUiPageReadyorRemove<UiIpcBlocked>. - UI → Host (
UiPlugin::events::<E>()): Dioxus pages send typed#[ui_event]values viasend_ui_event(&event)and subscribe viause_ui_state::<S>().UiPlugin::events::<E>()validates authority, blocking state, andUiEventPermissionsbefore triggeringOn<UiEvent<E>>.
Declarative OS menus
Define native menu bars and keyboard accelerators with #[vmux_app::menu::menu] (vmux_app::menu):
#[vmux_app::menu::menu(standard_edit = "Edit")]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum AppMenu {
#[submenu("File")]
#[item("New Note", id = "new_note", accelerator = "super+n")]
NewNote,
}
Install MenuPlugin and MenuActionPlugin::<AppMenu>::default() (plus NativeMenuPlugin when menu-native is enabled), then handle MessageReader<Selected<AppMenu>>. See examples/primitives/declarative_menu.rs and examples/apps/desktop/workspace.rs.
Hosting an existing web application
Enable vmux_app/hosting to host an existing HTTP(S) web app with a versioned RON package envelope pinned to the host's 40-character SDK revision:
(
schema_version: 1,
sdk_revision: "<the host's full 40-character SDK commit>",
entry: "https://example.test/app/",
manifest: (
metadata: Some((id: "example.web", version: "1.0.0")),
pages: [(
url: "https://example.test/app/",
title: "Example",
startup: true,
permissions: ["PageReady"],
)],
),
)
Decode with Package::try_parse and add WebHostPlugin::new(Contract::new(verified_sdk_revision), package). Web packages remain presentation-only; native behavior comes from statically linked Rust plugins declared in metadata.dependencies and exposed via Contract::event::<Request>(). See examples/apps/desktop/web_host.rs and examples/primitives/manifest_web_host.rs.