Merging dev into main #49

Merged
8464960 merged 260 commits from dev into main 2026-01-28 10:48:52 +00:00
Showing only changes of commit fe8e04d305 - Show all commits

View File

@@ -167,32 +167,29 @@ export function orderPhases(nodes: AppNode[],edges: Edge[]) : OrderedPhases {
) : OrderedPhases => {
// get the current phase and the next phases;
const currentPhase = phases[currentIndex];
const nextPhaseNodes = getOutgoers(currentPhase,phaseNodes,edges);
const nextNodes = getOutgoers(currentPhase,nodes, edges);
const nextPhaseNodes = getOutgoers(currentPhase, phaseNodes, edges);
const nextNodes = getOutgoers(currentPhase, nodes, edges);
// handles adding of the next phase to the chain, and error handle if an invalid state is received
if (nextPhaseNodes.length === 1 && nextNodes.length === 1) {
connections.set(currentPhase.id, nextPhaseNodes[0].id);
return nextPhase(phases.push(nextPhaseNodes[0] as PhaseNode) - 1, {phaseNodes: phases, connections: connections});
} else {
// handle erroneous states
if (nextNodes.length === 0){
throw new Error(`| INVALID PROGRAM | the source handle of "${currentPhase.id}" doesn't have any outgoing connections`);
} else {
if (nextNodes.length > 1) {
throw new Error(`| INVALID PROGRAM | the source handle of "${currentPhase.id}" connects to too many targets`);
} else {
if (nextNodes[0].type === "end"){
connections.set(currentPhase.id, "end");
// returns the final output of the function
return { phaseNodes: phases, connections: connections};
} else {
throw new Error(`| INVALID PROGRAM | the node "${nextNodes[0].id}" that "${currentPhase.id}" connects to is not a phase or end node`);
}
}
}
}
// handle erroneous states
if (nextNodes.length === 0) {
throw new Error(`| INVALID PROGRAM | the source handle of "${currentPhase.id}" doesn't have any outgoing connections`);
}
if (nextNodes.length > 1) {
throw new Error(`| INVALID PROGRAM | the source handle of "${currentPhase.id}" connects to too many targets`);
}
if (nextNodes[0].type === "end") {
connections.set(currentPhase.id, "end");
// returns the final output of the function
return {phaseNodes: phases, connections: connections};
}
throw new Error(`| INVALID PROGRAM | the node "${nextNodes[0].id}" that "${currentPhase.id}" connects to is not a phase or end node`);
}
// initializes the Map describing the connections between phase nodes
// we need this Map to make sure we preserve this information,
// so we don't need to do checks on the entire set of edges in further stages of the reduction algorithm