@diagrammo/dgmo 0.91.0 → 0.91.1

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/advanced.js CHANGED
@@ -349,7 +349,7 @@ import {
349
349
  renderSlopeChart,
350
350
  renderVenn,
351
351
  renderWordCloud
352
- } from "./chunk-3LINSNJT.js";
352
+ } from "./chunk-KA5CSR44.js";
353
353
  import {
354
354
  layoutBracket
355
355
  } from "./chunk-ABP5BUD6.js";
@@ -415,7 +415,7 @@ import "./chunk-BDXC7MDK.js";
415
415
  import {
416
416
  renderLegendSvg,
417
417
  renderLegendSvgFromConfig
418
- } from "./chunk-KFXY5IW2.js";
418
+ } from "./chunk-27KA4VV6.js";
419
419
  import "./chunk-KMU65FYM.js";
420
420
  import "./chunk-EPDBWATV.js";
421
421
  import {
package/dist/block.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-D3K4U3ZM.js";
5
5
  import {
6
6
  render
7
- } from "./chunk-3LINSNJT.js";
7
+ } from "./chunk-KA5CSR44.js";
8
8
  import "./chunk-ABP5BUD6.js";
9
9
  import {
10
10
  docsLink,
@@ -26,7 +26,7 @@ import "./chunk-A2RUBBVT.js";
26
26
  import "./chunk-3YTAOMMN.js";
27
27
  import "./chunk-IUBCDNT2.js";
28
28
  import "./chunk-BDXC7MDK.js";
29
- import "./chunk-KFXY5IW2.js";
29
+ import "./chunk-27KA4VV6.js";
30
30
  import "./chunk-KMU65FYM.js";
31
31
  import "./chunk-EPDBWATV.js";
32
32
  import "./chunk-HFG7KQOY.js";
@@ -2,7 +2,7 @@ import {
2
2
  D3_DATA_CHART_TYPES,
3
3
  renderDataChartD3,
4
4
  supportsD3DataChart
5
- } from "./chunk-KFXY5IW2.js";
5
+ } from "./chunk-27KA4VV6.js";
6
6
  import "./chunk-KMU65FYM.js";
7
7
  import "./chunk-EPDBWATV.js";
8
8
  import "./chunk-HFG7KQOY.js";
