#[cfg(feature = "widgets")]
mod confirm;
#[cfg(feature = "customize")]
mod customizations;
mod geometry;
pub mod guide;
mod instance;
#[cfg(feature = "widgets")]
mod movable;
#[cfg(all(feature = "playback", not(any(target_arch = "wasm32", target_os = "android", target_os = "ios"))))]
mod pip;
#[cfg(feature = "widgets")]
pub mod router;
mod runner;
mod secure;
#[cfg(all(feature = "headless", feature = "widgets"))]
pub mod testing;
#[cfg(all(feature = "web", target_arch = "wasm32", target_os = "unknown"))]
mod web_fonts;
#[cfg(doctest)]
#[doc = include_str!("../../../README.md")]
struct ReadmeDoctests;
pub static STRINGS: remedy_ui_engine::view::strings::Strings = remedy_ui_engine::engine_strings!("remedy-ui");
#[cfg(feature = "widgets")]
pub use confirm::ConfirmSpec;
pub use geometry::{GEOMETRY_KEY, GeometryStore};
pub use instance::{InstanceReply, ReplyLater};
#[cfg(feature = "widgets")]
pub use movable::{Movable, movable};
pub use remedy_ui_core::Edition;
pub use runner::{
App, AppConfig, BackgroundJob, Cancelled, CloseReason, Completion, GPU_PROMOTE_FRAME_COST,
GPU_PROMOTE_FRAME_STALL, GraphicsAdapter, Leaving, RendererChoice, RendererKind, Runner,
SINGLE_INSTANCE_REPLY, Window, WindowSpec, bundled_fonts,
};
#[cfg(feature = "web")]
pub use remedy_ui_bridge_web as web;
pub use remedy_ui_core as core;
pub use remedy_ui_core::a11y;
#[cfg(target_os = "android")]
pub mod android {
pub use remedy_ui_platform::bridge_android::*;
pub use remedy_ui_platform::main;
}
#[cfg(feature = "headless")]
pub use remedy_ui_platform::bridge_headless as headless;
#[cfg(feature = "gpu-embed")]
pub use remedy_ui_platform::embed_gpu as gpu_embed;
#[cfg(feature = "agents")]
pub use remedy_ui_widgets::automation as agents;
#[cfg(feature = "customize")]
pub use remedy_ui_widgets::customize;
#[cfg(feature = "devtools")]
pub use remedy_ui_widgets::devtools;
#[cfg(feature = "code")]
pub use remedy_ui_widgets::doc_code as code;
#[cfg(feature = "pages")]
pub use remedy_ui_widgets::doc_pages as pages;
#[cfg(feature = "rich")]
pub use remedy_ui_widgets::doc_rich as rich;
#[cfg(feature = "effects")]
pub mod effects {
pub use remedy_ui_engine::effects::*;
pub use remedy_ui_engine::media_effects::*;
#[cfg(feature = "markup")]
pub const MARKUP_PARAMS: &[crate::markup::spec::Param] = &[
crate::markup::spec::Param { name: "name", kind: crate::markup::spec::Kind::Word, required: true },
crate::markup::spec::Param { name: "param", kind: crate::markup::spec::Kind::Word, required: false },
crate::markup::spec::Param {
name: "value",
kind: crate::markup::spec::Kind::Number,
required: false,
},
];
#[cfg(feature = "markup")]
pub fn markup_element(ui: &crate::Ui, call: crate::markup::Call) -> crate::El {
let effect = call.label("name").and_then(library);
let mut el = match effect {
Some(e) => {
let (el, view) = effect_view(ui, Instance::new(e));
match (call.label("param").map(str::to_owned), call.number("value")) {
(Some(param), Some(value)) => el.bind_named("effect value", move || {
let _ = view.set(¶m, value.get() as f32);
}),
_ => el,
}
}
None => ui.el("effect"),
};
for c in call.children {
el = el.child(c);
}
el
}
#[cfg(feature = "markup")]
pub fn register_markup(widgets: &mut crate::markup::Widgets) {
widgets.register("effect", MARKUP_PARAMS, true, markup_element);
}
}
pub use remedy_ui_core::host;
pub use remedy_ui_core::input;
pub use remedy_ui_core::layout;
pub use remedy_ui_engine::paint;
#[cfg(feature = "macros")]
pub use remedy_ui_macros::Store;
#[cfg(feature = "anim")]
pub use remedy_ui_media::media_anim as anim;
#[cfg(feature = "image")]
pub use remedy_ui_media::media_image as image;
#[cfg(feature = "svg")]
pub use remedy_ui_media::media_image::svg;
#[cfg(feature = "isolated")]
pub use remedy_ui_media::media_isolated as isolated;
#[cfg(feature = "video")]
pub use remedy_ui_media::media_video as video;
#[cfg(feature = "playback")]
pub use remedy_ui_media_playback as playback;
#[cfg(feature = "webview")]
pub use remedy_ui_platform::embed_webview as webview;
#[cfg(feature = "gpu")]
pub mod gpu {
pub use remedy_ui_engine::render_gpu::{
GpuLimits, MAX_HEALTH_ENTRIES, MAX_HEALTH_LINE, MAX_KEPT_ERRORS, MAX_VIDEO_IMPORTS, SWAPCHAIN_WAIT,
VIDEO_FENCE_WAIT, gpu_limits, health::PRESENT_HANG, set_gpu_limits,
};
}
pub mod motion {
pub use remedy_ui_engine::view::Transition;
pub use remedy_ui_engine::view::motion::*;
}
pub use remedy_ui_core::reactive;
pub use remedy_ui_core::style;
#[cfg(feature = "board")]
pub use remedy_ui_engine::script;
#[cfg(feature = "script-lua")]
pub use remedy_ui_engine::script_lua;
#[cfg(feature = "script-wasm")]
pub use remedy_ui_engine::script_wasm;
pub use remedy_ui_engine::view;
pub use remedy_ui_engine::view::{CaughtError, Retry, Show, SuspenseBoundary, catch_errors, show, suspense};
pub use remedy_ui_engine::view::{
El, EnterKey, FieldKind, InputPurpose, PaintCx, PointerCaps, TextField, Ui, WindowDirection,
};
#[cfg(feature = "desktop")]
pub use remedy_ui_platform::services_desktop as desktop;
#[cfg(feature = "i18n")]
pub use remedy_ui_platform::services_i18n as i18n;
#[cfg(feature = "net")]
pub use remedy_ui_platform::services_net as net;
#[cfg(feature = "webstorage")]
pub use remedy_ui_platform::services_webstorage as webstorage;
pub use remedy_ui_text as text;
#[cfg(feature = "widgets")]
pub use remedy_ui_widgets::base as widgets;
#[cfg(feature = "board")]
pub use remedy_ui_widgets::board;
#[cfg(feature = "data")]
pub use remedy_ui_widgets::data;
#[cfg(feature = "extra")]
pub use remedy_ui_widgets::extra;
#[cfg(feature = "forms")]
pub use remedy_ui_widgets::forms;
#[cfg(feature = "music")]
pub use remedy_ui_widgets::music;
#[cfg(feature = "nav")]
pub use remedy_ui_widgets::nav;
#[cfg(feature = "markup")]
pub use remedy_ui_widgets::rui as markup;
#[cfg(feature = "spell")]
pub use remedy_ui_widgets::spell;
#[cfg(feature = "stage")]
pub use remedy_ui_widgets::stage;
#[cfg(feature = "widgets")]
pub use remedy_ui_widgets::themes;
#[cfg(feature = "update")]
pub use remedy_ui_widgets::update;
#[cfg(feature = "viz")]
pub use remedy_ui_widgets::viz;
#[cfg(feature = "term")]
pub use remedy_ui_widgets_term as term;
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum RunError {
SingleInstance {
reason: String,
},
Bridge {
reason: String,
},
UnsupportedPlatform,
NeedsFeature {
feature: &'static str,
},
}
impl std::fmt::Display for RunError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
RunError::SingleInstance { reason } => {
write!(f, "the app could not run as a single instance: {reason}")
}
RunError::Bridge { reason } => write!(f, "the app could not run: {reason}"),
RunError::UnsupportedPlatform => {
write!(f, "the app could not run: RemedyUI has no bridge for this platform yet")
}
RunError::NeedsFeature { feature } => {
write!(f, "the app could not run: this platform needs remedy-ui's `{feature}` feature")
}
}
}
}
impl std::error::Error for RunError {}
pub fn run(config: AppConfig, setup: impl FnOnce(&App) + 'static) -> Result<(), RunError> {
#[cfg(all(feature = "net", not(target_arch = "wasm32")))]
let _keepalive = KeepaliveOnExit(config.keepalive_grace);
#[cfg(all(feature = "net", target_os = "android"))]
remedy_ui_platform::services_net::on_keepalive(remedy_ui_platform::bridge_android::hold_process);
#[cfg(target_os = "android")]
remedy_ui_platform::bridge_android::set_held_grace(config.keepalive_grace);
#[cfg(feature = "svg")]
remedy_ui_media::media_image::svg::install();
let inbox = instance::SharedInbox::default();
#[cfg(all(feature = "web", target_arch = "wasm32", target_os = "unknown"))]
if config.single_instance {
let name = config.name.clone();
let web = config.web.clone();
let runner = Runner::new(config, setup).with_inbox(inbox.clone());
let args = remedy_ui_bridge_web::launch_args();
return remedy_ui_bridge_web::run_single_instance(&name, args, web, runner, move |a| {
instance::deliver(&inbox, a, None)
})
.map_err(|e| RunError::SingleInstance { reason: e.reason().to_owned() });
}
#[cfg(windows)]
remedy_ui_platform::bridge_windows::set_instance_wait(config.single_instance_wait);
#[cfg(all(unix, not(any(target_os = "macos", target_os = "ios", target_os = "android"))))]
remedy_ui_platform::bridge_linux::set_drop_waits(config.drop_waits.0, config.drop_waits.1);
if config.single_instance {
let args: Vec<String> = std::env::args().skip(1).collect();
let wait = config
.single_instance_reply
.map(|reply| instance::ReplyWait { reply, exit: config.single_instance_exit });
match instance::claim(&config.name, &args, wait, inbox.clone())
.map_err(|reason| RunError::SingleInstance { reason })?
{
instance::Claimed::First => {}
instance::Claimed::HandedOver(Some(code)) => std::process::exit(code),
instance::Claimed::HandedOver(None) => return Ok(()),
}
}
#[cfg(all(feature = "web", target_arch = "wasm32", target_os = "unknown"))]
let web = config.web.clone();
let runner = Runner::new(config, setup).with_inbox(inbox);
#[cfg(windows)]
{
remedy_ui_platform::bridge_windows::run(runner)
.map_err(|e| RunError::Bridge { reason: e.reason().to_owned() })
}
#[cfg(target_os = "macos")]
{
remedy_ui_platform::bridge_macos::run(runner)
.map_err(|e| RunError::Bridge { reason: e.reason().to_owned() })
}
#[cfg(all(unix, not(any(target_os = "macos", target_os = "ios", target_os = "android"))))]
{
remedy_ui_platform::bridge_linux::run(runner)
.map_err(|e| RunError::Bridge { reason: e.reason().to_owned() })
}
#[cfg(target_os = "android")]
{
remedy_ui_platform::bridge_android::run(runner)
.map_err(|e| RunError::Bridge { reason: e.reason().to_owned() })
}
#[cfg(target_os = "ios")]
{
drop(runner);
Err(RunError::UnsupportedPlatform)
}
#[cfg(all(feature = "web", target_arch = "wasm32", target_os = "unknown"))]
{
remedy_ui_bridge_web::run_with(web, runner)
.map_err(|e| RunError::Bridge { reason: e.reason().to_owned() })
}
#[cfg(all(not(feature = "web"), target_arch = "wasm32", target_os = "unknown"))]
{
drop(runner);
Err(RunError::NeedsFeature { feature: "web" })
}
#[cfg(not(any(windows, unix, all(target_arch = "wasm32", target_os = "unknown"))))]
{
drop(runner);
Err(RunError::UnsupportedPlatform)
}
}
#[cfg(all(feature = "net", not(target_arch = "wasm32")))]
struct KeepaliveOnExit(std::time::Duration);
#[cfg(all(feature = "net", not(target_arch = "wasm32")))]
impl Drop for KeepaliveOnExit {
fn drop(&mut self) {
remedy_ui_platform::services_net::finish_keepalive(self.0);
}
}
#[cfg(feature = "devtools")]
pub fn show_previews(previews: Vec<remedy_ui_widgets::devtools::Preview>) -> Result<(), RunError> {
let (theme, _) = remedy_ui_widgets::devtools::tool_style();
let config = AppConfig::new("RemedyUI previews").theme(theme, remedy_ui_themes_sheet);
run(config, move |app| {
app.open(WindowSpec::new("Previews").size(1100.0, 800.0), move |ui, _| {
let (theme, sheet) = remedy_ui_widgets::devtools::tool_style();
ui.set_theme(theme, sheet);
ui.root().child(remedy_ui_widgets::devtools::gallery(ui, &previews));
});
})
}
#[cfg(feature = "devtools")]
fn remedy_ui_themes_sheet(_: &remedy_ui_core::style::Theme) -> remedy_ui_core::style::StyleSheet {
remedy_ui_widgets::devtools::tool_style().1
}