@ts-graphviz/core 0.0.0-pr956-20240225073457
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 +13 -0
- package/LICENSE +22 -0
- package/README.md +47 -0
- package/lib/core.cjs +397 -0
- package/lib/core.d.ts +323 -0
- package/lib/core.js +397 -0
- package/package.json +37 -0
- package/src/attribute.ts +18 -0
- package/src/core.ts +5 -0
- package/src/from-dot.ts +73 -0
- package/src/model-factory/index.ts +2 -0
- package/src/model-factory/model-factory-builder.test.ts +79 -0
- package/src/model-factory/model-factory-builder.ts +55 -0
- package/src/model-factory/model-factory.test.ts +61 -0
- package/src/model-factory/model-factory.ts +40 -0
- package/src/model-factory/types.ts +46 -0
- package/src/models/AttributeList.spec.ts +58 -0
- package/src/models/AttributeList.ts +32 -0
- package/src/models/AttributesBase.spec.ts +79 -0
- package/src/models/AttributesBase.ts +62 -0
- package/src/models/AttributesGroup.spec.ts +18 -0
- package/src/models/AttributesGroup.ts +13 -0
- package/src/models/Digraph.spec.ts +17 -0
- package/src/models/Digraph.ts +11 -0
- package/src/models/DotObject.ts +5 -0
- package/src/models/Edge.spec.ts +48 -0
- package/src/models/Edge.ts +40 -0
- package/src/models/Graph.spec.ts +18 -0
- package/src/models/Graph.ts +11 -0
- package/src/models/GraphBase.spec.ts +364 -0
- package/src/models/GraphBase.ts +263 -0
- package/src/models/Node.spec.ts +25 -0
- package/src/models/Node.ts +37 -0
- package/src/models/RootGraph.spec.ts +69 -0
- package/src/models/RootGraph.ts +48 -0
- package/src/models/Subgraph.spec.ts +196 -0
- package/src/models/Subgraph.ts +44 -0
- package/src/models/index.ts +15 -0
- package/src/models/registerModelContext.ts +14 -0
- package/src/to-dot.ts +36 -0
- package/tsconfig.json +8 -0
- package/typedoc.json +4 -0
- package/vite.config.ts +22 -0
package/lib/core.d.ts
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { Attribute } from '@ts-graphviz/common';
|
|
2
|
+
import { AttributeKey } from '@ts-graphviz/common';
|
|
3
|
+
import { AttributeListKind } from '@ts-graphviz/common';
|
|
4
|
+
import { AttributeListModel } from '@ts-graphviz/common';
|
|
5
|
+
import { Attributes } from '@ts-graphviz/common';
|
|
6
|
+
import { AttributesEntities } from '@ts-graphviz/common';
|
|
7
|
+
import { AttributesGroupModel } from '@ts-graphviz/common';
|
|
8
|
+
import { AttributesObject } from '@ts-graphviz/common';
|
|
9
|
+
import { ClusterSubgraphAttributeKey } from '@ts-graphviz/common';
|
|
10
|
+
import { ConvertFromModelOptions } from '@ts-graphviz/ast';
|
|
11
|
+
import { ConvertToModelOptions } from '@ts-graphviz/ast';
|
|
12
|
+
import { DotObjectModel } from '@ts-graphviz/common';
|
|
13
|
+
import { EdgeAttributeKey } from '@ts-graphviz/common';
|
|
14
|
+
import { EdgeAttributesObject } from '@ts-graphviz/common';
|
|
15
|
+
import { EdgeModel } from '@ts-graphviz/common';
|
|
16
|
+
import { EdgeTargetLikeTuple } from '@ts-graphviz/common';
|
|
17
|
+
import { EdgeTargetTuple } from '@ts-graphviz/common';
|
|
18
|
+
import { ForwardRefNode } from '@ts-graphviz/common';
|
|
19
|
+
import { GraphAttributeKey } from '@ts-graphviz/common';
|
|
20
|
+
import { GraphAttributesObject } from '@ts-graphviz/common';
|
|
21
|
+
import { GraphBaseModel } from '@ts-graphviz/common';
|
|
22
|
+
import { GraphCommonAttributes } from '@ts-graphviz/common';
|
|
23
|
+
import { ModelsContext } from '@ts-graphviz/common';
|
|
24
|
+
import { NodeAttributeKey } from '@ts-graphviz/common';
|
|
25
|
+
import { NodeAttributesObject } from '@ts-graphviz/common';
|
|
26
|
+
import { NodeModel } from '@ts-graphviz/common';
|
|
27
|
+
import { ParseOptions } from '@ts-graphviz/ast';
|
|
28
|
+
import { Port } from '@ts-graphviz/common';
|
|
29
|
+
import { PrintOptions } from '@ts-graphviz/ast';
|
|
30
|
+
import { RootGraphModel } from '@ts-graphviz/common';
|
|
31
|
+
import { SubgraphAttributeKey } from '@ts-graphviz/common';
|
|
32
|
+
import { SubgraphAttributesObject } from '@ts-graphviz/common';
|
|
33
|
+
import { SubgraphModel } from '@ts-graphviz/common';
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @group Attribute
|
|
37
|
+
*/
|
|
38
|
+
export declare const attribute: Attribute.keys;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @group Attribute
|
|
42
|
+
*
|
|
43
|
+
* @deprecated Use {@link Attribute.keys} instead.
|
|
44
|
+
*/
|
|
45
|
+
export declare type AttributeKeyDict = Attribute.keys;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A set of attribute values for any object.
|
|
49
|
+
* @group Models
|
|
50
|
+
*/
|
|
51
|
+
export declare class AttributeList<K extends AttributeListKind, T extends AttributeKey = AttributeKey> extends AttributesBase<T> implements AttributeListModel<K, T> {
|
|
52
|
+
readonly $$kind: K;
|
|
53
|
+
get $$type(): 'AttributeList';
|
|
54
|
+
comment?: string;
|
|
55
|
+
constructor($$kind: K, attributes?: AttributesObject<T>);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Base class for DOT objects with attributes.
|
|
60
|
+
* @group Models
|
|
61
|
+
*/
|
|
62
|
+
export declare abstract class AttributesBase<T extends AttributeKey> extends DotObject implements Attributes<T> {
|
|
63
|
+
#private;
|
|
64
|
+
constructor(attributes?: AttributesObject<T>);
|
|
65
|
+
get values(): ReadonlyArray<[T, Attribute<T>]>;
|
|
66
|
+
get size(): number;
|
|
67
|
+
get<K extends T>(key: K): Attribute<K> | undefined;
|
|
68
|
+
set<K extends T>(key: K, value: Attribute<K>): void;
|
|
69
|
+
delete(key: T): void;
|
|
70
|
+
apply(attributes: AttributesObject<T> | AttributesEntities<T>): void;
|
|
71
|
+
clear(): void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A set of attribute values for any object.
|
|
76
|
+
* @group Models
|
|
77
|
+
*/
|
|
78
|
+
export declare class AttributesGroup<T extends AttributeKey = AttributeKey> extends AttributesBase<T> implements AttributesGroupModel<T> {
|
|
79
|
+
comment?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* DOT object class representing a digraph.
|
|
84
|
+
* @group Models
|
|
85
|
+
*/
|
|
86
|
+
export declare class Digraph extends RootGraph {
|
|
87
|
+
get directed(): boolean;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* digraph is a factory for creating Digraph objects.
|
|
92
|
+
* @group Model Factory
|
|
93
|
+
*/
|
|
94
|
+
export declare const digraph: ModelFactory;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Base class for DOT objects.
|
|
98
|
+
* @group Models
|
|
99
|
+
*/
|
|
100
|
+
export declare abstract class DotObject {
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* DOT object class representing a edge.
|
|
105
|
+
* @group Models
|
|
106
|
+
*/
|
|
107
|
+
export declare class Edge extends DotObject implements EdgeModel {
|
|
108
|
+
readonly targets: EdgeTargetTuple;
|
|
109
|
+
get $$type(): 'Edge';
|
|
110
|
+
comment?: string;
|
|
111
|
+
readonly attributes: AttributesGroupModel<EdgeAttributeKey>;
|
|
112
|
+
constructor(targets: EdgeTargetTuple, attributes?: EdgeAttributesObject);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* fromDot is a function that converts a DOT string to a model.
|
|
117
|
+
*
|
|
118
|
+
* @group Convert DOT to Model
|
|
119
|
+
*
|
|
120
|
+
* @param dot The DOT string to convert.
|
|
121
|
+
* @param options Options for converting the DOT string to a model.
|
|
122
|
+
* @returns A model of type {@link RootGraphModel}, {@link NodeModel}, {@link EdgeModel}, or {@link SubgraphModel},
|
|
123
|
+
* depending on the type specified in the options.
|
|
124
|
+
*/
|
|
125
|
+
export declare function fromDot(dot: string, options?: FromDotOptions<'Dot' | 'Graph'>): RootGraphModel;
|
|
126
|
+
|
|
127
|
+
export declare function fromDot(dot: string, options?: FromDotOptions<'Node'>): NodeModel;
|
|
128
|
+
|
|
129
|
+
export declare function fromDot(dot: string, options?: FromDotOptions<'Edge'>): EdgeModel;
|
|
130
|
+
|
|
131
|
+
export declare function fromDot(dot: string, options?: FromDotOptions<'Subgraph'>): SubgraphModel;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* This interface provides options for converting DOT to a model.
|
|
135
|
+
* @group Convert DOT to Model
|
|
136
|
+
*/
|
|
137
|
+
export declare interface FromDotOptions<T extends 'Dot' | 'Graph' | 'Node' | 'Edge' | 'Subgraph'> {
|
|
138
|
+
/**
|
|
139
|
+
* Options for parsing DOT.
|
|
140
|
+
*/
|
|
141
|
+
parse?: ParseOptions<T>;
|
|
142
|
+
/**
|
|
143
|
+
* Options for converting the parsed DOT to a model.
|
|
144
|
+
*/
|
|
145
|
+
convert?: ConvertToModelOptions;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* DOT object class representing a graph.
|
|
150
|
+
* @group Models
|
|
151
|
+
*/
|
|
152
|
+
export declare class Graph extends RootGraph {
|
|
153
|
+
get directed(): boolean;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* graph is a factory for creating Graph objects.
|
|
158
|
+
* @group Model Factory
|
|
159
|
+
*/
|
|
160
|
+
export declare const graph: ModelFactory;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Base class for Graph objects.
|
|
164
|
+
* @group Models
|
|
165
|
+
*/
|
|
166
|
+
export declare abstract class GraphBase<T extends AttributeKey> extends AttributesBase<T> implements GraphBaseModel<T> {
|
|
167
|
+
#private;
|
|
168
|
+
readonly id?: string;
|
|
169
|
+
comment?: string;
|
|
170
|
+
readonly attributes: Readonly<GraphCommonAttributes>;
|
|
171
|
+
get nodes(): ReadonlyArray<NodeModel>;
|
|
172
|
+
get edges(): ReadonlyArray<EdgeModel>;
|
|
173
|
+
get subgraphs(): ReadonlyArray<SubgraphModel>;
|
|
174
|
+
with(models: Partial<ModelsContext>): void;
|
|
175
|
+
addNode(node: NodeModel): void;
|
|
176
|
+
addEdge(edge: EdgeModel): void;
|
|
177
|
+
addSubgraph(subgraph: SubgraphModel): void;
|
|
178
|
+
existNode(nodeId: string): boolean;
|
|
179
|
+
existEdge(edge: EdgeModel): boolean;
|
|
180
|
+
existSubgraph(subgraph: SubgraphModel): boolean;
|
|
181
|
+
createSubgraph(id?: string, attributes?: SubgraphAttributesObject): SubgraphModel;
|
|
182
|
+
createSubgraph(attributes?: SubgraphAttributesObject): SubgraphModel;
|
|
183
|
+
removeNode(node: NodeModel | string): void;
|
|
184
|
+
removeEdge(edge: EdgeModel): void;
|
|
185
|
+
removeSubgraph(subgraph: SubgraphModel): void;
|
|
186
|
+
createNode(id: string, attributes?: NodeAttributesObject): NodeModel;
|
|
187
|
+
getSubgraph(id: string): SubgraphModel | undefined;
|
|
188
|
+
getNode(id: string): NodeModel | undefined;
|
|
189
|
+
createEdge(targets: EdgeTargetLikeTuple, attributes?: EdgeAttributesObject): EdgeModel;
|
|
190
|
+
subgraph(id: string, callback?: (subgraph: SubgraphModel) => void): SubgraphModel;
|
|
191
|
+
subgraph(id: string, attributes: SubgraphAttributesObject, callback?: (subgraph: SubgraphModel) => void): SubgraphModel;
|
|
192
|
+
subgraph(attributes: SubgraphAttributesObject, callback?: (subgraph: SubgraphModel) => void): SubgraphModel;
|
|
193
|
+
subgraph(callback?: (subgraph: SubgraphModel) => void): SubgraphModel;
|
|
194
|
+
node(id: string, callback?: (node: NodeModel) => void): NodeModel;
|
|
195
|
+
node(id: string, attributes: NodeAttributesObject, callback?: (node: NodeModel) => void): NodeModel;
|
|
196
|
+
node(attributes: NodeAttributesObject): void;
|
|
197
|
+
edge(targets: EdgeTargetLikeTuple, callback?: (edge: EdgeModel) => void): EdgeModel;
|
|
198
|
+
edge(targets: EdgeTargetLikeTuple, attributes: EdgeAttributesObject, callback?: (edge: EdgeModel) => void): EdgeModel;
|
|
199
|
+
edge(attributes: EdgeAttributesObject): void;
|
|
200
|
+
graph(attributes: SubgraphAttributesObject): void;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* @group Model Factory
|
|
205
|
+
*/
|
|
206
|
+
export declare interface ModelFactories {
|
|
207
|
+
/**
|
|
208
|
+
* API for creating directional graph objects.
|
|
209
|
+
*/
|
|
210
|
+
digraph: ModelFactory;
|
|
211
|
+
/**
|
|
212
|
+
* API for creating omnidirectional graph objects.
|
|
213
|
+
*/
|
|
214
|
+
graph: ModelFactory;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @group Model Factory
|
|
219
|
+
*/
|
|
220
|
+
export declare interface ModelFactoriesWithStrict extends ModelFactories {
|
|
221
|
+
strict: ModelFactories;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* ModelFactory is an interface that provides a way to create a {@link RootGraphModel} object.
|
|
226
|
+
*
|
|
227
|
+
* @param id - Optional string parameter that specifies the id of the {@link RootGraphModel} object.
|
|
228
|
+
* @param attributes - Optional GraphAttributesObject parameter that specifies the attributes of the {@link RootGraphModel} object.
|
|
229
|
+
* @param callback - Optional callback function that takes a {@link RootGraphModel} object as a parameter.
|
|
230
|
+
*
|
|
231
|
+
* @returns {@link RootGraphModel} - Returns a {@link RootGraphModel} object.
|
|
232
|
+
* @group Model Factory
|
|
233
|
+
*/
|
|
234
|
+
export declare interface ModelFactory {
|
|
235
|
+
(id?: string, attributes?: GraphAttributesObject, callback?: (g: RootGraphModel) => void): RootGraphModel;
|
|
236
|
+
(attributes?: GraphAttributesObject, callback?: (g: RootGraphModel) => void): RootGraphModel;
|
|
237
|
+
(id?: string, callback?: (g: RootGraphModel) => void): RootGraphModel;
|
|
238
|
+
(callback?: (g: RootGraphModel) => void): RootGraphModel;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* DOT object class representing a node.
|
|
243
|
+
* @group Models
|
|
244
|
+
*/
|
|
245
|
+
declare class Node_2 extends DotObject implements NodeModel {
|
|
246
|
+
readonly id: string;
|
|
247
|
+
get $$type(): 'Node';
|
|
248
|
+
comment?: string;
|
|
249
|
+
readonly attributes: AttributesGroup<NodeAttributeKey>;
|
|
250
|
+
constructor(id: string, attributes?: NodeAttributesObject);
|
|
251
|
+
port(port: string | Partial<Port>): ForwardRefNode;
|
|
252
|
+
}
|
|
253
|
+
export { Node_2 as Node }
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Base class representing a root graph(digraph, graph).
|
|
257
|
+
* @group Models
|
|
258
|
+
*/
|
|
259
|
+
export declare abstract class RootGraph extends GraphBase<GraphAttributeKey> implements RootGraphModel {
|
|
260
|
+
get $$type(): 'Graph';
|
|
261
|
+
readonly id?: string;
|
|
262
|
+
abstract readonly directed: boolean;
|
|
263
|
+
strict: boolean;
|
|
264
|
+
constructor(id?: string, attributes?: GraphAttributesObject);
|
|
265
|
+
constructor(id?: string, strict?: boolean, attributes?: GraphAttributesObject);
|
|
266
|
+
constructor(strict?: boolean, attributes?: GraphAttributesObject);
|
|
267
|
+
constructor(attributes?: GraphAttributesObject);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Provides a strict mode API.
|
|
272
|
+
* @group Model Factory
|
|
273
|
+
*/
|
|
274
|
+
export declare const strict: ModelFactories;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* DOT object class representing a subgraph.
|
|
278
|
+
* @group Models
|
|
279
|
+
*/
|
|
280
|
+
export declare class Subgraph extends GraphBase<SubgraphAttributeKey | ClusterSubgraphAttributeKey> implements SubgraphModel {
|
|
281
|
+
get $$type(): 'Subgraph';
|
|
282
|
+
readonly id?: string;
|
|
283
|
+
constructor(id?: string, attributes?: SubgraphAttributesObject);
|
|
284
|
+
constructor(attributes?: SubgraphAttributesObject);
|
|
285
|
+
isSubgraphCluster(): boolean;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Convert Model to DOT string.
|
|
290
|
+
*
|
|
291
|
+
* @group Convert Model to DOT
|
|
292
|
+
*
|
|
293
|
+
* @param model Dot Object Model, like {@link Digraph}, {@link Graph}, {@link Subgraph}, {@link Node}, and {@link Edge}
|
|
294
|
+
* @param options Optional options for the conversion.
|
|
295
|
+
* @returns DOT string
|
|
296
|
+
*/
|
|
297
|
+
export declare function toDot(model: DotObjectModel, options?: ToDotOptions): string;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* This interface provides options for converting a model to DOT.
|
|
301
|
+
* @group Convert Model to DOT
|
|
302
|
+
*/
|
|
303
|
+
export declare interface ToDotOptions {
|
|
304
|
+
/**
|
|
305
|
+
* Options for converting the model to DOT.
|
|
306
|
+
*/
|
|
307
|
+
convert?: ConvertFromModelOptions;
|
|
308
|
+
/**
|
|
309
|
+
* Options for printing DOT.
|
|
310
|
+
*/
|
|
311
|
+
print?: PrintOptions;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* withContext creates a {@link ModelFactoriesWithStrict} object with the given context.
|
|
316
|
+
*
|
|
317
|
+
* @param models - An object containing the models to be used in the context.
|
|
318
|
+
*
|
|
319
|
+
* @returns A ModelFactoriesWithStrict object containing the factories. * @group Model Factory
|
|
320
|
+
*/
|
|
321
|
+
export declare function withContext(models: Partial<ModelsContext>): ModelFactoriesWithStrict;
|
|
322
|
+
|
|
323
|
+
export { }
|