Improve node macro and add more diagnostics (#1999)

* Improve node macro ergonomics

* Fix type error in stub import

* Fix wasm nodes

* Code review

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Dennis Kobert
2024-09-21 21:57:45 +02:00
committed by GitHub
parent 3eb98c6d6d
commit cd4124a596
15 changed files with 358 additions and 122 deletions

View File

@@ -234,8 +234,8 @@ impl ArtboardGroup {
#[node_macro::node(category(""))]
async fn layer<F: 'n + Copy + Send>(
#[implementations((), Footprint)] footprint: F,
#[implementations(((), GraphicGroup), (Footprint, GraphicGroup))] stack: impl Node<F, Output = GraphicGroup>,
#[implementations(((), GraphicElement), (Footprint, GraphicElement))] graphic_element: impl Node<F, Output = GraphicElement>,
#[implementations(() -> GraphicGroup, Footprint -> GraphicGroup)] stack: impl Node<F, Output = GraphicGroup>,
#[implementations(() -> GraphicElement, Footprint -> GraphicElement)] graphic_element: impl Node<F, Output = GraphicElement>,
node_path: Vec<NodeId>,
) -> GraphicGroup {
let mut element = graphic_element.eval(footprint).await;
@@ -257,15 +257,15 @@ async fn layer<F: 'n + Copy + Send>(
async fn to_element<F: 'n + Send, Data: Into<GraphicElement> + 'n>(
#[implementations((), (), (), (), Footprint)] footprint: F,
#[implementations(
((), VectorData),
((), ImageFrame<Color>),
((), GraphicGroup),
((), TextureFrame),
(Footprint, VectorData),
(Footprint, ImageFrame<Color>),
(Footprint, GraphicGroup),
(Footprint, TextureFrame),
)]
() -> VectorData,
() -> ImageFrame<Color>,
() -> GraphicGroup,
() -> TextureFrame,
Footprint -> VectorData,
Footprint -> ImageFrame<Color>,
Footprint -> GraphicGroup,
Footprint -> TextureFrame,
)]
data: impl Node<F, Output = Data>,
) -> GraphicElement {
data.eval(footprint).await.into()
@@ -275,14 +275,14 @@ async fn to_element<F: 'n + Send, Data: Into<GraphicElement> + 'n>(
async fn to_group<F: 'n + Send, Data: Into<GraphicGroup> + 'n>(
#[implementations((), (), (), (), Footprint)] footprint: F,
#[implementations(
((), VectorData),
((), ImageFrame<Color>),
((), GraphicGroup),
((), TextureFrame),
(Footprint, VectorData),
(Footprint, ImageFrame<Color>),
(Footprint, GraphicGroup),
(Footprint, TextureFrame),
() -> VectorData,
() -> ImageFrame<Color>,
() -> GraphicGroup,
() -> TextureFrame,
Footprint -> VectorData,
Footprint -> ImageFrame<Color>,
Footprint -> GraphicGroup,
Footprint -> TextureFrame,
)]
element: impl Node<F, Output = Data>,
) -> GraphicGroup {
@@ -292,7 +292,7 @@ async fn to_group<F: 'n + Send, Data: Into<GraphicGroup> + 'n>(
#[node_macro::node(category(""))]
async fn to_artboard<F: 'n + Copy + Send + ApplyTransform>(
#[implementations((), Footprint)] mut footprint: F,
#[implementations(((), GraphicGroup), (Footprint, GraphicGroup))] contents: impl Node<F, Output = GraphicGroup>,
#[implementations(() -> GraphicGroup, Footprint -> GraphicGroup)] contents: impl Node<F, Output = GraphicGroup>,
label: String,
location: IVec2,
dimensions: IVec2,
@@ -314,8 +314,8 @@ async fn to_artboard<F: 'n + Copy + Send + ApplyTransform>(
#[node_macro::node(category(""))]
async fn append_artboard<F: 'n + Copy + Send>(
#[implementations((), Footprint)] footprint: F,
#[implementations(((), ArtboardGroup), (Footprint, ArtboardGroup))] artboards: impl Node<F, Output = ArtboardGroup>,
#[implementations(((), Artboard), (Footprint, Artboard))] artboard: impl Node<F, Output = Artboard>,
#[implementations(() -> ArtboardGroup, Footprint -> ArtboardGroup)] artboards: impl Node<F, Output = ArtboardGroup>,
#[implementations(() -> Artboard, Footprint -> Artboard)] artboard: impl Node<F, Output = Artboard>,
node_path: Vec<NodeId>,
) -> ArtboardGroup {
let artboard = artboard.eval(footprint).await;