ts-graphviz 1.0.0 → 1.0.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/README.ja.md +14 -7
- package/README.md +14 -7
- package/lib/ast/index.cjs +543 -527
- package/lib/ast/index.d.ts +215 -49
- package/lib/ast/index.js +543 -527
- package/lib/common/index.cjs +8 -0
- package/lib/common/index.d.ts +195 -6
- package/lib/common/index.js +8 -0
- package/lib/core/index.cjs +58 -113
- package/lib/core/index.d.ts +64 -347
- package/lib/core/index.js +58 -113
- package/package.json +3 -3
package/lib/common/index.cjs
CHANGED
|
@@ -2,24 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
/** @hidden */
|
|
5
6
|
function isForwardRefNode(object) {
|
|
6
7
|
return typeof object === 'object' && object !== null && typeof object.id === 'string';
|
|
7
8
|
}
|
|
9
|
+
/** @hidden */
|
|
8
10
|
function isNodeModel(object) {
|
|
9
11
|
return typeof object === 'object' && object !== null && object.$$type === 'Node' && typeof object.id === 'string';
|
|
10
12
|
}
|
|
13
|
+
/** @hidden */
|
|
11
14
|
function isNodeRef(node) {
|
|
12
15
|
return isNodeModel(node) || isForwardRefNode(node);
|
|
13
16
|
}
|
|
17
|
+
/** @hidden */
|
|
14
18
|
function isNodeRefLike(node) {
|
|
15
19
|
return typeof node === 'string' || isNodeRef(node);
|
|
16
20
|
}
|
|
21
|
+
/** @hidden */
|
|
17
22
|
function isNodeRefGroupLike(target) {
|
|
18
23
|
return Array.isArray(target) && target.every(isNodeRefLike);
|
|
19
24
|
}
|
|
25
|
+
/** @hidden */
|
|
20
26
|
function isCompass(c) {
|
|
21
27
|
return ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'c'].includes(c);
|
|
22
28
|
}
|
|
29
|
+
/** @hidden */
|
|
23
30
|
function toNodeRef(target) {
|
|
24
31
|
if (isNodeRef(target)) {
|
|
25
32
|
return target;
|
|
@@ -30,6 +37,7 @@ function toNodeRef(target) {
|
|
|
30
37
|
}
|
|
31
38
|
return { id, port };
|
|
32
39
|
}
|
|
40
|
+
/** @hidden */
|
|
33
41
|
function toNodeRefGroup(targets) {
|
|
34
42
|
if (targets.length < 2 && (isNodeRefLike(targets[0]) && isNodeRefLike(targets[1])) === false) {
|
|
35
43
|
throw Error('EdgeTargets must have at least 2 elements.');
|
package/lib/common/index.d.ts
CHANGED
|
@@ -1,29 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Directive indicating which direction the Edge should point.
|
|
3
|
+
* @group Attribute Types
|
|
3
4
|
*/
|
|
4
5
|
declare type Compass = 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw' | 'c' | '_';
|
|
5
6
|
/**
|
|
6
7
|
* A double with an optional prefix `'+'`.
|
|
7
8
|
*
|
|
8
9
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/addDouble/ addDouble}
|
|
10
|
+
* @group Attribute Types
|
|
9
11
|
*/
|
|
10
12
|
declare type AddDouble = `+${Double}`;
|
|
11
13
|
/**
|
|
12
14
|
* Double-precision floating point number.
|
|
13
15
|
*
|
|
14
16
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/double/ double}
|
|
17
|
+
* @group Attribute Types
|
|
15
18
|
*/
|
|
16
19
|
declare type Double = number;
|
|
17
20
|
/**
|
|
18
21
|
* Port Position
|
|
19
22
|
*
|
|
20
23
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/portPos/ portPos}
|
|
24
|
+
* @group Attribute Types
|
|
21
25
|
*/
|
|
22
26
|
declare type PortPos = `${string}:${Compass}` | Compass;
|
|
23
27
|
/**
|
|
24
28
|
* A colon-separated list of doubles: `"%f(:%f)*"` where each %f is a double.
|
|
25
29
|
*
|
|
26
30
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/doubleList/ doubleList}
|
|
31
|
+
* @group Attribute Types
|
|
27
32
|
*/
|
|
28
33
|
declare type DoubleList =
|
|
29
34
|
| Double
|
|
@@ -39,20 +44,25 @@ declare type DoubleList =
|
|
|
39
44
|
* Integer number.
|
|
40
45
|
*
|
|
41
46
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/int/ int}
|
|
47
|
+
* @group Attribute Types
|
|
42
48
|
*/
|
|
43
49
|
declare type Int = number;
|
|
44
50
|
/**
|
|
45
51
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/shape/ shape}
|
|
52
|
+
* @group Attribute Types
|
|
46
53
|
*/
|
|
47
54
|
declare type Shape = string;
|
|
48
55
|
/**
|
|
49
56
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/smoothType/ smoothType}
|
|
57
|
+
* @group Attribute Types
|
|
50
58
|
*/
|
|
51
59
|
declare type SmoothType = 'none' | 'avg_dist' | 'graph_dist' | 'power_dist' | 'rng' | 'spring' | 'triangle';
|
|
52
60
|
/**
|
|
53
61
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/splineType/ splineType}
|
|
62
|
+
* @group Attribute Types
|
|
54
63
|
*/
|
|
55
64
|
declare type SplineType = SplineType.spline | string;
|
|
65
|
+
/** @hidden */
|
|
56
66
|
declare namespace SplineType {
|
|
57
67
|
type prefix = endp | startp | `${endp}${startp}` | '';
|
|
58
68
|
type spline = `${prefix}point ${triple}`;
|
|
@@ -62,20 +72,24 @@ declare namespace SplineType {
|
|
|
62
72
|
}
|
|
63
73
|
/**
|
|
64
74
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/startType/ startType}
|
|
75
|
+
* @group Attribute Types
|
|
65
76
|
*/
|
|
66
77
|
declare type StartType = `${StartType.style}${StartType.seed}`;
|
|
78
|
+
/** @hidden */
|
|
67
79
|
declare namespace StartType {
|
|
68
80
|
type style = 'regular' | 'self' | 'random';
|
|
69
81
|
type seed = number;
|
|
70
82
|
}
|
|
71
83
|
/**
|
|
72
84
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/style/ style}
|
|
85
|
+
* @group Attribute Types
|
|
73
86
|
*/
|
|
74
87
|
declare type Style =
|
|
75
88
|
| Style.styleItem
|
|
76
89
|
| `${Style.styleItem},${Style.styleItem}`
|
|
77
90
|
| `${Style.styleItem},${Style.styleItem},${Style.styleItem}`
|
|
78
91
|
| `${Style.styleItem},${Style.styleItem},${Style.styleItem},${Style.styleItem}`;
|
|
92
|
+
/** @hidden */
|
|
79
93
|
declare namespace Style {
|
|
80
94
|
type styleItem =
|
|
81
95
|
| 'dashed'
|
|
@@ -96,6 +110,7 @@ declare namespace Style {
|
|
|
96
110
|
}
|
|
97
111
|
/**
|
|
98
112
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/viewPort/ viewPort}
|
|
113
|
+
* @group Attribute Types
|
|
99
114
|
*/
|
|
100
115
|
declare type ViewPort = `${Double},${Double},${Double},${Double},${Double}` | `${Double},${Double},${Double},${string}`;
|
|
101
116
|
/**
|
|
@@ -103,12 +118,14 @@ declare type ViewPort = `${Double},${Double},${Double},${Double},${Double}` | `$
|
|
|
103
118
|
* defining layer names and implicitly numbered 1,2,…
|
|
104
119
|
*
|
|
105
120
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/layerList/ layerList}
|
|
121
|
+
* @group Attribute Types
|
|
106
122
|
*/
|
|
107
123
|
declare type LayerList = string;
|
|
108
124
|
/**
|
|
109
125
|
* specifies a list of layers defined by the layers attribute.
|
|
110
126
|
*
|
|
111
127
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/layerRange/ layerRange}
|
|
128
|
+
* @group Attribute Types
|
|
112
129
|
*/
|
|
113
130
|
declare type LayerRange = string;
|
|
114
131
|
/**
|
|
@@ -130,16 +147,19 @@ declare type LayerRange = string;
|
|
|
130
147
|
*
|
|
131
148
|
* In all cases, the substring `"\L"` is replaced by the object's label attribute.
|
|
132
149
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/escString/ escString}
|
|
150
|
+
* @group Attribute Types
|
|
133
151
|
*/
|
|
134
152
|
declare type EscString = string;
|
|
135
153
|
/**
|
|
136
154
|
* @see {@link https://graphviz.org/doc/info/shapes.html#html HTML-Like Labels}
|
|
155
|
+
* @group Attribute Types
|
|
137
156
|
*/
|
|
138
157
|
declare type HTMLLikeLabel = `<${string}>`;
|
|
139
158
|
/**
|
|
140
159
|
* An escString or an HTML label.
|
|
141
160
|
*
|
|
142
161
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/lblString/ lblString}
|
|
162
|
+
* @group Attribute Types
|
|
143
163
|
*/
|
|
144
164
|
declare type LblString = HTMLLikeLabel | EscString;
|
|
145
165
|
/**
|
|
@@ -148,8 +168,10 @@ declare type LblString = HTMLLikeLabel | EscString;
|
|
|
148
168
|
* The optional `'!'` indicates the node position should not change (input-only).
|
|
149
169
|
*
|
|
150
170
|
* If dim=3, point may also have the format `"%f,%f,%f('!')?"` to represent the point (x,y,z).
|
|
171
|
+
* @group Attribute Types
|
|
151
172
|
*/
|
|
152
173
|
declare type Point = Point.position | `${Point.position}!`;
|
|
174
|
+
/** @hidden */
|
|
153
175
|
declare namespace Point {
|
|
154
176
|
type position =
|
|
155
177
|
| `%${Double},%${Double}`
|
|
@@ -165,10 +187,12 @@ declare namespace Point {
|
|
|
165
187
|
* A point with an optional prefix `'+'`.
|
|
166
188
|
*
|
|
167
189
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/addPoint/ addPoint}
|
|
190
|
+
* @group Attribute Types
|
|
168
191
|
*/
|
|
169
192
|
declare type AddPoint = `+${Point}`;
|
|
170
193
|
/**
|
|
171
194
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/pointList/ pointList}
|
|
195
|
+
* @group Attribute Types
|
|
172
196
|
*/
|
|
173
197
|
declare type PointList =
|
|
174
198
|
| Point
|
|
@@ -183,10 +207,12 @@ declare type PointList =
|
|
|
183
207
|
* - On the other hand, usually for aesthetic reasons, it may be desirable that all edges appear beneath nodes, even if the resulting drawing is ambiguous. This can be achieved by choosing `"edgesfirst"`.
|
|
184
208
|
*
|
|
185
209
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/outputMode/ outputMode}
|
|
210
|
+
* @group Attribute Types
|
|
186
211
|
*/
|
|
187
212
|
declare type OutputMode = 'breadthfirst' | 'nodesfirst' | 'edgesfirst';
|
|
188
213
|
/**
|
|
189
214
|
* @see {@link https://graphviz.org/docs/attr-types/packMode/ packMode}
|
|
215
|
+
* @group Attribute Types
|
|
190
216
|
*/
|
|
191
217
|
declare type PackMode = 'node' | 'clust' | 'graph' | `array${string}`;
|
|
192
218
|
/**
|
|
@@ -194,6 +220,7 @@ declare type PackMode = 'node' | 'clust' | 'graph' | `array${string}`;
|
|
|
194
220
|
* though layout quality can suffer a little.
|
|
195
221
|
*
|
|
196
222
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/quadType/ quadType}
|
|
223
|
+
* @group Attribute Types
|
|
197
224
|
*/
|
|
198
225
|
declare type QuadType = 'normal' | 'fast' | 'none';
|
|
199
226
|
/**
|
|
@@ -203,10 +230,12 @@ declare type QuadType = 'normal' | 'fast' | 'none';
|
|
|
203
230
|
* from left to right, from bottom to top, and from right to left, respectively.
|
|
204
231
|
*
|
|
205
232
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/rankdir/ rankdir}
|
|
233
|
+
* @group Attribute Types
|
|
206
234
|
*/
|
|
207
235
|
declare type Rankdir = 'TB' | 'LR' | 'BT' | 'RL';
|
|
208
236
|
/**
|
|
209
237
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/rankType/ rankType}
|
|
238
|
+
* @group Attribute Types
|
|
210
239
|
*/
|
|
211
240
|
declare type RankType = 'same' | 'min' | 'source' | 'max' | 'sink';
|
|
212
241
|
/**
|
|
@@ -216,6 +245,7 @@ declare type RankType = 'same' | 'min' | 'source' | 'max' | 'sink';
|
|
|
216
245
|
* of the lower-left corner `(llx,lly)` and the upper-right corner `(urx,ury)`.
|
|
217
246
|
*
|
|
218
247
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/rect/ rect}
|
|
248
|
+
* @group Attribute Types
|
|
219
249
|
*/
|
|
220
250
|
declare type Rect = `${Double},${Double},${Double},${Double}`;
|
|
221
251
|
/**
|
|
@@ -225,8 +255,10 @@ declare type Rect = `${Double},${Double},${Double},${Double}`;
|
|
|
225
255
|
* combinations of the 42 variations of the primitive set of 11 arrows.
|
|
226
256
|
*
|
|
227
257
|
* @see {@link https://graphviz.org/docs/attr-types/arrowType/ arrowType}
|
|
258
|
+
* @group Attribute Types
|
|
228
259
|
*/
|
|
229
260
|
declare type ArrowType = ArrowType.aname | `${ArrowType.aname}${ArrowType.aname}`;
|
|
261
|
+
/** @hidden */
|
|
230
262
|
declare namespace ArrowType {
|
|
231
263
|
type shape = 'box' | 'crow' | 'curve' | 'icurve' | 'diamond' | 'dot' | 'inv' | 'none' | 'normal' | 'tee' | 'vee';
|
|
232
264
|
type side = 'l' | 'r';
|
|
@@ -235,12 +267,15 @@ declare namespace ArrowType {
|
|
|
235
267
|
}
|
|
236
268
|
/**
|
|
237
269
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/clusterMode/ clusterMode}
|
|
270
|
+
* @group Attribute Types
|
|
238
271
|
*/
|
|
239
272
|
declare type ClusterMode = 'local' | 'global' | 'none';
|
|
240
273
|
/**
|
|
241
274
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/color/ color}
|
|
275
|
+
* @group Attribute Types
|
|
242
276
|
*/
|
|
243
277
|
declare type Color = Color.RGB_RGBA | Color.HSV | Color.ColorName | number;
|
|
278
|
+
/** @hidden */
|
|
244
279
|
declare namespace Color {
|
|
245
280
|
/**
|
|
246
281
|
* `"#%2x%2x%2x"` Red-Green-Blue (RGB)
|
|
@@ -1095,20 +1130,24 @@ declare namespace Color {
|
|
|
1095
1130
|
* @note A type that is too complicated to express in TypeScript.
|
|
1096
1131
|
*
|
|
1097
1132
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/colorList/}
|
|
1133
|
+
* @group Attribute Types
|
|
1098
1134
|
*/
|
|
1099
1135
|
declare type ColorList = string;
|
|
1100
1136
|
/**
|
|
1101
1137
|
* Direction Type
|
|
1102
1138
|
*
|
|
1103
1139
|
* @see {@link https://graphviz.gitlab.io/docs/attr-types/dirType/ dirType}
|
|
1140
|
+
* @group Attribute Types
|
|
1104
1141
|
*/
|
|
1105
1142
|
declare type DirType = 'forward' | 'back' | 'both' | 'none';
|
|
1106
1143
|
/**
|
|
1107
1144
|
* Page Direction
|
|
1108
1145
|
*
|
|
1109
1146
|
* @see {@link https://graphviz.org/docs/attr-types/pagedir/ pagedir}
|
|
1147
|
+
* @group Attribute Types
|
|
1110
1148
|
*/
|
|
1111
1149
|
declare type Pagedir = `${Pagedir.TB}${Pagedir.RL}`;
|
|
1150
|
+
/** @hidden */
|
|
1112
1151
|
declare namespace Pagedir {
|
|
1113
1152
|
type TB = 'T' | 'B';
|
|
1114
1153
|
type RL = 'R' | 'L';
|
|
@@ -1116,6 +1155,7 @@ declare namespace Pagedir {
|
|
|
1116
1155
|
|
|
1117
1156
|
/**
|
|
1118
1157
|
* Attribute types available for edges.
|
|
1158
|
+
* @group Attribute
|
|
1119
1159
|
*/
|
|
1120
1160
|
declare type EdgeAttributeKey =
|
|
1121
1161
|
| 'URL'
|
|
@@ -1186,6 +1226,7 @@ declare type EdgeAttributeKey =
|
|
|
1186
1226
|
| '_class';
|
|
1187
1227
|
/**
|
|
1188
1228
|
* Attribute types available for nodes.
|
|
1229
|
+
* @group Attribute
|
|
1189
1230
|
*/
|
|
1190
1231
|
declare type NodeAttributeKey =
|
|
1191
1232
|
| 'URL'
|
|
@@ -1239,6 +1280,7 @@ declare type NodeAttributeKey =
|
|
|
1239
1280
|
| '_class';
|
|
1240
1281
|
/**
|
|
1241
1282
|
* Attribute types available for graph.
|
|
1283
|
+
* @group Attribute
|
|
1242
1284
|
*/
|
|
1243
1285
|
declare type GraphAttributeKey =
|
|
1244
1286
|
| 'Damping'
|
|
@@ -1342,10 +1384,12 @@ declare type GraphAttributeKey =
|
|
|
1342
1384
|
| '_class';
|
|
1343
1385
|
/**
|
|
1344
1386
|
* Attribute types available for subgraph.
|
|
1387
|
+
* @group Attribute
|
|
1345
1388
|
*/
|
|
1346
1389
|
declare type SubgraphAttributeKey = 'rank';
|
|
1347
1390
|
/**
|
|
1348
1391
|
* Attribute types available for cluster subgraph.
|
|
1392
|
+
* @group Attribute
|
|
1349
1393
|
*/
|
|
1350
1394
|
declare type ClusterSubgraphAttributeKey =
|
|
1351
1395
|
| 'K'
|
|
@@ -1380,6 +1424,7 @@ declare type ClusterSubgraphAttributeKey =
|
|
|
1380
1424
|
| '_class';
|
|
1381
1425
|
/**
|
|
1382
1426
|
* Attribute types.
|
|
1427
|
+
* @group Attribute
|
|
1383
1428
|
*/
|
|
1384
1429
|
declare type AttributeKey =
|
|
1385
1430
|
| NodeAttributeKey
|
|
@@ -1562,8 +1607,14 @@ interface KeyValueMapping {
|
|
|
1562
1607
|
xlp: Point;
|
|
1563
1608
|
z: Double;
|
|
1564
1609
|
}
|
|
1610
|
+
/**
|
|
1611
|
+
* @group Attribute
|
|
1612
|
+
*/
|
|
1565
1613
|
declare type Attribute<T extends AttributeKey> = KeyValueMapping[T];
|
|
1566
1614
|
|
|
1615
|
+
/**
|
|
1616
|
+
* @group Models
|
|
1617
|
+
*/
|
|
1567
1618
|
declare type ASTType =
|
|
1568
1619
|
| 'Literal'
|
|
1569
1620
|
| 'Dot'
|
|
@@ -1578,87 +1629,205 @@ declare type ASTType =
|
|
|
1578
1629
|
| 'Subgraph';
|
|
1579
1630
|
/**
|
|
1580
1631
|
* Objects that can be Edge destinations satisfy this interface.
|
|
1632
|
+
* @group Models
|
|
1581
1633
|
*/
|
|
1582
1634
|
declare type NodeRef = NodeModel | ForwardRefNode;
|
|
1635
|
+
/**
|
|
1636
|
+
* @group Models
|
|
1637
|
+
*/
|
|
1583
1638
|
declare type NodeRefGroup = NodeRef[];
|
|
1584
1639
|
/**
|
|
1585
|
-
* string or an object implementing
|
|
1640
|
+
* string or an object implementing EdgeTarget.
|
|
1641
|
+
* @group Models
|
|
1586
1642
|
*/
|
|
1587
1643
|
declare type NodeRefLike = NodeRef | string;
|
|
1644
|
+
/**
|
|
1645
|
+
* @group Models
|
|
1646
|
+
*/
|
|
1588
1647
|
declare type NodeRefGroupLike = NodeRefLike[];
|
|
1648
|
+
/**
|
|
1649
|
+
* @group Models
|
|
1650
|
+
*/
|
|
1589
1651
|
declare type EdgeTarget = NodeRef | NodeRefGroup;
|
|
1652
|
+
/**
|
|
1653
|
+
* @group Models
|
|
1654
|
+
*/
|
|
1590
1655
|
declare type EdgeTargetLike = NodeRefLike | NodeRefGroupLike;
|
|
1656
|
+
/**
|
|
1657
|
+
* @group Models
|
|
1658
|
+
*/
|
|
1591
1659
|
declare type EdgeTargetTuple = [from: EdgeTarget, to: EdgeTarget, ...rest: EdgeTarget[]];
|
|
1660
|
+
/**
|
|
1661
|
+
* @group Models
|
|
1662
|
+
*/
|
|
1592
1663
|
declare type EdgeTargetLikeTuple = [from: EdgeTargetLike, to: EdgeTargetLike, ...rest: EdgeTargetLike[]];
|
|
1664
|
+
/**
|
|
1665
|
+
* An objects of attribute key/value pairs.
|
|
1666
|
+
* @group Models
|
|
1667
|
+
*/
|
|
1593
1668
|
declare type AttributesObject<T extends AttributeKey> = {
|
|
1594
1669
|
[K in T]?: Attribute<K>;
|
|
1595
1670
|
};
|
|
1671
|
+
/**
|
|
1672
|
+
* @group Models
|
|
1673
|
+
*/
|
|
1596
1674
|
declare type AttributeValue = Attribute<AttributeKey>;
|
|
1675
|
+
/**
|
|
1676
|
+
* An array of attribute key/value tuple.
|
|
1677
|
+
* @group Models
|
|
1678
|
+
*/
|
|
1597
1679
|
declare type AttributesEntities<T extends AttributeKey> = readonly [T, Attribute<T>][];
|
|
1680
|
+
/**
|
|
1681
|
+
* Attribute object that can be set to Edge.
|
|
1682
|
+
* @group Models
|
|
1683
|
+
*/
|
|
1598
1684
|
declare type EdgeAttributesObject = AttributesObject<EdgeAttributeKey>;
|
|
1685
|
+
/**
|
|
1686
|
+
* Attribute object that can be set to Node.
|
|
1687
|
+
* @group Models
|
|
1688
|
+
*/
|
|
1599
1689
|
declare type NodeAttributesObject = AttributesObject<NodeAttributeKey>;
|
|
1690
|
+
/**
|
|
1691
|
+
* Attribute object that can be set to Graph.
|
|
1692
|
+
* @group Models
|
|
1693
|
+
*/
|
|
1600
1694
|
declare type GraphAttributesObject = AttributesObject<GraphAttributeKey>;
|
|
1695
|
+
/**
|
|
1696
|
+
* Attribute object that can be set to Subgraph.
|
|
1697
|
+
* @group Models
|
|
1698
|
+
*/
|
|
1601
1699
|
declare type SubgraphAttributesObject = AttributesObject<ClusterSubgraphAttributeKey | SubgraphAttributeKey>;
|
|
1700
|
+
/**
|
|
1701
|
+
* @group Models
|
|
1702
|
+
*/
|
|
1602
1703
|
declare type DotObjectType = 'AttributeList' | 'Node' | 'Edge' | 'Subgraph' | 'Graph';
|
|
1704
|
+
/**
|
|
1705
|
+
* @group Models
|
|
1706
|
+
*/
|
|
1603
1707
|
interface DotObjectModel<T extends DotObjectType = DotObjectType> {
|
|
1604
1708
|
$$type: T;
|
|
1605
1709
|
}
|
|
1710
|
+
/**
|
|
1711
|
+
* @group Models
|
|
1712
|
+
*/
|
|
1606
1713
|
interface HasComment {
|
|
1607
1714
|
/** Comments to include when outputting with toDot. */
|
|
1608
1715
|
comment?: string;
|
|
1609
1716
|
}
|
|
1717
|
+
/**
|
|
1718
|
+
* @group Models
|
|
1719
|
+
*/
|
|
1610
1720
|
interface HasAttributes<T extends AttributeKey> {
|
|
1611
1721
|
readonly attributes: AttributesGroup<T>;
|
|
1612
1722
|
}
|
|
1723
|
+
/**
|
|
1724
|
+
* @group Models
|
|
1725
|
+
*/
|
|
1613
1726
|
interface ForwardRefNode extends Partial<Port> {
|
|
1614
1727
|
readonly id: string;
|
|
1615
1728
|
}
|
|
1729
|
+
/**
|
|
1730
|
+
* DOT object with the property
|
|
1731
|
+
* that attributes can be held as a set of keys and values.
|
|
1732
|
+
*
|
|
1733
|
+
* @typeParam T - The attribute keys to set DOT object.
|
|
1734
|
+
* @group Models
|
|
1735
|
+
*/
|
|
1616
1736
|
interface Attributes<T extends AttributeKey> {
|
|
1737
|
+
/** Size of the set of keys and values held by the DOT object. */
|
|
1617
1738
|
readonly size: number;
|
|
1739
|
+
/** The key/value tuples of the object attributes. */
|
|
1618
1740
|
readonly values: ReadonlyArray<[T, Attribute<T>]>;
|
|
1741
|
+
/**
|
|
1742
|
+
* Get the value of an attribute by a DOT object by specifying its key.
|
|
1743
|
+
*
|
|
1744
|
+
* If the value corresponding to the key does not exist, undefined is returned.
|
|
1745
|
+
*/
|
|
1619
1746
|
get(key: T): Attribute<T> | undefined;
|
|
1747
|
+
/** Set a value, by specifying the key of the attributes in the DOT object. */
|
|
1620
1748
|
set(key: T, value: Attribute<T>): void;
|
|
1749
|
+
/**
|
|
1750
|
+
* Apply keys and values that can be specified for DOT objects collectively.
|
|
1751
|
+
*
|
|
1752
|
+
* @param attributes - An array of objects or tuples of attribute key/value pairs.
|
|
1753
|
+
*/
|
|
1621
1754
|
apply(attributes: AttributesObject<T> | AttributesEntities<T>): void;
|
|
1755
|
+
/** Delete the value of an attribute from a DOT object by specifying a key. */
|
|
1622
1756
|
delete(key: T): void;
|
|
1757
|
+
/** Delete all attributes specified for the DOT object. */
|
|
1623
1758
|
clear(): void;
|
|
1624
1759
|
}
|
|
1760
|
+
/**
|
|
1761
|
+
* @group Models
|
|
1762
|
+
*/
|
|
1625
1763
|
interface AttributesGroup<T extends AttributeKey> extends Attributes<T>, HasComment {}
|
|
1764
|
+
/**
|
|
1765
|
+
* @group Models
|
|
1766
|
+
*/
|
|
1626
1767
|
declare type AttributeListKind = 'Graph' | 'Edge' | 'Node';
|
|
1768
|
+
/**
|
|
1769
|
+
* A list object of attributes commonly specified for nodes, subgraphs, and edges
|
|
1770
|
+
* under graph and subgraph.
|
|
1771
|
+
*
|
|
1772
|
+
* @typeParam K - The type of object is being specified.
|
|
1773
|
+
* @typeParam T - The attribute keys to set DOT object.
|
|
1774
|
+
* @group Models
|
|
1775
|
+
*/
|
|
1627
1776
|
interface AttributeListModel<K extends AttributeListKind = AttributeListKind, T extends AttributeKey = AttributeKey>
|
|
1628
1777
|
extends Attributes<T>,
|
|
1629
1778
|
HasComment,
|
|
1630
1779
|
DotObjectModel<'AttributeList'> {
|
|
1631
1780
|
$$kind: K;
|
|
1632
1781
|
}
|
|
1782
|
+
/**
|
|
1783
|
+
* Port on an edge node.
|
|
1784
|
+
* @group Models
|
|
1785
|
+
*/
|
|
1633
1786
|
interface Port {
|
|
1634
1787
|
port: string;
|
|
1635
1788
|
compass: Compass;
|
|
1636
1789
|
}
|
|
1790
|
+
/**
|
|
1791
|
+
* Model that can be converted to Node in DOT language.
|
|
1792
|
+
* @group Models
|
|
1793
|
+
*/
|
|
1637
1794
|
interface NodeModel extends HasComment, HasAttributes<NodeAttributeKey>, DotObjectModel<'Node'> {
|
|
1795
|
+
/** ID of the node */
|
|
1638
1796
|
readonly id: string;
|
|
1797
|
+
/** Returns ForwardRefNode with port and compass specified. */
|
|
1639
1798
|
port(port: string | Partial<Port>): ForwardRefNode;
|
|
1640
1799
|
}
|
|
1800
|
+
/**
|
|
1801
|
+
* Model that can be converted to Edge in DOT language.
|
|
1802
|
+
* @group Models
|
|
1803
|
+
*/
|
|
1641
1804
|
interface EdgeModel extends HasComment, HasAttributes<EdgeAttributeKey>, DotObjectModel<'Edge'> {
|
|
1642
1805
|
readonly targets: EdgeTargetTuple;
|
|
1643
1806
|
}
|
|
1644
1807
|
/**
|
|
1645
1808
|
* Cluster common attribute interface.
|
|
1646
|
-
*
|
|
1647
|
-
* @hidden
|
|
1809
|
+
* @group Models
|
|
1648
1810
|
*/
|
|
1649
1811
|
interface GraphCommonAttributes {
|
|
1650
|
-
/** Manage common attributes of graphs in a
|
|
1812
|
+
/** Manage common attributes of graphs in a graph. */
|
|
1651
1813
|
graph: AttributeListModel<'Graph', SubgraphAttributeKey | ClusterSubgraphAttributeKey>;
|
|
1652
|
-
/** Manage common attributes of edges in a
|
|
1814
|
+
/** Manage common attributes of edges in a graph. */
|
|
1653
1815
|
edge: AttributeListModel<'Edge', EdgeAttributeKey>;
|
|
1654
|
-
/** Manage common attributes of nodes in a
|
|
1816
|
+
/** Manage common attributes of nodes in a graph. */
|
|
1655
1817
|
node: AttributeListModel<'Node', NodeAttributeKey>;
|
|
1656
1818
|
}
|
|
1819
|
+
/**
|
|
1820
|
+
* DOT model representing a graph/digraph/subgraph.
|
|
1821
|
+
* @group Models
|
|
1822
|
+
*/
|
|
1657
1823
|
interface GraphBaseModel<T extends AttributeKey = AttributeKey> extends HasComment, Attributes<T> {
|
|
1658
1824
|
readonly id?: string;
|
|
1659
1825
|
readonly attributes: Readonly<GraphCommonAttributes>;
|
|
1826
|
+
/** Node objects in the graph. */
|
|
1660
1827
|
readonly nodes: ReadonlyArray<NodeModel>;
|
|
1828
|
+
/** Edge objects in the graph. */
|
|
1661
1829
|
readonly edges: ReadonlyArray<EdgeModel>;
|
|
1830
|
+
/** Subgraph objects in the graph. */
|
|
1662
1831
|
readonly subgraphs: ReadonlyArray<SubgraphModel>;
|
|
1663
1832
|
/**
|
|
1664
1833
|
* Add a Node to the graph.
|
|
@@ -1702,6 +1871,9 @@ interface GraphBaseModel<T extends AttributeKey = AttributeKey> extends HasComme
|
|
|
1702
1871
|
createNode(id: string, attributes?: NodeAttributesObject): NodeModel;
|
|
1703
1872
|
/**
|
|
1704
1873
|
* Create a Subgraph and add it to the graph.
|
|
1874
|
+
*
|
|
1875
|
+
* @param id - Subgraph ID
|
|
1876
|
+
* @param attributes - Subgraph attribute object
|
|
1705
1877
|
*/
|
|
1706
1878
|
createSubgraph(id?: string, attributes?: SubgraphAttributesObject): SubgraphModel;
|
|
1707
1879
|
createSubgraph(attributes?: SubgraphAttributesObject): SubgraphModel;
|
|
@@ -1982,11 +2154,20 @@ interface GraphBaseModel<T extends AttributeKey = AttributeKey> extends HasComme
|
|
|
1982
2154
|
*/
|
|
1983
2155
|
graph(attributes: SubgraphAttributesObject): void;
|
|
1984
2156
|
}
|
|
2157
|
+
/**
|
|
2158
|
+
* DOT model representing a subgraph.
|
|
2159
|
+
* @group Models
|
|
2160
|
+
*/
|
|
1985
2161
|
interface SubgraphModel
|
|
1986
2162
|
extends GraphBaseModel<SubgraphAttributeKey | ClusterSubgraphAttributeKey>,
|
|
1987
2163
|
DotObjectModel<'Subgraph'> {
|
|
2164
|
+
/** Determines whether the Subgraph is a SubgraphCluster. */
|
|
1988
2165
|
isSubgraphCluster(): boolean;
|
|
1989
2166
|
}
|
|
2167
|
+
/**
|
|
2168
|
+
* DOT model representing a root graphs(digraph and graph).
|
|
2169
|
+
* @group Models
|
|
2170
|
+
*/
|
|
1990
2171
|
interface RootGraphModel extends GraphBaseModel<GraphAttributeKey>, DotObjectModel<'Graph'> {
|
|
1991
2172
|
directed: boolean;
|
|
1992
2173
|
/**
|
|
@@ -2000,13 +2181,21 @@ interface RootGraphModel extends GraphBaseModel<GraphAttributeKey>, DotObjectMod
|
|
|
2000
2181
|
*/
|
|
2001
2182
|
strict: boolean;
|
|
2002
2183
|
}
|
|
2184
|
+
/** @hidden */
|
|
2003
2185
|
declare function isForwardRefNode(object: unknown): object is ForwardRefNode;
|
|
2186
|
+
/** @hidden */
|
|
2004
2187
|
declare function isNodeModel(object: unknown): object is NodeModel;
|
|
2188
|
+
/** @hidden */
|
|
2005
2189
|
declare function isNodeRef(node: unknown): node is NodeRef;
|
|
2190
|
+
/** @hidden */
|
|
2006
2191
|
declare function isNodeRefLike(node: unknown): node is NodeRefLike;
|
|
2192
|
+
/** @hidden */
|
|
2007
2193
|
declare function isNodeRefGroupLike(target: NodeRefLike | NodeRefGroupLike): target is NodeRefGroupLike;
|
|
2194
|
+
/** @hidden */
|
|
2008
2195
|
declare function isCompass(c: string): c is Compass;
|
|
2196
|
+
/** @hidden */
|
|
2009
2197
|
declare function toNodeRef(target: NodeRefLike): NodeRef;
|
|
2198
|
+
/** @hidden */
|
|
2010
2199
|
declare function toNodeRefGroup(targets: NodeRefGroupLike): NodeRefGroup;
|
|
2011
2200
|
|
|
2012
2201
|
export {
|
package/lib/common/index.js
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
|
+
/** @hidden */
|
|
1
2
|
function isForwardRefNode(object) {
|
|
2
3
|
return typeof object === 'object' && object !== null && typeof object.id === 'string';
|
|
3
4
|
}
|
|
5
|
+
/** @hidden */
|
|
4
6
|
function isNodeModel(object) {
|
|
5
7
|
return typeof object === 'object' && object !== null && object.$$type === 'Node' && typeof object.id === 'string';
|
|
6
8
|
}
|
|
9
|
+
/** @hidden */
|
|
7
10
|
function isNodeRef(node) {
|
|
8
11
|
return isNodeModel(node) || isForwardRefNode(node);
|
|
9
12
|
}
|
|
13
|
+
/** @hidden */
|
|
10
14
|
function isNodeRefLike(node) {
|
|
11
15
|
return typeof node === 'string' || isNodeRef(node);
|
|
12
16
|
}
|
|
17
|
+
/** @hidden */
|
|
13
18
|
function isNodeRefGroupLike(target) {
|
|
14
19
|
return Array.isArray(target) && target.every(isNodeRefLike);
|
|
15
20
|
}
|
|
21
|
+
/** @hidden */
|
|
16
22
|
function isCompass(c) {
|
|
17
23
|
return ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'c'].includes(c);
|
|
18
24
|
}
|
|
25
|
+
/** @hidden */
|
|
19
26
|
function toNodeRef(target) {
|
|
20
27
|
if (isNodeRef(target)) {
|
|
21
28
|
return target;
|
|
@@ -26,6 +33,7 @@ function toNodeRef(target) {
|
|
|
26
33
|
}
|
|
27
34
|
return { id, port };
|
|
28
35
|
}
|
|
36
|
+
/** @hidden */
|
|
29
37
|
function toNodeRefGroup(targets) {
|
|
30
38
|
if (targets.length < 2 && (isNodeRefLike(targets[0]) && isNodeRefLike(targets[1])) === false) {
|
|
31
39
|
throw Error('EdgeTargets must have at least 2 elements.');
|