feat: Fixes
This commit is contained in:
parent
022936d35c
commit
e607dfe6b6
10 changed files with 139 additions and 142 deletions
|
|
@ -30,7 +30,10 @@ tracing-subscriber = { version = "0.3", features = [
|
|||
tracing-error = { version = "0.2" }
|
||||
tracing-appender = { version = "0.2" }
|
||||
|
||||
uuid = { version = "1.8", features = [ "serde" ] }
|
||||
uuid = { version = "1.8", features = [
|
||||
"serde",
|
||||
"v4"
|
||||
] }
|
||||
tokio = { version = "1", features = [ "full" ] }
|
||||
serde = { version = "1", features = [ "derive" ] }
|
||||
chrono = { version = "0.4", features = [ "serde" ] }
|
||||
|
|
|
|||
|
|
@ -10,14 +10,7 @@ readme = { workspace = true }
|
|||
homepage = { workspace = true }
|
||||
authors = { workspace = true }
|
||||
|
||||
[features]
|
||||
tauri = [ "dep:tauri" ]
|
||||
cli = [ "dep:indicatif" ]
|
||||
|
||||
[dependencies]
|
||||
tauri = { workspace = true, optional = true }
|
||||
indicatif = { workspace = true, optional = true }
|
||||
|
||||
tracing = { workspace = true }
|
||||
tracing-subscriber = { workspace = true }
|
||||
tracing-error = { workspace = true }
|
||||
|
|
@ -39,8 +32,3 @@ dirs = { workspace = true }
|
|||
open = { workspace = true }
|
||||
sha1 = { workspace = true }
|
||||
discord-rich-presence = { workspace = true }
|
||||
notify = { workspace = true }
|
||||
notify-debouncer-mini = { workspace = true }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winreg = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@ pub enum ErrorKind {
|
|||
#[error("tokio join handle error: {0}")]
|
||||
JoinError(#[from] tokio::task::JoinError),
|
||||
|
||||
/// Wrapper around [`notify::Error`] to handle file watching errors.
|
||||
#[error("failed to watch file: {0}")]
|
||||
NotifyError(#[from] notify::Error),
|
||||
|
||||
/// Wrapper around [`flate2::CompressError`] to handle flate compression errors.
|
||||
#[error("failed to compress a file with flate: {0}")]
|
||||
FlateError(#[from] flate2::CompressError),
|
||||
|
|
@ -70,10 +66,6 @@ pub enum ErrorKind {
|
|||
/// Wrapper around [`crate::game::client::ClientManagerError`] to handle directory errors.
|
||||
#[error("failed to manage clients: {0}")]
|
||||
ClientManagerError(#[from] crate::game::client::ClientManagerError),
|
||||
|
||||
#[cfg(feature = "tauri")]
|
||||
#[error("failed to launch tauri: {0}")]
|
||||
TauriError(#[from] tauri::Error),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
|||
|
|
@ -1,209 +1,223 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use core::fmt;
|
||||
use std::{collections::HashMap, marker::PhantomData};
|
||||
|
||||
use serde::{de::{self, SeqAccess, Visitor}, Deserialize, Deserializer, Serialize};
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct MinecraftManifest {
|
||||
pub asset_index: AssetIndex,
|
||||
pub downloads: Downloads,
|
||||
#[serde(rename = "id")]
|
||||
pub version: String,
|
||||
pub java_version: JavaVersion,
|
||||
pub libraries: Vec<Library>,
|
||||
pub logging: Logging,
|
||||
pub main_class: String,
|
||||
pub arguments: Arguments,
|
||||
pub release_time: String,
|
||||
#[serde(rename = "type")]
|
||||
pub release_type: ReleaseType,
|
||||
pub asset_index: AssetIndex,
|
||||
pub downloads: Downloads,
|
||||
pub java_version: JavaVersion,
|
||||
pub libraries: Vec<Library>,
|
||||
pub logging: Logging,
|
||||
pub main_class: String,
|
||||
pub release_time: String,
|
||||
|
||||
#[serde(rename = "id")]
|
||||
pub version: String,
|
||||
|
||||
#[serde(rename = "type")]
|
||||
pub release_type: ReleaseType,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub minecraft_arguments: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub arguments: Option<ModernArguments>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(untagged)]
|
||||
pub enum Arguments {
|
||||
// TODO: https://serde.rs/string-or-struct.html
|
||||
MinecraftArguments(String),
|
||||
Arguments {
|
||||
game: Vec<ModernArgumentsItem>,
|
||||
jvm: Vec<ModernArgumentsItem>,
|
||||
},
|
||||
}
|
||||
|
||||
impl Default for Arguments {
|
||||
fn default() -> Self {
|
||||
Arguments::MinecraftArguments(String::new())
|
||||
}
|
||||
pub struct ModernArguments {
|
||||
game: Vec<ModernArgumentsItem>,
|
||||
jvm: Vec<ModernArgumentsItem>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(untagged)]
|
||||
pub enum ModernArgumentsItem {
|
||||
Simple(String),
|
||||
Rule {
|
||||
rules: Vec<Rule>,
|
||||
value: ArgumentRuleValue,
|
||||
},
|
||||
Simple(String),
|
||||
Rule(ArgumentRule),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(untagged)]
|
||||
pub enum ArgumentRuleValue {
|
||||
String(String),
|
||||
List(Vec<String>),
|
||||
pub struct ArgumentRule {
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
rules: Vec<Rule>,
|
||||
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
#[serde(deserialize_with = "string_or_seq")]
|
||||
value: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum ReleaseType {
|
||||
Snapshot,
|
||||
Release,
|
||||
OldBeta,
|
||||
OldAlpha,
|
||||
Snapshot,
|
||||
Release,
|
||||
OldBeta,
|
||||
OldAlpha,
|
||||
}
|
||||
|
||||
impl Default for ReleaseType {
|
||||
fn default() -> Self {
|
||||
ReleaseType::Release
|
||||
}
|
||||
fn default() -> Self { ReleaseType::Release }
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AssetIndex {
|
||||
pub id: String,
|
||||
pub sha1: String,
|
||||
pub url: String,
|
||||
pub id: String,
|
||||
pub sha1: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Downloads {
|
||||
pub client: Client,
|
||||
pub client: Client,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Client {
|
||||
pub sha1: String,
|
||||
pub url: String,
|
||||
pub sha1: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct JavaVersion {
|
||||
pub major_version: u8,
|
||||
pub major_version: u8,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Library {
|
||||
pub downloads: Downloads2,
|
||||
pub name: String,
|
||||
#[serde(default)]
|
||||
pub rules: Vec<Rule>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub natives: Option<Natives>,
|
||||
pub downloads: LibraryDownload,
|
||||
pub name: String,
|
||||
#[serde(skip_serializing_if = "Vec::is_empty", default)]
|
||||
pub rules: Vec<Rule>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub natives: Option<HashMap<String, String>>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Downloads2 {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub artifact: Option<Artifact>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub classifiers: Option<Classifiers>,
|
||||
pub struct LibraryDownload {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub artifact: Option<Artifact>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub classifiers: Option<Classifiers>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Artifact {
|
||||
pub path: String,
|
||||
pub sha1: String,
|
||||
pub url: String,
|
||||
pub path: String,
|
||||
pub sha1: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Classifiers {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[serde(rename = "natives-osx")]
|
||||
pub natives_osx: Option<Native>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[serde(rename = "natives-osx")]
|
||||
pub natives_osx: Option<Artifact>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[serde(rename = "natives-linux")]
|
||||
pub natives_linux: Option<Artifact>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[serde(rename = "natives-linux")]
|
||||
pub natives_linux: Option<Native>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[serde(rename = "natives-windows")]
|
||||
pub natives_windows: Option<Native>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Native {
|
||||
pub path: String,
|
||||
pub sha1: String,
|
||||
pub url: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[serde(rename = "natives-windows")]
|
||||
pub natives_windows: Option<Artifact>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Rule {
|
||||
pub action: RuleAction,
|
||||
pub action: RuleAction,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub os: Option<Os>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub os: Option<Os>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub features: Option<Value>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub features: Option<HashMap<String, bool>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(untagged)]
|
||||
pub enum RuleAction {
|
||||
Allow,
|
||||
Disallow,
|
||||
#[serde(rename = "allow")]
|
||||
Allow,
|
||||
#[serde(rename = "disallow")]
|
||||
Disallow,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Os {
|
||||
pub name: Option<String>,
|
||||
pub arch: Option<String>,
|
||||
pub version: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Natives {
|
||||
pub windows: Option<String>,
|
||||
pub linux: Option<String>,
|
||||
pub osx: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub name: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub arch: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub version: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Logging {
|
||||
pub client: Client2,
|
||||
pub client: Client2,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Client2 {
|
||||
pub argument: String,
|
||||
pub file: File,
|
||||
#[serde(rename = "type")]
|
||||
pub type_field: String,
|
||||
pub argument: String,
|
||||
pub file: File,
|
||||
#[serde(rename = "type")]
|
||||
pub type_field: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct File {
|
||||
pub id: String,
|
||||
pub sha1: String,
|
||||
pub url: String,
|
||||
pub id: String,
|
||||
pub sha1: String,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
fn string_or_seq<'de, D>(deserializer: D) -> Result<Vec<String>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
struct StringOrVec(PhantomData<Vec<String>>);
|
||||
|
||||
impl<'de> Visitor<'de> for StringOrVec {
|
||||
type Value = Vec<String>;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
formatter.write_str("string or list of strings")
|
||||
}
|
||||
|
||||
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
|
||||
where
|
||||
E: de::Error,
|
||||
{
|
||||
Ok(vec![value.into()])
|
||||
}
|
||||
|
||||
fn visit_seq<S>(self, seq: S) -> Result<Self::Value, S::Error>
|
||||
where
|
||||
S: SeqAccess<'de>,
|
||||
{
|
||||
Deserialize::deserialize(de::value::SeqAccessDeserializer::new(seq))
|
||||
}
|
||||
}
|
||||
|
||||
deserializer.deserialize_any(StringOrVec(PhantomData))
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ authors = { workspace = true }
|
|||
tauri-build = { workspace = true }
|
||||
|
||||
[dependencies]
|
||||
onelauncher = { path = "../onelauncher", features = [ "tauri" ] }
|
||||
onelauncher = { path = "../onelauncher" }
|
||||
|
||||
tauri = { workspace = true }
|
||||
tauri-plugin-shell = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use launcher_core::auth::{
|
||||
use onelauncher::auth::{
|
||||
microsoft_auth::MicrosoftAuthenticationMethod, Account, AuthenticationMethod,
|
||||
};
|
||||
use tauri::Manager;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use launcher_core::game::client::{ClientType, Instance, Manifest};
|
||||
use onelauncher::game::client::{ClientType, Instance, Manifest};
|
||||
use tauri::State;
|
||||
use tokio::sync::Mutex;
|
||||
use uuid::Uuid;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use launcher_core::game::client::ClientManager;
|
||||
use onelauncher::game::client::ClientManager;
|
||||
use tauri::{plugin::TauriPlugin, Manager, State};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use tracing_error::ExtractSpanTrace;
|
||||
|
||||
pub fn display_tracing_error(err: &launcher_core::Error) {
|
||||
pub fn display_tracing_error(err: &onelauncher::Error) {
|
||||
match get_span_trace(err) {
|
||||
Some(span_trace) => {
|
||||
tracing::error!(error = %err, span_trace = %span_trace);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
use std::error::Error;
|
||||
|
||||
use polyfrost_launcher::api;
|
||||
use tauri::{menu::Menu, App};
|
||||
use onelauncher_gui::api;
|
||||
use tauri::{menu::Menu, App, Manager};
|
||||
|
||||
#[derive(Clone, serde::Serialize)]
|
||||
struct Payload {
|
||||
|
|
@ -14,7 +14,7 @@ struct Payload {
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let _log_guard = launcher_core::start_logger();
|
||||
let _log_guard = onelauncher::start_logger();
|
||||
tracing::info!("initialized tracing subscriber. loading OneLauncher");
|
||||
|
||||
tauri::Builder::default()
|
||||
|
|
@ -22,7 +22,7 @@ async fn main() {
|
|||
.plugin(tauri_plugin_single_instance::init(|app, argv, cwd| {
|
||||
println!("{}, {argv:?}, {cwd}", app.package_info().name);
|
||||
|
||||
app.emit_all("single-instance", Payload { args: argv, cwd })
|
||||
app.emit("single-instance", Payload { args: argv, cwd })
|
||||
.unwrap();
|
||||
}))
|
||||
.plugin(tauri_plugin_window_state::Builder::default().build())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue