v0.1.0-pre.044

This commit is contained in:
2026-07-25 18:07:51 +02:00
parent e2a349c739
commit c2dbd207d3
25 changed files with 624 additions and 86 deletions

View File

@@ -0,0 +1,93 @@
// file: kb-app-demo-desktop/src/lib.rs
// version: 1
//! Tauri desktop demo application for `khadhroony-bot3`.
#![forbid(unsafe_code)]
#![deny(unreachable_pub)]
#![warn(missing_docs)]
mod constants;
mod splash;
use tauri::Manager; // rust-rules: trait-import
/// Runs the desktop demo application.
pub async fn run() -> kb_core::Result<()> {
let builder = tauri::Builder::default().setup(|app| {
let splash_window = match app.get_webview_window("splash") {
std::option::Option::Some(window) => window,
std::option::Option::None => {
return std::result::Result::Err(std::boxed::Box::new(std::io::Error::new(
std::io::ErrorKind::NotFound,
"splash window is missing",
)));
},
};
let main_window = match app.get_webview_window("main") {
std::option::Option::Some(window) => window,
std::option::Option::None => {
return std::result::Result::Err(std::boxed::Box::new(std::io::Error::new(
std::io::ErrorKind::NotFound,
"main window is missing",
)));
},
};
tauri::async_runtime::spawn(async move {
let started_at = tokio::time::Instant::now();
crate::emit_splash_order(
&splash_window,
"fadein",
std::option::Option::None,
std::option::Option::None,
std::option::Option::Some(crate::SPLASH_FADE_MS),
);
crate::emit_splash_order(
&splash_window,
"add_msg",
std::option::Option::Some("Initialisation de Khadhroony Bot3..."),
std::option::Option::Some("info"),
std::option::Option::None,
);
crate::wait_until_minimum(started_at, crate::SPLASH_MINIMUM_MS).await;
crate::emit_splash_order(
&splash_window,
"fadeout",
std::option::Option::None,
std::option::Option::None,
std::option::Option::Some(crate::SPLASH_FADE_MS),
);
tokio::time::sleep(std::time::Duration::from_millis(crate::SPLASH_CLOSE_WAIT_MS)).await;
if let std::result::Result::Err(error) = splash_window.destroy() {
tracing::error!(target: crate::TRACING_TARGET, "cannot destroy splash window: {error:?}");
}
if let std::result::Result::Err(error) = main_window.show() {
tracing::error!(target: crate::TRACING_TARGET, "cannot show main window: {error:?}");
}
if let std::result::Result::Err(error) = main_window.set_focus() {
tracing::error!(target: crate::TRACING_TARGET, "cannot focus main window: {error:?}");
}
});
return std::result::Result::Ok(());
});
let run_result = builder.run(tauri::generate_context!());
return match run_result {
std::result::Result::Ok(()) => std::result::Result::Ok(()),
std::result::Result::Err(error) => std::result::Result::Err(kb_core::Error::tauri(format!(
"cannot run desktop demo application: {error:?}"
))),
};
}
/// Minimum startup splash duration before fade-out begins.
pub(crate) use self::splash::SPLASH_MINIMUM_MS;
/// Splash fade duration.
pub(crate) use self::splash::SPLASH_FADE_MS;
/// Delay after fade-out before destroying the splash window.
pub(crate) use self::splash::SPLASH_CLOSE_WAIT_MS;
/// Emits one order to the splash frontend.
pub(crate) use self::splash::emit_splash_order;
/// Waits for the minimum splash duration.
pub(crate) use self::splash::wait_until_minimum;
/// Canonical tracing target for the desktop demo application.
pub(crate) use self::constants::TRACING_TARGET;