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
|
|
|
|
|
export async function addDefaultInstance() {
|
|
|
|
|
return await invoke('profile_create_empty')
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-13 12:03:15 -07:00
|
|
|
/// Creates instance
|
2023-04-03 13:46:04 -07:00
|
|
|
/// Returns a path to the profile created
|
2023-04-13 12:03:15 -07:00
|
|
|
export async function create(name, game_version, modloader, loader_version, icon) {
|
|
|
|
|
return await invoke('profile_create', { name, game_version, modloader, loader_version, 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-03-31 11:00:43 -07:00
|
|
|
export async function get(path) {
|
2023-04-03 13:46:04 -07:00
|
|
|
return await invoke('profile_get', { 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-03-31 11:00:43 -07:00
|
|
|
export async function list() {
|
|
|
|
|
return await invoke('profile_list')
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
export async function add_project_from_version(path, version_id) {
|
|
|
|
|
return await invoke('profile_add_project_from_version', { path, version_id })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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, project_path, project_type) {
|
|
|
|
|
return await invoke('profile_add_project_from_path', { path, project_path, project_type })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Toggle disabling a project
|
|
|
|
|
export async function toggle_disable_project(path, project_path) {
|
|
|
|
|
return await invoke('profile_toggle_disable_project', { path, project_path })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove a project
|
|
|
|
|
export async function remove_project(path, project_path) {
|
|
|
|
|
return await invoke('profile_remove_project', { path, project_path })
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|