From 9d0c0b3fb0570ef82f3d240ac5dd6d35c8b71b82 Mon Sep 17 00:00:00 2001 From: Erik Chou Date: Tue, 24 Feb 2026 15:20:08 -0800 Subject: [PATCH] Add JsDos and Ruffle engine types Co-Authored-By: Claude Opus 4.6 --- src/config.rs | 60 +++++++++++++++++++++++++++++++++++++++++--------- src/dev/mod.rs | 6 ++--- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/src/config.rs b/src/config.rs index 21ff719..93d1c66 100644 --- a/src/config.rs +++ b/src/config.rs @@ -102,6 +102,18 @@ pub struct CustomSection { pub entrypoint: String, } +#[derive(Debug, Deserialize)] +pub struct JsDosSection { + pub version: String, + pub entrypoint: String, +} + +#[derive(Debug, Deserialize)] +pub struct RuffleSection { + pub version: String, + pub entrypoint: String, +} + #[derive(Debug, Deserialize)] pub struct WavedashConfig { pub game_id: String, @@ -116,6 +128,12 @@ pub struct WavedashConfig { #[serde(rename = "custom")] pub custom: Option, + + #[serde(rename = "jsdos")] + pub jsdos: Option, + + #[serde(rename = "ruffle")] + pub ruffle: Option, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -123,6 +141,8 @@ pub enum EngineKind { Godot, Unity, Custom, + JsDos, + Ruffle, } impl EngineKind { @@ -131,6 +151,8 @@ impl EngineKind { EngineKind::Godot => "godot", EngineKind::Unity => "unity", EngineKind::Custom => "custom", + EngineKind::JsDos => "jsdos", + EngineKind::Ruffle => "ruffle", } } @@ -139,6 +161,8 @@ impl EngineKind { EngineKind::Godot => "GODOT", EngineKind::Unity => "UNITY", EngineKind::Custom => "CUSTOM", + EngineKind::JsDos => "JSDOS", + EngineKind::Ruffle => "RUFFLE", } } } @@ -160,16 +184,24 @@ impl WavedashConfig { } pub fn engine_type(&self) -> Result { - match ( - self.godot.is_some(), - self.unity.is_some(), - self.custom.is_some(), - ) { - (true, false, false) => Ok(EngineKind::Godot), - (false, true, false) => Ok(EngineKind::Unity), - (false, false, true) => Ok(EngineKind::Custom), + let engines: Vec = [ + self.godot.is_some().then_some(EngineKind::Godot), + self.unity.is_some().then_some(EngineKind::Unity), + self.custom.is_some().then_some(EngineKind::Custom), + self.jsdos.is_some().then_some(EngineKind::JsDos), + self.ruffle.is_some().then_some(EngineKind::Ruffle), + ] + .into_iter() + .flatten() + .collect(); + + match engines.len() { + 1 => Ok(engines[0]), + 0 => anyhow::bail!( + "Config must have exactly one engine section: [godot], [unity], [custom], [jsdos], or [ruffle]" + ), _ => anyhow::bail!( - "Config must have exactly one of [godot], [unity], or [custom] sections" + "Config must have exactly one engine section: [godot], [unity], [custom], [jsdos], or [ruffle]" ), } } @@ -181,12 +213,20 @@ impl WavedashConfig { Ok(&unity.version) } else if let Some(ref custom) = self.custom { Ok(&custom.version) + } else if let Some(ref jsdos) = self.jsdos { + Ok(&jsdos.version) + } else if let Some(ref ruffle) = self.ruffle { + Ok(&ruffle.version) } else { anyhow::bail!("No engine section found") } } pub fn entrypoint(&self) -> Option<&str> { - self.custom.as_ref().map(|c| c.entrypoint.as_str()) + self.custom + .as_ref() + .map(|c| c.entrypoint.as_str()) + .or_else(|| self.jsdos.as_ref().map(|j| j.entrypoint.as_str())) + .or_else(|| self.ruffle.as_ref().map(|r| r.entrypoint.as_str())) } } diff --git a/src/dev/mod.rs b/src/dev/mod.rs index f83aff5..5b5f5ba 100644 --- a/src/dev/mod.rs +++ b/src/dev/mod.rs @@ -63,11 +63,11 @@ pub async fn handle_dev(config_path: Option, verbose: bool, no_open: bo let engine_kind = wavedash_config.engine_type()?; let engine_label = engine_kind.as_label(); - let entrypoint = if matches!(engine_kind, EngineKind::Custom) { + let entrypoint = if matches!(engine_kind, EngineKind::Custom | EngineKind::JsDos | EngineKind::Ruffle) { Some( wavedash_config .entrypoint() - .ok_or_else(|| anyhow::anyhow!("Custom engine configs require an entrypoint"))? + .ok_or_else(|| anyhow::anyhow!("Engine config requires an entrypoint"))? .to_string(), ) } else { @@ -88,7 +88,7 @@ pub async fn handle_dev(config_path: Option, verbose: bool, no_open: bo })?; Some(fetch_entrypoint_params(engine_label, html_path).await?) } - EngineKind::Custom => None, + EngineKind::Custom | EngineKind::JsDos | EngineKind::Ruffle => None, }; let (rustls_config, cert_path, _key_path) = load_or_create_certificates().await?;