Migrate to SQLite for Internal Launcher Data (#1300)

* initial migration

* barebones profiles

* Finish profiles

* Add back file watcher

* UI support progress

* Finish most of cache

* Fix options page

* Fix forge, finish modrinth auth

* Accounts, process cache

* Run SQLX prepare

* Finish

* Run lint + actions

* Fix version to be compat with windows

* fix lint

* actually fix lint

* actually fix lint again
This commit is contained in:
Geometrically
2024-07-24 11:03:19 -07:00
committed by GitHub
parent 90f74427d9
commit 49a20a303a
156 changed files with 9208 additions and 8547 deletions

View File

@@ -45,11 +45,3 @@ export async function remove_user(user) {
export async function users() {
return await invoke('plugin:auth|auth_users')
}
// Get a user by UUID
// Prefer to use refresh() instead of this because it will refresh the credentials
// user is UUID
// Returns Credentials (of user)
export async function get_user(user) {
return await invoke('plugin:auth|auth_get_user', { user })
}

View File

@@ -0,0 +1,49 @@
import { invoke } from '@tauri-apps/api/tauri'
export async function get_project(id) {
return await invoke('plugin:cache|get_project', { id })
}
export async function get_project_many(ids) {
return await invoke('plugin:cache|get_project_many', { ids })
}
export async function get_version(id) {
return await invoke('plugin:cache|get_version', { id })
}
export async function get_version_many(ids) {
return await invoke('plugin:cache|get_version_many', { ids })
}
export async function get_user(id) {
return await invoke('plugin:cache|get_user', { id })
}
export async function get_user_many(ids) {
return await invoke('plugin:cache|get_user_many', { ids })
}
export async function get_team(id) {
return await invoke('plugin:cache|get_team', { id })
}
export async function get_team_many(ids) {
return await invoke('plugin:cache|get_team_many', { ids })
}
export async function get_organization(id) {
return await invoke('plugin:cache|get_organization', { id })
}
export async function get_organization_many(ids) {
return await invoke('plugin:cache|get_organization_many', { ids })
}
export async function get_search_results(id) {
return await invoke('plugin:cache|get_search_results', { id })
}
export async function get_search_results_many(ids) {
return await invoke('plugin:cache|get_search_results_many', { ids })
}

View File

@@ -17,7 +17,7 @@
// event.payload is the payload object
console.log(event)
})
Putting that in a script will print any emitted signal from rust
*/
import { listen } from '@tauri-apps/api/event'
@@ -93,15 +93,3 @@ export async function command_listener(callback) {
export async function warning_listener(callback) {
return await listen('warning', (event) => callback(event.payload))
}
/// Payload for the 'offline' event
/*
OfflinePayload {
offline: bool, true or false
}
*/
export async function offline_listener(callback) {
return await listen('offline', (event) => {
return callback(event.payload)
})
}

View File

@@ -14,6 +14,14 @@ JavaVersion {
*/
export async function get_java_versions() {
return await invoke('plugin:jre|get_java_versions')
}
export async function set_java_version(javaVersion) {
return await invoke('plugin:jre|set_java_version', { javaVersion })
}
// Finds all the installation of Java 7, if it exists
// Returns [JavaVersion]
export async function find_filtered_jres(version) {

View File

@@ -6,34 +6,8 @@ export async function get_game_versions() {
return await invoke('plugin:metadata|metadata_get_game_versions')
}
// Gets the fabric versions from daedalus
// Gets the given loader versions from daedalus
// Returns Manifest
export async function get_fabric_versions() {
const c = await invoke('plugin:metadata|metadata_get_fabric_versions')
console.log('Getting fabric versions', c)
return c
}
// Gets the forge versions from daedalus
// Returns Manifest
export async function get_forge_versions() {
const c = await invoke('plugin:metadata|metadata_get_forge_versions')
console.log('Getting forge versions', c)
return c
}
// Gets the quilt versions from daedalus
// Returns Manifest
export async function get_quilt_versions() {
const c = await invoke('plugin:metadata|metadata_get_quilt_versions')
console.log('Getting quilt versions', c)
return c
}
// Gets the neoforge versions from daedalus
// Returns Manifest
export async function get_neoforge_versions() {
const c = await invoke('plugin:metadata|metadata_get_neoforge_versions')
console.log('Getting neoforge versions', c)
return c
export async function get_loader_versions(loader) {
return await invoke('plugin:metadata|metadata_get_loader_versions', { loader })
}

View File

@@ -5,17 +5,10 @@
*/
import { invoke } from '@tauri-apps/api/tauri'
export async function authenticate_begin_flow(provider) {
return await invoke('plugin:mr_auth|authenticate_begin_flow', { provider })
export async function login(provider) {
return await invoke('modrinth_auth_login', { provider })
}
export async function authenticate_await_completion() {
return await invoke('plugin:mr_auth|authenticate_await_completion')
}
export async function cancel_flow() {
return await invoke('plugin:mr_auth|cancel_flow')
}
export async function login_pass(username, password, challenge) {
return await invoke('plugin:mr_auth|login_pass', { username, password, challenge })
}
@@ -34,10 +27,6 @@ export async function create_account(username, email, password, challenge, signU
})
}
export async function refresh() {
return await invoke('plugin:mr_auth|refresh')
}
export async function logout() {
return await invoke('plugin:mr_auth|logout')
}

View File

@@ -21,7 +21,8 @@ export async function install(projectId, versionId, packTitle, iconUrl) {
profile_creator.gameVersion,
profile_creator.modloader,
profile_creator.loaderVersion,
profile_creator.icon,
null,
true,
)
return await invoke('plugin:pack|pack_install', { location, profile })
@@ -39,7 +40,8 @@ export async function install_from_file(path) {
profile_creator.gameVersion,
profile_creator.modloader,
profile_creator.loaderVersion,
profile_creator.icon,
null,
true,
)
return await invoke('plugin:pack|pack_install', { location, profile })
}

View File

@@ -5,49 +5,19 @@
*/
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('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('plugin:process|process_get_exit_status_by_uuid', { uuid })
}
/// Gets all process IDs
/// Gets all running process IDs with a given profile path
/// Returns [u32]
export async function 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('plugin:process|process_get_all_running_uuids')
export async function get_by_profile_path(path) {
return await invoke('plugin:process|process_get_by_profile_path', { path })
}
/// Gets all running process IDs with a given profile path
/// Returns [u32]
export async function 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('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('plugin:process|process_get_all_running_profiles')
export async function get_all() {
return await invoke('plugin:process|process_get_all')
}
/// Kills a process by UUID
export async function kill_by_uuid(uuid) {
return await invoke('plugin:process|process_kill_by_uuid', { uuid })
export async function kill(pid) {
return await invoke('plugin:process|process_kill', { pid })
}

View File

@@ -16,7 +16,7 @@ import { invoke } from '@tauri-apps/api/tauri'
- icon is a path to an image file, which will be copied into the profile directory
*/
export async function create(name, gameVersion, modloader, loaderVersion, icon, noWatch) {
export async function create(name, gameVersion, modloader, loaderVersion, iconPath, skipInstall) {
//Trim string name to avoid "Unable to find directory"
name = name.trim()
return await invoke('plugin:profile_create|profile_create', {
@@ -24,8 +24,8 @@ export async function create(name, gameVersion, modloader, loaderVersion, icon,
gameVersion,
modloader,
loaderVersion,
icon,
noWatch,
iconPath,
skipInstall,
})
}
@@ -41,8 +41,18 @@ export async function remove(path) {
// Get a profile by path
// Returns a Profile
export async function get(path, clearProjects) {
return await invoke('plugin:profile|profile_get', { path, clearProjects })
export async function get(path) {
return await invoke('plugin:profile|profile_get', { path })
}
export async function get_many(paths) {
return await invoke('plugin:profile|profile_get_many', { paths })
}
// Get a profile's projects
// Returns a map of a path to profile file
export async function get_projects(path) {
return await invoke('plugin:profile|profile_get_projects', { path })
}
// Get a profile's full fs path
@@ -65,8 +75,8 @@ export async function 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('plugin:profile|profile_list', { clearProjects })
export async function list() {
return await invoke('plugin:profile|profile_list')
}
export async function check_installed(path, projectId) {
@@ -163,10 +173,8 @@ export async function 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('plugin:profile|profile_run_wait', { path })
export async function kill(path) {
return await invoke('plugin:profile|profile_kill', { path })
}
// Edits a profile

View File

@@ -16,11 +16,6 @@ export async function progress_bars_list() {
return await invoke('plugin:utils|progress_bars_list')
}
// Check if any safe loading bars are active
export async function check_safe_loading_bars_complete() {
return await invoke('plugin:utils|safety_check_safe_loading_bars')
}
// 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
@@ -28,8 +23,3 @@ export async function check_safe_loading_bars_complete() {
export async function get_opening_command() {
return await invoke('plugin:utils|get_opening_command')
}
// Wait for settings to sync
export async function await_sync() {
return await invoke('plugin:utils|await_sync')
}

View File

@@ -5,11 +5,6 @@
*/
import { invoke } from '@tauri-apps/api/tauri'
// Gets tag bundle of all tags
export async function get_tag_bundle() {
return await invoke('plugin:tags|tags_get_tag_bundle')
}
// Gets cached category tags
export async function get_categories() {
return await invoke('plugin:tags|tags_get_categories')

View File

@@ -1,11 +1,4 @@
import {
add_project_from_version as installMod,
check_installed,
get_full_path,
get_mod_full_path,
} from '@/helpers/profile'
import { useFetch } from '@/helpers/fetch.js'
import { handleError } from '@/store/notifications.js'
import { get_full_path, get_mod_full_path } from '@/helpers/profile'
import { invoke } from '@tauri-apps/api/tauri'
export async function isDev() {
@@ -49,55 +42,16 @@ export const releaseColor = (releaseType) => {
}
}
export const installVersionDependencies = async (profile, version) => {
for (const dep of version.dependencies) {
if (dep.dependency_type !== 'required') continue
// disallow fabric api install on quilt
if (dep.project_id === 'P7dR8mSH' && profile.metadata.loader === 'quilt') continue
if (dep.version_id) {
if (
dep.project_id &&
(await check_installed(profile.path, dep.project_id).catch(handleError))
)
continue
await installMod(profile.path, dep.version_id)
} else {
if (
dep.project_id &&
(await check_installed(profile.path, dep.project_id).catch(handleError))
)
continue
const depVersions = await useFetch(
`https://api.modrinth.com/v2/project/${dep.project_id}/version`,
'dependency versions',
)
const latest = depVersions.find(
(v) =>
v.game_versions.includes(profile.metadata.game_version) &&
v.loaders.includes(profile.metadata.loader),
)
if (latest) {
await installMod(profile.path, latest.id).catch(handleError)
}
export function debounce(fn, wait) {
let timer
return function (...args) {
if (timer) {
clearTimeout(timer) // clear any pre-existing timer
}
// eslint-disable-next-line @typescript-eslint/no-this-alias
const context = this // get the current context
timer = setTimeout(() => {
fn.apply(context, args) // call the function if time expires
}, wait)
}
}
export const openLink = (url) => {
window.__TAURI_INVOKE__('tauri', {
__tauriModule: 'Shell',
message: {
cmd: 'open',
path: url,
},
})
}
export const refreshOffline = async () => {
return await invoke('plugin:utils|refresh_offline', {})
}
// returns true/false
export const isOffline = async () => {
return await invoke('plugin:utils|is_offline', {})
}