footprint-explainable-ui 0.25.1 → 0.25.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3520,6 +3520,16 @@ function createDagreTraceLayout(options = {}) {
3520
3520
  return (graph) => dagreTraceLayout(graph, options);
3521
3521
  }
3522
3522
 
3523
+ // src/components/FlowchartView/_internal/devWarn.ts
3524
+ function isDevModeEnv() {
3525
+ const proc = globalThis.process;
3526
+ return proc?.env?.NODE_ENV !== "production";
3527
+ }
3528
+ function devWarn(messageFn, ...extras) {
3529
+ if (!isDevModeEnv()) return;
3530
+ console.warn(messageFn(), ...extras);
3531
+ }
3532
+
3523
3533
  // src/components/FlowchartView/_internal/snapLinearSuccessors.ts
3524
3534
  function snapLinearSuccessors(graph, options = {}) {
3525
3535
  if (graph.nodes.length === 0) return graph;
@@ -3625,30 +3635,34 @@ function centerForkParents(graph, options = {}) {
3625
3635
  (a, b) => b.position.y - a.position.y || a.position.x - b.position.x || a.id.localeCompare(b.id)
3626
3636
  );
3627
3637
  for (const n of order) {
3628
- if ((outDegree.get(n.id) ?? 0) < 2) continue;
3629
- if ((inDegree.get(n.id) ?? 0) > 1) continue;
3630
- const kids = (childrenOf.get(n.id) ?? []).filter(
3638
+ const outD = outDegree.get(n.id) ?? 0;
3639
+ const inD = inDegree.get(n.id) ?? 0;
3640
+ const isFork = outD >= 2 && inD <= 1;
3641
+ const isMerge = inD >= 2 && outD <= 1;
3642
+ if (!isFork && !isMerge) continue;
3643
+ const kin = ((isFork ? childrenOf.get(n.id) : predsOf.get(n.id)) ?? []).filter(
3631
3644
  (k) => byId.get(k)?.parentId === n.parentId
3632
3645
  // same compound only
3633
3646
  );
3634
- if (kids.length < 2) continue;
3635
- const centers = kids.map(centerX);
3647
+ if (kin.length < 2) continue;
3648
+ const centers = kin.map(centerX);
3636
3649
  const wN = width.get(n.id);
3637
3650
  const span = (Math.min(...centers) + Math.max(...centers)) / 2;
3638
3651
  workingX.set(n.id, clampX(n.id, span - wN / 2));
3652
+ const stepOf = isFork ? predsOf : childrenOf;
3639
3653
  let curId = n.id;
3640
3654
  const walked = /* @__PURE__ */ new Set([curId]);
3641
3655
  for (; ; ) {
3642
- const ps = predsOf.get(curId);
3643
- if (!ps || ps.length !== 1) break;
3644
- const p = ps[0];
3645
- if (walked.has(p)) break;
3646
- if ((outDegree.get(p) ?? 0) !== 1) break;
3647
- if ((inDegree.get(p) ?? 0) > 1) break;
3648
- if (byId.get(p)?.parentId !== byId.get(curId)?.parentId) break;
3649
- workingX.set(p, clampX(p, centerX(curId) - width.get(p) / 2));
3650
- walked.add(p);
3651
- curId = p;
3656
+ const nexts = stepOf.get(curId);
3657
+ if (!nexts || nexts.length !== 1) break;
3658
+ const m = nexts[0];
3659
+ if (walked.has(m)) break;
3660
+ if ((outDegree.get(m) ?? 0) > 1) break;
3661
+ if ((inDegree.get(m) ?? 0) > 1) break;
3662
+ if (byId.get(m)?.parentId !== byId.get(curId)?.parentId) break;
3663
+ workingX.set(m, clampX(m, centerX(curId) - width.get(m) / 2));
3664
+ walked.add(m);
3665
+ curId = m;
3652
3666
  }
3653
3667
  }
3654
3668
  const nodes = graph.nodes.map(
@@ -4965,6 +4979,13 @@ function TracedFlow({
4965
4979
  style
4966
4980
  }) {
4967
4981
  const layout = layoutProp ?? dagreTraceLayout;
4982
+ (0, import_react25.useEffect)(() => {
4983
+ if (layoutProp === dagreTraceLayout) {
4984
+ devWarn(
4985
+ () => "[footprint-explainable-ui] <TracedFlow layout={dagreTraceLayout}> bypasses the built-in measure-then-layout pipeline (content-exact sizing, fork/merge centering, straight spines). OMIT the `layout` prop to use it \u2014 passing the raw dagreTraceLayout silently forfeits every layout improvement eui ships."
4986
+ );
4987
+ }
4988
+ }, [layoutProp]);
4968
4989
  const colors = (0, import_react25.useMemo)(
4969
4990
  () => ({ ...DEFAULT_COLORS, ...colorOverrides ?? {} }),
4970
4991
  [colorOverrides]