1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//! `oxiui-dioxus` — Dioxus adapter for OxiUI.
//!
//! Provides [`DioxusCtx`] which implements [`UiCtx`] by collecting widget calls,
//! and [`run_dioxus`] which drives a content closure through the Dioxus rendering
//! pipeline.
//!
//! # Feature gate
//!
//! This crate is usable with `default = []`:
//! - [`DioxusCtx`] can be constructed and tested without the `dioxus` feature
//! (collection mode only, no heavy dependencies).
//! - Enable the `dioxus` feature to activate Dioxus rendering in [`run_dioxus`].
//!
//! # Architecture note (M5)
//!
//! Dioxus 0.7 is a reactive, component-based framework: components are functions
//! that return `Element` via the `rsx!` macro. This contrasts with OxiUI's
//! immediate-mode `UiCtx` closure approach. The M5 bridge operates as follows:
//!
//! 1. The content closure is executed against a [`DioxusCtx`], collecting widget
//! descriptions in `DioxusCtx::items`.
//! 2. (M6) Those items are translated into a Dioxus `rsx!` element tree and
//! passed to `dioxus::launch()` as the root component.
//!
//! The `desktop` feature of dioxus (wry/tao, WebKit, Chromium) is intentionally
//! **not** used: it pulls in C/C++ system dependencies that violate the
//! Pure Rust policy. Instead the `minimal` feature set is used for M5:
//! `["macro", "html", "signals", "hooks", "launch"]` — all Pure Rust.
//!
//! Full desktop rendering (M6) will use `dioxus-native` (the Pure Rust Vello/
//! Blitz-based renderer) once it stabilises.
//!
//! # Palette mapping note (M5)
//!
//! Dioxus 0.7 renders via CSS-in-Rust (inline `style=""` attributes).
//! The `palette` argument passed to [`run_dioxus`] is available for downstream
//! consumers who format `style` strings from the palette colours; it is not
//! automatically injected in M5. A helper `palette_to_css_vars()` is planned
//! for M6 to emit `:root { --background: #rrggbb; ... }` global CSS.
//!
//! # Usage (headless)
//!
//! ```rust,ignore
//! use oxiui_dioxus::run_dioxus;
//! use oxiui_theme::cooljapan_dark;
//!
//! run_dioxus(&*cooljapan_dark(), |ui| {
//! ui.heading("Hello from Dioxus");
//! ui.label("OxiUI + dioxus backend");
//! }).expect("run_dioxus should be Ok");
//! ```
pub use DioxusCtx;
use ;
/// Run a Dioxus-backed UI frame with the given theme and content closure.
///
/// # Palette mapping
///
/// Dioxus renders via CSS `style` attributes. The `palette` argument's
/// colours are available for inline-style use in M6+; they are not
/// automatically applied in M5 (see the crate-level note).
///
/// # Behaviour in M5
///
/// In M5 this function executes the content closure in headless collection
/// mode via [`DioxusCtx`] and returns `Ok(())`. No window is opened, no
/// Dioxus runtime is started. This satisfies the "example builds" acceptance
/// criterion without requiring a display or any C/C++ deps (wry/tao are not
/// used).
///
/// The full Dioxus launch path (M6) will use `dioxus-native` (Pure Rust Blitz
/// renderer) and looks like:
///
/// ```rust,ignore
/// #[cfg(feature = "dioxus")]
/// {
/// let items = ctx.items.clone();
/// dioxus::launch(move || {
/// // translate `items` into rsx! element tree
/// rsx! { /* ... */ }
/// });
/// }
/// ```
///
/// # Errors
///
/// Returns [`UiError::Backend`] if the Dioxus launch reports an error (M6+).
/// In M5 this function is always `Ok(())`.