0.3.1-0-pre.2
This commit is contained in:
21
crates/apps/game-snake-poc-tauri/src/lib.rs
Normal file
21
crates/apps/game-snake-poc-tauri/src/lib.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
// file: crates/apps/game-snake-poc-tauri/src/lib.rs
|
||||
// version: 1
|
||||
|
||||
//! Tauri Android application facade for the Snake WebAssembly POC.
|
||||
|
||||
#![forbid(unsafe_code)]
|
||||
#![deny(unreachable_pub)]
|
||||
#![warn(missing_docs)]
|
||||
|
||||
mod runtime;
|
||||
mod tauri;
|
||||
|
||||
/// Runs the Snake Tauri application.
|
||||
pub use self::tauri::run;
|
||||
|
||||
/// Runtime descriptor exposed by the native Tauri bridge.
|
||||
pub(crate) use self::runtime::RuntimeDescriptorDto;
|
||||
/// Records that the Tauri frontend completed its minimal startup sequence.
|
||||
pub(crate) use self::runtime::record_frontend_ready;
|
||||
/// Returns the canonical runtime descriptor for the Android WebView host.
|
||||
pub(crate) use self::runtime::runtime_descriptor;
|
||||
20
crates/apps/game-snake-poc-tauri/src/main.rs
Normal file
20
crates/apps/game-snake-poc-tauri/src/main.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
// file: crates/apps/game-snake-poc-tauri/src/main.rs
|
||||
// version: 1
|
||||
|
||||
//! Binary entry point for host-side Snake Tauri checks.
|
||||
|
||||
#![forbid(unsafe_code)]
|
||||
#![deny(unreachable_pub)]
|
||||
#![warn(missing_docs)]
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() -> std::process::ExitCode {
|
||||
let result = game_snake_poc_tauri_lib::run();
|
||||
return match result {
|
||||
std::result::Result::Ok(()) => std::process::ExitCode::SUCCESS,
|
||||
std::result::Result::Err(error) => {
|
||||
eprintln!("Snake Tauri application error: {error}");
|
||||
std::process::ExitCode::FAILURE
|
||||
},
|
||||
};
|
||||
}
|
||||
87
crates/apps/game-snake-poc-tauri/src/runtime.rs
Normal file
87
crates/apps/game-snake-poc-tauri/src/runtime.rs
Normal file
@@ -0,0 +1,87 @@
|
||||
// file: crates/apps/game-snake-poc-tauri/src/runtime.rs
|
||||
// version: 1
|
||||
|
||||
/// Stable runtime dimensions exposed to the Tauri frontend.
|
||||
#[derive(Clone, Debug, serde::Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct RuntimeDescriptorDto {
|
||||
device_class: String,
|
||||
execution_model: String,
|
||||
input_profile: String,
|
||||
platform_family: String,
|
||||
runtime_host: String,
|
||||
}
|
||||
|
||||
/// Returns the canonical runtime descriptor for the Android WebView host.
|
||||
pub(crate) fn runtime_descriptor() -> RuntimeDescriptorDto {
|
||||
let provenance = engine_v1_platform_api::RuntimeProvenance::new(
|
||||
engine_v1_platform_api::DeviceClass::Unknown,
|
||||
engine_v1_platform_api::ExecutionModel::Wasm,
|
||||
engine_v1_platform_api::InputProfile::Unknown,
|
||||
engine_v1_platform_api::PlatformFamily::Android,
|
||||
engine_v1_platform_api::RuntimeHost::TauriWebView,
|
||||
);
|
||||
return RuntimeDescriptorDto {
|
||||
device_class: device_class_label(provenance.device_class()).to_string(),
|
||||
execution_model: execution_model_label(provenance.execution_model()).to_string(),
|
||||
input_profile: input_profile_label(provenance.input_profile()).to_string(),
|
||||
platform_family: platform_family_label(provenance.platform_family()).to_string(),
|
||||
runtime_host: runtime_host_label(provenance.runtime_host()).to_string(),
|
||||
};
|
||||
}
|
||||
|
||||
/// Records that the Tauri frontend completed its minimal startup sequence.
|
||||
pub(crate) fn record_frontend_ready() {
|
||||
let descriptor = crate::runtime_descriptor();
|
||||
tracing::info!(
|
||||
target: "games::tauri::snake",
|
||||
action = "frontend_ready",
|
||||
platform_family = descriptor.platform_family,
|
||||
runtime_host = descriptor.runtime_host,
|
||||
execution_model = descriptor.execution_model,
|
||||
"Snake Tauri frontend ready"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
fn device_class_label(value: engine_v1_platform_api::DeviceClass) -> &'static str {
|
||||
return match value {
|
||||
engine_v1_platform_api::DeviceClass::Desktop => "desktop",
|
||||
engine_v1_platform_api::DeviceClass::Phone => "phone",
|
||||
engine_v1_platform_api::DeviceClass::Tablet => "tablet",
|
||||
engine_v1_platform_api::DeviceClass::Unknown => "unknown",
|
||||
};
|
||||
}
|
||||
|
||||
fn execution_model_label(value: engine_v1_platform_api::ExecutionModel) -> &'static str {
|
||||
return match value {
|
||||
engine_v1_platform_api::ExecutionModel::Native => "native",
|
||||
engine_v1_platform_api::ExecutionModel::Wasm => "wasm",
|
||||
};
|
||||
}
|
||||
|
||||
fn input_profile_label(value: engine_v1_platform_api::InputProfile) -> &'static str {
|
||||
return match value {
|
||||
engine_v1_platform_api::InputProfile::Gamepad => "gamepad",
|
||||
engine_v1_platform_api::InputProfile::KeyboardMouse => "keyboard-mouse",
|
||||
engine_v1_platform_api::InputProfile::Mixed => "mixed",
|
||||
engine_v1_platform_api::InputProfile::Touch => "touch",
|
||||
engine_v1_platform_api::InputProfile::Unknown => "unknown",
|
||||
};
|
||||
}
|
||||
|
||||
fn platform_family_label(value: engine_v1_platform_api::PlatformFamily) -> &'static str {
|
||||
return match value {
|
||||
engine_v1_platform_api::PlatformFamily::Android => "android",
|
||||
engine_v1_platform_api::PlatformFamily::Desktop => "desktop",
|
||||
engine_v1_platform_api::PlatformFamily::Web => "web",
|
||||
};
|
||||
}
|
||||
|
||||
fn runtime_host_label(value: engine_v1_platform_api::RuntimeHost) -> &'static str {
|
||||
return match value {
|
||||
engine_v1_platform_api::RuntimeHost::Browser => "browser",
|
||||
engine_v1_platform_api::RuntimeHost::Native => "native",
|
||||
engine_v1_platform_api::RuntimeHost::TauriWebView => "tauri-webview",
|
||||
};
|
||||
}
|
||||
65
crates/apps/game-snake-poc-tauri/src/tauri.rs
Normal file
65
crates/apps/game-snake-poc-tauri/src/tauri.rs
Normal file
@@ -0,0 +1,65 @@
|
||||
// file: crates/apps/game-snake-poc-tauri/src/tauri.rs
|
||||
// version: 1
|
||||
|
||||
//! Tauri runtime assembly and Web/Rust commands for the Snake Android POC.
|
||||
|
||||
#[tauri::command]
|
||||
fn get_runtime_descriptor() -> crate::RuntimeDescriptorDto {
|
||||
return crate::runtime_descriptor();
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn frontend_ready() {
|
||||
crate::record_frontend_ready();
|
||||
return;
|
||||
}
|
||||
|
||||
fn configure_plugins(builder: tauri::Builder<tauri::Wry>) -> tauri::Builder<tauri::Wry> {
|
||||
let tracing_plugin = tauri_plugin_tracing::Builder::new().build::<tauri::Wry>();
|
||||
return builder.plugin(tracing_plugin);
|
||||
}
|
||||
|
||||
#[allow(clippy::question_mark_used)] // Tauri generates the question-mark operator internally for command dispatch.
|
||||
fn configure_commands(builder: tauri::Builder<tauri::Wry>) -> tauri::Builder<tauri::Wry> {
|
||||
return builder.invoke_handler(tauri::generate_handler![get_runtime_descriptor, frontend_ready]);
|
||||
}
|
||||
|
||||
/// Runs the Snake Tauri application.
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() -> std::result::Result<(), String> {
|
||||
let logging_guard = game_logging_lib::init_console_tracing();
|
||||
let _logging_guard = match logging_guard {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => return std::result::Result::Err(error.to_string()),
|
||||
};
|
||||
tracing::info!(
|
||||
target: "games::tauri::snake",
|
||||
action = "runtime_start",
|
||||
platform_family = "android",
|
||||
runtime_host = "tauri-webview",
|
||||
execution_model = "wasm",
|
||||
"Starting Snake Tauri Android runtime"
|
||||
);
|
||||
let builder = tauri::Builder::default();
|
||||
let builder = configure_plugins(builder);
|
||||
let builder = configure_commands(builder);
|
||||
return match builder.run(tauri::generate_context!()) {
|
||||
std::result::Result::Ok(()) => {
|
||||
tracing::info!(
|
||||
target: "games::tauri::snake",
|
||||
action = "runtime_stop",
|
||||
"Snake Tauri runtime stopped"
|
||||
);
|
||||
std::result::Result::Ok(())
|
||||
},
|
||||
std::result::Result::Err(error) => {
|
||||
tracing::error!(
|
||||
target: "games::tauri::snake",
|
||||
action = "runtime_error",
|
||||
error = error.to_string(),
|
||||
"Snake Tauri runtime failed"
|
||||
);
|
||||
std::result::Result::Err(error.to_string())
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user