@@ -1600,6 +1600,35 @@ function renderSankey(svg, chart, width, height, colors, bgColor, textColor, top
1600
1600
  const maxRank = Math.max(...[...node.values()].map((n) => n.rank));
1601
1601
  const layers = Array.from({ length: maxRank + 1 }, () => []);
1602
1602
  for (const n of node.values()) layers[n.rank].push(n);
1603
+ const segs = [];
1604
+ const chains = /* @__PURE__ */ new Map();
1605
+ for (const l of forwardLinks) {
1606
+ const t = node.get(l.target);
1607
+ let prev = node.get(l.source);
1608
+ const chain = [];
1609
+ for (let r = prev.rank + 1; r <= t.rank; r++) {
1610
+ let next = t;
1611
+ if (r < t.rank) {
1612
+ next = {
1613
+ name: `${l.source}\u241F${l.target}\u241F${r}`,
1614
+ rank: r,
1615
+ value: l.value,
1616
+ order: prev.order,
1617
+ x: 0,
1618
+ y: 0,
1619
+ h: 0,
1620
+ raw: prev.raw,
1621
+ virtual: true
1622
+ };
1623
+ layers[r].push(next);
1624
+ }
1625
+ const seg = { s: prev, t: next, value: l.value, sy: 0, ty: 0 };
1626
+ chain.push(seg);
1627
+ segs.push(seg);
1628
+ prev = next;
1629
+ }
1630
+ chains.set(l, chain);
1631
+ }
1603
1632
  let plotLeft = 16;
1604
1633
  const top = topInset + 8;
1605
1634
  const rightPad = 16;
@@ -1657,7 +1686,7 @@ function renderSankey(svg, chart, width, height, colors, bgColor, textColor, top
1657
1686
  const order = forward ? [...layers.keys()] : [...layers.keys()].reverse();
1658
1687
  for (const r of order) {
1659
1688
  for (const n of layers[r]) {
1660
- const neigh = forward ? forwardLinks.filter((l) => l.target === n.name).map((l) => node.get(l.source)) : forwardLinks.filter((l) => l.source === n.name).map((l) => node.get(l.target));
1689
+ const neigh = forward ? segs.filter((g) => g.t === n).map((g) => g.s) : segs.filter((g) => g.s === n).map((g) => g.t);
1661
1690
  n.order = neigh.length ? neigh.reduce((a, m) => a + center(m), 0) / neigh.length : center(n);
1662
1691
  }
1663
1692
  placeLayer(layers[r]);
@@ -1665,9 +1694,23 @@ function renderSankey(svg, chart, width, height, colors, bgColor, textColor, top
1665
1694
  }
1666
1695
  const outOff = /* @__PURE__ */ new Map();
1667
1696
  const inOff = /* @__PURE__ */ new Map();
1668
- for (const n of node.values()) {
1669
- outOff.set(n.name, n.y);
1670
- inOff.set(n.name, n.y);
1697
+ for (const layer of layers) {
1698
+ for (const n of layer) {
1699
+ outOff.set(n, n.y);
1700
+ inOff.set(n, n.y);
1701
+ }
1702
+ }
1703
+ const slot = (n, th, off) => {
1704
+ const y = off.get(n);
1705
+ off.set(n, y + th);
1706
+ return y;
1707
+ };
1708
+ for (const g of [...segs].sort(
1709
+ (a, b) => a.s.y !== b.s.y ? a.s.y - b.s.y : a.t.y - b.t.y
1710
+ )) {
1711
+ const th = g.value * valueScale;
1712
+ g.sy = slot(g.s, th, outOff);
1713
+ g.ty = slot(g.t, th, inOff);
1671
1714
  }
1672
1715
  const ordered = [
1673
1716
  ...[...forwardLinks].sort((a, b) => {
@@ -1683,18 +1726,15 @@ function renderSankey(svg, chart, width, height, colors, bgColor, textColor, top
1683
1726
  const s = node.get(l.source);
1684
1727
  const t = node.get(l.target);
1685
1728
  const th = l.value * valueScale;
1686
- const sy = outOff.get(s.name);
1687
- const ty = inOff.get(t.name);
1688
- outOff.set(s.name, sy + th);
1689
- inOff.set(t.name, ty + th);
1690
1729
  const sx = s.x + NODE_W;
1691
1730
  const tx = t.x;
1692
- const cx0 = sx + (tx - sx) * 0.5;
1693
1731
  const raw = l.color ?? s.raw;
1694
1732
  const color = solid ? raw : mix(raw, bgColor, 45);
1695
1733
  const opacity = linkDimmed(l) ? RIBBON_FILL_OPACITY * EMPHASIS_DIM_OPACITY : RIBBON_FILL_OPACITY;
1696
1734
  let ribbon;
1697
1735
  if (backEdges.has(l)) {
1736
+ const sy = slot(s, th, outOff);
1737
+ const ty = slot(t, th, inOff);
1698
1738
  const lane = laneY + th / 2;
1699
1739
  laneY += th + LOOP_GAP;
1700
1740
  const k = th;
@@ -1705,10 +1745,20 @@ function renderSankey(svg, chart, width, height, colors, bgColor, textColor, top
1705
1745
  `M${sx},${y1} C${sx + k},${y1} ${sx + k},${lane} ${sx},${lane} L${tx},${lane} C${tx - k},${lane} ${tx - k},${y2} ${tx},${y2}`
1706
1746
  ).attr("fill", "none").attr("stroke", color).attr("stroke-width", th).attr("stroke-opacity", opacity);
1707
1747
  } else {
1708
- ribbon = svg.append("path").attr(
1709
- "d",
1710
- `M${sx},${sy} C${cx0},${sy} ${cx0},${ty} ${tx},${ty} L${tx},${ty + th} C${cx0},${ty + th} ${cx0},${sy + th} ${sx},${sy + th} Z`
1711
- ).attr("fill", color).attr("fill-opacity", opacity);
1748
+ const chain = chains.get(l);
1749
+ const top2 = [];
1750
+ const bottom = [];
1751
+ chain.forEach((g, i) => {
1752
+ const gx = g.s.x + NODE_W;
1753
+ const cx = (gx + g.t.x) / 2;
1754
+ top2.push(
1755
+ `${i === 0 ? "M" : "L"}${gx},${g.sy} C${cx},${g.sy} ${cx},${g.ty} ${g.t.x},${g.ty}`
1756
+ );
1757
+ bottom.unshift(
1758
+ `L${g.t.x},${g.ty + th} C${cx},${g.ty + th} ${cx},${g.sy + th} ${gx},${g.sy + th}`
1759
+ );
1760
+ });
1761
+ ribbon = svg.append("path").attr("d", `${top2.join(" ")} ${bottom.join(" ")} Z`).attr("fill", color).attr("fill-opacity", opacity);
1712
1762
  }
1713
1763
  tagDatum(ribbon, {
1714
1764
  line: l.lineNumber,
@@ -32,7 +32,7 @@ import {
32
32
  } from "./chunk-IUBCDNT2.js";
33
33
  import {
34
34
  renderDataChartD3
35
- } from "./chunk-KFXY5IW2.js";
35
+ } from "./chunk-27KA4VV6.js";
36
36
  import {
37
37
  computeQuadrantPointLabels
38
38
  } from "./chunk-KMU65FYM.js";
@@ -2089,7 +2089,7 @@ async function renderForExport(content, theme, palette, viewState, options) {
2089
2089
  const renderContent = override?.content ?? content;
2090
2090
  const detectedType = override?.type ?? detectedTypeRaw;
2091
2091
  if (detectedType !== null) {
2092
- const { supportsD3DataChart, renderDataChartD3: renderDataChartD32 } = await import("./charts-d3-YXD6VGZQ.js");
2092
+ const { supportsD3DataChart, renderDataChartD3: renderDataChartD32 } = await import("./charts-d3-KSA5UKVJ.js");
2093
2093
  if (supportsD3DataChart(detectedType)) {
2094
2094
  return renderDataChartD32(renderContent, theme, palette, {
2095
2095
  ...options?.width !== void 0 && { width: options.width },
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-Z6DXWULM.js";
15
15
  import {
16
16
  render
17
- } from "./chunk-3LINSNJT.js";
17
+ } from "./chunk-KA5CSR44.js";
18
18
  import "./chunk-ABP5BUD6.js";
19
19
  import {
20
20
  renderErrorCard
@@ -39,7 +39,7 @@ import {
39
39
  D3_DATA_CHART_TYPES,
40
40
  renderDataChartD3,
41
41
  supportsD3DataChart
42
- } from "./chunk-KFXY5IW2.js";
42
+ } from "./chunk-27KA4VV6.js";
43
43
  import "./chunk-KMU65FYM.js";
44
44
  import "./chunk-EPDBWATV.js";
45
45
  import "./chunk-HFG7KQOY.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagrammo/dgmo",
3
- "version": "0.91.0",
3
+ "version": "0.91.1",
4
4
  "description": "DGMO diagram markup language — parser, renderer, and color system",
5
5
  "license": "MIT",
6
6
  "author": "Diagrammo LLC",
@@ -116,7 +116,7 @@
116
116
  "check:duplication": "jscpd ./src",
117
117
  "check:deadcode": "knip",
118
118
  "check:spelling": "cspell \"src/**/*.ts\" \"tests/**/*.ts\"",
119
- "check:all": "pnpm check:node-modules && pnpm check:install-lock && pnpm check:deadcode && pnpm check:spelling && pnpm check:duplication && pnpm check:circular && pnpm check:deps && pnpm check:dep-ranges && pnpm check:security && node --test scripts/check-api.test.mjs && pnpm build && bash scripts/check-api.sh check && pnpm check:publish && pnpm check:types",
119
+ "check:all": "pnpm check:node-modules && pnpm check:install-lock && pnpm check:deadcode && pnpm check:spelling && pnpm check:duplication && pnpm check:circular && pnpm check:deps && pnpm check:dep-ranges && pnpm check:security && node --test scripts/check-api.test.mjs && node --test scripts/prepack-sourcemaps.test.mjs && pnpm build && bash scripts/check-api.sh check && pnpm check:publish && pnpm check:types",
120
120
  "check:circular": "node --test scripts/check-circular.test.mjs && madge --circular --extensions ts src/ --json | node scripts/check-circular.mjs",
121
121
  "check:deps": "depcheck --ignores='@diagrammo/dgmo,@diagrammo/dgmo-mcp,@codemirror/language,@lezer/*,lint-staged,tsup,axe-core,type-coverage'",
122
122
  "check:node-modules": "node --test scripts/check-node-modules.test.mjs && node scripts/check-node-modules.mjs",