Merge no std types into core-types (#4881)

* Merge no-std-types into core-types

* Remove no_std leftovers
This commit is contained in:
Dennis Kobert authored and GitHub committed 2026-11-01 01:27:11 +01:00
1 parent 1570b9d0d1
commit 2e19d9d00f
27 files changed
+56 -139

No files matched your search

Generated
+3 -23
View File
@@ -1279,13 +1279,15 @@ dependencies = [
"futures",
"glam",
"graphene-hash",
"half",
"image",
"kurbo",
"log",
"lyon_geom",
"no-std-types",
"node-macro",
"num-derive",
"num-traits",
"num_enum",
"parley",
"petgraph",
"polycool",
@@ -2540,7 +2542,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37bfe73dc8ec21f54d181e5a60554327ec3f1c600c455a75ccbfc65d2106a6c4"
dependencies = [
"bytemuck",
"libm",
"serde_core",
]
@@ -4635,25 +4636,6 @@ dependencies = [
"libc",
]
[[package]]
name = "no-std-types"
version = "0.0.0"
dependencies = [
"bytemuck",
"core-types",
"dyn-any",
"glam",
"graphene-hash",
"half",
"log",
"num-derive",
"num-traits",
"num_enum",
"serde",
"tsify",
"wasm-bindgen",
]
[[package]]
name = "node-docs"
version = "0.0.0"
@@ -4673,7 +4655,6 @@ dependencies = [
"convert_case 0.12.0",
"core-types",
"indoc",
"no-std-types",
"proc-macro-crate",
"proc-macro-error2",
"proc-macro2",
@@ -5824,7 +5805,6 @@ dependencies = [
"graphene-resource",
"image",
"ndarray",
"no-std-types",
"node-macro",
"num_enum",
"rand",
+2 -4
View File
@@ -89,7 +89,6 @@ graphene-application-io = { path = "node-graph/libraries/application-io" }
graphene-resource = { path = "node-graph/libraries/resources" }
graphene-animation = { path = "node-graph/libraries/animation" }
core-types = { path = "node-graph/libraries/core-types" }
no-std-types = { path = "node-graph/libraries/no-std-types" }
raster-types = { path = "node-graph/libraries/raster-types" }
vector-types = { path = "node-graph/libraries/vector-types" }
graphic-types = { path = "node-graph/libraries/graphic-types" }
@@ -210,7 +209,7 @@ color = "0.3"
rand = { version = "0.9", default-features = false, features = ["std_rng"] }
rand_chacha = "0.9"
glam = { version = "0.33", default-features = false, features = [
"nostd-libm",
"std",
"scalar-math",
"bytemuck",
"debug-glam-assert",
@@ -236,7 +235,7 @@ pretty_assertions = "1.4"
fern = { version = "0.7", features = ["colored"] }
num_enum = { version = "0.7", default-features = false }
num-derive = "0.4"
num-traits = { version = "0.2", default-features = false, features = ["libm"] }
num-traits = "0.2"
tsify = { version = "0.5", default-features = false, features = ["js"] }
syn = { version = "2.0", default-features = false, features = [
"full",
@@ -282,7 +281,6 @@ zip = { version = "8", default-features = false }
opt-level = 1
[profile.dev.package]
no-std-types = { opt-level = 1 }
core-types= { opt-level = 1 }
interpreted-executor = { opt-level = 1 } # This is a mitigation for https://github.com/rustwasm/wasm-pack/issues/981 which is needed because the node_registry function is too large
graphite-proc-macros = { opt-level = 1 }
+5 -4
View File
@@ -16,15 +16,13 @@ workspace = true
[features]
default = ["serde"]
serde = ["dep:serde"]
nightly = []
serde = ["dep:serde", "glam/serde", "half/serde"]
type_id_logging = []
dealloc_nodes = []
wasm = ["tsify", "wasm-bindgen", "no-std-types/wasm"]
wasm = ["tsify", "wasm-bindgen"]
[dependencies]
# Local dependencies
no-std-types = { workspace = true }
graphene-hash = { workspace = true, features = ["derive"] }
# Workspace dependencies
@@ -33,6 +31,9 @@ bitflags = { workspace = true }
bytemuck = { workspace = true }
node-macro = { workspace = true }
num-traits = { workspace = true }
num-derive = { workspace = true }
num_enum = { workspace = true, features = ["std"] }
half = { workspace = true, features = ["std"] }
rand = { workspace = true }
glam = { workspace = true }
serde_json = { workspace = true }
@@ -4,7 +4,8 @@ use num_enum::{FromPrimitive, IntoPrimitive};
#[repr(i32)]
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash, dyn_any::DynAny, serde::Serialize, serde::Deserialize, graphene_hash::CacheHash, FromPrimitive, IntoPrimitive)]
#[derive(dyn_any::DynAny, graphene_hash::CacheHash, Debug, Default, Clone, Copy, Eq, PartialEq, Hash, FromPrimitive, IntoPrimitive)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum BlendMode {
// Basic group
#[default]
@@ -7,7 +7,8 @@ use glam::Vec4;
use half::f16;
#[repr(C)]
#[derive(Default, Clone, Copy, PartialEq, Pod, Zeroable, Debug, dyn_any::DynAny, serde::Serialize, serde::Deserialize)]
#[derive(Default, Clone, Copy, PartialEq, Pod, Zeroable, Debug, dyn_any::DynAny)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct RGBA16F {
red: f16,
green: f16,
@@ -81,7 +82,8 @@ impl Pixel for RGBA16F {}
/// the linear-light [`Color`] type. Convert via [`From<SRGBA8> for Color`] and [`From<Color> for SRGBA8`].
#[repr(C)]
#[cfg_attr(feature = "wasm", derive(tsify::Tsify), tsify(from_wasm_abi))]
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, Pod, Zeroable, dyn_any::DynAny, serde::Serialize, serde::Deserialize, graphene_hash::CacheHash)]
#[derive(dyn_any::DynAny, graphene_hash::CacheHash, Debug, Default, Clone, Copy, PartialEq, Eq, Hash, Pod, Zeroable)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SRGBA8 {
pub red: u8,
pub green: u8,
@@ -202,7 +204,8 @@ impl From<SRGBA8> for Color {
#[repr(C)]
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
#[derive(Debug, Default, Clone, Copy, PartialEq, Pod, Zeroable, dyn_any::DynAny, serde::Serialize, serde::Deserialize)]
#[derive(dyn_any::DynAny, Debug, Default, Clone, Copy, PartialEq, Pod, Zeroable)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Luma(pub f32);
impl Luminance for Luma {
@@ -249,6 +252,7 @@ pub struct Color {
impl Eq for Color {}
// TODO: Eventually remove this document upgrade code
#[cfg(feature = "serde")]
impl serde::Serialize for Color {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
@@ -265,6 +269,7 @@ impl serde::Serialize for Color {
}
// TODO: Eventually remove this document upgrade code
#[cfg(feature = "serde")]
impl<'de> serde::Deserialize<'de> for Color {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
// Documents from before the linear-storage migration lack the `linear` marker and stored gamma-encoded floats; convert them on load.
@@ -1,7 +1,6 @@
use crate::runtime::{Generations, SourceId};
use crate::transform::Footprint;
use glam::DVec2;
pub use no_std_types::context::{ArcCtx, Ctx};
use std::any::Any;
use std::borrow::Borrow;
use std::collections::BTreeSet;
@@ -9,6 +8,15 @@ use std::hash::{Hash, Hasher};
use std::panic::Location;
use std::sync::Arc;
pub trait Ctx: Clone + Send {}
impl<T: Ctx> Ctx for Option<T> {}
impl<T: Ctx + Sync> Ctx for &T {}
impl Ctx for () {}
pub trait ArcCtx: Send + Sync {}
impl<T: ArcCtx> Ctx for Arc<T> {}
// ==============
// EXTRACT TRAITS
// ==============
+12 -4
View File
@@ -1,6 +1,9 @@
extern crate log;
pub mod blending;
pub mod bounds;
pub mod choice_type;
pub mod color;
pub mod consts;
pub mod context;
pub mod generic;
@@ -34,10 +37,6 @@ pub use list::{
ATTR_LETTER_TILT, ATTR_LINE_HEIGHT, ATTR_LOCATION, ATTR_MAX_HEIGHT, ATTR_MAX_WIDTH, ATTR_NAME, ATTR_OPACITY, ATTR_OPACITY_FILL, ATTR_START, ATTR_TEXT_ALIGN, ATTR_TRANSFORM, ATTR_TYPE,
};
pub use memo::MemoHash;
pub use no_std_types::AsU32;
pub use no_std_types::blending;
pub use no_std_types::choice_type;
pub use no_std_types::color;
pub use num_traits;
pub use poll::{Finality, Interrupt, LazyInput, NodeError, Poll, PollInput, Status};
pub use runtime::{Generations, RuntimeHandle, SourceId};
@@ -165,3 +164,12 @@ impl<P: NodeParameter> From<P> for ParameterRef {
}
}
}
pub trait AsU32 {
fn as_u32(&self) -> u32;
}
impl AsU32 for u32 {
fn as_u32(&self) -> u32 {
*self
}
}
+2 -2
View File
@@ -90,8 +90,8 @@ struct LegacyTable<T> {
}
// TODO: Eventually remove this document upgrade code
pub fn migrate_to_color<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Result<no_std_types::color::Color, D::Error> {
use no_std_types::color::Color;
pub fn migrate_to_color<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Result<crate::color::Color, D::Error> {
use crate::color::Color;
use serde::Deserialize;
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
@@ -15,11 +15,9 @@ publish.workspace = true
workspace = true
[features]
default = ["std"]
std = ["dep:kurbo"]
derive = ["graphene-hash-derive"]
[dependencies]
graphene-hash-derive = { path = "derive", optional = true }
glam = { workspace = true }
kurbo = { workspace = true, optional = true }
kurbo = { workspace = true }
@@ -1,8 +1,3 @@
#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(feature = "std")]
extern crate std;
#[cfg(feature = "derive")]
pub use graphene_hash_derive::CacheHash;
@@ -66,7 +61,6 @@ impl_via_hash! {
glam::BVec2, glam::BVec3, glam::BVec4,
}
#[cfg(feature = "std")]
impl_via_hash! {
String,
}
@@ -154,7 +148,6 @@ impl_glam_array! {
}
// kurbo path types: hash each element's verb and point coordinates via to_bits().
#[cfg(feature = "std")]
impl CacheHash for kurbo::Point {
#[inline]
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
@@ -163,7 +156,6 @@ impl CacheHash for kurbo::Point {
}
}
#[cfg(feature = "std")]
impl CacheHash for kurbo::PathEl {
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
core::hash::Hash::hash(&core::mem::discriminant(self), state);
@@ -183,7 +175,6 @@ impl CacheHash for kurbo::PathEl {
}
}
#[cfg(feature = "std")]
impl CacheHash for kurbo::BezPath {
#[inline]
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
@@ -224,7 +215,6 @@ impl<T: CacheHash, const N: usize> CacheHash for [T; N] {
}
}
#[cfg(feature = "std")]
impl<T: CacheHash> CacheHash for Vec<T> {
#[inline]
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
@@ -232,7 +222,6 @@ impl<T: CacheHash> CacheHash for Vec<T> {
}
}
#[cfg(feature = "std")]
impl<T: CacheHash> CacheHash for std::collections::BTreeSet<T> {
#[inline]
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
@@ -243,7 +232,6 @@ impl<T: CacheHash> CacheHash for std::collections::BTreeSet<T> {
}
}
#[cfg(feature = "std")]
impl<T: CacheHash + ?Sized> CacheHash for Box<T> {
#[inline]
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
@@ -251,7 +239,6 @@ impl<T: CacheHash + ?Sized> CacheHash for Box<T> {
}
}
#[cfg(feature = "std")]
impl<T: CacheHash + ?Sized> CacheHash for std::sync::Arc<T> {
#[inline]
fn cache_hash<H: core::hash::Hasher>(&self, state: &mut H) {
@@ -1,40 +0,0 @@
[package]
name = "no-std-types"
description = "Color, blending, and context types for Graphene"
version.workspace = true
license.workspace = true
authors.workspace = true
edition.workspace = true
repository.workspace = true
readme.workspace = true
homepage.workspace = true
rust-version.workspace = true
publish.workspace = true
[features]
wasm = ["tsify", "wasm-bindgen"]
[dependencies]
# Local dependencies
dyn-any = { workspace = true }
graphene-hash = { workspace = true }
# Workspace dependencies
bytemuck = { workspace = true }
glam = { workspace = true, features = ["debug-glam-assert", "std", "serde"] }
half = { workspace = true, features = ["std", "serde"] }
num-derive = { workspace = true }
num-traits = { workspace = true, features = ["std"] }
num_enum = { workspace = true, features = ["std"] }
serde = { workspace = true }
log = { workspace = true }
# Workspace wasm dependencies
tsify = { workspace = true, optional = true }
wasm-bindgen = { workspace = true, optional = true }
[dev-dependencies]
core-types = { workspace = true }
[package.metadata.cargo-shear]
ignored = ["core-types"]
@@ -1,8 +0,0 @@
pub trait Ctx: Clone + Send {}
impl<T: Ctx> Ctx for Option<T> {}
impl<T: Ctx + Sync> Ctx for &T {}
impl Ctx for () {}
pub trait ArcCtx: Send + Sync {}
impl<T: ArcCtx> Ctx for std::sync::Arc<T> {}
@@ -1,16 +0,0 @@
pub mod blending;
pub mod choice_type;
pub mod color;
pub mod context;
pub use context::Ctx;
pub use glam;
pub trait AsU32 {
fn as_u32(&self) -> u32;
}
impl AsU32 for u32 {
fn as_u32(&self) -> u32 {
*self
}
}
+1 -1
View File
@@ -5,7 +5,7 @@ pub mod raster_types;
pub use image::{Image, ImageError};
pub use raster_types::*;
// Re-export color types from no-std-types
// Re-export color types from core-types
pub use core_types::color::*;
/// as to not yet rename all references
-1
View File
@@ -29,4 +29,3 @@ proc-macro-error2 = "2"
[dev-dependencies]
core-types = { workspace = true }
no-std-types = { workspace = true }
@@ -110,12 +110,8 @@ fn derive_enum(enum_attributes: &[Attribute], name: Ident, input: syn::DataEnum)
.collect();
let crate_name = {
let crate_name = proc_macro_crate::crate_name("no-std-types").or_else(|_e| proc_macro_crate::crate_name("core-types")).map_err(|e| {
syn::Error::new(
Span::call_site(),
format!("Failed to find location of 'no-std-types' or 'core-types'. Make sure it is imported as a dependency: {e}"),
)
})?;
let crate_name = proc_macro_crate::crate_name("core-types")
.map_err(|e| syn::Error::new(Span::call_site(), format!("Failed to find location of 'core-types'. Make sure it is imported as a dependency: {e}")))?;
match crate_name {
proc_macro_crate::FoundCrate::Itself => quote!(crate),
proc_macro_crate::FoundCrate::Name(name) => {
-1
View File
@@ -27,7 +27,6 @@ wasm = [
[dependencies]
# Local dependencies
no-std-types = { workspace = true }
node-macro = { workspace = true }
dyn-any = { workspace = true }
core-types = { workspace = true }
+1 -1
View File
@@ -1,4 +1,4 @@
use no_std_types::color::Color;
use core_types::color::Color;
use raster_types::{CPU, Raster};
use vector_types::Gradient;
+3 -2
View File
@@ -3,13 +3,14 @@
use crate::adjust::Adjust;
use crate::color_lookup_table::{LutCache, LutParseError};
use core::fmt::Debug;
use core_types::color::Color;
use core_types::color::{linear_to_srgb, set_luminosity, srgb_to_linear};
use core_types::context::Ctx;
use core_types::list::{Item, List};
use core_types::transfer_curve::{TransferCurve, TransferCurveEvaluator};
use glam::DVec2;
use glam::Vec3;
use graphene_resource::Resource;
use no_std_types::color::{Color, linear_to_srgb, set_luminosity, srgb_to_linear};
use no_std_types::context::Ctx;
use num_enum::{FromPrimitive, IntoPrimitive};
use raster_types::{CPU, Image, Raster};
use vector_types::Gradient;
@@ -1,12 +1,12 @@
use crate::adjust::Adjust;
use core_types::Ctx;
use core_types::blending::BlendMode;
use core_types::color::Color;
use core_types::list::Item;
use no_std_types::Ctx;
use no_std_types::blending::BlendMode;
use no_std_types::color::Color;
use raster_types::{CPU, Raster};
use vector_types::Gradient;
pub use no_std_types::blending::{apply_blend_mode, blend_colors};
pub use core_types::blending::{apply_blend_mode, blend_colors};
/// Mixes the over color onto the under color by a blend mode and opacity, as if they were stacked layers.
#[node_macro::node(category("Color"), icon("NodeMixColors"), version(2))]
@@ -7,8 +7,8 @@ mod format_icc;
mod format_look;
use crate::adjustments::{SRGB_TO_XYZ_D50, WHITE_XYZ_D50, XYZ_D50_TO_SRGB, multiply_matrix};
use core_types::color::{linear_to_srgb, srgb_to_linear};
use graphene_resource::{Resource, ResourceHash};
use no_std_types::color::{linear_to_srgb, srgb_to_linear};
use std::sync::{Arc, Mutex, PoisonError};
pub const LUT_FILE_EXTENSIONS: &[&str] = &["cube", "3dl", "look", "csp", "icc", "icm"];