mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 13:30:48 +00:00
Groundwork for integrating Specta (#949)
* add derive(specta::Type) * use specta from git * introduce Uuid type * remove unnecessary specta::Type * document export_types test * upgrade Specta The previous Specta branch had some hacks that were just for this project. They have all been converted into proper features so they can be merged into main. * remove some unnecessary specta::Type uses * add MessageDiscriminantDef explanation * manually export types with specta * rename 'specta.rs' to 'export_types.rs' * rename 'export_types' to 'generate_ts_types' --------- Co-authored-by: Oscar Beaumont <oscar@otbeaumont.me>
This commit is contained in:
parent
e0146d57f7
commit
5388b59e97
72 changed files with 286 additions and 140 deletions
|
@ -20,6 +20,7 @@ log = "0.4"
|
|||
serde = { version = "1", features = ["derive", "rc"], optional = true }
|
||||
glam = { version = "0.22" }
|
||||
base64 = "0.13"
|
||||
specta.workspace = true
|
||||
|
||||
bytemuck = {version = "1.8" }
|
||||
anyhow = "1.0.66"
|
||||
|
|
|
@ -32,13 +32,13 @@ fn merge_ids(a: u64, b: u64) -> u64 {
|
|||
hasher.finish()
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Default)]
|
||||
#[derive(Clone, Debug, PartialEq, Default, specta::Type)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct DocumentNodeMetadata {
|
||||
pub position: IVec2,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, specta::Type)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct DocumentNode {
|
||||
pub name: String,
|
||||
|
@ -120,7 +120,7 @@ impl DocumentNode {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, specta::Type)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum NodeInput {
|
||||
Node(NodeId),
|
||||
|
@ -156,7 +156,7 @@ impl PartialEq for NodeInput {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, specta::Type)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum DocumentNodeImplementation {
|
||||
Network(NodeNetwork),
|
||||
|
@ -181,7 +181,7 @@ impl DocumentNodeImplementation {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, DynAny)]
|
||||
#[derive(Clone, Debug, Default, PartialEq, DynAny, specta::Type)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct NodeNetwork {
|
||||
pub inputs: Vec<NodeId>,
|
||||
|
|
|
@ -7,7 +7,7 @@ pub use std::sync::Arc;
|
|||
pub use crate::imaginate_input::{ImaginateMaskStartingFill, ImaginateSamplingMethod, ImaginateStatus};
|
||||
|
||||
/// A type that is known, allowing serialization (serde::Deserialize is not object safe)
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, specta::Type)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum TaggedValue {
|
||||
None,
|
||||
|
|
|
@ -2,7 +2,7 @@ use dyn_any::{DynAny, StaticType};
|
|||
use glam::DVec2;
|
||||
use std::fmt::Debug;
|
||||
|
||||
#[derive(Default, Debug, Clone, Copy, PartialEq, DynAny)]
|
||||
#[derive(Default, Debug, Clone, Copy, PartialEq, DynAny, specta::Type)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum ImaginateStatus {
|
||||
#[default]
|
||||
|
@ -14,7 +14,7 @@ pub enum ImaginateStatus {
|
|||
Terminated,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, specta::Type)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct ImaginateBaseImage {
|
||||
pub mime: String,
|
||||
|
@ -23,7 +23,7 @@ pub struct ImaginateBaseImage {
|
|||
pub size: DVec2,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, specta::Type)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct ImaginateMaskImage {
|
||||
pub svg: String,
|
||||
|
@ -31,7 +31,7 @@ pub struct ImaginateMaskImage {
|
|||
}
|
||||
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq)]
|
||||
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, specta::Type)]
|
||||
pub enum ImaginateMaskPaintMode {
|
||||
#[default]
|
||||
Inpaint,
|
||||
|
@ -39,7 +39,7 @@ pub enum ImaginateMaskPaintMode {
|
|||
}
|
||||
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, DynAny)]
|
||||
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, DynAny, specta::Type)]
|
||||
pub enum ImaginateMaskStartingFill {
|
||||
#[default]
|
||||
Fill,
|
||||
|
@ -70,7 +70,7 @@ impl std::fmt::Display for ImaginateMaskStartingFill {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq, DynAny)]
|
||||
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq, DynAny, specta::Type)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum ImaginateSamplingMethod {
|
||||
#[default]
|
||||
|
@ -163,7 +163,7 @@ impl std::fmt::Display for ImaginateSamplingMethod {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, specta::Type)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct ImaginateGenerationParameters {
|
||||
pub seed: u64,
|
||||
|
|
|
@ -17,7 +17,7 @@ macro_rules! generic {
|
|||
};
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, specta::Type)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct NodeIdentifier {
|
||||
pub name: std::borrow::Cow<'static, str>,
|
||||
|
@ -40,7 +40,7 @@ impl NodeIdentifier {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, specta::Type)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub enum Type {
|
||||
Generic(std::borrow::Cow<'static, str>),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue