@markdy/renderer-dom 1.0.22 → 1.0.24

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.
Files changed (2) hide show
  1. package/dist/index.js +89 -2
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -625,9 +625,68 @@ function circleBoundaryRoute(from, to) {
625
625
  { x: toCenter.x - ux * toRadius, y: toCenter.y - uy * toRadius }
626
626
  ]);
627
627
  }
628
+ function snapPortToNodeShape(node, port, neighbor, isSource) {
629
+ if (!node.shape || node.shape === "card" || node.shape === "rounded" || node.shape === "terminal" || node.shape === "container") {
630
+ return port;
631
+ }
632
+ const cx = node.x + node.width / 2;
633
+ const cy = node.y + node.height / 2;
634
+ const hw = node.width / 2;
635
+ const hh = node.height / 2;
636
+ if (node.shape === "diamond") {
637
+ const isVert = Math.abs(port.x - neighbor.x) < 0.01;
638
+ const isHoriz = Math.abs(port.y - neighbor.y) < 0.01;
639
+ if (isVert) {
640
+ const goingDown = isSource ? neighbor.y > port.y : port.y > neighbor.y;
641
+ const boundaryY = goingDown ? cy + hh * (1 - Math.min(1, Math.abs(port.x - cx) / hw)) : cy - hh * (1 - Math.min(1, Math.abs(port.x - cx) / hw));
642
+ return { x: port.x, y: Math.round(boundaryY * 10) / 10 };
643
+ }
644
+ if (isHoriz) {
645
+ const goingRight = isSource ? neighbor.x > port.x : port.x > neighbor.x;
646
+ const boundaryX = goingRight ? cx + hw * (1 - Math.min(1, Math.abs(port.y - cy) / hh)) : cx - hw * (1 - Math.min(1, Math.abs(port.y - cy) / hh));
647
+ return { x: Math.round(boundaryX * 10) / 10, y: port.y };
648
+ }
649
+ }
650
+ if (node.shape === "circle") {
651
+ const r = Math.min(node.width, node.height) / 2;
652
+ const isVert = Math.abs(port.x - neighbor.x) < 0.01;
653
+ const isHoriz = Math.abs(port.y - neighbor.y) < 0.01;
654
+ if (isVert) {
655
+ const goingDown = isSource ? neighbor.y > port.y : port.y > neighbor.y;
656
+ return { x: cx, y: goingDown ? cy + r : cy - r };
657
+ }
658
+ if (isHoriz) {
659
+ const goingRight = isSource ? neighbor.x > port.x : port.x > neighbor.x;
660
+ return { x: goingRight ? cx + r : cx - r, y: cy };
661
+ }
662
+ }
663
+ if (node.shape === "pill") {
664
+ const r = node.height / 2;
665
+ const isVert = Math.abs(port.x - neighbor.x) < 0.01;
666
+ const isHoriz = Math.abs(port.y - neighbor.y) < 0.01;
667
+ if (isHoriz) {
668
+ const goingRight = isSource ? neighbor.x > port.x : port.x > neighbor.x;
669
+ return { x: goingRight ? node.x + node.width : node.x, y: cy };
670
+ }
671
+ if (isVert) {
672
+ const goingDown = isSource ? neighbor.y > port.y : port.y > neighbor.y;
673
+ const clampedX = Math.max(node.x + r, Math.min(node.x + node.width - r, port.x));
674
+ return { x: clampedX, y: goingDown ? node.y + node.height : node.y };
675
+ }
676
+ }
677
+ return port;
678
+ }
679
+ function snapRouteEndpointsToShapes(points, from, to) {
680
+ if (points.length < 2) return points;
681
+ const out = [...points];
682
+ out[0] = snapPortToNodeShape(from, out[0], out[1], true);
683
+ out[out.length - 1] = snapPortToNodeShape(to, out[out.length - 1], out[out.length - 2], false);
684
+ return dedupePoints(out);
685
+ }
628
686
  function routeEdgePoints(from, to, routeObstacles, bounds, lane) {
629
687
  if (from.shape === "circle" && to.shape === "circle") return circleBoundaryRoute(from, to);
630
- return routeOrthogonal(boxRect(from), boxRect(to), routeObstacles, bounds, lane);
688
+ const raw = routeOrthogonal(boxRect(from), boxRect(to), routeObstacles, bounds, lane);
689
+ return snapRouteEndpointsToShapes(raw, from, to);
631
690
  }
