refactor(canvas): integrate graph-based handling for image source resolution and pipeline steps

This commit is contained in:
2026-04-04 10:28:20 +02:00
parent 90d6fe55b1
commit 12cd75c836
11 changed files with 477 additions and 218 deletions

View File

@@ -0,0 +1,37 @@
"use client";
import { createContext, useContext, useMemo, type ReactNode } from "react";
import {
buildGraphSnapshot,
type CanvasGraphEdgeLike,
type CanvasGraphNodeLike,
type CanvasGraphSnapshot,
} from "@/lib/canvas-render-preview";
type CanvasGraphContextValue = CanvasGraphSnapshot;
const CanvasGraphContext = createContext<CanvasGraphContextValue | null>(null);
export function CanvasGraphProvider({
nodes,
edges,
children,
}: {
nodes: readonly CanvasGraphNodeLike[];
edges: readonly CanvasGraphEdgeLike[];
children: ReactNode;
}) {
const value = useMemo(() => buildGraphSnapshot(nodes, edges), [edges, nodes]);
return <CanvasGraphContext.Provider value={value}>{children}</CanvasGraphContext.Provider>;
}
export function useCanvasGraph(): CanvasGraphContextValue {
const context = useContext(CanvasGraphContext);
if (!context) {
throw new Error("useCanvasGraph must be used within CanvasGraphProvider");
}
return context;
}