Compiler improvements (#145)

* Initial bug fixes

* fix compile error on non-mac

* Fix even more bugs

* Fix more

* fix more

* fix build

* fix build

* working basic

* removed zip

* working functions

* merge fixes

* fixed loadintg bar bug

* changed to one layer deep

* forge version numbers

* improvements + refactoring

* renamed things to fit plugin

* fixed bugs

* removed println

* overrides dont include mrpack

* merge

* fixes

* fixes

* fixed deletion

* merge errors

* force sync before export

* removed testing

* missed line

* removed console log

* mac error reverted

* incoreclty named helper

* added to new register method

* review changes

* minor changes

* moved create pack

* renamed function

---------

Co-authored-by: Jai A <jaiagr+gpg@pm.me>
This commit is contained in:
Wyatt Verchere
2023-06-28 09:58:58 -07:00
committed by GitHub
parent 47970d932b
commit f52e777379
38 changed files with 1047 additions and 896 deletions

View File

@@ -1,6 +1,22 @@
use crate::api::Result;
use tauri::plugin::TauriPlugin;
use theseus::prelude::*;
pub fn init<R: tauri::Runtime>() -> TauriPlugin<R> {
tauri::plugin::Builder::new("auth")
.invoke_handler(tauri::generate_handler![
auth_authenticate_begin_flow,
auth_authenticate_await_completion,
auth_cancel_flow,
auth_refresh,
auth_remove_user,
auth_has_user,
auth_users,
auth_get_user,
])
.build()
}
/// Authenticate a user with Hydra - part 1
/// This begins the authentication flow quasi-synchronously, returning a URL to visit (that the user will sign in at)
#[tauri::command]
@@ -22,7 +38,7 @@ pub async fn auth_cancel_flow() -> Result<()> {
}
/// Refresh some credentials using Hydra, if needed
// invoke('auth_refresh',user)
// invoke('plugin:auth|auth_refresh',user)
#[tauri::command]
pub async fn auth_refresh(user: uuid::Uuid) -> Result<Credentials> {
Ok(auth::refresh(user).await?)
@@ -34,14 +50,14 @@ pub async fn auth_remove_user(user: uuid::Uuid) -> Result<()> {
}
/// Check if a user exists in Theseus
// invoke('auth_has_user',user)
// invoke('plugin:auth|auth_has_user',user)
#[tauri::command]
pub async fn auth_has_user(user: uuid::Uuid) -> Result<bool> {
Ok(auth::has_user(user).await?)
}
/// Get a copy of the list of all user credentials
// invoke('auth_users',user)
// invoke('plugin:auth|auth_users',user)
#[tauri::command]
pub async fn auth_users() -> Result<Vec<Credentials>> {
Ok(auth::users().await?)
@@ -49,7 +65,7 @@ pub async fn auth_users() -> Result<Vec<Credentials>> {
/// Get a user from the UUID
/// Prefer to use refresh instead, as it will refresh the credentials as well
// invoke('auth_users',user)
// invoke('plugin:auth|auth_users',user)
#[tauri::command]
pub async fn auth_get_user(user: uuid::Uuid) -> Result<Credentials> {
Ok(auth::get_user(user).await?)

View File

@@ -1,9 +1,24 @@
use std::path::PathBuf;
use crate::api::Result;
use tauri::plugin::TauriPlugin;
use theseus::prelude::JavaVersion;
use theseus::prelude::*;
pub fn init<R: tauri::Runtime>() -> TauriPlugin<R> {
tauri::plugin::Builder::new("jre")
.invoke_handler(tauri::generate_handler![
jre_get_all_jre,
jre_find_filtered_jres,
jre_autodetect_java_globals,
jre_validate_globals,
jre_get_jre,
jre_auto_install_java,
jre_get_max_memory,
])
.build()
}
/// Get all JREs that exist on the system
#[tauri::command]
pub async fn jre_get_all_jre() -> Result<Vec<JavaVersion>> {
@@ -12,27 +27,24 @@ pub async fn jre_get_all_jre() -> Result<Vec<JavaVersion>> {
// Finds the installation of Java 8, if it exists
#[tauri::command]
pub async fn jre_find_jre_8_jres() -> Result<Vec<JavaVersion>> {
Ok(jre::find_filtered_jres("1.8").await?)
}
// finds the installation of Java 17, if it exists
#[tauri::command]
pub async fn jre_find_jre_17_jres() -> Result<Vec<JavaVersion>> {
Ok(jre::find_filtered_jres("1.17").await?)
}
// Finds the highest version of Java 18+, if it exists
#[tauri::command]
pub async fn jre_find_jre_18plus_jres() -> Result<Vec<JavaVersion>> {
Ok(jre::find_filtered_jres("1.18").await?)
pub async fn jre_find_filtered_jres(
jres: Vec<JavaVersion>,
version: String,
allow_higher: bool,
) -> Result<Vec<JavaVersion>> {
Ok(jre::find_filtered_jres(&version, jres, allow_higher).await?)
}
// Autodetect Java globals, by searching the users computer.
// Selects from the given JREs, and returns a new JavaGlobals
// Returns a *NEW* JavaGlobals that can be put into Settings
#[tauri::command]
pub async fn jre_autodetect_java_globals() -> Result<JavaGlobals> {
Ok(jre::autodetect_java_globals().await?)
pub async fn jre_autodetect_java_globals(
java_8: Vec<JavaVersion>,
java_17: Vec<JavaVersion>,
java_18plus: Vec<JavaVersion>,
) -> Result<JavaGlobals> {
Ok(jre::autodetect_java_globals(java_8, java_17, java_18plus).await?)
}
// Validates java globals, by checking if the paths exist

View File

@@ -12,6 +12,18 @@ pub struct Logs {
}
*/
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
tauri::plugin::Builder::new("logs")
.invoke_handler(tauri::generate_handler![
logs_get_logs,
logs_get_logs_by_datetime,
logs_get_output_by_datetime,
logs_delete_logs,
logs_delete_logs_by_datetime,
])
.build()
}
/// Get all Logs for a profile, sorted by datetime
#[tauri::command]
pub async fn logs_get_logs(

View File

@@ -2,6 +2,17 @@ use crate::api::Result;
use daedalus::minecraft::VersionManifest;
use daedalus::modded::Manifest;
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
tauri::plugin::Builder::new("metadata")
.invoke_handler(tauri::generate_handler![
metadata_get_game_versions,
metadata_get_fabric_versions,
metadata_get_forge_versions,
metadata_get_quilt_versions,
])
.build()
}
/// Gets the game versions from daedalus
#[tauri::command]
pub async fn metadata_get_game_versions() -> Result<VersionManifest> {

View File

@@ -45,16 +45,6 @@ pub enum TheseusSerializableError {
// }
// }
// Lists active progress bars
// Create a new HashMap with the same keys
// Values provided should not be used directly, as they are not guaranteed to be up-to-date
#[tauri::command]
pub async fn progress_bars_list(
) -> Result<std::collections::HashMap<uuid::Uuid, theseus::LoadingBar>> {
let res = theseus::EventState::list_progress_bars().await?;
Ok(res)
}
// This is a very simple macro that implements a very basic Serializable for each variant of TheseusSerializableError,
// where the field is the string. (This allows easy extension to errors without many match arms)
macro_rules! impl_serialize {

View File

@@ -1,23 +1,33 @@
use crate::api::Result;
use std::path::{Path, PathBuf};
use theseus::prelude::*;
use std::path::PathBuf;
use theseus::{
pack::{
install::install_pack,
install_from::{CreatePackLocation, CreatePackProfile},
},
prelude::*,
};
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
tauri::plugin::Builder::new("pack")
.invoke_handler(tauri::generate_handler![
pack_install,
pack_get_profile_from_pack,
])
.build()
}
#[tauri::command]
pub async fn pack_install_version_id(
project_id: String,
version_id: String,
pack_title: String,
pack_icon: Option<String>,
pub async fn pack_install(
location: CreatePackLocation,
profile: PathBuf,
) -> Result<PathBuf> {
let res = pack::install_pack_from_version_id(
project_id, version_id, pack_title, pack_icon,
)
.await?;
Ok(res)
Ok(install_pack(location, profile).await?)
}
#[tauri::command]
pub async fn pack_install_file(path: &Path) -> Result<PathBuf> {
let res = pack::install_pack_from_file(path.to_path_buf()).await?;
Ok(res)
pub fn pack_get_profile_from_pack(
location: CreatePackLocation,
) -> Result<CreatePackProfile> {
Ok(pack::install_from::get_profile_from_pack(location))
}

View File

@@ -4,6 +4,23 @@ use crate::api::Result;
use theseus::prelude::*;
use uuid::Uuid;
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
tauri::plugin::Builder::new("process")
.invoke_handler(tauri::generate_handler![
process_has_finished_by_uuid,
process_get_exit_status_by_uuid,
process_get_all_uuids,
process_get_all_running_uuids,
process_get_uuids_by_profile_path,
process_get_all_running_profile_paths,
process_get_all_running_profiles,
process_get_output_by_uuid,
process_kill_by_uuid,
process_wait_for_by_uuid,
])
.build()
}
// Checks if a process has finished by process UUID
#[tauri::command]
pub async fn process_has_finished_by_uuid(uuid: Uuid) -> Result<bool> {

View File

@@ -6,8 +6,35 @@ use std::path::{Path, PathBuf};
use theseus::prelude::*;
use uuid::Uuid;
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
tauri::plugin::Builder::new("profile")
.invoke_handler(tauri::generate_handler![
profile_remove,
profile_get,
profile_get_optimal_jre_key,
profile_list,
profile_check_installed,
profile_install,
profile_update_all,
profile_update_project,
profile_add_project_from_version,
profile_add_project_from_path,
profile_toggle_disable_project,
profile_remove_project,
profile_run,
profile_run_wait,
profile_run_credentials,
profile_run_wait_credentials,
profile_edit,
profile_edit_icon,
profile_export_mrpack,
profile_get_potential_override_folders,
])
.build()
}
// Remove a profile
// invoke('profile_add_path',path)
// invoke('plugin:profile|profile_add_path',path)
#[tauri::command]
pub async fn profile_remove(path: &Path) -> Result<()> {
profile::remove(path).await?;
@@ -15,7 +42,7 @@ pub async fn profile_remove(path: &Path) -> Result<()> {
}
// Get a profile by path
// invoke('profile_add_path',path)
// invoke('plugin:profile|profile_add_path',path)
#[tauri::command]
pub async fn profile_get(
path: &Path,
@@ -35,7 +62,7 @@ pub async fn profile_get_optimal_jre_key(
}
// Get a copy of the profile set
// invoke('profile_list')
// invoke('plugin:profile|profile_list')
#[tauri::command]
pub async fn profile_list(
clear_projects: Option<bool>,
@@ -65,7 +92,7 @@ pub async fn profile_check_installed(
}
/// Installs/Repairs a profile
/// invoke('profile_install')
/// invoke('plugin:profile|profile_install')
#[tauri::command]
pub async fn profile_install(path: &Path) -> Result<()> {
profile::install(path).await?;
@@ -73,7 +100,7 @@ pub async fn profile_install(path: &Path) -> Result<()> {
}
/// Updates all of the profile's projects
/// invoke('profile_update_all')
/// invoke('plugin:profile|profile_update_all')
#[tauri::command]
pub async fn profile_update_all(
path: &Path,
@@ -82,7 +109,7 @@ pub async fn profile_update_all(
}
/// Updates a specified project
/// invoke('profile_update_project')
/// invoke('plugin:profile|profile_update_project')
#[tauri::command]
pub async fn profile_update_project(
path: &Path,
@@ -92,7 +119,7 @@ pub async fn profile_update_project(
}
// Adds a project to a profile from a version ID
// invoke('profile_add_project_from_version')
// invoke('plugin:profile|profile_add_project_from_version')
#[tauri::command]
pub async fn profile_add_project_from_version(
path: &Path,
@@ -102,7 +129,7 @@ pub async fn profile_add_project_from_version(
}
// Adds a project to a profile from a path
// invoke('profile_add_project_from_path')
// invoke('plugin:profile|profile_add_project_from_path')
#[tauri::command]
pub async fn profile_add_project_from_path(
path: &Path,
@@ -115,7 +142,7 @@ pub async fn profile_add_project_from_path(
}
// Toggles disabling a project from its path
// invoke('profile_toggle_disable_project')
// invoke('plugin:profile|profile_toggle_disable_project')
#[tauri::command]
pub async fn profile_toggle_disable_project(
path: &Path,
@@ -125,7 +152,7 @@ pub async fn profile_toggle_disable_project(
}
// Removes a project from a profile
// invoke('profile_remove_project')
// invoke('plugin:profile|profile_remove_project')
#[tauri::command]
pub async fn profile_remove_project(
path: &Path,
@@ -173,7 +200,7 @@ pub async fn profile_get_potential_override_folders(
// Run minecraft using a profile using the default credentials
// Returns the UUID, which can be used to poll
// for the actual Child in the state.
// invoke('profile_run', path)
// invoke('plugin:profile|profile_run', path)
#[tauri::command]
pub async fn profile_run(path: &Path) -> Result<Uuid> {
let minecraft_child = profile::run(path).await?;
@@ -182,7 +209,7 @@ pub async fn profile_run(path: &Path) -> Result<Uuid> {
}
// Run Minecraft using a profile using the default credentials, and wait for the result
// invoke('profile_run_wait', path)
// invoke('plugin:profile|profile_run_wait', path)
#[tauri::command]
pub async fn profile_run_wait(path: &Path) -> Result<()> {
let proc_lock = profile::run(path).await?;
@@ -193,7 +220,7 @@ pub async fn profile_run_wait(path: &Path) -> Result<()> {
// Run Minecraft using a profile using chosen credentials
// Returns the UUID, which can be used to poll
// for the actual Child in the state.
// invoke('profile_run_credentials', {path, credentials})')
// invoke('plugin:profile|profile_run_credentials', {path, credentials})')
#[tauri::command]
pub async fn profile_run_credentials(
path: &Path,
@@ -205,7 +232,7 @@ pub async fn profile_run_credentials(
}
// Run Minecraft using a profile using the chosen credentials, and wait for the result
// invoke('profile_run_wait', {path, credentials)
// invoke('plugin:profile|profile_run_wait', {path, credentials)
#[tauri::command]
pub async fn profile_run_wait_credentials(
path: &Path,
@@ -235,7 +262,7 @@ pub struct EditProfileMetadata {
}
// Edits a profile
// invoke('profile_edit', {path, editProfile})
// invoke('plugin:profile|profile_edit', {path, editProfile})
#[tauri::command]
pub async fn profile_edit(
path: &Path,
@@ -275,7 +302,7 @@ pub async fn profile_edit(
}
// Edits a profile's icon
// invoke('profile_edit_icon')
// invoke('plugin:profile|profile_edit_icon')
#[tauri::command]
pub async fn profile_edit_icon(
path: &Path,

View File

@@ -2,16 +2,14 @@ use crate::api::Result;
use std::path::PathBuf;
use theseus::prelude::*;
// Generic basic profile creation tool.
// Creates an essentially empty dummy profile with profile_create
#[tauri::command]
pub async fn profile_create_empty() -> Result<PathBuf> {
let res = profile_create::profile_create_empty().await?;
Ok(res)
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
tauri::plugin::Builder::new("profile_create")
.invoke_handler(tauri::generate_handler![profile_create,])
.build()
}
// Creates a profile at the given filepath and adds it to the in-memory state
// invoke('profile_add',profile)
// invoke('plugin:profile|profile_add',profile)
#[tauri::command]
pub async fn profile_create(
name: String, // the name of the profile, and relative path

View File

@@ -20,8 +20,14 @@ pub struct FrontendSettings {
pub collapsed_navigation: bool,
}
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
tauri::plugin::Builder::new("settings")
.invoke_handler(tauri::generate_handler![settings_get, settings_set,])
.build()
}
// Get full settings
// invoke('settings_get')
// invoke('plugin:settings|settings_get')
#[tauri::command]
pub async fn settings_get() -> Result<Settings> {
let res = settings::get().await?;
@@ -29,7 +35,7 @@ pub async fn settings_get() -> Result<Settings> {
}
// Set full settings
// invoke('settings_set', settings)
// invoke('plugin:settings|settings_set', settings)
#[tauri::command]
pub async fn settings_set(settings: Settings) -> Result<()> {
settings::set(settings).await?;

View File

@@ -1,6 +1,19 @@
use crate::api::Result;
use theseus::tags::{Category, DonationPlatform, GameVersion, Loader, Tags};
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
tauri::plugin::Builder::new("tags")
.invoke_handler(tauri::generate_handler![
tags_get_categories,
tags_get_report_types,
tags_get_loaders,
tags_get_game_versions,
tags_get_donation_platforms,
tags_get_tag_bundle,
])
.build()
}
/// Gets cached category tags from the database
#[tauri::command]
pub async fn tags_get_categories() -> Result<Vec<Category>> {

View File

@@ -1,6 +1,26 @@
use crate::api::Result;
use std::process::Command;
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
tauri::plugin::Builder::new("utils")
.invoke_handler(tauri::generate_handler![
should_disable_mouseover,
show_in_folder,
progress_bars_list,
])
.build()
}
// Lists active progress bars
// Create a new HashMap with the same keys
// Values provided should not be used directly, as they are not guaranteed to be up-to-date
#[tauri::command]
pub async fn progress_bars_list(
) -> Result<std::collections::HashMap<uuid::Uuid, theseus::LoadingBar>> {
let res = theseus::EventState::list_progress_bars().await?;
Ok(res)
}
// cfg only on mac os
// disables mouseover and fixes a random crash error only fixed by recent versions of macos
#[cfg(target_os = "macos")]