diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 07c6625..a6fb06d 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -9,6 +9,15 @@ use std::{ const WEB_BUILD_DIR: &str = "web-build"; +#[derive(clap::ValueEnum, Clone, Debug, PartialEq)] +enum BuildTarget { + Messages, + Wasm, + Server, + Routes, + Keys, +} + #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct Cli { @@ -19,7 +28,11 @@ struct Cli { #[derive(Subcommand, Debug)] enum Commands { /// Builds the website and server, including wasm files - Build, + Build { + /// Build only specific targets (comma-separated). Omit for full build. + #[arg(long, value_delimiter = ',')] + only: Vec, + }, /// Runs the server locally Start { @@ -64,16 +77,20 @@ fn main() { let cli = Cli::parse(); match &cli.command { - Commands::Build => { + Commands::Build { only } => { println!("Executing build command..."); - build(); + if only.is_empty() { + build_full(); + } else { + build_targeted(only); + } } Commands::Start { rebuild } => { println!("Starting server..."); if *rebuild { println!("Rebuilding web pages..."); - build(); + build_full(); } // Change the current working directory of the running Rust program println!("Changing directory to {WEB_BUILD_DIR}..."); let cd_result = std::env::set_current_dir(WEB_BUILD_DIR); @@ -254,9 +271,15 @@ fn handle_command_status(status_result: std::io::Result, command_nam } } -fn build() { +// --- Build steps --- + +fn ensure_web_build_dir() { + let status = Command::new("mkdir").args(["-p", WEB_BUILD_DIR]).status(); + handle_command_status(status, "mkdir web-build"); +} + +fn build_message_tools_wasm() { println!("Building wasm package (message-tools)..."); - // build the wasm package let status = Command::new("wasm-pack") .arg("build") .arg("--out-dir") @@ -266,20 +289,10 @@ fn build() { .arg("no-modules") .status(); handle_command_status(status, "wasm-pack build message-tools"); +} - println!("Building wasm package (fractal-engine)..."); - let status = Command::new("wasm-pack") - .arg("build") - .arg("--out-dir") - .arg("../../routes/root/pkg") - .arg("crates/fractal-engine") - .arg("--target") - .arg("no-modules") - .status(); - handle_command_status(status, "wasm-pack build fractal-engine"); - +fn build_server() { println!("Building server executable..."); - // build the server executable let status = Command::new("cargo") .arg("build") .arg("--release") @@ -287,28 +300,34 @@ fn build() { .args(["--target", "x86_64-unknown-linux-musl"]) .status(); handle_command_status(status, "cargo build server"); +} - let server_bin = "target/x86_64-unknown-linux-musl/release/server"; +fn copy_routes() { + ensure_web_build_dir(); - println!("Creating build directory..."); - // make webpage build directory if it doesn't already exist - let status = Command::new("mkdir").args(["-p", WEB_BUILD_DIR]).status(); - handle_command_status(status, "mkdir web-build"); - - println!("Copying files..."); - // copy relevant files (use trailing slash to merge into existing directory) + println!("Copying routes..."); let status = Command::new("cp") .args(["-R", "-f", "routes"]) .arg(WEB_BUILD_DIR) .status(); handle_command_status(status, "cp routes"); +} +fn copy_server_binary() { + ensure_web_build_dir(); + + let server_bin = "target/x86_64-unknown-linux-musl/release/server"; + println!("Copying server binary..."); let status = Command::new("cp") .arg("-f") .arg(server_bin) .arg(format!("{WEB_BUILD_DIR}")) .status(); handle_command_status(status, "cp server bin"); +} + +fn ensure_keys_and_copy() { + ensure_web_build_dir(); let pubkey_file = "target/public_keys.json"; @@ -333,7 +352,7 @@ fn build() { let status = Command::new("mkdir") .args(["-p", &format!("{WEB_BUILD_DIR}/pubkeys")]) .status(); - handle_command_status(status, "mkdir web-build"); + handle_command_status(status, "mkdir pubkeys"); let status = Command::new("cp") .arg("-f") @@ -341,6 +360,49 @@ fn build() { .arg(format!("{WEB_BUILD_DIR}/pubkeys/")) .status(); handle_command_status(status, "cp pubkeys"); +} +// --- Build orchestration --- + +fn build_full() { + build_message_tools_wasm(); + build_server(); + copy_routes(); + copy_server_binary(); + ensure_keys_and_copy(); println!("\nBuild successful!"); } + +fn build_targeted(targets: &[BuildTarget]) { + let mut did_wasm = false; + + for target in targets { + match target { + BuildTarget::Messages => { + build_message_tools_wasm(); + did_wasm = true; + } + BuildTarget::Wasm => { + build_message_tools_wasm(); + did_wasm = true; + } + BuildTarget::Server => { + build_server(); + copy_server_binary(); + } + BuildTarget::Routes => { + copy_routes(); + } + BuildTarget::Keys => { + ensure_keys_and_copy(); + } + } + } + + // WASM output lands inside routes/, so always copy routes after any WASM build + if did_wasm { + copy_routes(); + } + + println!("\nTargeted build successful!"); +} diff --git a/crates/fractal-engine/src/wasm.rs b/crates/fractal-engine/src/wasm.rs index f49fe17..2c90318 100644 --- a/crates/fractal-engine/src/wasm.rs +++ b/crates/fractal-engine/src/wasm.rs @@ -81,7 +81,12 @@ pub fn render_fractal_animated(canvas_id: &str, time: f64, scale: u32) -> Result .dyn_into::()?; temp_ctx.put_image_data(&image_data, 0.0, 0.0)?; - context.set_image_smoothing_enabled(false); + context.set_image_smoothing_enabled(true); + js_sys::Reflect::set( + context.as_ref(), + &JsValue::from_str("imageSmoothingQuality"), + &JsValue::from_str("high"), + )?; context.draw_image_with_html_canvas_element_and_dw_and_dh( &temp_canvas, 0.0, 0.0, diff --git a/routes/contact/index.html b/routes/contact/index.html index cc50bfa..45faaa7 100644 --- a/routes/contact/index.html +++ b/routes/contact/index.html @@ -5,11 +5,18 @@ Contact @@ -97,7 +122,7 @@
-
+

Contact

- - + + diff --git a/routes/contact/message/index.html b/routes/contact/message/index.html index bdebb4a..568f946 100644 --- a/routes/contact/message/index.html +++ b/routes/contact/message/index.html @@ -5,6 +5,12 @@ Direct Message @@ -230,20 +302,7 @@
- +
@@ -261,44 +320,11 @@
-