From 59a377ddad1e72dfad1c8b1c738f17c5ef7cf7c8 Mon Sep 17 00:00:00 2001 From: STEINNI Date: Sat, 28 Feb 2026 11:14:04 +0000 Subject: [PATCH] graflow: source grooming + demo panels subflow compatible --- bzGraflow.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/bzGraflow.js b/bzGraflow.js index 999da3a..3c06e67 100644 --- a/bzGraflow.js +++ b/bzGraflow.js @@ -288,7 +288,7 @@ class BZgraflow extends Buildoz{ childEl.style.transform = 'none' childEl.style.willChange = '' this.dispatchEvent(new CustomEvent('subflowLoaded', { - detail: { flowUrl }, + detail: { subflow: childEl }, bubbles: true, composed: true, })) @@ -366,7 +366,7 @@ class BZgraflow extends Buildoz{ this.hostContainer.style.visibility = 'visible' childEl.style.willChange = '' this.dispatchEvent(new CustomEvent('subflowExited', { - detail: { }, + detail: { subflow: childEl }, bubbles: true, composed: true, })) @@ -611,11 +611,14 @@ class BZgraflow extends Buildoz{ // Compute indexes for each layer (int part) & add sub-index for ports // Also compute max width/height for each layer - let maxHeight = 0; let maxWidth = 0 - const layerHeights = []; const layerWidths = []; + let maxHeight = 0 + let maxWidth = 0 + const layerHeights = [] + const layerWidths = [] const indexes = {} // indexes[nid] = { base: , ports: { [portId]: } } for(const layer of layers){ - let totHeight = 0; let totWidth = 0 + let totHeight = 0 + let totWidth = 0 for(const [idx, nid] of layer.entries()){ // Use offset* (not impacted by CSS transforms) to keep autoPlace stable during zoom animations. const bb = this.stagedNodes[nid].getBoundingClientRect() @@ -910,9 +913,9 @@ class BZgraflow extends Buildoz{ computeLayers(nodes, parents) { const layer = {} const dfs = (id) => { - if (layer[id] !== undefined) return(layer[id]) + if(layer[id] !== undefined) return(layer[id]) - if (parents[id].length === 0) { + if(parents[id].length === 0) { layer[id] = 0 } else { layer[id] = 1 + Math.max(...parents[id].map(dfs)) @@ -938,7 +941,7 @@ class BZgraflow extends Buildoz{ if(links.some(l => l.from[0] === l.to[0])) return(true) // self-loops const { adj } = this.buildGraphStructures(nodes, links) - const visiting = new Set(); + const visiting = new Set() const visited = new Set() const dfs = (nid) => { if(visiting.has(nid)) { @@ -961,7 +964,8 @@ class BZgraflow extends Buildoz{ findBackEdges(nodes, links) { const { adj } = this.buildGraphStructures(nodes, links, true) - const color = {}; nodes.forEach(n => color[n.id] = 'white') + const color = {} + nodes.forEach(n => color[n.id] = 'white') const backEdges = [] function dfs(u) { @@ -969,9 +973,9 @@ class BZgraflow extends Buildoz{ for (const neighbor of adj[u]) { const v = neighbor.to const linkIdx = neighbor.linkIdx - if (color[v] === 'gray') { + if(color[v] === 'gray') { backEdges.push(linkIdx) // 👈 cycle edge - return link index - } else if (color[v] === 'white') { + } else if(color[v] === 'white') { dfs(v) } } @@ -979,7 +983,7 @@ class BZgraflow extends Buildoz{ } nodes.forEach(n => { - if (color[n.id] === 'white') dfs(n.id) + if(color[n.id] === 'white') dfs(n.id) }) return(backEdges)