@tokens-studio/graph-engine
Version:
An execution engine to handle Token Studios generators and resolvers
24 lines • 1.12 kB
JavaScript
import { isSubgraphContainer } from "../programmatic/node.js";
export const getAllOutputs = (node) => {
return Object.fromEntries(Object.entries(node.outputs).map(([key, value]) => [key, value.value]));
};
export function cloneSubgraphs(originalNode, clonedNode) {
if (isSubgraphContainer(originalNode)) {
const container = originalNode;
const graphProperties = container.getGraphProperties();
Object.entries(graphProperties).forEach(([key, graph]) => {
if (graph && typeof graph.clone === 'function') {
const clonedGraph = graph.clone();
// assign the cloned graph to the corresponding property on the cloned node
clonedNode[key] = clonedGraph;
// ensure nodes within the cloned inner graph point back to the cloned graph
Object.values(clonedGraph.nodes).forEach((node) => {
if (typeof node.setGraph === 'function') {
node.setGraph(clonedGraph);
}
});
}
});
}
}
//# sourceMappingURL=node.js.map