@ts-graphviz/ast 0.0.0-pr956-20240225073457 → 0.0.0-pr956-20240225160253
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/CHANGELOG.md +291 -3
- package/lib/ast.cjs +25 -60
- package/lib/ast.js +25 -60
- package/package.json +43 -24
- package/src/ast.ts +0 -8
- package/src/builder/__snapshots__/create-element.test.ts.snap +0 -166
- package/src/builder/builder.test.ts +0 -36
- package/src/builder/builder.ts +0 -44
- package/src/builder/create-element.test.ts +0 -110
- package/src/builder/create-element.ts +0 -13
- package/src/builder/index.ts +0 -3
- package/src/builder/types.ts +0 -226
- package/src/dot-shim/index.ts +0 -2
- package/src/dot-shim/parser/__snapshots__/parse.test.ts.snap +0 -2613
- package/src/dot-shim/parser/dot.peggy +0 -396
- package/src/dot-shim/parser/index.ts +0 -1
- package/src/dot-shim/parser/parse.test.ts +0 -263
- package/src/dot-shim/parser/parse.ts +0 -121
- package/src/dot-shim/parser/peggy.options.json +0 -15
- package/src/dot-shim/printer/index.ts +0 -6
- package/src/dot-shim/printer/plugins/AttributeListPrintPlugin.ts +0 -22
- package/src/dot-shim/printer/plugins/AttributePrintPlugin.ts +0 -11
- package/src/dot-shim/printer/plugins/CommentPrintPlugin.ts +0 -40
- package/src/dot-shim/printer/plugins/DotPrintPlugin.ts +0 -12
- package/src/dot-shim/printer/plugins/EdgePrintPlugin.ts +0 -27
- package/src/dot-shim/printer/plugins/GraphPrintPlugin.ts +0 -32
- package/src/dot-shim/printer/plugins/LiteralPrintPlugin.ts +0 -24
- package/src/dot-shim/printer/plugins/NodePrintPlugin.ts +0 -24
- package/src/dot-shim/printer/plugins/NodeRefGroupPrintPlugin.ts +0 -17
- package/src/dot-shim/printer/plugins/NodeRefPrintPlugin.ts +0 -18
- package/src/dot-shim/printer/plugins/SubgraphPrintPlugin.ts +0 -27
- package/src/dot-shim/printer/plugins/index.ts +0 -26
- package/src/dot-shim/printer/plugins/utils/index.ts +0 -1
- package/src/dot-shim/printer/plugins/utils/tokens.ts +0 -51
- package/src/dot-shim/printer/printer.ts +0 -46
- package/src/dot-shim/printer/stringify.test.ts +0 -823
- package/src/dot-shim/printer/stringify.ts +0 -19
- package/src/dot-shim/printer/types.ts +0 -74
- package/src/model-shim/from-model/converter.ts +0 -43
- package/src/model-shim/from-model/from-model.ts +0 -19
- package/src/model-shim/from-model/index.ts +0 -3
- package/src/model-shim/from-model/plugins/AttributeListPlugin.ts +0 -19
- package/src/model-shim/from-model/plugins/EdgePlugin.ts +0 -140
- package/src/model-shim/from-model/plugins/GraphPlugin.ts +0 -36
- package/src/model-shim/from-model/plugins/NodePlugin.ts +0 -33
- package/src/model-shim/from-model/plugins/SubraphPlugin.ts +0 -28
- package/src/model-shim/from-model/plugins/index.ts +0 -13
- package/src/model-shim/from-model/plugins/utils/convert-attribute.ts +0 -47
- package/src/model-shim/from-model/plugins/utils/convert-cluster-children.ts +0 -44
- package/src/model-shim/from-model/plugins/utils/convert-comment.ts +0 -16
- package/src/model-shim/from-model/plugins/utils/index.ts +0 -3
- package/src/model-shim/from-model/types.ts +0 -62
- package/src/model-shim/index.ts +0 -2
- package/src/model-shim/to-model/converter.ts +0 -42
- package/src/model-shim/to-model/index.ts +0 -3
- package/src/model-shim/to-model/plugins/DotPlugin.ts +0 -25
- package/src/model-shim/to-model/plugins/EdgePlugin.ts +0 -26
- package/src/model-shim/to-model/plugins/GraphPlugin.ts +0 -15
- package/src/model-shim/to-model/plugins/NodePlugin.ts +0 -25
- package/src/model-shim/to-model/plugins/SubgraphPlugin.ts +0 -14
- package/src/model-shim/to-model/plugins/index.ts +0 -13
- package/src/model-shim/to-model/plugins/utils/apply-statments.ts +0 -96
- package/src/model-shim/to-model/plugins/utils/comment-holder.ts +0 -31
- package/src/model-shim/to-model/plugins/utils/convert-to-edge-target-tuple.ts +0 -21
- package/src/model-shim/to-model/to-model.test.ts +0 -34
- package/src/model-shim/to-model/to-model.ts +0 -16
- package/src/model-shim/to-model/types.ts +0 -71
- package/src/types.ts +0 -370
- package/tsconfig.json +0 -8
- package/typedoc.json +0 -4
- package/vite.config.ts +0 -22
package/src/types.ts
DELETED
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
import type { ASTType, AttributeKey, Compass } from '@ts-graphviz/common';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The FilePosition interface represents the position of a file in terms of its offset, line number, and column number.
|
|
5
|
-
*
|
|
6
|
-
* @group AST
|
|
7
|
-
*/
|
|
8
|
-
export interface FilePosition {
|
|
9
|
-
/**
|
|
10
|
-
* The offset of the file.
|
|
11
|
-
*/
|
|
12
|
-
offset: number;
|
|
13
|
-
/**
|
|
14
|
-
* The line number of the file.
|
|
15
|
-
*/
|
|
16
|
-
line: number;
|
|
17
|
-
/**
|
|
18
|
-
* The column number of the file.
|
|
19
|
-
*/
|
|
20
|
-
column: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* FileRange interface represents a range of positions within a file.
|
|
25
|
-
* @group AST
|
|
26
|
-
*/
|
|
27
|
-
export interface FileRange {
|
|
28
|
-
/**
|
|
29
|
-
* The start position of the range.
|
|
30
|
-
*/
|
|
31
|
-
start: FilePosition;
|
|
32
|
-
/**
|
|
33
|
-
* The end position of the range.
|
|
34
|
-
*/
|
|
35
|
-
end: FilePosition;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* This interface provides common properties to be used across all abstract syntax tree (AST) objects.
|
|
40
|
-
*
|
|
41
|
-
* @group AST
|
|
42
|
-
*/
|
|
43
|
-
export interface ASTCommonPropaties {
|
|
44
|
-
/**
|
|
45
|
-
* The start and end location of the AST object.
|
|
46
|
-
*/
|
|
47
|
-
location?: FileRange;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* This interface represents the properties of a dot AST node.
|
|
52
|
-
* @group AST
|
|
53
|
-
*/
|
|
54
|
-
export interface DotASTPropaties extends ASTCommonPropaties {}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* This interface defines the properties of a Graph AST Node.
|
|
58
|
-
* @group AST
|
|
59
|
-
*/
|
|
60
|
-
export interface GraphASTPropaties extends ASTCommonPropaties {
|
|
61
|
-
/**
|
|
62
|
-
* An optional identifier for the Graph AST Node.
|
|
63
|
-
*/
|
|
64
|
-
id?: LiteralASTNode;
|
|
65
|
-
/**
|
|
66
|
-
* A boolean indicating whether the graph is directed.
|
|
67
|
-
*/
|
|
68
|
-
directed: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* A boolean indicating whether the graph is strict.
|
|
71
|
-
*/
|
|
72
|
-
strict: boolean;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* LiteralASTPropaties defines interface for literal AST nodes.
|
|
77
|
-
*
|
|
78
|
-
* @group AST
|
|
79
|
-
*/
|
|
80
|
-
export interface LiteralASTPropaties<T extends string = string>
|
|
81
|
-
extends ASTCommonPropaties {
|
|
82
|
-
/**
|
|
83
|
-
* The value of the literal.
|
|
84
|
-
*/
|
|
85
|
-
value: T;
|
|
86
|
-
/**
|
|
87
|
-
* A flag indicating whether the literal was quoted or not.
|
|
88
|
-
* If 'html' then the literal is an html like value.
|
|
89
|
-
*/
|
|
90
|
-
quoted: boolean | 'html';
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* SubgraphASTPropaties describes the properties of an AST node representing a subgraph.
|
|
95
|
-
* @group AST
|
|
96
|
-
*/
|
|
97
|
-
export interface SubgraphASTPropaties extends ASTCommonPropaties {
|
|
98
|
-
/**
|
|
99
|
-
* id is an optional {@link LiteralASTNode} that represents the identifier of the subgraph.
|
|
100
|
-
*/
|
|
101
|
-
id?: LiteralASTNode;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* SubgraphASTPropaties describes the properties of an AST node representing a node.
|
|
106
|
-
* @group AST
|
|
107
|
-
*/
|
|
108
|
-
export interface NodeASTPropaties extends ASTCommonPropaties {
|
|
109
|
-
/**
|
|
110
|
-
* The unique identifier of the node.
|
|
111
|
-
*/
|
|
112
|
-
id: LiteralASTNode;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* EdgeASTPropaties is an interface that defines the properties of an {@link EdgeASTNode}.
|
|
117
|
-
* @group AST
|
|
118
|
-
*/
|
|
119
|
-
export interface EdgeASTPropaties extends ASTCommonPropaties {
|
|
120
|
-
/**
|
|
121
|
-
* An array of EdgeTargetASTNodes.
|
|
122
|
-
* The {@link EdgeTargetASTNode} represents a node that is the target of an edge.
|
|
123
|
-
*/
|
|
124
|
-
targets: [
|
|
125
|
-
from: EdgeTargetASTNode,
|
|
126
|
-
to: EdgeTargetASTNode,
|
|
127
|
-
...rest: EdgeTargetASTNode[],
|
|
128
|
-
];
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* NodeRefASTPropaties is an interface that defines the properties of a {@link NodeRefASTNode}.
|
|
133
|
-
* @group AST
|
|
134
|
-
*/
|
|
135
|
-
export interface NodeRefASTPropaties extends ASTCommonPropaties {
|
|
136
|
-
id: LiteralASTNode;
|
|
137
|
-
port?: LiteralASTNode;
|
|
138
|
-
compass?: LiteralASTNode<Compass>;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* NodeRefGroupASTPropaties is an interface that defines the properties of a {@link NodeRefGroupASTNode}.
|
|
143
|
-
* @group AST
|
|
144
|
-
*/
|
|
145
|
-
export interface NodeRefGroupASTPropaties extends ASTCommonPropaties {}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* AttributeASTPropaties interface defines the properties of an {@link AttributeASTNode}.
|
|
149
|
-
* @group AST
|
|
150
|
-
*/
|
|
151
|
-
export interface AttributeASTPropaties<T extends AttributeKey = AttributeKey>
|
|
152
|
-
extends ASTCommonPropaties {
|
|
153
|
-
key: LiteralASTNode<T>;
|
|
154
|
-
value: LiteralASTNode;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* AttributeListASTPropaties interface defines the properties of an {@link AttributeListASTNode}.
|
|
159
|
-
* @group AST
|
|
160
|
-
*/
|
|
161
|
-
export interface AttributeListASTPropaties extends ASTCommonPropaties {
|
|
162
|
-
kind: 'Graph' | 'Edge' | 'Node';
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* CommentKind is an enum type that describes a type of comment.
|
|
167
|
-
*
|
|
168
|
-
* @group AST
|
|
169
|
-
*/
|
|
170
|
-
export type CommentKind = 'Block' | 'Slash' | 'Macro';
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* @group AST
|
|
174
|
-
*/
|
|
175
|
-
export interface CommentASTPropaties extends ASTCommonPropaties {
|
|
176
|
-
/**
|
|
177
|
-
* A string that specifies the kind of comment.
|
|
178
|
-
*/
|
|
179
|
-
kind: CommentKind;
|
|
180
|
-
/**
|
|
181
|
-
* A string that contains the actual content of the comment.
|
|
182
|
-
*/
|
|
183
|
-
value: string;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* ASTBaseNode is an interface that serves as the base for all AST nodes.
|
|
188
|
-
* It requires all leaf interfaces to specify a type property,
|
|
189
|
-
* which is of type {@link ASTType}.
|
|
190
|
-
*
|
|
191
|
-
* @group AST
|
|
192
|
-
*/
|
|
193
|
-
export interface ASTBaseNode {
|
|
194
|
-
/**
|
|
195
|
-
* Every leaf interface that extends ASTBaseNode
|
|
196
|
-
* must specify a type property.
|
|
197
|
-
*/
|
|
198
|
-
type: ASTType;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* ASTBaseParentNode represents a parent node that has some child nodes.
|
|
203
|
-
*
|
|
204
|
-
* @template STMT The type of {@link ASTBaseNode} to be stored in the children array.
|
|
205
|
-
* @group AST
|
|
206
|
-
*/
|
|
207
|
-
export interface ASTBaseParentNode<STMT extends ASTBaseNode = ASTBaseNode>
|
|
208
|
-
extends ASTBaseNode {
|
|
209
|
-
children: STMT[];
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* LiteralASTNode is a type of AST node that represents a literal value.
|
|
214
|
-
*
|
|
215
|
-
* @group AST
|
|
216
|
-
*/
|
|
217
|
-
export interface LiteralASTNode<T extends string = string>
|
|
218
|
-
extends ASTBaseParentNode<never>,
|
|
219
|
-
LiteralASTPropaties<T> {
|
|
220
|
-
type: 'Literal';
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* DotASTNode is a type of AST node that represents a dot in a graph.
|
|
225
|
-
*
|
|
226
|
-
* @group AST
|
|
227
|
-
*/
|
|
228
|
-
export interface DotASTNode
|
|
229
|
-
extends ASTBaseParentNode<StatementASTNode>,
|
|
230
|
-
DotASTPropaties {
|
|
231
|
-
type: 'Dot';
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* GraphASTNode is a type of AST node that represents a graph.
|
|
236
|
-
*
|
|
237
|
-
* @group AST
|
|
238
|
-
*/
|
|
239
|
-
export interface GraphASTNode
|
|
240
|
-
extends ASTBaseParentNode<ClusterStatementASTNode>,
|
|
241
|
-
GraphASTPropaties {
|
|
242
|
-
type: 'Graph';
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* AttributeASTNode is a type of AST node that represents an attribute.
|
|
247
|
-
* @group AST
|
|
248
|
-
*/
|
|
249
|
-
export interface AttributeASTNode<T extends AttributeKey = AttributeKey>
|
|
250
|
-
extends ASTBaseParentNode<never>,
|
|
251
|
-
AttributeASTPropaties<T> {
|
|
252
|
-
type: 'Attribute';
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* CommentASTNode is a type of AST node that represents a comment.
|
|
257
|
-
* @group AST
|
|
258
|
-
*/
|
|
259
|
-
export interface CommentASTNode
|
|
260
|
-
extends ASTBaseParentNode<never>,
|
|
261
|
-
CommentASTPropaties {
|
|
262
|
-
type: 'Comment';
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* AttributeListASTNode is a type of AST node that represents a list of attributes.
|
|
267
|
-
* @group AST
|
|
268
|
-
*/
|
|
269
|
-
export interface AttributeListASTNode
|
|
270
|
-
extends ASTBaseParentNode<AttributeASTNode | CommentASTNode>,
|
|
271
|
-
AttributeListASTPropaties {
|
|
272
|
-
type: 'AttributeList';
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* NodeRefASTNode is a type of AST node that represents a reference to a node.
|
|
277
|
-
* @group AST
|
|
278
|
-
*/
|
|
279
|
-
export interface NodeRefASTNode
|
|
280
|
-
extends ASTBaseParentNode<never>,
|
|
281
|
-
NodeRefASTPropaties {
|
|
282
|
-
type: 'NodeRef';
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* NodeRefGroupASTNode is a type of AST node that represents a group of nodes referenced together.
|
|
287
|
-
* @group AST
|
|
288
|
-
*/
|
|
289
|
-
export interface NodeRefGroupASTNode
|
|
290
|
-
extends ASTBaseParentNode<NodeRefASTNode>,
|
|
291
|
-
NodeRefGroupASTPropaties {
|
|
292
|
-
type: 'NodeRefGroup';
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* This type is used to represent a target of an edge in an AST (Abstract Syntax Tree).
|
|
297
|
-
*
|
|
298
|
-
* @group AST
|
|
299
|
-
*/
|
|
300
|
-
export type EdgeTargetASTNode = NodeRefASTNode | NodeRefGroupASTNode;
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* EdgeASTNode is a type of AST node that represents an edge in a graph.
|
|
304
|
-
* @group AST
|
|
305
|
-
*/
|
|
306
|
-
export interface EdgeASTNode
|
|
307
|
-
extends ASTBaseParentNode<AttributeASTNode | CommentASTNode>,
|
|
308
|
-
EdgeASTPropaties {
|
|
309
|
-
type: 'Edge';
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* NodeASTNode is a type of AST node that represents a node in a graph.
|
|
314
|
-
* @group AST
|
|
315
|
-
*/
|
|
316
|
-
export interface NodeASTNode
|
|
317
|
-
extends ASTBaseParentNode<AttributeASTNode | CommentASTNode>,
|
|
318
|
-
NodeASTPropaties {
|
|
319
|
-
type: 'Node';
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* SubgraphASTNode is a type of AST node that represents a subgraph.
|
|
324
|
-
* @group AST
|
|
325
|
-
*/
|
|
326
|
-
export interface SubgraphASTNode
|
|
327
|
-
extends ASTBaseParentNode<ClusterStatementASTNode>,
|
|
328
|
-
SubgraphASTPropaties {
|
|
329
|
-
type: 'Subgraph';
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* @group AST
|
|
333
|
-
*/
|
|
334
|
-
export type StatementASTNode = GraphASTNode | CommentASTNode;
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* ClusterStatementASTNode is a type used to represent a statement in a cluster graph.
|
|
338
|
-
* @group AST
|
|
339
|
-
*/
|
|
340
|
-
export type ClusterStatementASTNode =
|
|
341
|
-
| AttributeASTNode
|
|
342
|
-
| AttributeListASTNode
|
|
343
|
-
| EdgeASTNode
|
|
344
|
-
| NodeASTNode
|
|
345
|
-
| SubgraphASTNode
|
|
346
|
-
| CommentASTNode;
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* ASTNode is a type used to define a set of different types of AST nodes that can be used in a graph.
|
|
350
|
-
*
|
|
351
|
-
* @group AST
|
|
352
|
-
*/
|
|
353
|
-
export type ASTNode =
|
|
354
|
-
| LiteralASTNode
|
|
355
|
-
| DotASTNode
|
|
356
|
-
| GraphASTNode
|
|
357
|
-
| AttributeASTNode
|
|
358
|
-
| CommentASTNode
|
|
359
|
-
| AttributeListASTNode
|
|
360
|
-
| NodeRefASTNode
|
|
361
|
-
| NodeRefGroupASTNode
|
|
362
|
-
| EdgeASTNode
|
|
363
|
-
| NodeASTNode
|
|
364
|
-
| SubgraphASTNode;
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* ASTChildNode is a type alias used to represent the child nodes of a given {@link ASTBaseParentNode}.
|
|
368
|
-
* @group AST
|
|
369
|
-
*/
|
|
370
|
-
export type ASTChildNode<T> = T extends ASTBaseParentNode<infer C> ? C : never;
|
package/tsconfig.json
DELETED
package/typedoc.json
DELETED
package/vite.config.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import dts from 'vite-plugin-dts';
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
build: {
|
|
6
|
-
outDir: './lib',
|
|
7
|
-
minify: false,
|
|
8
|
-
lib: {
|
|
9
|
-
entry: './src/ast.ts',
|
|
10
|
-
formats: ['es', 'cjs'],
|
|
11
|
-
fileName: 'ast',
|
|
12
|
-
},
|
|
13
|
-
rollupOptions: {
|
|
14
|
-
external: ['@ts-graphviz/common'],
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
plugins: [
|
|
18
|
-
dts({
|
|
19
|
-
rollupTypes: true,
|
|
20
|
-
}),
|
|
21
|
-
],
|
|
22
|
-
});
|