@shumoku/core 0.2.1 → 0.2.3
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/renderer/index.d.ts +7 -0
- package/dist/renderer/index.d.ts.map +1 -0
- package/dist/renderer/index.js +6 -0
- package/dist/renderer/index.js.map +1 -0
- package/dist/renderer/svg.d.ts +153 -0
- package/dist/renderer/svg.d.ts.map +1 -0
- package/dist/renderer/svg.js +1170 -0
- package/dist/renderer/svg.js.map +1 -0
- package/dist/renderer/types.d.ts +70 -0
- package/dist/renderer/types.d.ts.map +1 -0
- package/dist/renderer/types.js +6 -0
- package/dist/renderer/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shumoku Renderer
|
|
3
|
+
* SVG renderer for network diagrams
|
|
4
|
+
*/
|
|
5
|
+
export { SVGRenderer, type SVGRendererOptions } from './svg.js';
|
|
6
|
+
export type { DataAttributeOptions, DeviceInfo, EndpointInfo, LinkInfo, PortInfo, RenderMode, } from './types.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/renderer/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAG/D,YAAY,EACV,oBAAoB,EACpB,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,UAAU,GACX,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/renderer/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAA2B,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG Renderer
|
|
3
|
+
* Renders NetworkGraph to SVG
|
|
4
|
+
*/
|
|
5
|
+
import type { LayoutResult, NetworkGraph } from '../models/index.js';
|
|
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 declare const svgRenderer: SVGRenderer;
|
|
153
|
+
//# sourceMappingURL=sv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