graflow: source grooming + demo panels subflow compatible

This commit is contained in:
STEINNI
2026-02-28 11:14:04 +00:00
parent 6133a16076
commit 59a377ddad

View File

@@ -288,7 +288,7 @@ class BZgraflow extends Buildoz{
childEl.style.transform = 'none' childEl.style.transform = 'none'
childEl.style.willChange = '' childEl.style.willChange = ''
this.dispatchEvent(new CustomEvent('subflowLoaded', { this.dispatchEvent(new CustomEvent('subflowLoaded', {
detail: { flowUrl }, detail: { subflow: childEl },
bubbles: true, bubbles: true,
composed: true, composed: true,
})) }))
@@ -366,7 +366,7 @@ class BZgraflow extends Buildoz{
this.hostContainer.style.visibility = 'visible' this.hostContainer.style.visibility = 'visible'
childEl.style.willChange = '' childEl.style.willChange = ''
this.dispatchEvent(new CustomEvent('subflowExited', { this.dispatchEvent(new CustomEvent('subflowExited', {
detail: { }, detail: { subflow: childEl },
bubbles: true, bubbles: true,
composed: true, composed: true,
})) }))
@@ -611,11 +611,14 @@ class BZgraflow extends Buildoz{
// Compute indexes for each layer (int part) & add sub-index for ports // Compute indexes for each layer (int part) & add sub-index for ports
// Also compute max width/height for each layer // Also compute max width/height for each layer
let maxHeight = 0; let maxWidth = 0 let maxHeight = 0
const layerHeights = []; const layerWidths = []; let maxWidth = 0
const layerHeights = []
const layerWidths = []
const indexes = {} // indexes[nid] = { base: <int>, ports: { [portId]: <float in [0,1)> } } const indexes = {} // indexes[nid] = { base: <int>, ports: { [portId]: <float in [0,1)> } }
for(const layer of layers){ for(const layer of layers){
let totHeight = 0; let totWidth = 0 let totHeight = 0
let totWidth = 0
for(const [idx, nid] of layer.entries()){ for(const [idx, nid] of layer.entries()){
// Use offset* (not impacted by CSS transforms) to keep autoPlace stable during zoom animations. // Use offset* (not impacted by CSS transforms) to keep autoPlace stable during zoom animations.
const bb = this.stagedNodes[nid].getBoundingClientRect() const bb = this.stagedNodes[nid].getBoundingClientRect()
@@ -910,9 +913,9 @@ class BZgraflow extends Buildoz{
computeLayers(nodes, parents) { computeLayers(nodes, parents) {
const layer = {} const layer = {}
const dfs = (id) => { 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 layer[id] = 0
} else { } else {
layer[id] = 1 + Math.max(...parents[id].map(dfs)) 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 if(links.some(l => l.from[0] === l.to[0])) return(true) // self-loops
const { adj } = this.buildGraphStructures(nodes, links) const { adj } = this.buildGraphStructures(nodes, links)
const visiting = new Set(); const visiting = new Set()
const visited = new Set() const visited = new Set()
const dfs = (nid) => { const dfs = (nid) => {
if(visiting.has(nid)) { if(visiting.has(nid)) {
@@ -961,7 +964,8 @@ class BZgraflow extends Buildoz{
findBackEdges(nodes, links) { findBackEdges(nodes, links) {
const { adj } = this.buildGraphStructures(nodes, links, true) 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 = [] const backEdges = []
function dfs(u) { function dfs(u) {
@@ -969,9 +973,9 @@ class BZgraflow extends Buildoz{
for (const neighbor of adj[u]) { for (const neighbor of adj[u]) {
const v = neighbor.to const v = neighbor.to
const linkIdx = neighbor.linkIdx const linkIdx = neighbor.linkIdx
if (color[v] === 'gray') { if(color[v] === 'gray') {
backEdges.push(linkIdx) // 👈 cycle edge - return link index backEdges.push(linkIdx) // 👈 cycle edge - return link index
} else if (color[v] === 'white') { } else if(color[v] === 'white') {
dfs(v) dfs(v)
} }
} }
@@ -979,7 +983,7 @@ class BZgraflow extends Buildoz{
} }
nodes.forEach(n => { nodes.forEach(n => {
if (color[n.id] === 'white') dfs(n.id) if(color[n.id] === 'white') dfs(n.id)
}) })
return(backEdges) return(backEdges)