@shumoku/renderer 0.2.0
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/html/iife-entry.d.ts +9 -0
- package/dist/html/iife-entry.d.ts.map +1 -0
- package/dist/html/iife-entry.js +9 -0
- package/dist/html/iife-entry.js.map +1 -0
- package/dist/html/index.d.ts +23 -0
- package/dist/html/index.d.ts.map +1 -0
- package/dist/html/index.js +210 -0
- package/dist/html/index.js.map +1 -0
- package/dist/html/runtime.d.ts +6 -0
- package/dist/html/runtime.d.ts.map +1 -0
- package/dist/html/runtime.js +582 -0
- package/dist/html/runtime.js.map +1 -0
- package/dist/iife-string.js +2 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/shumoku-interactive.iife.js +38 -0
- package/dist/style.css +136 -0
- package/dist/svg.d.ts +158 -0
- package/dist/svg.d.ts.map +1 -0
- package/dist/svg.js +1174 -0
- package/dist/svg.js.map +1 -0
- package/dist/types.d.ts +121 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +63 -0
- package/src/build-css.ts +159 -0
- package/src/build-iife-string.ts +19 -0
- package/src/build-iife.ts +24 -0
- package/src/html/iife-entry.ts +12 -0
- package/src/html/index.ts +226 -0
- package/src/html/runtime.ts +654 -0
- package/src/index.ts +22 -0
- package/src/svg.ts +1502 -0
- package/src/types.ts +125 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
(()=>{var{defineProperty:v,getOwnPropertyNames:zq,getOwnPropertyDescriptor:Fq}=Object,Lq=Object.prototype.hasOwnProperty;var Jq=new WeakMap,Aq=(J)=>{var I=Jq.get(J),q;if(I)return I;if(I=v({},"__esModule",{value:!0}),J&&typeof J==="object"||typeof J==="function")zq(J).map((Q)=>!Lq.call(I,Q)&&v(I,Q,{get:()=>J[Q],enumerable:!(q=Fq(J,Q))||q.enumerable}));return Jq.set(J,I),I};var Gq=(J,I)=>{for(var q in I)v(J,q,{get:I[q],enumerable:!0,configurable:!0,set:(Q)=>I[q]=()=>Q})};var Wq={};Gq(Wq,{ShumokuInteractive:()=>Qq});var W=null,Y=null,C=null,w=!1;function Uq(){if(!W)W=document.createElement("div"),W.style.cssText=`
|
|
2
|
+
position: fixed;
|
|
3
|
+
z-index: 10000;
|
|
4
|
+
padding: 6px 10px;
|
|
5
|
+
background: #1e293b;
|
|
6
|
+
color: #fff;
|
|
7
|
+
font-size: 12px;
|
|
8
|
+
border-radius: 4px;
|
|
9
|
+
pointer-events: none;
|
|
10
|
+
opacity: 0;
|
|
11
|
+
transition: opacity 0.15s;
|
|
12
|
+
font-family: system-ui, sans-serif;
|
|
13
|
+
max-width: 300px;
|
|
14
|
+
white-space: pre-line;
|
|
15
|
+
`,document.body.appendChild(W);return W}function Kq(J,I,q){let Q=Uq();Q.textContent=J;let j=12,L=I+j,z=q+j;requestAnimationFrame(()=>{let _=Q.getBoundingClientRect();if(L+_.width>window.innerWidth-j)L=I-_.width-j;if(z+_.height>window.innerHeight-j)z=q-_.height-j;Q.style.left=`${Math.max(j,L)}px`,Q.style.top=`${Math.max(j,z)}px`}),Q.style.left=`${L}px`,Q.style.top=`${z}px`,Q.style.opacity="1"}function x(){if(W)W.style.opacity="0"}function Oq(){if(!Y)Y=document.createElement("div"),Y.style.cssText=`
|
|
16
|
+
position: fixed;
|
|
17
|
+
top: 0;
|
|
18
|
+
left: 0;
|
|
19
|
+
right: 0;
|
|
20
|
+
bottom: 0;
|
|
21
|
+
background: rgba(0, 0, 0, 0.5);
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
opacity: 0;
|
|
24
|
+
transition: opacity 0.15s ease;
|
|
25
|
+
z-index: 9998;
|
|
26
|
+
`,document.body.appendChild(Y);return Y}var y=null,X=null;function Zq(){if(!y)y=document.createElement("div"),y.style.cssText=`
|
|
27
|
+
position: fixed;
|
|
28
|
+
top: 0;
|
|
29
|
+
left: 0;
|
|
30
|
+
pointer-events: none;
|
|
31
|
+
z-index: 9999;
|
|
32
|
+
`,document.body.appendChild(y);return y}function p(){if(!C||!X)return;if(!document.contains(C)){R(null);return}let J=C.closest("svg");if(!J)return;let I=J.getBoundingClientRect(),q=J.getAttribute("viewBox");if(q)X.setAttribute("viewBox",q);X.style.left=`${I.left}px`,X.style.top=`${I.top}px`,X.style.width=`${I.width}px`,X.style.height=`${I.height}px`}function R(J){if(J===C)return;if(C)C.classList.remove("shumoku-highlight");let I=Zq();I.innerHTML="",X=null,C=J;let q=Oq();if(J){J.classList.add("shumoku-highlight");let Q=J.closest("svg");if(Q){let j=Q.getAttribute("viewBox");if(j){let L=J.cloneNode(!0);L.classList.remove("shumoku-highlight");let z=document.createElementNS("http://www.w3.org/2000/svg","svg");z.setAttribute("viewBox",j),z.style.cssText=`
|
|
33
|
+
position: absolute;
|
|
34
|
+
overflow: visible;
|
|
35
|
+
filter: drop-shadow(0 0 4px #fff) drop-shadow(0 0 8px #fff) drop-shadow(0 0 12px rgba(100, 150, 255, 0.8));
|
|
36
|
+
`;let _=Q.querySelector("defs");if(_)z.appendChild(_.cloneNode(!0));z.appendChild(L),I.appendChild(z),X=z,p()}}q.style.opacity="1"}else q.style.opacity="0"}function Dq(){}function c(J){let I=J.closest(".port[data-port]");if(I){let j=I.getAttribute("data-port")||"";return{text:`${I.getAttribute("data-port-device")||""}:${j}`,element:I}}let q=J.closest(".link-group[data-link-id]");if(q){let j=q.getAttribute("data-link-from")||"",L=q.getAttribute("data-link-to")||"",z=q.getAttribute("data-link-bandwidth"),_=q.getAttribute("data-link-vlan"),b=`${j} ↔ ${L}`;if(z)b+=`
|
|
37
|
+
${z}`;if(_)b+=`
|
|
38
|
+
VLAN: ${_}`;return{text:b,element:q}}let Q=J.closest(".node[data-id]");if(Q){let j=Q.getAttribute("data-device-json"),L;if(j)try{let z=JSON.parse(j);L=z.label||z.id}catch{L=Q.getAttribute("data-id")||""}else L=Q.getAttribute("data-id")||"";return{text:L,element:Q}}return null}function f(J){let I=J.getAttribute("viewBox");if(!I)return null;let q=I.split(/\s+|,/).map(Number);if(q.length!==4||q.some(Number.isNaN))return null;return{x:q[0],y:q[1],width:q[2],height:q[3]}}function P(J,I){J.setAttribute("viewBox",`${I.x} ${I.y} ${I.width} ${I.height}`)}function Nq(J){let I=typeof J.target==="string"?document.querySelector(J.target):J.target;if(!I)throw Error("Target not found");let q=I.closest("svg")||I.querySelector("svg")||I;if(!(q instanceof SVGSVGElement))throw Error("SVG element not found");Dq();let Q=J.panZoom?.enabled??!0,j=J.panZoom?.minScale??0.1,L=J.panZoom?.maxScale??10,z=1.2,_=null;(()=>{if(_=f(q),!_){let $=q.getBBox();_={x:$.x,y:$.y,width:$.width,height:$.height},P(q,_)}})();let $q=()=>{if(!_)return 1;let $=f(q);if(!$)return 1;return _.width/$.width},u=!1,G=!1,T=0,m=0,F=null,s=0,E=null,M=null,h=($)=>{if(G)return;if(w)return;let N=$,K=c(N.target);if(K)Kq(K.text,N.clientX,N.clientY),R(K.element);else x(),R(null)},g=()=>{if(w)return;if(G)return;x(),R(null)},l=($)=>{if(!Q)return;let N=$;if(N.button!==0)return;if(c(N.target))return;G=!0,T=N.clientX,m=N.clientY,F=f(q),q.style.cursor="grabbing",$.preventDefault()},r=($)=>{if(!G||!F)return;let N=$,K=q.getBoundingClientRect(),k=N.clientX-T,A=N.clientY-m,O=F.width/K.width,Z=F.height/K.height;P(q,{x:F.x-k*O,y:F.y-A*Z,width:F.width,height:F.height})},a=()=>{if(G)G=!1,F=null,q.style.cursor=""},n=($)=>{if(!Q)return;let N=$;N.preventDefault();let K=f(q);if(!K||!_)return;let k=q.getBoundingClientRect(),A=(N.clientX-k.left)/k.width,O=(N.clientY-k.top)/k.height,Z=K.x+K.width*A,U=K.y+K.height*O,H=N.deltaY>0?z:1/z,D=K.width*H,B=K.height*H,d=_.width/D;if(d<j||d>L)return;P(q,{x:Z-D*A,y:U-B*O,width:D,height:B})},o=($)=>{w=!0;let N=$;if(N.touches.length===1&&Q){let K=N.touches[0],k=document.elementFromPoint(K.clientX,K.clientY);if(!(k?c(k):null))G=!0,T=K.clientX,m=K.clientY,F=f(q)}else if(N.touches.length===2&&Q){G=!1;let K=N.touches[0],k=N.touches[1];s=Math.hypot(k.clientX-K.clientX,k.clientY-K.clientY),E=f(q);let A=q.getBoundingClientRect(),O=(K.clientX+k.clientX)/2,Z=(K.clientY+k.clientY)/2,U=E;if(U){let H=(O-A.left)/A.width,D=(Z-A.top)/A.height;M={x:U.x+U.width*H,y:U.y+U.height*D}}}},i=($)=>{let N=$;if(N.touches.length===1&&G&&F){let K=N.touches[0],k=q.getBoundingClientRect(),A=K.clientX-T,O=K.clientY-m,Z=F.width/k.width,U=F.height/k.height;P(q,{x:F.x-A*Z,y:F.y-O*U,width:F.width,height:F.height}),N.preventDefault()}else if(N.touches.length===2&&E&&M&&_){let K=N.touches[0],k=N.touches[1],O=Math.hypot(k.clientX-K.clientX,k.clientY-K.clientY)/s,Z=E.width/O,U=E.height/O,H=_.width/Z;if(H<j||H>L)return;let D=q.getBoundingClientRect(),B=(K.clientX+k.clientX)/2,d=(K.clientY+k.clientY)/2,_q=(B-D.left)/D.width,jq=(d-D.top)/D.height;P(q,{x:M.x-Z*_q,y:M.y-U*jq,width:Z,height:U}),N.preventDefault()}},t=($)=>{let N=$;if(N.touches.length===0)G=!1,F=null,E=null,M=null;else if(N.touches.length===1){E=null,M=null,G=!0;let K=N.touches[0];T=K.clientX,m=K.clientY,F=f(q)}},e=($)=>{if(!w)return;if(G)return;let N=$,K=$.target,k=c(K);if(k)Kq(k.text,N.clientX,N.clientY),R(k.element),u=!0,$.preventDefault();else if(u)x(),R(null),u=!1},V=()=>{p()},S=null,qq="",Iq=()=>{if(C){let $=q.getAttribute("viewBox")||"";if($!==qq)qq=$,p()}S=requestAnimationFrame(Iq)};S=requestAnimationFrame(Iq);let kq=()=>{if(_)P(q,_)};if(Q)q.style.touchAction="none";return q.addEventListener("mousemove",h),q.addEventListener("mouseleave",g),q.addEventListener("mousedown",l),q.addEventListener("click",e),q.addEventListener("wheel",n,{passive:!1}),q.addEventListener("touchstart",o,{passive:!0}),q.addEventListener("touchmove",i,{passive:!1}),q.addEventListener("touchend",t),document.addEventListener("mousemove",r),document.addEventListener("mouseup",a),window.addEventListener("scroll",V,!0),window.addEventListener("resize",V),{destroy:()=>{if(q.removeEventListener("mousemove",h),q.removeEventListener("mouseleave",g),q.removeEventListener("mousedown",l),q.removeEventListener("click",e),q.removeEventListener("wheel",n),q.removeEventListener("touchstart",o),q.removeEventListener("touchmove",i),q.removeEventListener("touchend",t),document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",a),window.removeEventListener("scroll",V,!0),window.removeEventListener("resize",V),S!==null)cancelAnimationFrame(S);if(R(null),W)W.remove(),W=null;if(Y)Y.remove(),Y=null;if(y)y.remove(),y=null},showDeviceModal:()=>{},hideModal:()=>{},showLinkTooltip:()=>{},hideTooltip:()=>{x(),R(null),u=!1},resetView:kq,getScale:$q}}var Qq={initInteractive:Nq};window.ShumokuInteractive=Qq;})();
|
package/dist/style.css
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @shumoku/renderer - Optional Stylesheet
|
|
3
|
+
* Import this if you want to customize styles via CSS instead of JS
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* CSS Custom Properties (override these for theming) */
|
|
7
|
+
:root {
|
|
8
|
+
--shumoku-bg: #ffffff;
|
|
9
|
+
--shumoku-surface: #ffffff;
|
|
10
|
+
--shumoku-text: #1e293b;
|
|
11
|
+
--shumoku-text-secondary: #64748b;
|
|
12
|
+
--shumoku-border: #e2e8f0;
|
|
13
|
+
--shumoku-node-fill: #e2e8f0;
|
|
14
|
+
--shumoku-node-stroke: #64748b;
|
|
15
|
+
--shumoku-link-stroke: #94a3b8;
|
|
16
|
+
--shumoku-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* Dark mode */
|
|
20
|
+
@media (prefers-color-scheme: dark) {
|
|
21
|
+
:root {
|
|
22
|
+
--shumoku-bg: #1e293b;
|
|
23
|
+
--shumoku-surface: #334155;
|
|
24
|
+
--shumoku-text: #f1f5f9;
|
|
25
|
+
--shumoku-text-secondary: #94a3b8;
|
|
26
|
+
--shumoku-border: #475569;
|
|
27
|
+
--shumoku-node-fill: #334155;
|
|
28
|
+
--shumoku-node-stroke: #64748b;
|
|
29
|
+
--shumoku-link-stroke: #64748b;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* Tooltip */
|
|
34
|
+
.shumoku-tooltip {
|
|
35
|
+
position: fixed;
|
|
36
|
+
z-index: 10001;
|
|
37
|
+
max-width: 300px;
|
|
38
|
+
padding: 8px 12px;
|
|
39
|
+
border-radius: 6px;
|
|
40
|
+
font-size: 12px;
|
|
41
|
+
line-height: 1.4;
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
background: var(--shumoku-surface);
|
|
44
|
+
color: var(--shumoku-text);
|
|
45
|
+
border: 1px solid var(--shumoku-border);
|
|
46
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
47
|
+
font-family: var(--shumoku-font);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* Modal Backdrop */
|
|
51
|
+
.shumoku-modal-backdrop {
|
|
52
|
+
position: fixed;
|
|
53
|
+
top: 0;
|
|
54
|
+
left: 0;
|
|
55
|
+
right: 0;
|
|
56
|
+
bottom: 0;
|
|
57
|
+
z-index: 10000;
|
|
58
|
+
background: rgba(0, 0, 0, 0.4);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Modal */
|
|
62
|
+
.shumoku-modal {
|
|
63
|
+
position: fixed;
|
|
64
|
+
top: 50%;
|
|
65
|
+
left: 50%;
|
|
66
|
+
transform: translate(-50%, -50%);
|
|
67
|
+
z-index: 10001;
|
|
68
|
+
min-width: 320px;
|
|
69
|
+
max-width: 480px;
|
|
70
|
+
max-height: 80vh;
|
|
71
|
+
overflow-y: auto;
|
|
72
|
+
border-radius: 12px;
|
|
73
|
+
background: var(--shumoku-surface);
|
|
74
|
+
color: var(--shumoku-text);
|
|
75
|
+
border: 1px solid var(--shumoku-border);
|
|
76
|
+
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
|
|
77
|
+
font-family: var(--shumoku-font);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* Bottom Sheet Backdrop */
|
|
81
|
+
.shumoku-bottom-sheet-backdrop {
|
|
82
|
+
position: fixed;
|
|
83
|
+
top: 0;
|
|
84
|
+
left: 0;
|
|
85
|
+
right: 0;
|
|
86
|
+
bottom: 0;
|
|
87
|
+
z-index: 10000;
|
|
88
|
+
background: rgba(0, 0, 0, 0.4);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* Bottom Sheet */
|
|
92
|
+
.shumoku-bottom-sheet {
|
|
93
|
+
position: fixed;
|
|
94
|
+
left: 0;
|
|
95
|
+
right: 0;
|
|
96
|
+
bottom: 0;
|
|
97
|
+
z-index: 10001;
|
|
98
|
+
max-height: 80vh;
|
|
99
|
+
overflow: hidden;
|
|
100
|
+
border-radius: 16px 16px 0 0;
|
|
101
|
+
background: var(--shumoku-surface);
|
|
102
|
+
color: var(--shumoku-text);
|
|
103
|
+
box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
|
|
104
|
+
font-family: var(--shumoku-font);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* Bottom Sheet Handle */
|
|
108
|
+
.shumoku-sheet-handle {
|
|
109
|
+
padding: 12px;
|
|
110
|
+
text-align: center;
|
|
111
|
+
cursor: grab;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.shumoku-sheet-handle > div {
|
|
115
|
+
width: 36px;
|
|
116
|
+
height: 4px;
|
|
117
|
+
background: var(--shumoku-border);
|
|
118
|
+
border-radius: 2px;
|
|
119
|
+
margin: 0 auto;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* Close Button */
|
|
123
|
+
.shumoku-modal-close {
|
|
124
|
+
padding: 8px 16px;
|
|
125
|
+
border-radius: 6px;
|
|
126
|
+
border: 1px solid var(--shumoku-border);
|
|
127
|
+
background: var(--shumoku-surface);
|
|
128
|
+
color: var(--shumoku-text);
|
|
129
|
+
font-size: 13px;
|
|
130
|
+
cursor: pointer;
|
|
131
|
+
transition: background 0.15s ease;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.shumoku-modal-close:hover {
|
|
135
|
+
background: var(--shumoku-bg);
|
|
136
|
+
}
|
package/dist/svg.d.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG Renderer
|
|
3
|
+
* Renders NetworkGraph to SVG
|
|
4
|
+
*/
|
|
5
|
+
import type { LayoutResult, NetworkGraph } from '@shumoku/core';
|
|
6
|
+
import type { DataAttributeOptions, RenderMode } from './types.js';
|
|
7
|
+
export interface SVGRendererOptions {
|
|
8
|
+
/** Font family */
|
|
9
|
+
fontFamily?: string;
|
|
10
|
+
/** Include interactive elements (deprecated, use renderMode) */
|
|
11
|
+
interactive?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Render mode
|
|
14
|
+
* - 'static': Pure SVG without interactive data attributes (default)
|
|
15
|
+
* - 'interactive': SVG with data attributes for runtime interactivity
|
|
16
|
+
*/
|
|
17
|
+
renderMode?: RenderMode;
|
|
18
|
+
/**
|
|
19
|
+
* Data attributes to include in interactive mode
|
|
20
|
+
* Only used when renderMode is 'interactive'
|
|
21
|
+
*/
|
|
22
|
+
dataAttributes?: DataAttributeOptions;
|
|
23
|
+
}
|
|
24
|
+
export declare class SVGRenderer {
|
|
25
|
+
private options;
|
|
26
|
+
private themeColors;
|
|
27
|
+
private iconTheme;
|
|
28
|
+
constructor(options?: SVGRendererOptions);
|
|
29
|
+
/** Check if interactive mode is enabled */
|
|
30
|
+
private get isInteractive();
|
|
31
|
+
/** Get data attribute options with defaults */
|
|
32
|
+
private get dataAttrs();
|
|
33
|
+
/**
|
|
34
|
+
* Get theme colors based on theme type
|
|
35
|
+
*/
|
|
36
|
+
private getThemeColors;
|
|
37
|
+
/**
|
|
38
|
+
* Get icon theme variant based on theme type
|
|
39
|
+
*/
|
|
40
|
+
private getIconTheme;
|
|
41
|
+
render(graph: NetworkGraph, layout: LayoutResult): string;
|
|
42
|
+
/**
|
|
43
|
+
* Calculate legend dimensions without rendering
|
|
44
|
+
*/
|
|
45
|
+
private calculateLegendDimensions;
|
|
46
|
+
/**
|
|
47
|
+
* Parse legend settings from various input formats
|
|
48
|
+
*/
|
|
49
|
+
private getLegendSettings;
|
|
50
|
+
/**
|
|
51
|
+
* Render legend showing visual elements used in the diagram
|
|
52
|
+
*/
|
|
53
|
+
private renderLegend;
|
|
54
|
+
/**
|
|
55
|
+
* Render bandwidth indicator for legend
|
|
56
|
+
*/
|
|
57
|
+
private renderBandwidthLegendIcon;
|
|
58
|
+
private renderHeader;
|
|
59
|
+
private renderDefs;
|
|
60
|
+
private renderStyles;
|
|
61
|
+
private renderSubgraph;
|
|
62
|
+
/** Render node background (shape only) */
|
|
63
|
+
/** Render complete node (bg + fg as one unit) */
|
|
64
|
+
private renderNode;
|
|
65
|
+
private renderNodeBackground;
|
|
66
|
+
/** Build data attributes for a node (interactive mode only) */
|
|
67
|
+
private buildNodeDataAttributes;
|
|
68
|
+
/** Render node foreground (content only, ports rendered separately) */
|
|
69
|
+
private renderNodeForeground;
|
|
70
|
+
/**
|
|
71
|
+
* Render ports on a node (as separate groups)
|
|
72
|
+
*/
|
|
73
|
+
private renderPorts;
|
|
74
|
+
private renderNodeShape;
|
|
75
|
+
/**
|
|
76
|
+
* Calculate icon dimensions for a node
|
|
77
|
+
*/
|
|
78
|
+
private calculateIconInfo;
|
|
79
|
+
/**
|
|
80
|
+
* Render node content (icon + label) with dynamic vertical centering
|
|
81
|
+
*/
|
|
82
|
+
private renderNodeContent;
|
|
83
|
+
private renderLink;
|
|
84
|
+
/** Build data attributes for a link (interactive mode only) */
|
|
85
|
+
private buildLinkDataAttributes;
|
|
86
|
+
private formatEndpointLabels;
|
|
87
|
+
/**
|
|
88
|
+
* Calculate position for endpoint label near the port (not along the line)
|
|
89
|
+
* This avoids label clustering at the center of links
|
|
90
|
+
* Labels are placed based on port position relative to node center
|
|
91
|
+
*/
|
|
92
|
+
private getEndpointLabelPosition;
|
|
93
|
+
/**
|
|
94
|
+
* Render endpoint labels (IP) with white background
|
|
95
|
+
*/
|
|
96
|
+
private renderEndpointLabels;
|
|
97
|
+
private getLinkStrokeWidth;
|
|
98
|
+
/**
|
|
99
|
+
* Bandwidth rendering configuration - line count represents speed
|
|
100
|
+
* 1G → 1 line
|
|
101
|
+
* 10G → 2 lines
|
|
102
|
+
* 25G → 3 lines
|
|
103
|
+
* 40G → 4 lines
|
|
104
|
+
* 100G → 5 lines
|
|
105
|
+
*/
|
|
106
|
+
private getBandwidthConfig;
|
|
107
|
+
/**
|
|
108
|
+
* Render bandwidth lines (single or multiple parallel lines)
|
|
109
|
+
*/
|
|
110
|
+
private renderBandwidthLines;
|
|
111
|
+
/**
|
|
112
|
+
* Generate SVG path string from points with rounded corners
|
|
113
|
+
*/
|
|
114
|
+
private generatePath;
|
|
115
|
+
/**
|
|
116
|
+
* Calculate offsets for parallel lines (centered around 0)
|
|
117
|
+
*/
|
|
118
|
+
private calculateLineOffsets;
|
|
119
|
+
/**
|
|
120
|
+
* Offset points perpendicular to line direction, handling each segment properly
|
|
121
|
+
* For orthogonal paths, this maintains parallel lines through bends
|
|
122
|
+
*/
|
|
123
|
+
private offsetPoints;
|
|
124
|
+
/**
|
|
125
|
+
* Get perpendicular unit vector for a line segment
|
|
126
|
+
*/
|
|
127
|
+
private getPerpendicular;
|
|
128
|
+
/**
|
|
129
|
+
* Get default link type based on redundancy
|
|
130
|
+
*/
|
|
131
|
+
private getDefaultLinkType;
|
|
132
|
+
/**
|
|
133
|
+
* Get default arrow type based on redundancy
|
|
134
|
+
*/
|
|
135
|
+
private getDefaultArrowType;
|
|
136
|
+
/**
|
|
137
|
+
* VLAN color palette - distinct colors for different VLANs
|
|
138
|
+
*/
|
|
139
|
+
private static readonly VLAN_COLORS;
|
|
140
|
+
/**
|
|
141
|
+
* Get stroke color based on VLANs
|
|
142
|
+
*/
|
|
143
|
+
private getVlanStroke;
|
|
144
|
+
private getLinkDasharray;
|
|
145
|
+
private getMidPoint;
|
|
146
|
+
private escapeXml;
|
|
147
|
+
/**
|
|
148
|
+
* Simple string hash for consistent but varied label placement
|
|
149
|
+
*/
|
|
150
|
+
private hashString;
|
|
151
|
+
}
|
|
152
|
+
export interface RenderOptions extends SVGRendererOptions {
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Render NetworkGraph to SVG string
|
|
156
|
+
*/
|
|
157
|
+
export declare function render(graph: NetworkGraph, layout: LayoutResult, options?: RenderOptions): string;
|
|
158
|
+
//# sourceMappingURL=svg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../src/svg.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAKV,YAAY,EAKZ,YAAY,EAIb,MAAM,eAAe,CAAA;AAUtB,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAgElE,MAAM,WAAW,kBAAkB;IACjC,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gEAAgE;IAChE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAA;CACtC;AAaD,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,WAAW,CAA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