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")]

View File

@@ -111,82 +111,19 @@ fn main() {
}
})
}
builder = builder.invoke_handler(tauri::generate_handler![
initialize_state,
is_dev,
api::progress_bars_list,
api::profile_create::profile_create_empty,
api::profile_create::profile_create,
api::profile::profile_remove,
api::profile::profile_get,
api::profile::profile_get_optimal_jre_key,
api::profile::profile_list,
api::profile::profile_install,
api::profile::profile_update_all,
api::profile::profile_update_project,
api::profile::profile_add_project_from_version,
api::profile::profile_add_project_from_path,
api::profile::profile_toggle_disable_project,
api::profile::profile_remove_project,
api::profile::profile_run,
api::profile::profile_run_wait,
api::profile::profile_run_credentials,
api::profile::profile_run_wait_credentials,
api::profile::profile_edit,
api::profile::profile_edit_icon,
api::profile::profile_check_installed,
api::pack::pack_install_version_id,
api::pack::pack_install_file,
api::auth::auth_authenticate_begin_flow,
api::auth::auth_authenticate_await_completion,
api::auth::auth_cancel_flow,
api::auth::auth_refresh,
api::auth::auth_remove_user,
api::auth::auth_has_user,
api::auth::auth_users,
api::auth::auth_get_user,
api::tags::tags_get_categories,
api::tags::tags_get_donation_platforms,
api::tags::tags_get_game_versions,
api::tags::tags_get_loaders,
api::tags::tags_get_report_types,
api::tags::tags_get_tag_bundle,
api::settings::settings_get,
api::settings::settings_set,
api::jre::jre_get_all_jre,
api::jre::jre_autodetect_java_globals,
api::jre::jre_find_jre_18plus_jres,
api::jre::jre_find_jre_17_jres,
api::jre::jre_find_jre_8_jres,
api::jre::jre_validate_globals,
api::jre::jre_get_jre,
api::jre::jre_auto_install_java,
api::jre::jre_get_max_memory,
api::profile::profile_export_mrpack,
api::profile::profile_get_potential_override_folders,
api::process::process_get_all_uuids,
api::process::process_get_all_running_uuids,
api::process::process_get_uuids_by_profile_path,
api::process::process_get_all_running_profile_paths,
api::process::process_get_all_running_profiles,
api::process::process_get_exit_status_by_uuid,
api::process::process_has_finished_by_uuid,
api::process::process_get_output_by_uuid,
api::process::process_kill_by_uuid,
api::process::process_wait_for_by_uuid,
api::metadata::metadata_get_game_versions,
api::metadata::metadata_get_fabric_versions,
api::metadata::metadata_get_forge_versions,
api::metadata::metadata_get_quilt_versions,
api::logs::logs_get_logs,
api::logs::logs_get_logs_by_datetime,
api::logs::logs_get_output_by_datetime,
api::logs::logs_delete_logs,
api::logs::logs_delete_logs_by_datetime,
api::utils::show_in_folder,
api::utils::should_disable_mouseover,
]);
let builder = builder
.plugin(api::auth::init())
.plugin(api::logs::init())
.plugin(api::jre::init())
.plugin(api::metadata::init())
.plugin(api::pack::init())
.plugin(api::process::init())
.plugin(api::profile::init())
.plugin(api::profile_create::init())
.plugin(api::settings::init())
.plugin(api::tags::init())
.plugin(api::utils::init())
.invoke_handler(tauri::generate_handler![initialize_state, is_dev]);
builder
.run(tauri::generate_context!())

View File

