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.
|
|
|
|
|
*/
|
2024-08-27 21:49:36 +02:00
|
|
|
import { invoke } from '@tauri-apps/api/core'
|
2023-03-31 11:00:43 -07:00
|
|
|
|
2026-04-29 09:53:10 -07:00
|
|
|
export interface LoadingBarType {
|
|
|
|
|
type?: string
|
|
|
|
|
version?: string
|
|
|
|
|
profile_path?: string
|
|
|
|
|
pack_name?: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface LoadingBar {
|
|
|
|
|
id?: string | number
|
|
|
|
|
loading_bar_uuid?: string | number
|
|
|
|
|
title?: string
|
|
|
|
|
message?: string
|
|
|
|
|
current?: number
|
|
|
|
|
total?: number
|
|
|
|
|
bar_type?: LoadingBarType
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type OpeningCommandEvent =
|
|
|
|
|
| 'RunMRPack'
|
|
|
|
|
| 'InstallServer'
|
|
|
|
|
| 'InstallVersion'
|
|
|
|
|
| 'InstallMod'
|
|
|
|
|
| 'InstallModpack'
|
|
|
|
|
| string
|
|
|
|
|
|
|
|
|
|
export interface OpeningCommand {
|
|
|
|
|
event: OpeningCommandEvent
|
|
|
|
|
id?: string
|
|
|
|
|
path?: string
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-31 11:00:43 -07:00
|
|
|
// Initialize the theseus API state
|
|
|
|
|
// This should be called during the initializion/opening of the launcher
|
|
|
|
|
export async function initialize_state() {
|
2026-04-29 09:53:10 -07:00
|
|
|
return await invoke<void>('initialize_state')
|
2023-03-31 11:00:43 -07:00
|
|
|
}
|
2023-04-26 10:28:08 -07:00
|
|
|
|
|
|
|
|
// Gets active progress bars
|
|
|
|
|
export async function progress_bars_list() {
|
2026-04-29 09:53:10 -07:00
|
|
|
return await invoke<Record<string, LoadingBar>>('plugin:utils|progress_bars_list')
|
2023-04-26 10:28:08 -07:00
|
|
|
}
|
2023-06-30 08:11:32 -07:00
|
|
|
|
|
|
|
|
// Get opening command
|
|
|
|
|
// For example, if a user clicks on an .mrpack to open the app.
|
|
|
|
|
// This should be called once and only when the app is done booting up and ready to receive a command
|
|
|
|
|
// Returns a Command struct- see events.js
|
|
|
|
|
export async function get_opening_command() {
|
2026-04-29 09:53:10 -07:00
|
|
|
return await invoke<OpeningCommand | null>('plugin:utils|get_opening_command')
|
2023-06-30 08:11:32 -07:00
|
|
|
}
|