0.3.1-0-pre.2

This commit is contained in:
2026-09-20 21:30:12 +02:00
parent ba718ce4ec
commit 51371c1b24
29 changed files with 981 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/apps/game-snake-poc-wasm/src/runtime.rs
// version: 2
// version: 3
const FIXED_STEP_MILLIS: u64 = 16;
@@ -31,8 +31,16 @@ impl SnakeWasmGame {
};
}
/// Updates browser-observed device and input dimensions while preserving Web/WASM/Browser provenance.
pub fn configure_runtime_provenance(&mut self, device_class: &str, input_profile: &str) -> bool {
/// Updates host-observed runtime provenance while preserving WebAssembly execution.
pub fn configure_runtime_provenance(&mut self, platform_family: &str, runtime_host: &str, device_class: &str, input_profile: &str) -> bool {
let platform_family = match parse_platform_family(platform_family) {
Some(value) => value,
None => return false,
};
let runtime_host = match parse_runtime_host(runtime_host) {
Some(value) => value,
None => return false,
};
let device_class = match parse_device_class(device_class) {
Some(value) => value,
None => return false,
@@ -45,8 +53,8 @@ impl SnakeWasmGame {
device_class,
engine_v1_platform_api::ExecutionModel::Wasm,
input_profile,
engine_v1_platform_api::PlatformFamily::Web,
engine_v1_platform_api::RuntimeHost::Browser,
platform_family,
runtime_host,
);
return true;
}
@@ -236,6 +244,24 @@ impl SnakeWasmGame {
}
}
fn parse_platform_family(label: &str) -> Option<engine_v1_platform_api::PlatformFamily> {
return match label {
"android" => Some(engine_v1_platform_api::PlatformFamily::Android),
"desktop" => Some(engine_v1_platform_api::PlatformFamily::Desktop),
"web" => Some(engine_v1_platform_api::PlatformFamily::Web),
_ => None,
};
}
fn parse_runtime_host(label: &str) -> Option<engine_v1_platform_api::RuntimeHost> {
return match label {
"browser" => Some(engine_v1_platform_api::RuntimeHost::Browser),
"native" => Some(engine_v1_platform_api::RuntimeHost::Native),
"tauri-webview" => Some(engine_v1_platform_api::RuntimeHost::TauriWebView),
_ => None,
};
}
fn parse_device_class(label: &str) -> Option<engine_v1_platform_api::DeviceClass> {
return match label {
"desktop" => Some(engine_v1_platform_api::DeviceClass::Desktop),

View File

@@ -1,5 +1,5 @@
// file: crates/apps/game-snake-poc-wasm/unit_tests/runtime.rs
// version: 2
// version: 3
#[test]
fn direction_is_queued_without_advancing_simulation() {
@@ -34,7 +34,7 @@ fn browser_runtime_provenance_preserves_static_and_observed_dimensions() {
assert_eq!(game.provenance_runtime_host(), "browser");
assert_eq!(game.provenance_device_class(), "unknown");
assert_eq!(game.provenance_input_profile(), "unknown");
assert!(game.configure_runtime_provenance("phone", "touch"));
assert!(game.configure_runtime_provenance("web", "browser", "phone", "touch"));
assert_eq!(game.provenance_device_class(), "phone");
assert_eq!(game.provenance_input_profile(), "touch");
assert_eq!(game.provenance_platform_family(), "web");
@@ -45,8 +45,19 @@ fn browser_runtime_provenance_preserves_static_and_observed_dimensions() {
#[test]
fn invalid_runtime_provenance_labels_are_rejected_without_mutation() {
let mut game = crate::SnakeWasmGame::new();
assert!(game.configure_runtime_provenance("desktop", "keyboard-mouse"));
assert!(!game.configure_runtime_provenance("console", "telepathy"));
assert!(game.configure_runtime_provenance("web", "browser", "desktop", "keyboard-mouse"));
assert!(!game.configure_runtime_provenance("console", "spaceship", "console", "telepathy"));
assert_eq!(game.provenance_device_class(), "desktop");
assert_eq!(game.provenance_input_profile(), "keyboard-mouse");
}
#[test]
fn tauri_android_runtime_provenance_is_supported_by_the_shared_adapter() {
let mut game = crate::SnakeWasmGame::new();
assert!(game.configure_runtime_provenance("android", "tauri-webview", "phone", "touch"));
assert_eq!(game.provenance_platform_family(), "android");
assert_eq!(game.provenance_runtime_host(), "tauri-webview");
assert_eq!(game.provenance_execution_model(), "wasm");
assert_eq!(game.provenance_device_class(), "phone");
assert_eq!(game.provenance_input_profile(), "touch");
}