ts-graphviz 1.5.5-dev.bdbba8a60 → 1.5.5
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.md +1 -0
- package/lib/adapter/browser/index.cjs +0 -11
- package/lib/adapter/browser/index.js +0 -11
- package/lib/adapter/deno/mod.js +2 -2
- package/lib/adapter/node/index.cjs +1 -13
- package/lib/adapter/node/index.js +2 -14
- package/lib/adapter/types/index.d.ts +15 -0
- package/lib/adapter/utils/index.cjs +5 -4
- package/lib/adapter/utils/index.d.ts +8 -2
- package/lib/adapter/utils/index.js +5 -4
- package/lib/ast/index.cjs +0 -47
- package/lib/ast/index.d.ts +328 -17
- package/lib/ast/index.js +0 -47
- package/lib/common/index.cjs +0 -17
- package/lib/common/index.d.ts +13 -0
- package/lib/common/index.js +0 -17
- package/lib/core/index.cjs +0 -75
- package/lib/core/index.d.ts +35 -9
- package/lib/core/index.js +0 -75
- package/package.json +120 -120
package/lib/ast/index.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { pipe, map } from '../utils/index.js';
|
|
2
2
|
import { isNodeModel, isForwardRefNode, createModelsContext } from '../common/index.js';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* @group Create AST
|
|
6
|
-
*/
|
|
7
4
|
class Builder {
|
|
8
5
|
options;
|
|
9
|
-
/** @internal */
|
|
10
6
|
getLocation() {
|
|
11
7
|
return this.options?.locationFunction?.() ?? null;
|
|
12
8
|
}
|
|
13
9
|
constructor(options) {
|
|
14
10
|
this.options = options;
|
|
15
11
|
}
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
12
|
createElement(type, props, children) {
|
|
18
13
|
return {
|
|
19
14
|
...props,
|
|
@@ -24,9 +19,6 @@ class Builder {
|
|
|
24
19
|
}
|
|
25
20
|
}
|
|
26
21
|
|
|
27
|
-
/**
|
|
28
|
-
* @group Create AST
|
|
29
|
-
*/
|
|
30
22
|
const createElement = Builder.prototype.createElement.bind(new Builder());
|
|
31
23
|
|
|
32
24
|
const EOL = /\r?\n/;
|
|
@@ -258,12 +250,8 @@ const defaultPlugins$2 = [
|
|
|
258
250
|
SubgraphPrintPlugin,
|
|
259
251
|
];
|
|
260
252
|
|
|
261
|
-
/**
|
|
262
|
-
* @group Convert AST to DOT
|
|
263
|
-
*/
|
|
264
253
|
class Printer {
|
|
265
254
|
options;
|
|
266
|
-
/** @internal */
|
|
267
255
|
#plugins = [...defaultPlugins$2];
|
|
268
256
|
constructor(options = {}) {
|
|
269
257
|
this.options = options;
|
|
@@ -289,13 +277,6 @@ class Printer {
|
|
|
289
277
|
}
|
|
290
278
|
}
|
|
291
279
|
|
|
292
|
-
/**
|
|
293
|
-
* Stringify Graphviz AST Node.
|
|
294
|
-
*
|
|
295
|
-
* @param ast Graphviz AST node.
|
|
296
|
-
* @returns DOT language string.
|
|
297
|
-
* @group Convert AST to DOT
|
|
298
|
-
*/
|
|
299
280
|
function stringify(ast, options) {
|
|
300
281
|
const result = new Printer(options).print(ast);
|
|
301
282
|
if (!result) {
|
|
@@ -304,7 +285,6 @@ function stringify(ast, options) {
|
|
|
304
285
|
return result;
|
|
305
286
|
}
|
|
306
287
|
|
|
307
|
-
/* eslint-disable */
|
|
308
288
|
function peg$padEnd(str, targetLength, padString) {
|
|
309
289
|
padString = padString || ' ';
|
|
310
290
|
if (str.length > targetLength) {
|
|
@@ -534,9 +514,7 @@ function peg$parse(input, options) {
|
|
|
534
514
|
);
|
|
535
515
|
};
|
|
536
516
|
const peg$c21 = function (id, rhs, _children) {
|
|
537
|
-
// @ts-ignore
|
|
538
517
|
return b.createElement(
|
|
539
|
-
// @ts-ignore
|
|
540
518
|
'Edge',
|
|
541
519
|
{
|
|
542
520
|
targets: [id, ...rhs],
|
|
@@ -5247,9 +5225,6 @@ const parse$1 = peg$parse;
|
|
|
5247
5225
|
function parse(input, options) {
|
|
5248
5226
|
return parse$1(input, options);
|
|
5249
5227
|
}
|
|
5250
|
-
/**
|
|
5251
|
-
* @group Convert DOT to AST
|
|
5252
|
-
*/
|
|
5253
5228
|
const DotSyntaxError = DotSyntaxError$1;
|
|
5254
5229
|
|
|
5255
5230
|
function convertAttribute(key, value) {
|
|
@@ -5555,12 +5530,8 @@ const SubgraphPlugin$1 = {
|
|
|
5555
5530
|
|
|
5556
5531
|
const defaultPlugins$1 = [AttributeListPlugin, EdgePlugin$1, NodePlugin$1, GraphPlugin$1, SubgraphPlugin$1];
|
|
5557
5532
|
|
|
5558
|
-
/**
|
|
5559
|
-
* @group Convert Model to AST
|
|
5560
|
-
*/
|
|
5561
5533
|
class FromModelConverter {
|
|
5562
5534
|
options;
|
|
5563
|
-
/** @hidden */
|
|
5564
5535
|
#plugins = [...defaultPlugins$1];
|
|
5565
5536
|
constructor(options = {}) {
|
|
5566
5537
|
this.options = options;
|
|
@@ -5583,9 +5554,6 @@ class FromModelConverter {
|
|
|
5583
5554
|
}
|
|
5584
5555
|
}
|
|
5585
5556
|
|
|
5586
|
-
/**
|
|
5587
|
-
* @group Convert Model to AST
|
|
5588
|
-
*/
|
|
5589
5557
|
function fromModel(model, options) {
|
|
5590
5558
|
return new FromModelConverter(options).convert(model);
|
|
5591
5559
|
}
|
|
@@ -5761,23 +5729,12 @@ const NodePlugin = {
|
|
|
5761
5729
|
|
|
5762
5730
|
const defaultPlugins = [NodePlugin, EdgePlugin, SubgraphPlugin, GraphPlugin, DotPlugin];
|
|
5763
5731
|
|
|
5764
|
-
/**
|
|
5765
|
-
* @group Convert AST to Model
|
|
5766
|
-
* @alpha
|
|
5767
|
-
*/
|
|
5768
5732
|
class ToModelConverter {
|
|
5769
5733
|
options;
|
|
5770
|
-
/** @hidden */
|
|
5771
5734
|
plugins = [...defaultPlugins];
|
|
5772
5735
|
constructor(options = {}) {
|
|
5773
5736
|
this.options = options;
|
|
5774
5737
|
}
|
|
5775
|
-
/**
|
|
5776
|
-
* Convert AST to Model.
|
|
5777
|
-
*
|
|
5778
|
-
* @param ast AST node.
|
|
5779
|
-
* @alpha
|
|
5780
|
-
*/
|
|
5781
5738
|
convert(ast) {
|
|
5782
5739
|
const plugins = [...this.plugins];
|
|
5783
5740
|
const context = {
|
|
@@ -5795,10 +5752,6 @@ class ToModelConverter {
|
|
|
5795
5752
|
}
|
|
5796
5753
|
}
|
|
5797
5754
|
|
|
5798
|
-
/**
|
|
5799
|
-
* @group Convert AST to Model
|
|
5800
|
-
* @beta
|
|
5801
|
-
*/
|
|
5802
5755
|
function toModel(ast, options) {
|
|
5803
5756
|
return new ToModelConverter(options).convert(ast);
|
|
5804
5757
|
}
|
package/lib/common/index.cjs
CHANGED
|
@@ -1,30 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
/** @hidden */
|
|
4
3
|
function isForwardRefNode(object) {
|
|
5
4
|
return typeof object === 'object' && object !== null && typeof object.id === 'string';
|
|
6
5
|
}
|
|
7
|
-
/** @hidden */
|
|
8
6
|
function isNodeModel(object) {
|
|
9
7
|
return typeof object === 'object' && object !== null && object.$$type === 'Node' && typeof object.id === 'string';
|
|
10
8
|
}
|
|
11
|
-
/** @hidden */
|
|
12
9
|
function isNodeRef(node) {
|
|
13
10
|
return isNodeModel(node) || isForwardRefNode(node);
|
|
14
11
|
}
|
|
15
|
-
/** @hidden */
|
|
16
12
|
function isNodeRefLike(node) {
|
|
17
13
|
return typeof node === 'string' || isNodeRef(node);
|
|
18
14
|
}
|
|
19
|
-
/** @hidden */
|
|
20
15
|
function isNodeRefGroupLike(target) {
|
|
21
16
|
return Array.isArray(target) && target.every(isNodeRefLike);
|
|
22
17
|
}
|
|
23
|
-
/** @hidden */
|
|
24
18
|
function isCompass(c) {
|
|
25
19
|
return ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'c'].includes(c);
|
|
26
20
|
}
|
|
27
|
-
/** @hidden */
|
|
28
21
|
function toNodeRef(target) {
|
|
29
22
|
if (isNodeRef(target)) {
|
|
30
23
|
return target;
|
|
@@ -35,7 +28,6 @@ function toNodeRef(target) {
|
|
|
35
28
|
}
|
|
36
29
|
return { id, port };
|
|
37
30
|
}
|
|
38
|
-
/** @hidden */
|
|
39
31
|
function toNodeRefGroup(targets) {
|
|
40
32
|
if (targets.length < 2 && (isNodeRefLike(targets[0]) && isNodeRefLike(targets[1])) === false) {
|
|
41
33
|
throw Error('EdgeTargets must have at least 2 elements.');
|
|
@@ -43,22 +35,13 @@ function toNodeRefGroup(targets) {
|
|
|
43
35
|
return targets.map((t) => toNodeRef(t));
|
|
44
36
|
}
|
|
45
37
|
|
|
46
|
-
/**
|
|
47
|
-
* @group Models Context
|
|
48
|
-
* @alpha
|
|
49
|
-
*/
|
|
50
38
|
const RootModelsContext = Object.seal({
|
|
51
|
-
// NOTE: RootModelsContext is also initialized after the model class is declared in the 'core/index.cjs' module.
|
|
52
39
|
Graph: null,
|
|
53
40
|
Digraph: null,
|
|
54
41
|
Subgraph: null,
|
|
55
42
|
Node: null,
|
|
56
43
|
Edge: null,
|
|
57
44
|
});
|
|
58
|
-
/**
|
|
59
|
-
* @group Models Context
|
|
60
|
-
* @alpha
|
|
61
|
-
*/
|
|
62
45
|
function createModelsContext(models) {
|
|
63
46
|
return Object.assign(Object.seal(Object.assign({}, RootModelsContext)), models);
|
|
64
47
|
}
|
package/lib/common/index.d.ts
CHANGED
|
@@ -1434,6 +1434,9 @@ type AttributeKey =
|
|
|
1434
1434
|
| SubgraphAttributeKey
|
|
1435
1435
|
| ClusterSubgraphAttributeKey;
|
|
1436
1436
|
|
|
1437
|
+
/**
|
|
1438
|
+
* KeyValueMapping is an interface that defines a set of attributes that can be used to configure a graph.
|
|
1439
|
+
*/
|
|
1437
1440
|
interface KeyValueMapping {
|
|
1438
1441
|
_background: string;
|
|
1439
1442
|
area: Double;
|
|
@@ -1609,6 +1612,9 @@ interface KeyValueMapping {
|
|
|
1609
1612
|
z: Blank | Double;
|
|
1610
1613
|
}
|
|
1611
1614
|
/**
|
|
1615
|
+
* This type represents an Attribute, which is a key-value mapping of an {@link AttributeKey} to a value.
|
|
1616
|
+
*
|
|
1617
|
+
* @param T The {@link AttributeKey} to be mapped to a value.
|
|
1612
1618
|
* @group Attribute
|
|
1613
1619
|
*/
|
|
1614
1620
|
type Attribute<T extends AttributeKey> = KeyValueMapping[T];
|
|
@@ -1636,6 +1642,7 @@ declare const RootModelsContext: ModelsContext;
|
|
|
1636
1642
|
declare function createModelsContext(models: Partial<ModelsContext>): ModelsContext;
|
|
1637
1643
|
|
|
1638
1644
|
/**
|
|
1645
|
+
* ASTType is an enumeration of the different types of nodes that can be found in an AST(Abstract Syntax Tree ).
|
|
1639
1646
|
* @group Models
|
|
1640
1647
|
*/
|
|
1641
1648
|
type ASTType =
|
|
@@ -1725,9 +1732,15 @@ type SubgraphAttributesObject = AttributesObject<ClusterSubgraphAttributeKey | S
|
|
|
1725
1732
|
*/
|
|
1726
1733
|
type DotObjectType = 'AttributeList' | 'Node' | 'Edge' | 'Subgraph' | 'Graph';
|
|
1727
1734
|
/**
|
|
1735
|
+
* DotObjectModel is an interface that defines a generic type for a {@link DotObjectType}.
|
|
1736
|
+
*
|
|
1737
|
+
* @template T The type of the {@link DotObjectType}.
|
|
1728
1738
|
* @group Models
|
|
1729
1739
|
*/
|
|
1730
1740
|
interface DotObjectModel<T extends DotObjectType = DotObjectType> {
|
|
1741
|
+
/**
|
|
1742
|
+
* The type of the DotObjectType.
|
|
1743
|
+
*/
|
|
1731
1744
|
$$type: T;
|
|
1732
1745
|
}
|
|
1733
1746
|
/**
|
package/lib/common/index.js
CHANGED
|
@@ -1,28 +1,21 @@
|
|
|
1
|
-
/** @hidden */
|
|
2
1
|
function isForwardRefNode(object) {
|
|
3
2
|
return typeof object === 'object' && object !== null && typeof object.id === 'string';
|
|
4
3
|
}
|
|
5
|
-
/** @hidden */
|
|
6
4
|
function isNodeModel(object) {
|
|
7
5
|
return typeof object === 'object' && object !== null && object.$$type === 'Node' && typeof object.id === 'string';
|
|
8
6
|
}
|
|
9
|
-
/** @hidden */
|
|
10
7
|
function isNodeRef(node) {
|
|
11
8
|
return isNodeModel(node) || isForwardRefNode(node);
|
|
12
9
|
}
|
|
13
|
-
/** @hidden */
|
|
14
10
|
function isNodeRefLike(node) {
|
|
15
11
|
return typeof node === 'string' || isNodeRef(node);
|
|
16
12
|
}
|
|
17
|
-
/** @hidden */
|
|
18
13
|
function isNodeRefGroupLike(target) {
|
|
19
14
|
return Array.isArray(target) && target.every(isNodeRefLike);
|
|
20
15
|
}
|
|
21
|
-
/** @hidden */
|
|
22
16
|
function isCompass(c) {
|
|
23
17
|
return ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'c'].includes(c);
|
|
24
18
|
}
|
|
25
|
-
/** @hidden */
|
|
26
19
|
function toNodeRef(target) {
|
|
27
20
|
if (isNodeRef(target)) {
|
|
28
21
|
return target;
|
|
@@ -33,7 +26,6 @@ function toNodeRef(target) {
|
|
|
33
26
|
}
|
|
34
27
|
return { id, port };
|
|
35
28
|
}
|
|
36
|
-
/** @hidden */
|
|
37
29
|
function toNodeRefGroup(targets) {
|
|
38
30
|
if (targets.length < 2 && (isNodeRefLike(targets[0]) && isNodeRefLike(targets[1])) === false) {
|
|
39
31
|
throw Error('EdgeTargets must have at least 2 elements.');
|
|
@@ -41,22 +33,13 @@ function toNodeRefGroup(targets) {
|
|
|
41
33
|
return targets.map((t) => toNodeRef(t));
|
|
42
34
|
}
|
|
43
35
|
|
|
44
|
-
/**
|
|
45
|
-
* @group Models Context
|
|
46
|
-
* @alpha
|
|
47
|
-
*/
|
|
48
36
|
const RootModelsContext = Object.seal({
|
|
49
|
-
// NOTE: RootModelsContext is also initialized after the model class is declared in the 'core/index.js' module.
|
|
50
37
|
Graph: null,
|
|
51
38
|
Digraph: null,
|
|
52
39
|
Subgraph: null,
|
|
53
40
|
Node: null,
|
|
54
41
|
Edge: null,
|
|
55
42
|
});
|
|
56
|
-
/**
|
|
57
|
-
* @group Models Context
|
|
58
|
-
* @alpha
|
|
59
|
-
*/
|
|
60
43
|
function createModelsContext(models) {
|
|
61
44
|
return Object.assign(Object.seal(Object.assign({}, RootModelsContext)), models);
|
|
62
45
|
}
|
package/lib/core/index.cjs
CHANGED
|
@@ -3,25 +3,13 @@
|
|
|
3
3
|
var index_js = require('../common/index.cjs');
|
|
4
4
|
var index_js$1 = require('../ast/index.cjs');
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* @group Attribute
|
|
8
|
-
*/
|
|
9
6
|
const attribute = new Proxy(Object.freeze({}), {
|
|
10
7
|
get: (_, key) => key,
|
|
11
8
|
});
|
|
12
9
|
|
|
13
|
-
/**
|
|
14
|
-
* Base class for DOT objects.
|
|
15
|
-
* @group Models
|
|
16
|
-
*/
|
|
17
10
|
class DotObject {}
|
|
18
11
|
|
|
19
|
-
/**
|
|
20
|
-
* Base class for DOT objects with attributes.
|
|
21
|
-
* @group Models
|
|
22
|
-
*/
|
|
23
12
|
class AttributesBase extends DotObject {
|
|
24
|
-
/** @hidden */
|
|
25
13
|
#attrs = new Map();
|
|
26
14
|
constructor(attributes) {
|
|
27
15
|
super();
|
|
@@ -57,10 +45,6 @@ class AttributesBase extends DotObject {
|
|
|
57
45
|
}
|
|
58
46
|
}
|
|
59
47
|
|
|
60
|
-
/**
|
|
61
|
-
* A set of attribute values for any object.
|
|
62
|
-
* @group Models
|
|
63
|
-
*/
|
|
64
48
|
class AttributeList extends AttributesBase {
|
|
65
49
|
$$kind;
|
|
66
50
|
get $$type() {
|
|
@@ -73,12 +57,7 @@ class AttributeList extends AttributesBase {
|
|
|
73
57
|
}
|
|
74
58
|
}
|
|
75
59
|
|
|
76
|
-
/**
|
|
77
|
-
* Base class for Graph objects.
|
|
78
|
-
* @group Models
|
|
79
|
-
*/
|
|
80
60
|
class GraphBase extends AttributesBase {
|
|
81
|
-
/** @hidden */
|
|
82
61
|
#models = index_js.RootModelsContext;
|
|
83
62
|
id;
|
|
84
63
|
comment;
|
|
@@ -96,7 +75,6 @@ class GraphBase extends AttributesBase {
|
|
|
96
75
|
get subgraphs() {
|
|
97
76
|
return Array.from(this.#objects.subgraphs.values());
|
|
98
77
|
}
|
|
99
|
-
/** @hidden */
|
|
100
78
|
#objects = {
|
|
101
79
|
nodes: new Map(),
|
|
102
80
|
edges: new Set(),
|
|
@@ -208,10 +186,6 @@ class GraphBase extends AttributesBase {
|
|
|
208
186
|
}
|
|
209
187
|
}
|
|
210
188
|
|
|
211
|
-
/**
|
|
212
|
-
* Base class representing a root graph(digraph, graph).
|
|
213
|
-
* @group Models
|
|
214
|
-
*/
|
|
215
189
|
class RootGraph extends GraphBase {
|
|
216
190
|
get $$type() {
|
|
217
191
|
return 'Graph';
|
|
@@ -229,30 +203,18 @@ class RootGraph extends GraphBase {
|
|
|
229
203
|
}
|
|
230
204
|
}
|
|
231
205
|
|
|
232
|
-
/**
|
|
233
|
-
* DOT object class representing a digraph.
|
|
234
|
-
* @group Models
|
|
235
|
-
*/
|
|
236
206
|
class Digraph extends RootGraph {
|
|
237
207
|
get directed() {
|
|
238
208
|
return true;
|
|
239
209
|
}
|
|
240
210
|
}
|
|
241
211
|
|
|
242
|
-
/**
|
|
243
|
-
* DOT object class representing a graph.
|
|
244
|
-
* @group Models
|
|
245
|
-
*/
|
|
246
212
|
class Graph extends RootGraph {
|
|
247
213
|
get directed() {
|
|
248
214
|
return false;
|
|
249
215
|
}
|
|
250
216
|
}
|
|
251
217
|
|
|
252
|
-
/**
|
|
253
|
-
* DOT object class representing a subgraph.
|
|
254
|
-
* @group Models
|
|
255
|
-
*/
|
|
256
218
|
class Subgraph extends GraphBase {
|
|
257
219
|
get $$type() {
|
|
258
220
|
return 'Subgraph';
|
|
@@ -274,18 +236,10 @@ class Subgraph extends GraphBase {
|
|
|
274
236
|
}
|
|
275
237
|
}
|
|
276
238
|
|
|
277
|
-
/**
|
|
278
|
-
* A set of attribute values for any object.
|
|
279
|
-
* @group Models
|
|
280
|
-
*/
|
|
281
239
|
class AttributesGroup extends AttributesBase {
|
|
282
240
|
comment;
|
|
283
241
|
}
|
|
284
242
|
|
|
285
|
-
/**
|
|
286
|
-
* DOT object class representing a node.
|
|
287
|
-
* @group Models
|
|
288
|
-
*/
|
|
289
243
|
class Node extends DotObject {
|
|
290
244
|
id;
|
|
291
245
|
get $$type() {
|
|
@@ -306,10 +260,6 @@ class Node extends DotObject {
|
|
|
306
260
|
}
|
|
307
261
|
}
|
|
308
262
|
|
|
309
|
-
/**
|
|
310
|
-
* DOT object class representing a edge.
|
|
311
|
-
* @group Models
|
|
312
|
-
*/
|
|
313
263
|
class Edge extends DotObject {
|
|
314
264
|
targets;
|
|
315
265
|
get $$type() {
|
|
@@ -335,7 +285,6 @@ Object.assign(index_js.RootModelsContext, {
|
|
|
335
285
|
Edge,
|
|
336
286
|
});
|
|
337
287
|
|
|
338
|
-
/** @hidden */
|
|
339
288
|
function ModelFactoryBuilder(directed, strictMode) {
|
|
340
289
|
return (...args) => {
|
|
341
290
|
const G = directed ? this.Digraph : this.Graph;
|
|
@@ -358,24 +307,9 @@ function createModelFactories(strict, context = index_js.RootModelsContext) {
|
|
|
358
307
|
}
|
|
359
308
|
|
|
360
309
|
const noStrict = createModelFactories(false);
|
|
361
|
-
/**
|
|
362
|
-
* API for creating directional graph objects.
|
|
363
|
-
* @group Model Factory
|
|
364
|
-
*/
|
|
365
310
|
const digraph = noStrict.digraph;
|
|
366
|
-
/**
|
|
367
|
-
* API for creating omnidirectional graph objects.
|
|
368
|
-
* @group Model Factory
|
|
369
|
-
*/
|
|
370
311
|
const graph = noStrict.graph;
|
|
371
|
-
/**
|
|
372
|
-
* Provides a strict mode API.
|
|
373
|
-
* @group Model Factory
|
|
374
|
-
*/
|
|
375
312
|
const strict = createModelFactories(true);
|
|
376
|
-
/**
|
|
377
|
-
* @group Model Factory
|
|
378
|
-
*/
|
|
379
313
|
function withContext(models) {
|
|
380
314
|
const context = index_js.createModelsContext(models);
|
|
381
315
|
return Object.freeze({
|
|
@@ -384,15 +318,6 @@ function withContext(models) {
|
|
|
384
318
|
});
|
|
385
319
|
}
|
|
386
320
|
|
|
387
|
-
/**
|
|
388
|
-
* Convert Model to DOT string.
|
|
389
|
-
*
|
|
390
|
-
* @group Convert Model to DOT
|
|
391
|
-
*
|
|
392
|
-
* @param model Dot Object Model, like {@link Digraph}, {@link Graph}, {@link Subgraph}, {@link Node}, and {@link Edge}
|
|
393
|
-
* @param options
|
|
394
|
-
* @returns DOT string
|
|
395
|
-
*/
|
|
396
321
|
function toDot(model, options) {
|
|
397
322
|
const ast = index_js$1.fromModel(model, options?.convert);
|
|
398
323
|
return index_js$1.stringify(ast, options?.print);
|
package/lib/core/index.d.ts
CHANGED
|
@@ -2680,6 +2680,13 @@ declare class Subgraph extends GraphBase<SubgraphAttributeKey | ClusterSubgraphA
|
|
|
2680
2680
|
}
|
|
2681
2681
|
|
|
2682
2682
|
/**
|
|
2683
|
+
* ModelFactory is an interface that provides a way to create a {@link RootGraphModel} object.
|
|
2684
|
+
*
|
|
2685
|
+
* @param id - Optional string parameter that specifies the id of the {@link RootGraphModel} object.
|
|
2686
|
+
* @param attributes - Optional GraphAttributesObject parameter that specifies the attributes of the {@link RootGraphModel} object.
|
|
2687
|
+
* @param callback - Optional callback function that takes a {@link RootGraphModel} object as a parameter.
|
|
2688
|
+
*
|
|
2689
|
+
* @returns {@link RootGraphModel} - Returns a {@link RootGraphModel} object.
|
|
2683
2690
|
* @group Model Factory
|
|
2684
2691
|
*/
|
|
2685
2692
|
interface ModelFactory {
|
|
@@ -2709,12 +2716,12 @@ interface ModelFactoriesWithStrict extends ModelFactories {
|
|
|
2709
2716
|
}
|
|
2710
2717
|
|
|
2711
2718
|
/**
|
|
2712
|
-
*
|
|
2719
|
+
* digraph is a factory for creating Digraph objects.
|
|
2713
2720
|
* @group Model Factory
|
|
2714
2721
|
*/
|
|
2715
2722
|
declare const digraph: ModelFactory;
|
|
2716
2723
|
/**
|
|
2717
|
-
*
|
|
2724
|
+
* graph is a factory for creating Graph objects.
|
|
2718
2725
|
* @group Model Factory
|
|
2719
2726
|
*/
|
|
2720
2727
|
declare const graph: ModelFactory;
|
|
@@ -2724,16 +2731,27 @@ declare const graph: ModelFactory;
|
|
|
2724
2731
|
*/
|
|
2725
2732
|
declare const strict: ModelFactories;
|
|
2726
2733
|
/**
|
|
2727
|
-
* @
|
|
2734
|
+
* withContext creates a {@link ModelFactoriesWithStrict} object with the given context.
|
|
2735
|
+
*
|
|
2736
|
+
* @param models - An object containing the models to be used in the context.
|
|
2737
|
+
*
|
|
2738
|
+
* @returns A ModelFactoriesWithStrict object containing the factories. * @group Model Factory
|
|
2728
2739
|
*/
|
|
2729
2740
|
declare function withContext(models: Partial<ModelsContext>): ModelFactoriesWithStrict;
|
|
2730
2741
|
|
|
2731
2742
|
/**
|
|
2743
|
+
* This interface provides options for converting a model to DOT.
|
|
2732
2744
|
* @group Convert Model to DOT
|
|
2733
2745
|
* @alpha
|
|
2734
2746
|
*/
|
|
2735
2747
|
interface ToDotOptions {
|
|
2748
|
+
/**
|
|
2749
|
+
* Options for converting the model to DOT.
|
|
2750
|
+
*/
|
|
2736
2751
|
convert?: ConvertFromModelOptions;
|
|
2752
|
+
/**
|
|
2753
|
+
* Options for printing DOT.
|
|
2754
|
+
*/
|
|
2737
2755
|
print?: PrintOptions;
|
|
2738
2756
|
}
|
|
2739
2757
|
/**
|
|
@@ -2742,27 +2760,35 @@ interface ToDotOptions {
|
|
|
2742
2760
|
* @group Convert Model to DOT
|
|
2743
2761
|
*
|
|
2744
2762
|
* @param model Dot Object Model, like {@link Digraph}, {@link Graph}, {@link Subgraph}, {@link Node}, and {@link Edge}
|
|
2745
|
-
* @param options
|
|
2763
|
+
* @param options Optional options for the conversion.
|
|
2746
2764
|
* @returns DOT string
|
|
2747
2765
|
*/
|
|
2748
2766
|
declare function toDot(model: DotObjectModel, options?: ToDotOptions): string;
|
|
2749
2767
|
|
|
2750
2768
|
/**
|
|
2751
|
-
*
|
|
2769
|
+
* This interface provides options for converting DOT to a model.
|
|
2770
|
+
* @group Convert DOT to Model
|
|
2752
2771
|
* @alpha
|
|
2753
2772
|
*/
|
|
2754
2773
|
interface FromDotOptions<T extends 'Dot' | 'Graph' | 'Node' | 'Edge' | 'Subgraph'> {
|
|
2774
|
+
/**
|
|
2775
|
+
* Options for parsing DOT.
|
|
2776
|
+
*/
|
|
2755
2777
|
parse?: ParseOptions<T>;
|
|
2778
|
+
/**
|
|
2779
|
+
* Options for converting the parsed DOT to a model.
|
|
2780
|
+
*/
|
|
2756
2781
|
convert?: ConvertToModelOptions;
|
|
2757
2782
|
}
|
|
2758
2783
|
/**
|
|
2759
|
-
*
|
|
2784
|
+
* fromDot is a function that converts a DOT string to a model.
|
|
2760
2785
|
*
|
|
2761
2786
|
* @group Convert DOT to Model
|
|
2762
2787
|
*
|
|
2763
|
-
* @param dot DOT string
|
|
2764
|
-
* @param options
|
|
2765
|
-
* @returns
|
|
2788
|
+
* @param dot The DOT string to convert.
|
|
2789
|
+
* @param options Options for converting the DOT string to a model.
|
|
2790
|
+
* @returns A model of type {@link RootGraphModel}, {@link NodeModel}, {@link EdgeModel}, or {@link SubgraphModel},
|
|
2791
|
+
* depending on the type specified in the options.
|
|
2766
2792
|
* @beta
|
|
2767
2793
|
*/
|
|
2768
2794
|
declare function fromDot(dot: string, options?: FromDotOptions<'Dot' | 'Graph'>): RootGraphModel;
|