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.
@@ -1955,6 +1955,16 @@ function TraceFlow(props) {
1955
1955
  var import_react18 = require("react");
1956
1956
  var import_react19 = require("@xyflow/react");
1957
1957
 
1958
+ // src/components/FlowchartView/_internal/devWarn.ts
1959
+ function isDevModeEnv() {
1960
+ const proc = globalThis.process;
1961
+ return proc?.env?.NODE_ENV !== "production";
1962
+ }
1963
+ function devWarn(messageFn, ...extras) {
1964
+ if (!isDevModeEnv()) return;
1965
+ console.warn(messageFn(), ...extras);
1966
+ }
1967
+
1958
1968
  // src/components/FlowchartView/_internal/snapLinearSuccessors.ts
1959
1969
  function snapLinearSuccessors(graph, options = {}) {
1960
1970
  if (graph.nodes.length === 0) return graph;
@@ -2060,30 +2070,34 @@ function centerForkParents(graph, options = {}) {
2060
2070
  (a, b) => b.position.y - a.position.y || a.position.x - b.position.x || a.id.localeCompare(b.id)
2061
2071
  );
2062
2072
  for (const n of order) {
2063
- if ((outDegree.get(n.id) ?? 0) < 2) continue;
2064
- if ((inDegree.get(n.id) ?? 0) > 1) continue;
2065
- const kids = (childrenOf.get(n.id) ?? []).filter(
2073
+ const outD = outDegree.get(n.id) ?? 0;
2074
+ const inD = inDegree.get(n.id) ?? 0;
2075
+ const isFork = outD >= 2 && inD <= 1;
2076
+ const isMerge = inD >= 2 && outD <= 1;
2077
+ if (!isFork && !isMerge) continue;
2078
+ const kin = ((isFork ? childrenOf.get(n.id) : predsOf.get(n.id)) ?? []).filter(
2066
2079
  (k) => byId.get(k)?.parentId === n.parentId
2067
2080
  // same compound only
2068
2081
  );
2069
- if (kids.length < 2) continue;
2070
- const centers = kids.map(centerX);
2082
+ if (kin.length < 2) continue;
2083
+ const centers = kin.map(centerX);
2071
2084
  const wN = width.get(n.id);
2072
2085
  const span = (Math.min(...centers) + Math.max(...centers)) / 2;
2073
2086
  workingX.set(n.id, clampX(n.id, span - wN / 2));
2087
+ const stepOf = isFork ? predsOf : childrenOf;
2074
2088
  let curId = n.id;
2075
2089
  const walked = /* @__PURE__ */ new Set([curId]);
2076
2090
  for (; ; ) {
2077
- const ps = predsOf.get(curId);
2078
- if (!ps || ps.length !== 1) break;
2079
- const p = ps[0];
2080
- if (walked.has(p)) break;
2081
- if ((outDegree.get(p) ?? 0) !== 1) break;
2082
- if ((inDegree.get(p) ?? 0) > 1) break;
2083
- if (byId.get(p)?.parentId !== byId.get(curId)?.parentId) break;
2084
- workingX.set(p, clampX(p, centerX(curId) - width.get(p) / 2));
2085
- walked.add(p);
2086
- curId = p;
2091
+ const nexts = stepOf.get(curId);
2092
+ if (!nexts || nexts.length !== 1) break;
2093
+ const m = nexts[0];
2094
+ if (walked.has(m)) break;
2095
+ if ((outDegree.get(m) ?? 0) > 1) break;
2096
+ if ((inDegree.get(m) ?? 0) > 1) break;
2097
+ if (byId.get(m)?.parentId !== byId.get(curId)?.parentId) break;
2098
+ workingX.set(m, clampX(m, centerX(curId) - width.get(m) / 2));
2099
+ walked.add(m);
2100
+ curId = m;
2087
2101
  }
2088
2102
  }
2089
2103
  const nodes = graph.nodes.map(
@@ -2095,16 +2109,6 @@ function withForkCentering(base, options = {}) {
2095
2109
  return (graph) => centerForkParents(base(graph), options);
2096
2110
  }
2097
2111
 
2098
- // src/components/FlowchartView/_internal/devWarn.ts
2099
- function isDevModeEnv() {
2100
- const proc = globalThis.process;
2101
- return proc?.env?.NODE_ENV !== "production";
2102
- }
2103
- function devWarn(messageFn, ...extras) {
2104
- if (!isDevModeEnv()) return;
2105
- console.warn(messageFn(), ...extras);
2106
- }
2107
-
2108
2112
  // src/components/FlowchartView/_internal/notifyChange.ts
2109
2113
  function createNotifier(label = "notifier") {
2110
2114
  const listeners = /* @__PURE__ */ new Set();
@@ -2644,6 +2648,13 @@ function TracedFlow({
2644
2648
  style
2645
2649
  }) {
2646
2650
  const layout = layoutProp ?? dagreTraceLayout;
2651
+ (0, import_react18.useEffect)(() => {
2652
+ if (layoutProp === dagreTraceLayout) {
2653
+ devWarn(
2654
+ () => "[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."
2655
+ );
2656
+ }
2657
+ }, [layoutProp]);
2647
2658
  const colors = (0, import_react18.useMemo)(
2648
2659
  () => ({ ...DEFAULT_COLORS, ...colorOverrides ?? {} }),
2649
2660
  [colorOverrides]