diff --git a/Cargo.lock b/Cargo.lock index 3396996dff..3bb4dadd64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -345,7 +345,7 @@ dependencies = [ "getrandom 0.2.15", "once_cell", "version_check", - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -487,7 +487,7 @@ dependencies = [ "serde_cbor", "serde_json", "thiserror 1.0.64", - "uuid 1.12.0", + "uuid 1.16.0", ] [[package]] @@ -1337,7 +1337,7 @@ checksum = "d38f2da7a0a2c4ccf0065be06397cc26a81f4e528be095826eee9d4adbb8c60f" dependencies = [ "byteorder", "fnv", - "uuid 1.12.0", + "uuid 1.16.0", ] [[package]] @@ -1464,7 +1464,7 @@ dependencies = [ "time", "tokio 1.42.0", "url", - "uuid 1.12.0", + "uuid 1.16.0", ] [[package]] @@ -2213,7 +2213,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" dependencies = [ "serde", - "uuid 1.12.0", + "uuid 1.16.0", ] [[package]] @@ -3233,6 +3233,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", +] + [[package]] name = "gif" version = "0.13.1" @@ -4582,7 +4594,7 @@ dependencies = [ "tracing-subscriber", "url", "urlencoding", - "uuid 1.12.0", + "uuid 1.16.0", "validator", "webp", "woothee", @@ -4968,7 +4980,7 @@ dependencies = [ "serde_json", "thiserror 1.0.64", "time", - "uuid 1.12.0", + "uuid 1.16.0", "wasm-bindgen-futures", "web-sys", "yaup", @@ -6349,7 +6361,7 @@ version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -6694,6 +6706,12 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "640c9bd8497b02465aeef5375144c26062e0dcd5939dfcbb0f5db76cb8c17c73" +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + [[package]] name = "r2d2" version = "0.8.10" @@ -6736,6 +6754,17 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", + "zerocopy 0.8.24", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -6756,6 +6785,16 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", +] + [[package]] name = "rand_core" version = "0.5.1" @@ -6774,6 +6813,15 @@ dependencies = [ "getrandom 0.2.15", ] +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.2", +] + [[package]] name = "rand_hc" version = "0.2.0" @@ -7148,7 +7196,7 @@ dependencies = [ "rkyv_derive", "seahash", "tinyvec", - "uuid 1.12.0", + "uuid 1.16.0", ] [[package]] @@ -7532,7 +7580,7 @@ dependencies = [ "serde", "serde_json", "url", - "uuid 1.12.0", + "uuid 1.16.0", ] [[package]] @@ -7785,7 +7833,7 @@ dependencies = [ "thiserror 1.0.64", "time", "url", - "uuid 1.12.0", + "uuid 1.16.0", ] [[package]] @@ -8985,7 +9033,7 @@ dependencies = [ "thiserror 2.0.7", "time", "url", - "uuid 1.12.0", + "uuid 1.16.0", "walkdir", ] @@ -9078,7 +9126,7 @@ dependencies = [ "thiserror 2.0.7", "toml 0.8.19", "url", - "uuid 1.12.0", + "uuid 1.16.0", ] [[package]] @@ -9259,7 +9307,7 @@ dependencies = [ "toml 0.8.19", "url", "urlpattern", - "uuid 1.12.0", + "uuid 1.16.0", "walkdir", ] @@ -9355,7 +9403,7 @@ dependencies = [ "tracing-subscriber", "url", "urlencoding", - "uuid 1.12.0", + "uuid 1.16.0", "whoami", "winreg 0.52.0", "zip 0.6.6", @@ -9397,7 +9445,7 @@ dependencies = [ "tracing", "tracing-error", "url", - "uuid 1.12.0", + "uuid 1.16.0", "window-shadows", ] @@ -9416,7 +9464,7 @@ dependencies = [ "tracing-error", "tracing-subscriber", "url", - "uuid 1.12.0", + "uuid 1.16.0", "webbrowser", ] @@ -10033,7 +10081,7 @@ dependencies = [ "mutually_exclusive_features", "pin-project", "tracing", - "uuid 1.12.0", + "uuid 1.16.0", ] [[package]] @@ -10381,12 +10429,13 @@ dependencies = [ [[package]] name = "uuid" -version = "1.12.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "744018581f9a3454a9e15beb8a33b017183f1e7c0cd170232a2d1453b23a51c4" +checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" dependencies = [ - "getrandom 0.2.15", - "rand 0.8.5", + "getrandom 0.3.2", + "js-sys", + "rand 0.9.0", "serde", "wasm-bindgen", ] @@ -10537,6 +10586,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasite" version = "0.1.0" @@ -11317,6 +11375,15 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags 2.6.0", +] + [[package]] name = "woothee" version = "0.13.0" @@ -11644,7 +11711,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", - "zerocopy-derive", + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" +dependencies = [ + "zerocopy-derive 0.8.24", ] [[package]] @@ -11658,6 +11734,17 @@ dependencies = [ "syn 2.0.90", ] +[[package]] +name = "zerocopy-derive" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "zerofrom" version = "0.1.4" diff --git a/apps/app-frontend/src/App.vue b/apps/app-frontend/src/App.vue index 00c82c0cf5..1a12bd35c7 100644 --- a/apps/app-frontend/src/App.vue +++ b/apps/app-frontend/src/App.vue @@ -303,6 +303,7 @@ async function handleCommand(e) { } } else { // Other commands are URL-based (deep linking) + console.log(e.event) urlModal.value.show(e) } } diff --git a/apps/app-frontend/src/helpers/types.d.ts b/apps/app-frontend/src/helpers/types.d.ts index 1007744d0f..5dc07a2bb9 100644 --- a/apps/app-frontend/src/helpers/types.d.ts +++ b/apps/app-frontend/src/helpers/types.d.ts @@ -2,6 +2,7 @@ import type { ModrinthId } from '@modrinth/utils' type GameInstance = { path: string + uuid: string install_stage: InstallStage name: string diff --git a/packages/app-lib/Cargo.toml b/packages/app-lib/Cargo.toml index eb098779f2..df006755d2 100644 --- a/packages/app-lib/Cargo.toml +++ b/packages/app-lib/Cargo.toml @@ -13,7 +13,7 @@ toml = "0.8.12" sha1_smol = { version = "1.0.0", features = ["std"] } sha2 = "0.10.8" url = "2.2" -uuid = { version = "1.1", features = ["serde", "v4"] } +uuid = { version = "1.16.0", features = ["serde", "v4"] } zip = "0.6.5" async_zip = { version = "0.0.17", features = ["chrono", "tokio-fs", "deflate", "bzip2", "zstd", "deflate64"] } flate2 = "1.0.28" diff --git a/packages/app-lib/src/api/handler.rs b/packages/app-lib/src/api/handler.rs index fd6b766ec3..9827d8486b 100644 --- a/packages/app-lib/src/api/handler.rs +++ b/packages/app-lib/src/api/handler.rs @@ -8,33 +8,38 @@ use crate::{ util::io, }; -/// Handles external functions (such as through URL deep linkage) -/// Link is extracted value (link) in somewhat URL format, such as -/// subdomain1/subdomain2 -/// (Does not include modrinth://) pub async fn handle_url(sublink: &str) -> crate::Result { - Ok(match sublink.split_once('/') { - // /mod/{id} - Installs a mod of mod id - Some(("mod", id)) => CommandPayload::InstallMod { id: id.to_string() }, - // /version/{id} - Installs a specific version of id - Some(("version", id)) => { - CommandPayload::InstallVersion { id: id.to_string() } - } - // /modpack/{id} - Installs a modpack of modpack id - Some(("modpack", id)) => { - CommandPayload::InstallModpack { id: id.to_string() } - } + let parts: Vec<&str> = sublink.split('/').filter(|s| !s.is_empty()).collect(); + + if parts.is_empty() { + emit_warning(&format!("Invalid command, unrecognized path: {sublink}")).await?; + return Err(crate::ErrorKind::InputError(format!( + "Invalid command, unrecognized path: {sublink}" + )) + .into()); + } + + match parts.as_slice() { + // /mod/{id} - Installs a mod of mod id + ["mod", id] => Ok(CommandPayload::InstallMod { id: id.to_string() }), + // /version/{id} - Installs a specific version of id + ["version", id] => Ok(CommandPayload::InstallVersion { id: id.to_string() }), + // /modpack/{id} - Installs a modpack of modpack id + ["modpack", id] => Ok(CommandPayload::InstallModpack { id: id.to_string() }), + // /instance/{uuid}/{action_type} - Performs a specific action on a specific instance. + // {action_type} is of "play" | "edit" + ["instance", id, action_type] => Ok(CommandPayload::ManageInstance { id: id.to_string(), action_type: action_type.to_string() }), _ => { emit_warning(&format!( "Invalid command, unrecognized path: {sublink}" )) - .await?; - return Err(crate::ErrorKind::InputError(format!( + .await?; + Err(crate::ErrorKind::InputError(format!( "Invalid command, unrecognized path: {sublink}" )) - .into()); + .into()) } - }) + } } pub async fn parse_command( @@ -59,12 +64,12 @@ pub async fn parse_command( "Invalid command, unrecognized filetype: {}", path.display() )) - .await?; + .await?; Err(crate::ErrorKind::InputError(format!( "Invalid command, unrecognized filetype: {}", path.display() )) - .into()) + .into()) } } @@ -72,4 +77,4 @@ pub async fn parse_and_emit_command(command_string: &str) -> crate::Result<()> { let command = parse_command(command_string).await?; emit_command(command).await?; Ok(()) -} +} \ No newline at end of file diff --git a/packages/app-lib/src/event/mod.rs b/packages/app-lib/src/event/mod.rs index 0c0ac023e8..e3bdfa50ae 100644 --- a/packages/app-lib/src/event/mod.rs +++ b/packages/app-lib/src/event/mod.rs @@ -211,6 +211,10 @@ pub enum CommandPayload { InstallModpack { id: String, }, + ManageInstance { + id: String, + action_type: String + }, RunMRPack { // run or install .mrpack path: PathBuf, diff --git a/packages/app-lib/src/state/profiles.rs b/packages/app-lib/src/state/profiles.rs index 97b92cf8d8..c4f8fd4618 100644 --- a/packages/app-lib/src/state/profiles.rs +++ b/packages/app-lib/src/state/profiles.rs @@ -12,11 +12,13 @@ use sqlx::SqlitePool; use std::convert::TryFrom; use std::convert::TryInto; use std::path::Path; +use uuid::Uuid; // Represent a Minecraft instance. #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Profile { pub path: String, + pub uuid: Uuid, pub install_stage: ProfileInstallStage, pub name: String,