2023-04-07 13:31:06 -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.
|
|
|
|
|
*/
|
2024-08-27 21:49:36 +02:00
|
|
|
import { invoke } from '@tauri-apps/api/core'
|
2023-04-07 13:31:06 -07:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
JavaVersion {
|
|
|
|
|
path: Path
|
|
|
|
|
version: String
|
|
|
|
|
}
|
2023-05-16 15:30:04 -07:00
|
|
|
|
2023-04-07 13:31:06 -07:00
|
|
|
*/
|
|
|
|
|
|
2024-07-24 11:03:19 -07:00
|
|
|
export async function get_java_versions() {
|
2025-08-14 21:48:38 +01:00
|
|
|
return await invoke('plugin:jre|get_java_versions')
|
2024-07-24 11:03:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function set_java_version(javaVersion) {
|
2025-08-14 21:48:38 +01:00
|
|
|
return await invoke('plugin:jre|set_java_version', { javaVersion })
|
2024-07-24 11:03:19 -07:00
|
|
|
}
|
|
|
|
|
|
2023-04-07 13:31:06 -07:00
|
|
|
// Finds all the installation of Java 7, if it exists
|
|
|
|
|
// Returns [JavaVersion]
|
2024-04-18 20:28:52 -07:00
|
|
|
export async function find_filtered_jres(version) {
|
2025-08-14 21:48:38 +01:00
|
|
|
return await invoke('plugin:jre|jre_find_filtered_jres', { version })
|
2023-04-07 13:31:06 -07:00
|
|
|
}
|
|
|
|
|
|
2023-04-17 12:40:27 -07:00
|
|
|
// 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) {
|
2025-08-14 21:48:38 +01:00
|
|
|
return await invoke('plugin:jre|jre_get_jre', { path })
|
2023-04-17 12:40:27 -07:00
|
|
|
}
|
|
|
|
|
|
2023-09-12 09:27:03 -07:00
|
|
|
// Tests JRE version by running 'java -version' on it.
|
|
|
|
|
// Returns true if the version is valid, and matches given (after extraction)
|
2025-07-07 14:11:36 -05:00
|
|
|
export async function test_jre(path, majorVersion) {
|
2025-08-14 21:48:38 +01:00
|
|
|
return await invoke('plugin:jre|jre_test_jre', { path, majorVersion })
|
2023-09-12 09:27:03 -07:00
|
|
|
}
|
|
|
|
|
|
2023-05-16 15:30:04 -07:00
|
|
|
// Automatically installs specified java version
|
2023-06-20 22:03:59 -04:00
|
|
|
export async function auto_install_java(javaVersion) {
|
2025-08-14 21:48:38 +01:00
|
|
|
return await invoke('plugin:jre|jre_auto_install_java', { javaVersion })
|
2023-05-16 15:30:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get max memory in KiB
|
|
|
|
|
export async function get_max_memory() {
|
2025-08-14 21:48:38 +01:00
|
|
|
return await invoke('plugin:jre|jre_get_max_memory')
|
2023-05-16 15:30:04 -07:00
|
|
|
}
|