@@ -17,7 +17,7 @@ import { invoke } from '@tauri-apps/api/tauri'
/// This begins the authentication flow quasi-synchronously
/// This returns a URL to be opened in a browser
export async function authenticate_begin_flow() {
return await invoke('auth_authenticate_begin_flow')
return await invoke('plugin:auth|auth_authenticate_begin_flow')
}
/// Authenticate a user with Hydra - part 2
@@ -25,11 +25,11 @@ export async function authenticate_begin_flow() {
/// (and also adding the credentials to the state)
/// This returns a Credentials object
export async function authenticate_await_completion() {
return await invoke('auth_authenticate_await_completion')
return await invoke('plugin:auth|auth_authenticate_await_completion')
}
export async function cancel_flow() {
return await invoke('auth_cancel_flow')
return await invoke('plugin:auth|auth_cancel_flow')
}
/// Refresh some credentials using Hydra, if needed
@@ -37,26 +37,26 @@ export async function cancel_flow() {
/// update_name is bool
/// Returns a Credentials object
export async function refresh(user, update_name) {
return await invoke('auth_refresh', { user, update_name })
return await invoke('plugin:auth|auth_refresh', { user, update_name })
}
/// Remove a user account from the database
/// user is UUID
export async function remove_user(user) {
return await invoke('auth_remove_user', { user })
return await invoke('plugin:auth|auth_remove_user', { user })
}
// Add a path as a profile in-memory
// user is UUID
/// Returns a bool
export async function has_user(user) {
return await invoke('auth_has_user', { user })
return await invoke('plugin:auth|auth_has_user', { user })
}
/// Returns a list of users
/// Returns an Array of Credentials
export async function users() {
return await invoke('auth_users')
return await invoke('plugin:auth|auth_users')
}
// Get a user by UUID
@@ -64,5 +64,5 @@ export async function users() {
// user is UUID
// Returns Credentials (of user)
export async function get_user(user) {
return await invoke('auth_get_user', { user })
return await invoke('plugin:auth|auth_get_user', { user })
}

View File

@@ -17,51 +17,63 @@ JavaVersion {
/// Get all JREs that exist on the system
// Returns an array of JavaVersion
export async function get_all_jre() {
return await invoke('jre_get_all_jre')
return await invoke('plugin:jre|jre_get_all_jre')
}
// Finds all the installation of Java 7, if it exists
// Returns [JavaVersion]
export async function find_jre_8_jres() {
return await invoke('jre_find_jre_8_jres')
const jres = await invoke('plugin:jre|jre_get_all_jre')
const version = '1.8'
const allowHigher = false
return await invoke('plugin:jre|jre_find_filtered_jres', { jres, version, allowHigher })
}
// Finds the installation of Java 17, if it exists
// Returns [JavaVersion]
export async function find_jre_17_jres() {
return await invoke('jre_find_jre_17_jres')
const jres = await invoke('plugin:jre|jre_get_all_jre')
const version = '1.17'
const allowHigher = false
return await invoke('plugin:jre|jre_find_filtered_jres', { jres, version, allowHigher })
}
// Finds the highest version of Java 18+, if it exists
// Returns [JavaVersion]
export async function find_jre_18plus_jres() {
return await invoke('jre_find_jre_18plus_jres')
const jres = await invoke('plugin:jre|jre_get_all_jre')
const version = '1.18'
const allowHigher = true
return await invoke('plugin:jre|jre_find_filtered_jres', { jres, version, allowHigher })
}
// Validates globals. Recommend directing the user to reassigned the globals if this returns false
// Returns [JavaVersion]
export async function validate_globals() {
return await invoke('jre_validate_globals')
return await invoke('plugin:jre|jre_validate_globals')
}
// Gets java version from a specific path by trying to run 'java -version' on it.
// This also validates it, as it returns null if no valid java version is found at the path
export async function get_jre(path) {
return await invoke('jre_get_jre', { path })
return await invoke('plugin:jre|jre_get_jre', { path })
}
// Autodetect Java globals, by searching the users computer.
// Returns a *NEW* JavaGlobals that can be put into Settings
export async function autodetect_java_globals() {
return await invoke('jre_autodetect_java_globals')
const java8 = await find_jre_8_jres()
const java17 = await find_jre_17_jres()
const java18plus = await find_jre_18plus_jres()
return await invoke('plugin:jre|jre_autodetect_java_globals', { java8, java17, java18plus })
}
// Automatically installs specified java version
export async function auto_install_java(javaVersion) {
return await invoke('jre_auto_install_java', { javaVersion })
return await invoke('plugin:jre|jre_auto_install_java', { javaVersion })
}
// Get max memory in KiB
export async function get_max_memory() {
return await invoke('jre_get_max_memory')
return await invoke('plugin:jre|jre_get_max_memory')
}

View File

@@ -18,25 +18,25 @@ pub struct Logs {
/// Get all logs that exist for a given profile
/// This is returned as an array of Log objects, sorted by datetime_string (the folder name, when the log was created)
export async function get_logs(profileUuid, clearContents) {
return await invoke('logs_get_logs', { profileUuid, clearContents })
return await invoke('plugin:logs|logs_get_logs', { profileUuid, clearContents })
}
/// Get a profile's log by datetime_string (the folder name, when the log was created)
export async function get_logs_by_datetime(profileUuid, datetimeString) {
return await invoke('logs_get_logs_by_datetime', { profileUuid, datetimeString })
return await invoke('plugin:logs|logs_get_logs_by_datetime', { profileUuid, datetimeString })
}
/// Get a profile's stdout only by datetime_string (the folder name, when the log was created)
export async function get_output_by_datetime(profileUuid, datetimeString) {
return await invoke('logs_get_output_by_datetime', { profileUuid, datetimeString })
return await invoke('plugin:logs|logs_get_output_by_datetime', { profileUuid, datetimeString })
}
/// Delete a profile's log by datetime_string (the folder name, when the log was created)
export async function delete_logs_by_datetime(profileUuid, datetimeString) {
return await invoke('logs_delete_logs_by_datetime', { profileUuid, datetimeString })
return await invoke('plugin:logs|logs_delete_logs_by_datetime', { profileUuid, datetimeString })
}
/// Delete all logs for a given profile
export async function delete_logs(profileUuid) {
return await invoke('logs_delete_logs', { profileUuid })
return await invoke('plugin:logs|logs_delete_logs', { profileUuid })
}

View File

@@ -3,23 +3,23 @@ import { invoke } from '@tauri-apps/api/tauri'
/// Gets the game versions from daedalus
// Returns a VersionManifest
export async function get_game_versions() {
return await invoke('metadata_get_game_versions')
return await invoke('plugin:metadata|metadata_get_game_versions')
}
// Gets the fabric versions from daedalus
// Returns Manifest
export async function get_fabric_versions() {
return await invoke('metadata_get_fabric_versions')
return await invoke('plugin:metadata|metadata_get_fabric_versions')
}
// Gets the forge versions from daedalus
// Returns Manifest
export async function get_forge_versions() {
return await invoke('metadata_get_forge_versions')
return await invoke('plugin:metadata|metadata_get_forge_versions')
}
// Gets the quilt versions from daedalus
// Returns Manifest
export async function get_quilt_versions() {
return await invoke('metadata_get_quilt_versions')
return await invoke('plugin:metadata|metadata_get_quilt_versions')
}

View File

@@ -4,13 +4,42 @@
* and deserialized into a usable JS object.
*/
import { invoke } from '@tauri-apps/api/tauri'
import { create } from './profile'
// Installs pack from a version ID
export async function install(projectId, versionId, packTitle, packIcon) {
return await invoke('pack_install_version_id', { projectId, versionId, packTitle, packIcon })
export async function install(projectId, versionId, packTitle, iconUrl) {
const location = {
type: 'fromVersionId',
project_id: projectId,
version_id: versionId,
title: packTitle,
icon_url: iconUrl,
}
const profile_creator = await invoke('plugin:pack|pack_get_profile_from_pack', { location })
const profile = await create(
profile_creator.name,
profile_creator.gameVersion,
profile_creator.modloader,
profile_creator.loaderVersion,
profile_creator.icon
)
return await invoke('plugin:pack|pack_install', { location, profile })
}
// Installs pack from a path
export async function install_from_file(path) {
return await invoke('pack_install_file', { path })
const location = {
type: 'fromFile',
path: path,
}
const profile_creator = await invoke('plugin:pack|pack_get_profile_from_pack', { location })
const profile = await create(
profile_creator.name,
profile_creator.gameVersion,
profile_creator.modloader,
profile_creator.loaderVersion,
profile_creator.icon
)
return await invoke('plugin:pack|pack_install', { location, profile })
}

View File

@@ -8,52 +8,52 @@ import { invoke } from '@tauri-apps/api/tauri'
/// Gets if a process has finished by UUID
/// Returns bool
export async function has_finished_by_uuid(uuid) {
return await invoke('process_has_finished_by_uuid', { uuid })
return await invoke('plugin:process|process_has_finished_by_uuid', { uuid })
}
/// Gets process exit status by UUID
/// Returns u32
export async function get_exit_status_by_uuid(uuid) {
return await invoke('process_get_exit_status_by_uuid', { uuid })
return await invoke('plugin:process|process_get_exit_status_by_uuid', { uuid })
}
/// Gets all process IDs
/// Returns [u32]
export async function get_all_uuids() {
return await invoke('process_get_all_uuids')
return await invoke('plugin:process|process_get_all_uuids')
}
/// Gets all running process IDs
/// Returns [u32]
export async function get_all_running_uuids() {
return await invoke('process_get_all_running_uuids')
return await invoke('plugin:process|process_get_all_running_uuids')
}
/// Gets all running process IDs with a given profile path
/// Returns [u32]
export async function get_uuids_by_profile_path(profilePath) {
return await invoke('process_get_uuids_by_profile_path', { profilePath })
return await invoke('plugin:process|process_get_uuids_by_profile_path', { profilePath })
}
/// Gets all running process IDs with a given profile path
/// Returns [u32]
export async function get_all_running_profile_paths(profilePath) {
return await invoke('process_get_all_running_profile_paths', { profilePath })
return await invoke('plugin:process|process_get_all_running_profile_paths', { profilePath })
}
/// Gets all running process IDs with a given profile path
/// Returns [u32]
export async function get_all_running_profiles() {
return await invoke('process_get_all_running_profiles')
return await invoke('plugin:process|process_get_all_running_profiles')
}
/// Gets process stdout by UUID
/// Returns String
export async function get_output_by_uuid(uuid) {
return await invoke('process_get_output_by_uuid', { uuid })
return await invoke('plugin:process|process_get_output_by_uuid', { uuid })
}
/// Kills a process by UUID
export async function kill_by_uuid(uuid) {
return await invoke('process_kill_by_uuid', { uuid })
return await invoke('plugin:process|process_kill_by_uuid', { uuid })
}

View File

@@ -5,11 +5,6 @@
*/
import { invoke } from '@tauri-apps/api/tauri'
// Add empty default instance
export async function create_empty() {
return await invoke('profile_create_empty')
}
/// Add instance
/*
name: String, // the name of the profile, and relative path to create
@@ -22,71 +17,81 @@ export async function create_empty() {
*/
export async function create(name, gameVersion, modloader, loaderVersion, icon) {
return await invoke('profile_create', { name, gameVersion, modloader, loaderVersion, icon })
return await invoke('plugin:profile_create|profile_create', {
name,
gameVersion,
modloader,
loaderVersion,
icon,
})
}
// Remove a profile
export async function remove(path) {
return await invoke('profile_remove', { path })
return await invoke('plugin:profile|profile_remove', { path })
}
// Get a profile by path
// Returns a Profile
export async function get(path, clearProjects) {
return await invoke('profile_get', { path, clearProjects })
return await invoke('plugin:profile|profile_get', { path, clearProjects })
}
// Get optimal java version from profile
// Returns a java version
export async function get_optimal_jre_key(path) {
return await invoke('profile_get_optimal_jre_key', { path })
return await invoke('plugin:profile|profile_get_optimal_jre_key', { path })
}
// Get a copy of the profile set
// Returns hashmap of path -> Profile
export async function list(clearProjects) {
return await invoke('profile_list', { clearProjects })
return await invoke('plugin:profile|profile_list', { clearProjects })
}
export async function check_installed(path, projectId) {
return await invoke('profile_check_installed', { path, projectId })
return await invoke('plugin:profile|profile_check_installed', { path, projectId })
}
// Installs/Repairs a profile
export async function install(path) {
return await invoke('profile_install', { path })
return await invoke('plugin:profile|profile_install', { path })
}
// Updates all of a profile's projects
export async function update_all(path) {
return await invoke('profile_update_all', { path })
return await invoke('plugin:profile|profile_update_all', { path })
}
// Updates a specified project
export async function update_project(path, projectPath) {
return await invoke('profile_update_project', { path, projectPath })
return await invoke('plugin:profile|profile_update_project', { path, projectPath })
}
// Add a project to a profile from a version
// Returns a path to the new project file
export async function add_project_from_version(path, versionId) {
return await invoke('profile_add_project_from_version', { path, versionId })
return await invoke('plugin:profile|profile_add_project_from_version', { path, versionId })
}
// Add a project to a profile from a path + project_type
// Returns a path to the new project file
export async function add_project_from_path(path, projectPath, projectType) {
return await invoke('profile_add_project_from_path', { path, projectPath, projectType })
return await invoke('plugin:profile|profile_add_project_from_path', {
path,
projectPath,
projectType,
})
}
// Toggle disabling a project
export async function toggle_disable_project(path, projectPath) {
return await invoke('profile_toggle_disable_project', { path, projectPath })
return await invoke('plugin:profile|profile_toggle_disable_project', { path, projectPath })
}
// Remove a project
export async function remove_project(path, projectPath) {
return await invoke('profile_remove_project', { path, projectPath })
return await invoke('plugin:profile|profile_remove_project', { path, projectPath })
}
// Export a profile to .mrpack
@@ -116,21 +121,21 @@ export async function get_potential_override_folders(profilePath) {
// Run Minecraft using a pathed profile
// Returns PID of child
export async function run(path) {
return await invoke('profile_run', { path })
return await invoke('plugin:profile|profile_run', { path })
}
// Run Minecraft using a pathed profile
// Waits for end
export async function run_wait(path) {
return await invoke('profile_run_wait', { path })
return await invoke('plugin:profile|profile_run_wait', { path })
}
// Edits a profile
export async function edit(path, editProfile) {
return await invoke('profile_edit', { path, editProfile })
return await invoke('plugin:profile|profile_edit', { path, editProfile })
}
// Edits a profile's icon
export async function edit_icon(path, iconPath) {
return await invoke('profile_edit_icon', { path, iconPath })
return await invoke('plugin:profile|profile_edit_icon', { path, iconPath })
}

View File

@@ -30,10 +30,10 @@ Memorysettings {
// Get full settings object
export async function get() {
return await invoke('settings_get')
return await invoke('plugin:settings|settings_get')
}
// Set full settings object
export async function set(settings) {
return await invoke('settings_set', { settings })
return await invoke('plugin:settings|settings_set', { settings })
}

View File

@@ -13,5 +13,5 @@ export async function initialize_state() {
// Gets active progress bars
export async function progress_bars_list() {
return await invoke('progress_bars_list')
return await invoke('plugin:utils|progress_bars_list')
}

View File

@@ -7,30 +7,30 @@ import { invoke } from '@tauri-apps/api/tauri'
// Gets tag bundle of all tags
export async function get_tag_bundle() {
return await invoke('tags_get_tag_bundle')
return await invoke('plugin:tags|tags_get_tag_bundle')
}
// Gets cached category tags
export async function get_categories() {
return await invoke('tags_get_categories')
return await invoke('plugin:tags|tags_get_categories')
}
// Gets cached loaders tags
export async function get_loaders() {
return await invoke('tags_get_loaders')
return await invoke('plugin:tags|tags_get_loaders')
}
// Gets cached game_versions tags
export async function get_game_versions() {
return await invoke('tags_get_game_versions')
return await invoke('plugin:tags|tags_get_game_versions')
}
// Gets cached donation_platforms tags
export async function get_donation_platforms() {
return await invoke('tags_get_donation_platforms')
return await invoke('plugin:tags|tags_get_donation_platforms')
}
// Gets cached licenses tags
export async function get_report_types() {
return await invoke('tags_get_report_types')
return await invoke('plugin:tags|tags_get_report_types')
}

View File

@@ -8,7 +8,7 @@ export async function isDev() {
}
export async function showInFolder(path) {
return await invoke('show_in_folder', { path })
return await invoke('plugin:utils|show_in_folder', { path })
}
export const releaseColor = (releaseType) => {

View File

@@ -9,7 +9,7 @@ export default {
async checkDisableMouseover() {
try {
// Fetch the CSS content from the Rust backend
const should_disable_mouseover = await invoke('should_disable_mouseover')
const should_disable_mouseover = await invoke('plugin:utils|should_disable_mouseover')
if (should_disable_mouseover) {
// Create a style element and set its content