@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
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, test } from 'vitest';
|
|
2
|
+
import './registerModelContext.js';
|
|
3
|
+
|
|
4
|
+
import { attribute as _ } from '../attribute.js';
|
|
5
|
+
import { DotObject } from './DotObject.js';
|
|
6
|
+
import { GraphBase } from './GraphBase.js';
|
|
7
|
+
import { RootGraph } from './RootGraph.js';
|
|
8
|
+
|
|
9
|
+
class TestRootGraph extends RootGraph {
|
|
10
|
+
public directed = true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let g: RootGraph;
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
g = new TestRootGraph();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('Constructor', () => {
|
|
19
|
+
test('no args', () => {
|
|
20
|
+
g = new TestRootGraph();
|
|
21
|
+
expect(g.id).toBeUndefined();
|
|
22
|
+
expect(g.values).toStrictEqual([]);
|
|
23
|
+
expect(g.strict).toStrictEqual(false);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('first argument is id', () => {
|
|
27
|
+
g = new TestRootGraph('foo');
|
|
28
|
+
expect(g.id).toStrictEqual('foo');
|
|
29
|
+
expect(g.values).toStrictEqual([]);
|
|
30
|
+
expect(g.strict).toStrictEqual(false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('first argument is id, seccond argument is strict, third argument is attribute object', () => {
|
|
34
|
+
g = new TestRootGraph('foo', true, { [_.label]: 'Test label' });
|
|
35
|
+
expect(g.id).toStrictEqual('foo');
|
|
36
|
+
expect(g.values).toStrictEqual([[_.label, 'Test label']]);
|
|
37
|
+
expect(g.strict).toStrictEqual(true);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('first argument is attribute object', () => {
|
|
41
|
+
g = new TestRootGraph({ [_.label]: 'Test label' });
|
|
42
|
+
expect(g.id).toBeUndefined();
|
|
43
|
+
expect(g.values).toStrictEqual([[_.label, 'Test label']]);
|
|
44
|
+
expect(g.strict).toStrictEqual(false);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('first argument is strict', () => {
|
|
48
|
+
g = new TestRootGraph(true);
|
|
49
|
+
expect(g.id).toBeUndefined();
|
|
50
|
+
expect(g.values).toStrictEqual([]);
|
|
51
|
+
expect(g.strict).toStrictEqual(true);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('first argument is strict, seccond is attribute object', () => {
|
|
55
|
+
g = new TestRootGraph(true, { [_.label]: 'Test label' });
|
|
56
|
+
expect(g.id).toBeUndefined();
|
|
57
|
+
expect(g.values).toStrictEqual([[_.label, 'Test label']]);
|
|
58
|
+
expect(g.strict).toStrictEqual(true);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should be instance of GraphBase/DotObject', () => {
|
|
63
|
+
expect(g).toBeInstanceOf(GraphBase);
|
|
64
|
+
expect(g).toBeInstanceOf(DotObject);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('$$type propaty should be "Graph"', () => {
|
|
68
|
+
expect(g.$$type).toStrictEqual('Graph');
|
|
69
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GraphAttributeKey,
|
|
3
|
+
GraphAttributesObject,
|
|
4
|
+
RootGraphModel,
|
|
5
|
+
} from '@ts-graphviz/common';
|
|
6
|
+
import { GraphBase } from './GraphBase.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Base class representing a root graph(digraph, graph).
|
|
10
|
+
* @group Models
|
|
11
|
+
*/
|
|
12
|
+
export abstract class RootGraph
|
|
13
|
+
extends GraphBase<GraphAttributeKey>
|
|
14
|
+
implements RootGraphModel
|
|
15
|
+
{
|
|
16
|
+
public get $$type(): 'Graph' {
|
|
17
|
+
return 'Graph';
|
|
18
|
+
}
|
|
19
|
+
public readonly id?: string;
|
|
20
|
+
public abstract readonly directed: boolean;
|
|
21
|
+
public strict: boolean;
|
|
22
|
+
|
|
23
|
+
constructor(id?: string, attributes?: GraphAttributesObject);
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
id?: string,
|
|
27
|
+
strict?: boolean,
|
|
28
|
+
attributes?: GraphAttributesObject,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
constructor(strict?: boolean, attributes?: GraphAttributesObject);
|
|
32
|
+
|
|
33
|
+
constructor(attributes?: GraphAttributesObject);
|
|
34
|
+
|
|
35
|
+
constructor(...args: unknown[]) {
|
|
36
|
+
super();
|
|
37
|
+
this.id = args.find((arg): arg is string => typeof arg === 'string');
|
|
38
|
+
this.strict =
|
|
39
|
+
args.find((arg): arg is boolean => typeof arg === 'boolean') ?? false;
|
|
40
|
+
const attributes = args.find(
|
|
41
|
+
(arg): arg is GraphAttributesObject =>
|
|
42
|
+
typeof arg === 'object' && arg !== null,
|
|
43
|
+
);
|
|
44
|
+
if (attributes !== undefined) {
|
|
45
|
+
this.apply(attributes);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, test } from 'vitest';
|
|
2
|
+
import './registerModelContext.js';
|
|
3
|
+
|
|
4
|
+
import { EdgeTargetTuple, SubgraphModel } from '@ts-graphviz/common';
|
|
5
|
+
import { attribute as _ } from '../attribute.js';
|
|
6
|
+
import { AttributesBase } from './AttributesBase.js';
|
|
7
|
+
import { DotObject } from './DotObject.js';
|
|
8
|
+
import { GraphBase } from './GraphBase.js';
|
|
9
|
+
import { Node } from './Node.js';
|
|
10
|
+
import { Subgraph } from './Subgraph.js';
|
|
11
|
+
|
|
12
|
+
describe('class Subgraph', () => {
|
|
13
|
+
let subgraph: SubgraphModel;
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
subgraph = new Subgraph();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should be instance of Subgraph/Cluster/AttributesBase/DotObject', () => {
|
|
20
|
+
expect(subgraph).toBeInstanceOf(Subgraph);
|
|
21
|
+
expect(subgraph).toBeInstanceOf(GraphBase);
|
|
22
|
+
expect(subgraph).toBeInstanceOf(AttributesBase);
|
|
23
|
+
expect(subgraph).toBeInstanceOf(DotObject);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('Constructor', () => {
|
|
27
|
+
test('first argument is id, and second attributes object', () => {
|
|
28
|
+
subgraph = new Subgraph('test', {
|
|
29
|
+
[_.K]: 1,
|
|
30
|
+
});
|
|
31
|
+
expect(subgraph.id).toBe('test');
|
|
32
|
+
expect(subgraph.get(_.K)).toBe(1);
|
|
33
|
+
});
|
|
34
|
+
test('first argument is attributes object', () => {
|
|
35
|
+
subgraph = new Subgraph({
|
|
36
|
+
[_.K]: 1,
|
|
37
|
+
});
|
|
38
|
+
expect(subgraph.get(_.K)).toBe(1);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('Declaratively set the attributes of the objects in the cluster', () => {
|
|
43
|
+
test('node', () => {
|
|
44
|
+
subgraph.node({
|
|
45
|
+
label: 'test label',
|
|
46
|
+
});
|
|
47
|
+
expect(subgraph.attributes.node.get(_.label)).toBe('test label');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('edge', () => {
|
|
51
|
+
subgraph.edge({
|
|
52
|
+
label: 'test label',
|
|
53
|
+
});
|
|
54
|
+
expect(subgraph.attributes.edge.get(_.label)).toBe('test label');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('graph', () => {
|
|
58
|
+
subgraph.graph({
|
|
59
|
+
label: 'test label',
|
|
60
|
+
});
|
|
61
|
+
expect(subgraph.attributes.graph.get(_.label)).toBe('test label');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('set attributes', () => {
|
|
66
|
+
subgraph.set(_.rank, 'same');
|
|
67
|
+
expect(subgraph.get(_.rank)).toBe('same');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('set attributes by apply', () => {
|
|
71
|
+
test('with attributes object', () => {
|
|
72
|
+
subgraph.apply({
|
|
73
|
+
[_.rank]: 'same',
|
|
74
|
+
});
|
|
75
|
+
expect(subgraph.get(_.rank)).toBe('same');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('with entities', () => {
|
|
79
|
+
subgraph.apply([[_.rank, 'same']]);
|
|
80
|
+
expect(subgraph.get(_.rank)).toBe('same');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should be subgraph, when subgraph id is "test"', () => {
|
|
85
|
+
expect(subgraph.isSubgraphCluster()).toBe(false);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('create node with attributes', () => {
|
|
89
|
+
const node = subgraph.createNode('n', {
|
|
90
|
+
[_.label]: 'Label',
|
|
91
|
+
});
|
|
92
|
+
expect(node.id).toBe('n');
|
|
93
|
+
expect(node.attributes.size).toBe(1);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('create edge with attributes', () => {
|
|
97
|
+
const nodes = [...Array(2)].map((_v, i) =>
|
|
98
|
+
subgraph.createNode(`node${i + 1}`),
|
|
99
|
+
) as EdgeTargetTuple;
|
|
100
|
+
const edge = subgraph.createEdge(nodes, {
|
|
101
|
+
[_.label]: 'Label',
|
|
102
|
+
});
|
|
103
|
+
expect(edge.attributes.size).toBe(1);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('create edge by node group', () => {
|
|
107
|
+
const [node1, node2, node3, node4] = Array(4)
|
|
108
|
+
.fill(true)
|
|
109
|
+
.map((_v, i) => subgraph.createNode(`node${i + 1}`));
|
|
110
|
+
const edge = subgraph.createEdge([node1, [node2, node3], node4]);
|
|
111
|
+
expect(edge.targets.length).toBe(3);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('create subgraph with attributes', () => {
|
|
115
|
+
subgraph = subgraph.createSubgraph('test', {
|
|
116
|
+
[_.label]: 'Label',
|
|
117
|
+
});
|
|
118
|
+
expect(subgraph.id).toBe('test');
|
|
119
|
+
expect(subgraph.size).toBe(1);
|
|
120
|
+
|
|
121
|
+
subgraph = subgraph.createSubgraph({
|
|
122
|
+
[_.label]: 'Label',
|
|
123
|
+
});
|
|
124
|
+
expect(subgraph.size).toBe(1);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test.each([
|
|
128
|
+
['cluster', true],
|
|
129
|
+
['cluster_hoge', true],
|
|
130
|
+
['hoge_cluster', false],
|
|
131
|
+
['example', false],
|
|
132
|
+
])(
|
|
133
|
+
'if cluster named "%s", isSubgraphCluster should be %p',
|
|
134
|
+
(id, expected) => {
|
|
135
|
+
subgraph = new Subgraph(id);
|
|
136
|
+
expect(subgraph.isSubgraphCluster()).toBe(expected);
|
|
137
|
+
},
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
describe('addXxx existXxx removeXxx APIs', () => {
|
|
141
|
+
it('Node operation methods works', () => {
|
|
142
|
+
const id = 'node';
|
|
143
|
+
expect(subgraph.existNode(id)).toBe(false);
|
|
144
|
+
const node = new Node(id);
|
|
145
|
+
subgraph.addNode(node);
|
|
146
|
+
expect(subgraph.existNode(id)).toBe(true);
|
|
147
|
+
subgraph.removeNode(node);
|
|
148
|
+
expect(subgraph.existNode(id)).toBe(false);
|
|
149
|
+
subgraph.addNode(node);
|
|
150
|
+
expect(subgraph.existNode(id)).toBe(true);
|
|
151
|
+
subgraph.removeNode(node.id);
|
|
152
|
+
expect(subgraph.existNode(id)).toBe(false);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('Edge operation methods works', () => {
|
|
156
|
+
const nodes = [...Array(2)].map((_v, i) =>
|
|
157
|
+
subgraph.createNode(`node${i + 1}`),
|
|
158
|
+
) as EdgeTargetTuple;
|
|
159
|
+
const edge = subgraph.createEdge(nodes);
|
|
160
|
+
expect(subgraph.existEdge(edge)).toBe(true);
|
|
161
|
+
subgraph.removeEdge(edge);
|
|
162
|
+
expect(subgraph.existEdge(edge)).toBe(false);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('Subgraph operation methods works', () => {
|
|
166
|
+
const sub = subgraph.createSubgraph('sub');
|
|
167
|
+
expect(subgraph.existSubgraph(sub)).toBe(true);
|
|
168
|
+
subgraph.removeSubgraph(sub);
|
|
169
|
+
expect(subgraph.existSubgraph(sub)).toBe(false);
|
|
170
|
+
subgraph.addSubgraph(sub);
|
|
171
|
+
expect(subgraph.existSubgraph(sub)).toBe(true);
|
|
172
|
+
subgraph.removeSubgraph(sub);
|
|
173
|
+
expect(subgraph.existSubgraph(sub)).toBe(false);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('should be undefined, when id not set', () => {
|
|
177
|
+
const sub = subgraph.createSubgraph();
|
|
178
|
+
expect(sub.id).toBeUndefined();
|
|
179
|
+
expect(sub.isSubgraphCluster()).toBe(false);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('throws an error when the EdgeTarget element is missing', () => {
|
|
183
|
+
const n = subgraph.node('n');
|
|
184
|
+
expect(() =>
|
|
185
|
+
subgraph.edge([] as unknown as EdgeTargetTuple),
|
|
186
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
187
|
+
`[Error: The element of Edge target is missing or not satisfied as Edge target.]`,
|
|
188
|
+
);
|
|
189
|
+
expect(() =>
|
|
190
|
+
subgraph.edge([n] as unknown as EdgeTargetTuple),
|
|
191
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
192
|
+
`[Error: The element of Edge target is missing or not satisfied as Edge target.]`,
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ClusterSubgraphAttributeKey,
|
|
3
|
+
SubgraphAttributeKey,
|
|
4
|
+
SubgraphAttributesObject,
|
|
5
|
+
SubgraphModel,
|
|
6
|
+
} from '@ts-graphviz/common';
|
|
7
|
+
import { GraphBase } from './GraphBase.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* DOT object class representing a subgraph.
|
|
11
|
+
* @group Models
|
|
12
|
+
*/
|
|
13
|
+
export class Subgraph
|
|
14
|
+
extends GraphBase<SubgraphAttributeKey | ClusterSubgraphAttributeKey>
|
|
15
|
+
implements SubgraphModel
|
|
16
|
+
{
|
|
17
|
+
public get $$type(): 'Subgraph' {
|
|
18
|
+
return 'Subgraph';
|
|
19
|
+
}
|
|
20
|
+
public readonly id?: string;
|
|
21
|
+
|
|
22
|
+
constructor(id?: string, attributes?: SubgraphAttributesObject);
|
|
23
|
+
|
|
24
|
+
constructor(attributes?: SubgraphAttributesObject);
|
|
25
|
+
|
|
26
|
+
constructor(...args: unknown[]) {
|
|
27
|
+
super();
|
|
28
|
+
this.id = args.find((arg): arg is string => typeof arg === 'string');
|
|
29
|
+
const attributes = args.find(
|
|
30
|
+
(arg): arg is SubgraphAttributesObject =>
|
|
31
|
+
typeof arg === 'object' && arg !== null,
|
|
32
|
+
);
|
|
33
|
+
if (attributes !== undefined) {
|
|
34
|
+
this.apply(attributes);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public isSubgraphCluster(): boolean {
|
|
39
|
+
if (typeof this.id === 'string') {
|
|
40
|
+
return this.id.startsWith('cluster');
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import './registerModelContext.js';
|
|
2
|
+
|
|
3
|
+
export * from './DotObject.js';
|
|
4
|
+
export * from './AttributesBase.js';
|
|
5
|
+
export * from './AttributeList.js';
|
|
6
|
+
export * from './AttributesBase.js';
|
|
7
|
+
export * from './AttributesGroup.js';
|
|
8
|
+
export * from './Digraph.js';
|
|
9
|
+
export * from './DotObject.js';
|
|
10
|
+
export * from './Edge.js';
|
|
11
|
+
export * from './Graph.js';
|
|
12
|
+
export * from './GraphBase.js';
|
|
13
|
+
export * from './Node.js';
|
|
14
|
+
export * from './RootGraph.js';
|
|
15
|
+
export * from './Subgraph.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RootModelsContext } from '@ts-graphviz/common';
|
|
2
|
+
import { Digraph } from './Digraph.js';
|
|
3
|
+
import { Edge } from './Edge.js';
|
|
4
|
+
import { Graph } from './Graph.js';
|
|
5
|
+
import { Node } from './Node.js';
|
|
6
|
+
import { Subgraph } from './Subgraph.js';
|
|
7
|
+
|
|
8
|
+
Object.assign(RootModelsContext, {
|
|
9
|
+
Graph,
|
|
10
|
+
Digraph,
|
|
11
|
+
Subgraph,
|
|
12
|
+
Node,
|
|
13
|
+
Edge,
|
|
14
|
+
});
|
package/src/to-dot.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConvertFromModelOptions,
|
|
3
|
+
PrintOptions,
|
|
4
|
+
fromModel,
|
|
5
|
+
stringify,
|
|
6
|
+
} from '@ts-graphviz/ast';
|
|
7
|
+
import { DotObjectModel } from '@ts-graphviz/common';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* This interface provides options for converting a model to DOT.
|
|
11
|
+
* @group Convert Model to DOT
|
|
12
|
+
*/
|
|
13
|
+
export interface ToDotOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Options for converting the model to DOT.
|
|
16
|
+
*/
|
|
17
|
+
convert?: ConvertFromModelOptions;
|
|
18
|
+
/**
|
|
19
|
+
* Options for printing DOT.
|
|
20
|
+
*/
|
|
21
|
+
print?: PrintOptions;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Convert Model to DOT string.
|
|
26
|
+
*
|
|
27
|
+
* @group Convert Model to DOT
|
|
28
|
+
*
|
|
29
|
+
* @param model Dot Object Model, like {@link Digraph}, {@link Graph}, {@link Subgraph}, {@link Node}, and {@link Edge}
|
|
30
|
+
* @param options Optional options for the conversion.
|
|
31
|
+
* @returns DOT string
|
|
32
|
+
*/
|
|
33
|
+
export function toDot(model: DotObjectModel, options?: ToDotOptions): string {
|
|
34
|
+
const ast = fromModel(model, options?.convert);
|
|
35
|
+
return stringify(ast, options?.print);
|
|
36
|
+
}
|
package/tsconfig.json
ADDED
package/typedoc.json
ADDED
package/vite.config.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import dts from 'vite-plugin-dts';
|
|
2
|
+
import { defineConfig } from 'vitest/config';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
build: {
|
|
6
|
+
outDir: './lib',
|
|
7
|
+
minify: false,
|
|
8
|
+
lib: {
|
|
9
|
+
entry: './src/core.ts',
|
|
10
|
+
formats: ['es', 'cjs'],
|
|
11
|
+
},
|
|
12
|
+
rollupOptions: {
|
|
13
|
+
external: ['@ts-graphviz/common', '@ts-graphviz/ast'],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
plugins: [
|
|
17
|
+
dts({
|
|
18
|
+
outDir: './lib',
|
|
19
|
+
rollupTypes: true,
|
|
20
|
+
}),
|
|
21
|
+
],
|
|
22
|
+
});
|