You've already forked AstralRinth
forked from didirus/AstralRinth
* refactor: migrate to common eslint+prettier configs * fix: prettier frontend * feat: config changes * fix: lint issues * fix: lint * fix: type imports * fix: cyclical import issue * fix: lockfile * fix: missing dep * fix: switch to tabs * fix: continue switch to tabs * fix: rustfmt parity * fix: moderation lint issue * fix: lint issues * fix: ui intl * fix: lint issues * Revert "fix: rustfmt parity" This reverts commit cb99d2376c321d813d4b7fc7e2a213bb30a54711. * feat: revert last rs
66 lines
1.7 KiB
JavaScript
66 lines
1.7 KiB
JavaScript
/**
|
|
* 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/core'
|
|
|
|
import { create } from './profile'
|
|
|
|
// Installs pack from a version ID
|
|
export async function create_profile_and_install(
|
|
projectId,
|
|
versionId,
|
|
packTitle,
|
|
iconUrl,
|
|
createInstanceCallback = () => {},
|
|
) {
|
|
const location = {
|
|
type: 'fromVersionId',
|
|
project_id: projectId,
|
|
version_id: versionId,
|
|
title: packTitle,
|
|
icon_url: iconUrl,
|
|
}
|
|
const profile_creator = await invoke('plugin:pack|pack_get_profile_from_pack', { location })
|
|
const profile = await create(
|
|
profile_creator.name,
|
|
profile_creator.gameVersion,
|
|
profile_creator.modloader,
|
|
profile_creator.loaderVersion,
|
|
null,
|
|
true,
|
|
)
|
|
createInstanceCallback(profile)
|
|
|
|
return await invoke('plugin:pack|pack_install', { location, profile })
|
|
}
|
|
|
|
export async function install_to_existing_profile(projectId, versionId, title, profilePath) {
|
|
const location = {
|
|
type: 'fromVersionId',
|
|
project_id: projectId,
|
|
version_id: versionId,
|
|
title,
|
|
}
|
|
return await invoke('plugin:pack|pack_install', { location, profile: profilePath })
|
|
}
|
|
|
|
// Installs pack from a path
|
|
export async function create_profile_and_install_from_file(path) {
|
|
const location = {
|
|
type: 'fromFile',
|
|
path: path,
|
|
}
|
|
const profile_creator = await invoke('plugin:pack|pack_get_profile_from_pack', { location })
|
|
const profile = await create(
|
|
profile_creator.name,
|
|
profile_creator.gameVersion,
|
|
profile_creator.modloader,
|
|
profile_creator.loaderVersion,
|
|
null,
|
|
true,
|
|
)
|
|
return await invoke('plugin:pack|pack_install', { location, profile })
|
|
}
|