632
691
  function ensureEdgeLayer(scene) {
633
692
  const existing = scene.querySelector(`svg[${EDGE_LAYER_ATTR}='1']`);
@@ -1782,8 +1841,30 @@ function ensureNodeStyles(doc) {
1782
1841
  opacity: 1;
1783
1842
  transform: translateY(0);
1784
1843
  }
1844
+ .markdy-node[data-shape="diamond"],
1845
+ .markdy-node[data-shape="diamond"][data-visible="1"],
1846
+ .markdy-node[data-shape="diamond"][data-focal="1"],
1847
+ .markdy-node[data-shape="diamond"][data-focused="1"],
1848
+ .markdy-node[data-shape="diamond"][data-glow="1"],
1849
+ .markdy-scene-root .markdy-node[data-shape="diamond"],
1850
+ .markdy-scene-root .markdy-node[data-shape="diamond"][data-visible="1"],
1851
+ .markdy-scene-root .markdy-node[data-shape="diamond"][data-focal="1"],
1852
+ .markdy-scene-root .markdy-node[data-shape="diamond"][data-focused="1"],
1853
+ .markdy-scene-root .markdy-node[data-shape="diamond"][data-glow="1"],
1854
+ .markdy-scene-root[data-flat="1"] .markdy-node[data-shape="diamond"],
1855
+ .markdy-scene-root[data-flat="1"] .markdy-node[data-shape="diamond"][data-visible="1"],
1856
+ .markdy-scene-root[data-flat="1"] .markdy-node[data-shape="diamond"][data-focal="1"],
1857
+ .markdy-scene-root[data-markdy-theme="terminal"] .markdy-node[data-shape="diamond"],
1858
+ .markdy-scene-root[data-markdy-theme="terminal"] .markdy-node[data-shape="diamond"][data-focal="1"],
1859
+ .markdy-scene-root[data-markdy-theme="sketchy"] .markdy-node[data-shape="diamond"],
1860
+ .markdy-scene-root[data-markdy-theme="sketchy"] .markdy-node[data-shape="diamond"][data-focal="1"],
1861
+ .markdy-scene-root[data-markdy-theme="nebula"] .markdy-node[data-shape="diamond"],
1862
+ .markdy-scene-root[data-markdy-theme="nebula"] .markdy-node[data-shape="diamond"][data-focal="1"] {
1863
+ border: none;
1864
+ box-shadow: none;
1865
+ }
1785
1866
  .markdy-node[data-shape="diamond"] {
1786
- border-radius: 4px;
1867
+ border-radius: 0;
1787
1868
  transform: rotate(0deg);
1788
1869
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
1789
1870
  filter: drop-shadow(0 0 1px var(--md-hairline, rgba(15, 23, 42, 0.2))) drop-shadow(0 4px 12px var(--md-shadow, rgba(2, 6, 23, 0.15)));
@@ -1791,6 +1872,12 @@ function ensureNodeStyles(doc) {
1791
1872
  .markdy-node[data-shape="diamond"][data-focal="1"] {
1792
1873
  filter: drop-shadow(0 0 1.5px var(--md-accent)) drop-shadow(0 4px 14px var(--md-shadow, rgba(2, 6, 23, 0.15)));
1793
1874
  }
1875
+ .markdy-node[data-shape="diamond"][data-focused="1"] {
1876
+ filter: drop-shadow(0 0 2px var(--md-accent)) drop-shadow(0 0 14px color-mix(in srgb, var(--md-accent) 60%, transparent));
1877
+ }
1878
+ .markdy-node[data-shape="diamond"][data-glow="1"] {
1879
+ filter: drop-shadow(0 0 2px color-mix(in srgb, var(--md-glow-color, var(--md-accent)) 70%, transparent)) drop-shadow(0 0 24px color-mix(in srgb, var(--md-glow-color, var(--md-accent)) 55%, transparent));
1880
+ }
1794
1881
  .markdy-node[data-shape="diamond"] .markdy-node__body {
1795
1882
  justify-content: center;
1796
1883
  padding: 6px 16%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markdy/renderer-dom",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "Browser renderer for diagram-native animated MarkdyScript architecture diagrams, built on the Web Animations API.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -45,14 +45,14 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "html2canvas": "^1.4.1",
48
- "@markdy/core": "1.0.22"
48
+ "@markdy/core": "1.0.24"
49
49
  },
50
50
  "devDependencies": {
51
51
  "jsdom": "^29.1.1",
52
52
  "tsup": "^8.5.1",
53
53
  "typescript": "^5.9.3",
54
54
  "vitest": "^4.1.7",
55
- "@markdy/stdlib-systems": "1.0.22"
55
+ "@markdy/stdlib-systems": "1.0.24"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "tsup",