refactor: Add specta::Type everywhere
This commit is contained in:
parent
ae49d82d9e
commit
718f1c00de
6 changed files with 30 additions and 5 deletions
|
|
@ -31,7 +31,12 @@ tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-wo
|
|||
tauri-plugin-updater = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v2", features = [ "rustls-tls" ] }
|
||||
|
||||
rspc = { version = "0.2.0", features = [ "specta2" ] }
|
||||
specta = { version = "=2.0.0-rc.12" }
|
||||
specta = { version = "=2.0.0-rc.12", features = [
|
||||
"chrono",
|
||||
"uuid",
|
||||
"serde",
|
||||
"serde_json"
|
||||
] }
|
||||
tauri-specta = { version = "=2.0.0-rc.10", features = [
|
||||
"javascript",
|
||||
"typescript"
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ const CLUSTER_JSON: &str = "cluster.json";
|
|||
pub(crate) struct Clusters(pub HashMap<ClusterPath, Cluster>);
|
||||
|
||||
/// Core Cluster stages used in package logic.
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
#[derive(Serialize, Deserialize, Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ClusterStage {
|
||||
|
|
@ -141,6 +142,7 @@ impl From<InnerPathLinux> for RawPackagePath {
|
|||
}
|
||||
|
||||
/// Relative [`PathBuf`] for a specific [`Package`] of a [`Cluster`].
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, Hash)]
|
||||
#[serde(transparent)]
|
||||
pub struct PackagePath(pub PathBuf);
|
||||
|
|
@ -187,6 +189,7 @@ impl PackagePath {
|
|||
|
||||
/// Represents a single Instance and installation of Minecraft
|
||||
/// Contains settings and identifiers on a per-Cluster basis, falling back to default settings for Options<>
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct Cluster {
|
||||
/// The Uuid of a specific cluster.
|
||||
|
|
@ -219,6 +222,7 @@ pub struct Cluster {
|
|||
}
|
||||
|
||||
/// Represents core Cluster metadata ([`Cluster#meta`]).
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct ClusterMeta {
|
||||
/// The user-facing name of the cluster stored as a string.
|
||||
|
|
@ -267,6 +271,7 @@ pub struct ClusterMeta {
|
|||
}
|
||||
|
||||
/// Optional data used to link a specific cluster to a package project.
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct PackageData {
|
||||
/// The package ID as a String.
|
||||
|
|
@ -283,6 +288,7 @@ pub fn default_locked() -> Option<bool> {
|
|||
}
|
||||
|
||||
/// Available mod loaders to be used for a cluster.
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Copy, Deserialize, Serialize, Default)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum Loader {
|
||||
|
|
@ -330,6 +336,7 @@ impl Loader {
|
|||
|
||||
/// Custom Java arguments on a per-cluster basis.
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
pub struct JavaOptions {
|
||||
/// A custom java version from the global java store, if specified.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ impl PackageType {
|
|||
|
||||
/// A struct that represents a Package.
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
pub struct Package {
|
||||
pub sha512: String,
|
||||
pub meta: PackageMetadata,
|
||||
|
|
@ -146,6 +147,7 @@ pub struct Package {
|
|||
}
|
||||
|
||||
/// Metadata that represents a [`Package`].
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
pub enum PackageMetadata {
|
||||
|
|
@ -168,6 +170,7 @@ pub enum PackageMetadata {
|
|||
}
|
||||
|
||||
/// Universal metadata for any managed package from a Mod distribution platform.
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct ManagedPackage {
|
||||
// Core Metadata
|
||||
|
|
@ -193,6 +196,7 @@ pub struct ManagedPackage {
|
|||
}
|
||||
|
||||
/// Universal managed package version of a package.
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct ManagedVersion {
|
||||
pub id: String,
|
||||
|
|
@ -216,6 +220,7 @@ pub struct ManagedVersion {
|
|||
}
|
||||
|
||||
/// Universal interface for managed package files.
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct ManagedVersionFile {
|
||||
pub url: String,
|
||||
|
|
@ -228,6 +233,7 @@ pub struct ManagedVersionFile {
|
|||
}
|
||||
|
||||
/// Universal interface for managed package dependencies.
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct ManagedDependency {
|
||||
pub version_id: Option<String>,
|
||||
|
|
@ -237,6 +243,7 @@ pub struct ManagedDependency {
|
|||
}
|
||||
|
||||
/// Universal interface for managed package authors and users.
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct ManagedUser {
|
||||
pub id: String,
|
||||
|
|
@ -249,6 +256,7 @@ pub struct ManagedUser {
|
|||
}
|
||||
|
||||
/// The type of a [`ManagedDependency`].
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub enum PackageDependency {
|
||||
Required,
|
||||
|
|
@ -259,7 +267,8 @@ pub enum PackageDependency {
|
|||
|
||||
/// The Client/Server side type of a [`Package`].
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
// #[serde(rename_all = "kebab-case")]
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
pub enum PackageSide {
|
||||
Required,
|
||||
Optional,
|
||||
|
|
@ -268,8 +277,9 @@ pub enum PackageSide {
|
|||
}
|
||||
|
||||
/// The file type of a [`Package`].
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
// #[serde(rename_all = "kebab-case")]
|
||||
pub enum PackageFile {
|
||||
RequiredPack,
|
||||
OptionalPack,
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ pub enum Theme {
|
|||
|
||||
/// Global memory settings across all clusters.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
pub struct Memory {
|
||||
/// Maximum amount of Java memory available globally.
|
||||
pub maximum: u32,
|
||||
|
|
@ -156,6 +157,7 @@ impl Default for Memory {
|
|||
|
||||
/// Global Minecraft resolution.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
pub struct Resolution(pub u16, pub u16);
|
||||
|
||||
impl Default for Resolution {
|
||||
|
|
@ -167,6 +169,7 @@ impl Default for Resolution {
|
|||
/// Global initialization hooks for all Minecraft clusters.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
|
||||
#[serde(default)]
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
pub struct InitHooks {
|
||||
/// Pre-launch hook.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ use super::io;
|
|||
/// Use [`locate_java`] to get an array of all located java instances on the machine
|
||||
/// paths from https://github.com/PrismLauncher/PrismLauncher/blob/develop/launcher/java/JavaUtils.cpp under GPL 3.0
|
||||
/// paths and java_check from https://github.com/modrinth/theseus/blob/master/theseus/src/util/jre.rs under MIT
|
||||
#[cfg_attr(feature = "tauri", derive(specta::Type))]
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Clone)]
|
||||
pub struct JavaVersion {
|
||||
pub version: String,
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ export default petal({
|
|||
'**/*.svg',
|
||||
'*.rs',
|
||||
'pnpm-lock.yaml',
|
||||
'./src-tauri/prisma/migrations/migration_lock.toml',
|
||||
'./desktop/src/bindings.ts',
|
||||
'desktop/src/bindings.ts',
|
||||
],
|
||||
}).append([
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue