2023-03-31 11:00:43 -07:00
|
|
|
/**
|
|
|
|
|
* All theseus API calls return serialized values (both return values and errors);
|
|
|
|
|
* So, for example, addDefaultInstance creates a blank Profile object, where the Rust struct is serialized,
|
|
|
|
|
* and deserialized into a usable JS object.
|
|
|
|
|
*/
|
|
|
|
|
import { invoke } from '@tauri-apps/api/tauri'
|
|
|
|
|
|
|
|
|
|
// Add empty default instance
|
2023-04-17 12:40:27 -07:00
|
|
|
export async function create_empty() {
|
2023-03-31 11:00:43 -07:00
|
|
|
return await invoke('profile_create_empty')
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-17 12:40:27 -07:00
|
|
|
/// Add instance
|
|
|
|
|
/*
|
|
|
|
|
name: String, // the name of the profile, and relative path to create
|
|
|
|
|
game_version: String, // the game version of the profile
|
|
|
|
|
modloader: ModLoader, // the modloader to use
|
|
|
|
|
- ModLoader is an enum, with the following variants: Vanilla, Forge, Fabric, Quilt
|
|
|
|
|
loader_version: String, // the modloader version to use, set to "latest", "stable", or the ID of your chosen loader
|
|
|
|
|
icon: Path, // the icon for the profile
|
|
|
|
|
- icon is a path to an image file, which will be copied into the profile directory
|
|
|
|
|
*/
|
|
|
|
|
|
2023-04-24 22:22:10 -04:00
|
|
|
export async function create(name, gameVersion, modloader, loaderVersion, icon) {
|
|
|
|
|
return await invoke('profile_create', { name, gameVersion, modloader, loaderVersion, icon })
|
2023-03-31 11:00:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove a profile
|
|
|
|
|
export async function remove(path) {
|
2023-04-03 13:46:04 -07:00
|
|
|
return await invoke('profile_remove', { path })
|
2023-03-31 11:00:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get a profile by path
|
2023-04-03 13:46:04 -07:00
|
|
|
// Returns a Profile
|
2023-05-11 18:11:15 -07:00
|
|
|
export async function get(path, clearProjects) {
|
|
|
|
|
return await invoke('profile_get', { path, clearProjects })
|
2023-03-31 11:00:43 -07:00
|
|
|
}
|
|
|
|
|
|
2023-05-19 18:59:32 -07:00
|
|
|
// 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 })
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-31 11:00:43 -07:00
|
|
|
// Get a copy of the profile set
|
2023-04-03 13:46:04 -07:00
|
|
|
// Returns hashmap of path -> Profile
|
2023-05-11 18:11:15 -07:00
|
|
|
export async function list(clearProjects) {
|
|
|
|
|
return await invoke('profile_list', { clearProjects })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function check_installed(path, projectId) {
|
|
|
|
|
return await invoke('profile_check_installed', { path, projectId })
|
2023-03-31 11:00:43 -07:00
|
|
|
}
|
|
|
|
|
|
2023-04-26 10:28:08 -07:00
|
|
|
// Installs/Repairs a profile
|
|
|
|
|
export async function install(path) {
|
|
|
|
|
return await invoke('profile_install', { path })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Updates all of a profile's projects
|
|
|
|
|
export async function update_all(path) {
|
|
|
|
|
return await invoke('profile_update_all', { path })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Updates a specified project
|
|
|
|
|
export async function update_project(path, projectPath) {
|
|
|
|
|
return await invoke('profile_update_project', { path, projectPath })
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-13 12:03:15 -07:00
|
|
|
// Add a project to a profile from a version
|
|
|
|
|
// Returns a path to the new project file
|
2023-04-26 10:28:08 -07:00
|
|
|
export async function add_project_from_version(path, versionId) {
|
|
|
|
|
return await invoke('profile_add_project_from_version', { path, versionId })
|
2023-04-13 12:03:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add a project to a profile from a path + project_type
|
|
|
|
|
// Returns a path to the new project file
|
2023-04-26 10:28:08 -07:00
|
|
|
export async function add_project_from_path(path, projectPath, projectType) {
|
|
|
|
|
return await invoke('profile_add_project_from_path', { path, projectPath, projectType })
|
2023-04-13 12:03:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Toggle disabling a project
|
2023-04-26 10:28:08 -07:00
|
|
|
export async function toggle_disable_project(path, projectPath) {
|
|
|
|
|
return await invoke('profile_toggle_disable_project', { path, projectPath })
|
2023-04-13 12:03:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove a project
|
2023-04-26 10:28:08 -07:00
|
|
|
export async function remove_project(path, projectPath) {
|
|
|
|
|
return await invoke('profile_remove_project', { path, projectPath })
|
2023-04-13 12:03:15 -07:00
|
|
|
}
|
|
|
|
|
|
2023-06-26 14:29:53 -07:00
|
|
|
// Export a profile to .mrpack
|
|
|
|
|
/// included_overrides is an array of paths to override folders to include (ie: 'mods', 'resource_packs')
|
|
|
|
|
// Version id is optional (ie: 1.1.5)
|
|
|
|
|
export async function export_profile_mrpack(path, exportLocation, includedOverrides, versionId) {
|
|
|
|
|
return await invoke('profile_export_mrpack', {
|
|
|
|
|
path,
|
|
|
|
|
exportLocation,
|
|
|
|
|
includedOverrides,
|
|
|
|
|
versionId,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Given a folder path, populate an array of all the subfolders
|
|
|
|
|
// Intended to be used for finding potential override folders
|
|
|
|
|
// profile
|
|
|
|
|
// -- mods
|
|
|
|
|
// -- resourcepacks
|
|
|
|
|
// -- file1
|
|
|
|
|
// => [mods, resourcepacks]
|
|
|
|
|
// allows selection for 'included_overrides' in export_profile_mrpack
|
|
|
|
|
export async function get_potential_override_folders(profilePath) {
|
|
|
|
|
return await invoke('profile_get_potential_override_folders', { profilePath })
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-31 11:00:43 -07:00
|
|
|
// Run Minecraft using a pathed profile
|
|
|
|
|
// Returns PID of child
|
2023-04-08 18:54:38 -07:00
|
|
|
export async function run(path) {
|
|
|
|
|
return await invoke('profile_run', { path })
|
2023-03-31 11:00:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Run Minecraft using a pathed profile
|
|
|
|
|
// Waits for end
|
2023-04-08 18:54:38 -07:00
|
|
|
export async function run_wait(path) {
|
|
|
|
|
return await invoke('profile_run_wait', { path })
|
2023-03-31 11:00:43 -07:00
|
|
|
}
|
2023-05-11 10:26:00 -07:00
|
|
|
|
|
|
|
|
// Edits a profile
|
|
|
|
|
export async function edit(path, editProfile) {
|
|
|
|
|
return await invoke('profile_edit', { path, editProfile })
|
|
|
|
|
}
|
2023-05-19 18:59:32 -07:00
|
|
|
|
|
|
|
|
// Edits a profile's icon
|
|
|
|
|
export async function edit_icon(path, iconPath) {
|
|
|
|
|
return await invoke('profile_edit_icon', { path, iconPath })
|
|
|
|
|
}
|