ts-graphviz 1.5.5-dev.bdbba8a60 → 1.5.6-dev.29eb2444f
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 +75 -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.d.ts +1 -1
- package/lib/adapter/node/index.js +2 -14
- package/lib/adapter/types/index.d.ts +27 -2
- 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 +3871 -1278
- package/lib/common/index.js +0 -17
- package/lib/core/index.cjs +0 -75
- package/lib/core/index.d.ts +40 -2491
- package/lib/core/index.js +0 -75
- package/lib/index.d.ts +1 -0
- package/lib/utils/index.d.ts +8 -1
- package/package.json +2 -2
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
|
}
|