ts-graphviz 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/LICENSE +22 -0
- package/README.md +676 -0
- package/lib/adapter.cjs +14 -0
- package/lib/adapter.d.ts +1 -0
- package/lib/adapter.js +1 -0
- package/lib/ast.cjs +14 -0
- package/lib/ast.d.ts +1 -0
- package/lib/ast.js +1 -0
- package/lib/ts-graphviz.cjs +21 -0
- package/lib/ts-graphviz.d.ts +2 -0
- package/lib/ts-graphviz.js +2 -0
- package/media/Makefile +7 -0
- package/media/adapter-state-machine.dot +8 -0
- package/media/adapter-state-machine.svg +1 -0
- package/media/state-machine.dot +12 -0
- package/media/state-machine.svg +1 -0
- package/media/ts-graphviz.dot +21 -0
- package/media/ts-graphviz.svg +1 -0
- package/package.json +81 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
The MIT License (MIT)
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2019-2024 Yuki Yamazaki
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
[](https://app.codacy.com/gh/ts-graphviz/ts-graphviz?utm_source=github.com&utm_medium=referral&utm_content=ts-graphviz/ts-graphviz&utm_campaign=Badge_Grade_Settings)
|
|
2
|
+
[](https://github.com/kamiazya/ts-graphviz/actions?workflow=NodeCI)
|
|
3
|
+
[](https://badge.fury.io/js/ts-graphviz)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](http://makeapullrequest.com)
|
|
6
|
+
[](https://github.com/facebook/jest)
|
|
7
|
+
[](https://github.com/facebook/jest)
|
|
8
|
+

|
|
9
|
+
[](https://github.com/denoland/deno)
|
|
10
|
+

|
|
11
|
+
[](#contributors)
|
|
12
|
+
[](https://tidelift.com/subscription/pkg/npm-ts-graphviz?utm_source=npm-ts-graphviz&utm_medium=readme)
|
|
13
|
+
|
|
14
|
+
# ts-graphviz
|
|
15
|
+
|
|
16
|
+
[Graphviz](https://graphviz.gitlab.io/) library for TypeScript.
|
|
17
|
+
|
|
18
|
+
[](https://github.com/ts-graphviz/ts-graphviz)
|
|
19
|
+
[](https://www.npmjs.com/package/ts-graphviz)
|
|
20
|
+
[](https://yarnpkg.com/package/ts-graphviz)
|
|
21
|
+
[](https://ts-graphviz.github.io/ts-graphviz/)
|
|
22
|
+
[](https://github.com/sponsors/kamiazya)
|
|
23
|
+
|
|
24
|
+
> [English](https://github.com/ts-graphviz/ts-graphviz/blob/main/packages/ts-graphviz/README.md) | [日本語](https://github.com/ts-graphviz/ts-graphviz/blob/main/packages/ts-graphviz/README_ja.md)
|
|
25
|
+
|
|
26
|
+
## Key Features ✨
|
|
27
|
+
|
|
28
|
+
`ts-graphviz` package provides models and ASTs for the Graphviz DOT language fully integrated with TypeScript.
|
|
29
|
+
|
|
30
|
+
- **TypeScript-friendly API**
|
|
31
|
+
- It provides models in the DOT language. TypeScript type definitions are also provided for attributes and even attribute types.
|
|
32
|
+
- **Freedom from programming paradigms**
|
|
33
|
+
- Designed to be object-oriented, it provides APIs that can be adapted to both imperative and declarative APIs. You can choose the paradigm that best fits your project.
|
|
34
|
+
- **Suitable for any use cases**
|
|
35
|
+
- Both a high-layer API to provide models and a low-layer API to handle ASTs are provided to address any use cases.
|
|
36
|
+
|
|
37
|
+
## Installation 💽
|
|
38
|
+
|
|
39
|
+
### Node.js
|
|
40
|
+
|
|
41
|
+
This package can then be installed using a package manager.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# npm
|
|
45
|
+
$ npm install -S ts-graphviz
|
|
46
|
+
# or yarn
|
|
47
|
+
$ yarn add ts-graphviz
|
|
48
|
+
# or pnpm
|
|
49
|
+
$ pnpm add ts-graphviz
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
> **Note** Want to try before installing? Check out [Runkit](https://npm.runkit.com/ts-graphviz) to see how it works.
|
|
53
|
+
|
|
54
|
+
### Deno 🦕
|
|
55
|
+
|
|
56
|
+
[Deno v1.28 and above supports npm](https://deno.land/manual/node/npm_specifiers).
|
|
57
|
+
|
|
58
|
+
You can install and use the package by specifying the following:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { toDot } from 'npm:ts-graphviz';
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Usage 📑
|
|
65
|
+
|
|
66
|
+
This section provides an overview of the package.
|
|
67
|
+
|
|
68
|
+
For more detailed API specifications, please refer to the comments in the TypeScript type definitions and the [document](https://ts-graphviz.github.io/ts-graphviz/) automatically generated based on them.
|
|
69
|
+
|
|
70
|
+
### `ts-graphviz` Module 🚩
|
|
71
|
+
|
|
72
|
+
This module provides **Model**, an interface for working with the DOT language in JavaScript/TypeScript.
|
|
73
|
+
|
|
74
|
+

|
|
75
|
+
|
|
76
|
+
#### Object-Oriented ❤️
|
|
77
|
+
|
|
78
|
+
**Model** is designed to be object-oriented and provides classes `Digraph`, `Graph`, `Subgraph`, `Node`, and `Edge`.
|
|
79
|
+
|
|
80
|
+
Provides a `toDot` function to convert **Model** to **DOT** (DOT language string).
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { attribute as _, Digraph, Subgraph, Node, Edge, toDot } from 'ts-graphviz';
|
|
84
|
+
|
|
85
|
+
const G = new Digraph();
|
|
86
|
+
const A = new Subgraph('A');
|
|
87
|
+
const node1 = new Node('node1', {
|
|
88
|
+
[_.color]: 'red'
|
|
89
|
+
});
|
|
90
|
+
const node2 = new Node('node2', {
|
|
91
|
+
[_.color]: 'blue'
|
|
92
|
+
});
|
|
93
|
+
const edge = new Edge([node1, node2], {
|
|
94
|
+
[_.label]: 'Edge Label',
|
|
95
|
+
[_.color]: 'pink'
|
|
96
|
+
});
|
|
97
|
+
G.addSubgraph(A);
|
|
98
|
+
A.addNode(node1);
|
|
99
|
+
A.addNode(node2);
|
|
100
|
+
A.addEdge(edge);
|
|
101
|
+
const dot = toDot(G);
|
|
102
|
+
// digraph {
|
|
103
|
+
// subgraph "A" {
|
|
104
|
+
// "node1" [
|
|
105
|
+
// color = "red",
|
|
106
|
+
// ];
|
|
107
|
+
// "node2" [
|
|
108
|
+
// color = "blue",
|
|
109
|
+
// ];
|
|
110
|
+
// "node1" -> "node2" [
|
|
111
|
+
// label = "Edge Label",
|
|
112
|
+
// color = "pink",
|
|
113
|
+
// ];
|
|
114
|
+
// }
|
|
115
|
+
// }
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
<details>
|
|
119
|
+
<summary>Advanced Usage</summary>
|
|
120
|
+
|
|
121
|
+
##### Custom Class 🤖
|
|
122
|
+
|
|
123
|
+
You can also add your own implementation by inheriting from the class.
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
import { Digraph, Node, Edge, EdgeTargetTuple, attribute as _, toDot } from 'ts-graphviz';
|
|
127
|
+
|
|
128
|
+
class MyCustomDigraph extends Digraph {
|
|
129
|
+
constructor() {
|
|
130
|
+
super('G', {
|
|
131
|
+
[_.label]: 'This is Custom Digraph',
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
class MyCustomNode extends Node {
|
|
136
|
+
constructor(id: string) {
|
|
137
|
+
super(`node_${id}`, {
|
|
138
|
+
[_.label]: `This is Custom Node ${id}`,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
class MyCustomEdge extends Edge {
|
|
144
|
+
constructor(targets: EdgeTargetTuple) {
|
|
145
|
+
super(targets, {
|
|
146
|
+
[_.label]: 'This is Custom Edge',
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const digraph = new MyCustomDigraph();
|
|
152
|
+
const node1 = new MyCustomNode('A');
|
|
153
|
+
const node2 = new MyCustomNode('B');
|
|
154
|
+
const edge = new MyCustomEdge([node1, node2]);
|
|
155
|
+
digraph.addNode(node1);
|
|
156
|
+
digraph.addNode(node2);
|
|
157
|
+
digraph.addEdge(edge);
|
|
158
|
+
const dot = toDot(digraph);
|
|
159
|
+
// digraph "G" {
|
|
160
|
+
// label = "This is Custom Digraph";
|
|
161
|
+
// "node_A" [
|
|
162
|
+
// label = "This is Custom Node A";
|
|
163
|
+
// ];
|
|
164
|
+
// "node_B" [
|
|
165
|
+
// label = "This is Custom Node B";
|
|
166
|
+
// ];
|
|
167
|
+
// "node_A" -> "node_B" [
|
|
168
|
+
// label = "This is Custom Edge";
|
|
169
|
+
// ];
|
|
170
|
+
// }
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
##### Models Context API ( `with` method) 🧅
|
|
174
|
+
|
|
175
|
+
You can also use the _Models Context API_ to create custom classes for objects generated inside of Graph.
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
The `with` methods of `Digraph`, `Graph`, and `Subgraph`, which are implementations of `GraphBaseModel`, are provided to predefine custom models.
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
const g = new Digraph();
|
|
182
|
+
g.with({
|
|
183
|
+
Node: MyCustomNode,
|
|
184
|
+
Edge: MyCustomEdge,
|
|
185
|
+
});
|
|
186
|
+
const a = g.createNode('A'); // MyCustomNode
|
|
187
|
+
const b = g.createNode('B'); // MyCustomNode
|
|
188
|
+
g.createEdge([a, b]); // MyCustomEdge
|
|
189
|
+
const dot = toDot(g);
|
|
190
|
+
// digraph {
|
|
191
|
+
// "node_A" [
|
|
192
|
+
// label = "This is Custom Node A";
|
|
193
|
+
// ];
|
|
194
|
+
// "node_B" [
|
|
195
|
+
// label = "This is Custom Node B";
|
|
196
|
+
// ];
|
|
197
|
+
// "node_A" -> "node_B" [
|
|
198
|
+
// label = "This is Custom Edge";
|
|
199
|
+
// ];
|
|
200
|
+
// }
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
##### `fromDot` function ⏪
|
|
204
|
+
|
|
205
|
+
> The status of this function is ! [beta](https://img.shields.io/badge/-beta-orange).
|
|
206
|
+
|
|
207
|
+
The main scenario for using this library is to use the `toDot` function, but it also supports conversions in the reverse direction.
|
|
208
|
+
|
|
209
|
+
By converting **DOT** to **Model**, a portion of the code can be written in the DOT language.
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
const G = fromDot(
|
|
213
|
+
`digraph {
|
|
214
|
+
node_A [
|
|
215
|
+
label = "This is a Label of Node A";
|
|
216
|
+
];
|
|
217
|
+
}`,
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
G.edge(['node_A', 'node_B']);
|
|
221
|
+
|
|
222
|
+
const dot = toDot(G)
|
|
223
|
+
// digraph {
|
|
224
|
+
// "node_A" [
|
|
225
|
+
// label = "This is a Label of Node A";
|
|
226
|
+
// ];
|
|
227
|
+
// "node_A" -> "node_B";
|
|
228
|
+
// }
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
</details>
|
|
232
|
+
|
|
233
|
+
#### Declarative API 😎
|
|
234
|
+
|
|
235
|
+
When creating `Graph` or `Digraph`, you can use _Model Factory_ to provide a notation more similar to the **DOT** language.
|
|
236
|
+
|
|
237
|
+
**Model** also has a declarative API, so you can consistently choose a declarative paradigm.
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
import { attribute as _, digraph, toDot } from 'ts-graphviz';
|
|
242
|
+
|
|
243
|
+
const G = digraph('G', (g) => {
|
|
244
|
+
const a = g.node('aa');
|
|
245
|
+
const b = g.node('bb');
|
|
246
|
+
const c = g.node('cc');
|
|
247
|
+
g.edge([a, b, c], {
|
|
248
|
+
[_.color]: 'red'
|
|
249
|
+
});
|
|
250
|
+
g.subgraph('A', (A) => {
|
|
251
|
+
const Aa = A.node('Aaa', {
|
|
252
|
+
[_.color]: 'pink'
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
const Ab = A.node('Abb', {
|
|
256
|
+
[_.color]: 'violet'
|
|
257
|
+
});
|
|
258
|
+
const Ac = A.node('Acc');
|
|
259
|
+
A.edge([Aa.port('a'), Ab, Ac, 'E'], {
|
|
260
|
+
[_.color]: 'red'
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const dot = toDot(G);
|
|
266
|
+
// digraph "G" {
|
|
267
|
+
// "aa";
|
|
268
|
+
// "bb";
|
|
269
|
+
// "cc";
|
|
270
|
+
// subgraph "A" {
|
|
271
|
+
// "Aaa" [
|
|
272
|
+
// color = "pink",
|
|
273
|
+
// ];
|
|
274
|
+
// "Abb" [
|
|
275
|
+
// color = "violet",
|
|
276
|
+
// ];
|
|
277
|
+
// "Acc";
|
|
278
|
+
// "Aaa":"a" -> "Abb" -> "Acc" -> "E" [
|
|
279
|
+
// color = "red",
|
|
280
|
+
// ];
|
|
281
|
+
// }
|
|
282
|
+
// "aa" -> "bb" -> "cc" [
|
|
283
|
+
// color = "red",
|
|
284
|
+
// ];
|
|
285
|
+
// }
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
> **Note** Of course, we also provide an API for creating strict mode graphs.
|
|
289
|
+
>
|
|
290
|
+
> ```typescript
|
|
291
|
+
> import { strict, toDot } from 'ts-graphviz';
|
|
292
|
+
>
|
|
293
|
+
> const G = strict.graph(...);
|
|
294
|
+
> const dot = toDot(G);
|
|
295
|
+
> // strict graph {
|
|
296
|
+
> // }
|
|
297
|
+
> ```
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
<details>
|
|
301
|
+
<summary>Advanced Usage</summary>
|
|
302
|
+
|
|
303
|
+
##### Models Context API ( `withContext` function ) 💈
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
The `withContext` function returns a _Model Factory_ function.
|
|
307
|
+
|
|
308
|
+
This _Model Factory_ provides a means to replace `RootGraphModel` with a custom class, such as `Digraph` or `Graph`.
|
|
309
|
+
|
|
310
|
+
This API provides a way to integrate declarative APIs and custom classes.
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
const { digraph } = withContext({
|
|
314
|
+
Digraph: MyCustomDigraph,
|
|
315
|
+
Node: MyCustomNode,
|
|
316
|
+
Edge: MyCustomEdge,
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
const G = digraph((g) => {
|
|
320
|
+
const a = g.node('A'); // MyCustomNode
|
|
321
|
+
const b = g.node('B'); // MyCustomNode
|
|
322
|
+
g.edge([a, b]); // MyCustomEdge
|
|
323
|
+
});
|
|
324
|
+
const dot = toDot(g);
|
|
325
|
+
// digraph "G" {
|
|
326
|
+
// label = "This is Custom Digraph";
|
|
327
|
+
// "node_A" [
|
|
328
|
+
// label = "This is Custom Node A";
|
|
329
|
+
// ];
|
|
330
|
+
// "node_B" [
|
|
331
|
+
// label = "This is Custom Node B";
|
|
332
|
+
// ];
|
|
333
|
+
// "node_A" -> "node_B" [
|
|
334
|
+
// label = "This is Custom Edge";
|
|
335
|
+
// ];
|
|
336
|
+
// }
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
</details>
|
|
340
|
+
|
|
341
|
+
### `ts-graphviz/adapter` Module 🔌
|
|
342
|
+
|
|
343
|
+
> This module status is .
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
Provides an interface to run Graphviz dot commands.
|
|
347
|
+
|
|
348
|
+
[Graphviz](https://graphviz.gitlab.io/) must be installed so that the dot command can be executed.
|
|
349
|
+
|
|
350
|
+
Execute the dot command to output a DOT language string to a stream or file.
|
|
351
|
+
|
|
352
|
+

|
|
353
|
+
|
|
354
|
+
This module provides the following functions.
|
|
355
|
+
|
|
356
|
+
- The `toStream` function converts **DOT** to **Stream**.
|
|
357
|
+
```ts
|
|
358
|
+
import { toStream } from 'ts-graphviz/adapter';
|
|
359
|
+
|
|
360
|
+
const dot = `
|
|
361
|
+
digraph example {
|
|
362
|
+
node1 [
|
|
363
|
+
label = "My Node",
|
|
364
|
+
]
|
|
365
|
+
}
|
|
366
|
+
`;
|
|
367
|
+
|
|
368
|
+
const stream = await toStream(dot, { format: 'svg' });
|
|
369
|
+
// Node.js
|
|
370
|
+
stream.pipe(process.stdout);
|
|
371
|
+
// Deno
|
|
372
|
+
await stream.pipeTo(Deno.stdout.writable);
|
|
373
|
+
```
|
|
374
|
+
- Writes **DOT** to a file at the specified path `toFile` function
|
|
375
|
+
```ts
|
|
376
|
+
import { toFile } from 'ts-graphviz/adapter';
|
|
377
|
+
|
|
378
|
+
const dot = `
|
|
379
|
+
digraph example {
|
|
380
|
+
node1 [
|
|
381
|
+
label = "My Node",
|
|
382
|
+
]
|
|
383
|
+
}
|
|
384
|
+
`;
|
|
385
|
+
|
|
386
|
+
await toFile(dot, './result.svg', { format: 'svg' });
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
> **Note** Designed to work with Node.js and Deno, Stream is runtime native.
|
|
390
|
+
|
|
391
|
+
### `ts-graphviz/ast` Module 🔢
|
|
392
|
+
|
|
393
|
+
> This module status is .
|
|
394
|
+
|
|
395
|
+
An API is provided to handle ASTs for advanced use.
|
|
396
|
+
|
|
397
|
+

|
|
398
|
+
|
|
399
|
+
The following functions are provided as described in the state transition diagram.
|
|
400
|
+
|
|
401
|
+
- The `fromModel` function converts **Model** to **AST**.
|
|
402
|
+
- The `toModel` function converts **AST** to **Model**.
|
|
403
|
+
- The `stringify` function converts **AST** to **DOT**.
|
|
404
|
+
- The `parse` function to convert from **DOT** to **AST**.
|
|
405
|
+
|
|
406
|
+
> **Note** As you can see from the above figure, the `toDot` function provided by the `ts-graphviz` package is a composite of `fromModel` and `stringify`. The `fromDot` function is a composite of `parse` and `toModel`.
|
|
407
|
+
|
|
408
|
+
Detailed usage is TODO.
|
|
409
|
+
Please refer to the TypeScript type definition.
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
<details>
|
|
413
|
+
<summary>The parse function and AST</summary>
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
```typescript
|
|
417
|
+
import { parse } from 'ts-graphviz/ast';
|
|
418
|
+
|
|
419
|
+
const ast = parse(`
|
|
420
|
+
digraph example {
|
|
421
|
+
node1 [
|
|
422
|
+
label = "My Node",
|
|
423
|
+
]
|
|
424
|
+
}
|
|
425
|
+
`);
|
|
426
|
+
// {
|
|
427
|
+
// type: 'Dot',
|
|
428
|
+
// location: {
|
|
429
|
+
// start: { offset: 3, line: 2, column: 3 },
|
|
430
|
+
// end: { offset: 68, line: 7, column: 1 }
|
|
431
|
+
// },
|
|
432
|
+
// children: [
|
|
433
|
+
// {
|
|
434
|
+
// id: {
|
|
435
|
+
// value: 'example',
|
|
436
|
+
// quoted: false,
|
|
437
|
+
// type: 'Literal',
|
|
438
|
+
// location: {
|
|
439
|
+
// start: { offset: 11, line: 2, column: 11 },
|
|
440
|
+
// end: { offset: 18, line: 2, column: 18 }
|
|
441
|
+
// },
|
|
442
|
+
// children: []
|
|
443
|
+
// },
|
|
444
|
+
// directed: true,
|
|
445
|
+
// strict: false,
|
|
446
|
+
// type: 'Graph',
|
|
447
|
+
// location: {
|
|
448
|
+
// start: { offset: 3, line: 2, column: 3 },
|
|
449
|
+
// end: { offset: 67, line: 6, column: 4 }
|
|
450
|
+
// },
|
|
451
|
+
// children: [
|
|
452
|
+
// {
|
|
453
|
+
// id: {
|
|
454
|
+
// value: 'node1',
|
|
455
|
+
// quoted: false,
|
|
456
|
+
// type: 'Literal',
|
|
457
|
+
// location: {
|
|
458
|
+
// start: { offset: 25, line: 3, column: 5 },
|
|
459
|
+
// end: { offset: 30, line: 3, column: 10 }
|
|
460
|
+
// },
|
|
461
|
+
// children: []
|
|
462
|
+
// },
|
|
463
|
+
// type: 'Node',
|
|
464
|
+
// location: {
|
|
465
|
+
// start: { offset: 25, line: 3, column: 5 },
|
|
466
|
+
// end: { offset: 63, line: 5, column: 6 }
|
|
467
|
+
// },
|
|
468
|
+
// children: [
|
|
469
|
+
// {
|
|
470
|
+
// key: {
|
|
471
|
+
// value: 'label',
|
|
472
|
+
// quoted: false,
|
|
473
|
+
// type: 'Literal',
|
|
474
|
+
// location: {
|
|
475
|
+
// start: { offset: 39, line: 4, column: 7 },
|
|
476
|
+
// end: { offset: 44, line: 4, column: 12 }
|
|
477
|
+
// },
|
|
478
|
+
// children: []
|
|
479
|
+
// },
|
|
480
|
+
// value: {
|
|
481
|
+
// value: 'My Node',
|
|
482
|
+
// quoted: true,
|
|
483
|
+
// type: 'Literal',
|
|
484
|
+
// location: {
|
|
485
|
+
// start: { offset: 47, line: 4, column: 15 },
|
|
486
|
+
// end: { offset: 56, line: 4, column: 24 }
|
|
487
|
+
// },
|
|
488
|
+
// children: []
|
|
489
|
+
// },
|
|
490
|
+
// location: {
|
|
491
|
+
// start: { offset: 39, line: 4, column: 7 },
|
|
492
|
+
// end: { offset: 57, line: 4, column: 25 }
|
|
493
|
+
// },
|
|
494
|
+
// type: 'Attribute',
|
|
495
|
+
// children: []
|
|
496
|
+
// }
|
|
497
|
+
// ]
|
|
498
|
+
// }
|
|
499
|
+
// ]
|
|
500
|
+
// }
|
|
501
|
+
// ]
|
|
502
|
+
// }
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
</details>
|
|
506
|
+
|
|
507
|
+
### Extending the Type System 🧰
|
|
508
|
+
|
|
509
|
+
> The status of this feature is .
|
|
510
|
+
|
|
511
|
+
With ts-graphviz, you can extend the library's type system to customize graph visualization solutions to meet specific needs.
|
|
512
|
+
|
|
513
|
+
> **Note** To allow for customization, types are named with the `$` symbol.
|
|
514
|
+
>
|
|
515
|
+
> If you want to extend a type definition in cases not listed below, check the source code to see if you can extend it with `$...`.
|
|
516
|
+
>
|
|
517
|
+
> If not, please create an issue or pull request.
|
|
518
|
+
|
|
519
|
+
#### Use Case: Specifying Custom Graph Layout and Output Formats
|
|
520
|
+
|
|
521
|
+
```ts
|
|
522
|
+
import { $keywords } from 'ts-graphviz';
|
|
523
|
+
import { toFile } from 'ts-graphviz/adapter';
|
|
524
|
+
|
|
525
|
+
// 1. Declare the 'ts-graphviz/adapter' module.
|
|
526
|
+
declare module 'ts-graphviz/adapter' {
|
|
527
|
+
export namespace Layout {
|
|
528
|
+
// 2. Define the $values interface in the Layout namespace.
|
|
529
|
+
// 3. Inherit from $keywords<'my-custom-algorithm'> and specify the name of the new layout engine in <...>.
|
|
530
|
+
export interface $values extends $keywords<'my-custom-algorithm'> {}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
export namespace Format {
|
|
534
|
+
// 4. Define the $values interface in the Format namespace.
|
|
535
|
+
// 5. Inherit from $keywords<'mp4'> and specify the name of the new output format in <...>.
|
|
536
|
+
export interface $values extends $keywords<'mp4'> {}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
toFile('digraph { a -> b }', '/path/to/file', {
|
|
541
|
+
layout: 'my-custom-algorithm',
|
|
542
|
+
format: 'mp4',
|
|
543
|
+
});
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
#### Use Case: Adding Custom Attributes
|
|
547
|
+
|
|
548
|
+
```ts
|
|
549
|
+
import { digraph, toDot, attribute as _, $keywords } from 'ts-graphviz';
|
|
550
|
+
|
|
551
|
+
// 1. Declare the 'ts-graphviz' module.
|
|
552
|
+
declare module 'ts-graphviz' {
|
|
553
|
+
export namespace GraphAttributeKey {
|
|
554
|
+
// 2. Define the $values interface in the GraphAttributeKey namespace.
|
|
555
|
+
// 3. Inherit from $keywords<'hoge'> and specify the name of the new attribute in <...>.
|
|
556
|
+
export interface $values extends $keywords<'hoge'> {}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
export namespace Attribute {
|
|
560
|
+
// 4. Define the $keys interface in the Attribute namespace.
|
|
561
|
+
// 5. Inherit from $keywords<'hoge'> and specify the name of the new attribute in <...>.
|
|
562
|
+
export interface $keys extends $keywords<'hoge'> {}
|
|
563
|
+
|
|
564
|
+
// 6. Define the $types interface in the Attribute namespace.
|
|
565
|
+
// 7. Specify the new attribute in the key and define its corresponding value in the value.
|
|
566
|
+
export interface $types {
|
|
567
|
+
hoge: string;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
console.log(
|
|
573
|
+
toDot(
|
|
574
|
+
digraph((g) => {
|
|
575
|
+
g.set(_.hoge, 'fuga');
|
|
576
|
+
}),
|
|
577
|
+
),
|
|
578
|
+
);
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
## Who's using `ts-graphviz` 📜
|
|
582
|
+
|
|
583
|
+
- [Apollo GraphQL](https://github.com/apollographql)
|
|
584
|
+
- [AWS](https://github.com/aws)
|
|
585
|
+
- [IBM (StrongLoop)](https://strongloop.com)
|
|
586
|
+
- [The University of Tokyo](https://github.com/csg-tokyo)
|
|
587
|
+
- [Transmute](https://github.com/transmute-industries)
|
|
588
|
+
|
|
589
|
+
> **Note** Let us know that you're using `ts-graphviz` on [GitHub Discussions](https://github.com/ts-graphviz/ts-graphviz/discussions/736) 🙏
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
## Related Projects 💫
|
|
593
|
+
|
|
594
|
+
Related projects can be found at [**ts-graphviz** GitHub Organization](https://github.com/ts-graphviz).
|
|
595
|
+
|
|
596
|
+
The TypeScript/JavaScript ecosystem provides a variety of OSS with the goal of making Graphviz more connected and easier to use.
|
|
597
|
+
|
|
598
|
+
## Contributors 👥
|
|
599
|
+
|
|
600
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
601
|
+
|
|
602
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
603
|
+
<!-- prettier-ignore-start -->
|
|
604
|
+
<!-- markdownlint-disable -->
|
|
605
|
+
<table>
|
|
606
|
+
<tbody>
|
|
607
|
+
<tr>
|
|
608
|
+
<td align="center" valign="top" width="14.28%"><a href="http://blog.kamiazya.tech/"><img src="https://avatars0.githubusercontent.com/u/35218186?v=4?s=100" width="100px;" alt="Yuki Yamazaki"/><br /><sub><b>Yuki Yamazaki</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/commits?author=kamiazya" title="Code">💻</a> <a href="https://github.com/ts-graphviz/ts-graphviz/commits?author=kamiazya" title="Tests">⚠️</a> <a href="https://github.com/ts-graphviz/ts-graphviz/commits?author=kamiazya" title="Documentation">📖</a> <a href="#ideas-kamiazya" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
609
|
+
<td align="center" valign="top" width="14.28%"><a href="https://laysent.com"><img src="https://avatars2.githubusercontent.com/u/1191606?v=4?s=100" width="100px;" alt="LaySent"/><br /><sub><b>LaySent</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Alaysent" title="Bug reports">🐛</a> <a href="https://github.com/ts-graphviz/ts-graphviz/commits?author=laysent" title="Tests">⚠️</a></td>
|
|
610
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/elasticdotventures"><img src="https://avatars0.githubusercontent.com/u/35611074?v=4?s=100" width="100px;" alt="elasticdotventures"/><br /><sub><b>elasticdotventures</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/commits?author=elasticdotventures" title="Documentation">📖</a></td>
|
|
611
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ChristianMurphy"><img src="https://avatars.githubusercontent.com/u/3107513?v=4?s=100" width="100px;" alt="Christian Murphy"/><br /><sub><b>Christian Murphy</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/commits?author=ChristianMurphy" title="Code">💻</a> <a href="#ideas-ChristianMurphy" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/ts-graphviz/ts-graphviz/commits?author=ChristianMurphy" title="Documentation">📖</a></td>
|
|
612
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/ArtemAdamenko"><img src="https://avatars.githubusercontent.com/u/2178516?v=4?s=100" width="100px;" alt="Artem"/><br /><sub><b>Artem</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3AArtemAdamenko" title="Bug reports">🐛</a></td>
|
|
613
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/fredericohpandolfo"><img src="https://avatars.githubusercontent.com/u/24229136?v=4?s=100" width="100px;" alt="fredericohpandolfo"/><br /><sub><b>fredericohpandolfo</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Afredericohpandolfo" title="Bug reports">🐛</a></td>
|
|
614
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/diegoquinteiro"><img src="https://avatars.githubusercontent.com/u/1878108?v=4?s=100" width="100px;" alt="diegoquinteiro"/><br /><sub><b>diegoquinteiro</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Adiegoquinteiro" title="Bug reports">🐛</a></td>
|
|
615
|
+
</tr>
|
|
616
|
+
<tr>
|
|
617
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/robross0606"><img src="https://avatars.githubusercontent.com/u/2965467?v=4?s=100" width="100px;" alt="robross0606"/><br /><sub><b>robross0606</b></sub></a><br /><a href="#ideas-robross0606" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
618
|
+
<td align="center" valign="top" width="14.28%"><a href="https://blake-regalia.net"><img src="https://avatars.githubusercontent.com/u/1456400?v=4?s=100" width="100px;" alt="Blake Regalia"/><br /><sub><b>Blake Regalia</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Ablake-regalia" title="Bug reports">🐛</a></td>
|
|
619
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/bigbug"><img src="https://avatars.githubusercontent.com/u/27259?v=4?s=100" width="100px;" alt="bigbug"/><br /><sub><b>bigbug</b></sub></a><br /><a href="#question-bigbug" title="Answering Questions">💬</a></td>
|
|
620
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/murawakimitsuhiro"><img src="https://avatars.githubusercontent.com/u/13833242?v=4?s=100" width="100px;" alt="mrwk"/><br /><sub><b>mrwk</b></sub></a><br /><a href="#question-murawakimitsuhiro" title="Answering Questions">💬</a></td>
|
|
621
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/svdvonde"><img src="https://avatars.githubusercontent.com/u/2751783?v=4?s=100" width="100px;" alt="svdvonde"/><br /><sub><b>svdvonde</b></sub></a><br /><a href="#question-svdvonde" title="Answering Questions">💬</a></td>
|
|
622
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/seethroughdev"><img src="https://avatars.githubusercontent.com/u/203779?v=4?s=100" width="100px;" alt="Adam"/><br /><sub><b>Adam</b></sub></a><br /><a href="#question-seethroughdev" title="Answering Questions">💬</a></td>
|
|
623
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/trevor-scheer"><img src="https://avatars.githubusercontent.com/u/29644393?v=4?s=100" width="100px;" alt="Trevor Scheer"/><br /><sub><b>Trevor Scheer</b></sub></a><br /><a href="#a11y-trevor-scheer" title="Accessibility">️️️️♿️</a></td>
|
|
624
|
+
</tr>
|
|
625
|
+
<tr>
|
|
626
|
+
<td align="center" valign="top" width="14.28%"><a href="https://pre.ms"><img src="https://avatars.githubusercontent.com/u/238277?v=4?s=100" width="100px;" alt="Prem Pillai"/><br /><sub><b>Prem Pillai</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Acloud-on-prem" title="Bug reports">🐛</a></td>
|
|
627
|
+
</tr>
|
|
628
|
+
</tbody>
|
|
629
|
+
</table>
|
|
630
|
+
|
|
631
|
+
<!-- markdownlint-restore -->
|
|
632
|
+
<!-- prettier-ignore-end -->
|
|
633
|
+
|
|
634
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
635
|
+
|
|
636
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors)
|
|
637
|
+
specification. Contributions of any kind welcome!
|
|
638
|
+
|
|
639
|
+
## How to Contribute 💪
|
|
640
|
+
|
|
641
|
+
The easiest way to contribute is to use the library and star [repository](https://github.com/ts-graphviz/ts-graphviz).
|
|
642
|
+
|
|
643
|
+
### Questions 💭
|
|
644
|
+
|
|
645
|
+
Feel free to ask questions on [GitHub Discussions](https://github.com/ts-graphviz/ts-graphviz/discussions).
|
|
646
|
+
|
|
647
|
+
### Report bugs / request additional features 💡
|
|
648
|
+
|
|
649
|
+
Please register at [GitHub Issues](https://github.com/ts-graphviz/ts-graphviz/issues/new/choose).
|
|
650
|
+
|
|
651
|
+
### Development / Bug Fixes 🧑💻
|
|
652
|
+
|
|
653
|
+
See [CONTRIBUTING.md](https://github.com/ts-graphviz/ts-graphviz/blob/main/CONTRIBUTING.md).
|
|
654
|
+
|
|
655
|
+
### Financial Support 💸
|
|
656
|
+
|
|
657
|
+
Please support [ts-graphviz](https://github.com/sponsors/ts-graphviz).
|
|
658
|
+
|
|
659
|
+
Our goal for ts-graphviz is to attract 10 sponsors who can provide ongoing support to help cover development and maintenance costs,
|
|
660
|
+
and help us continue expanding and improving the library. By achieving this goal, we can ensure that ts-graphviz remains a valuable resource
|
|
661
|
+
for developers who need to analyze and visualize complex graph structures, while also fostering a strong and supportive community of users and sponsors.
|
|
662
|
+
|
|
663
|
+
> **Note** Even just a dollar is enough motivation to develop 😊
|
|
664
|
+
|
|
665
|
+
## ts-graphviz for Enterprise 🏢
|
|
666
|
+
|
|
667
|
+
Available as part of the Tidelift Subscription.
|
|
668
|
+
|
|
669
|
+
The maintainers of ts-graphviz and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open-source dependencies you use to build your applications.
|
|
670
|
+
Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use.
|
|
671
|
+
|
|
672
|
+
[Learn more](https://tidelift.com/subscription/pkg/npm-ts-graphviz?utm_source=npm-ts-graphviz&utm_medium=referral&utm_campaign=enterprise&utm_term=repo).
|
|
673
|
+
|
|
674
|
+
## License ⚖️
|
|
675
|
+
|
|
676
|
+
This software is released under the MIT License, see [LICENSE](https://github.com/ts-graphviz/ts-graphviz/blob/main/LICENSE).
|
package/lib/adapter.cjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const adapter = require('@ts-graphviz/adapter');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.keys(adapter).forEach(k => {
|
|
10
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: () => adapter[k]
|
|
13
|
+
});
|
|
14
|
+
});
|
package/lib/adapter.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@ts-graphviz/adapter';
|
package/lib/adapter.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@ts-graphviz/adapter';
|
package/lib/ast.cjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const ast = require('@ts-graphviz/ast');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.keys(ast).forEach(k => {
|
|
10
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: () => ast[k]
|
|
13
|
+
});
|
|
14
|
+
});
|
package/lib/ast.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@ts-graphviz/ast';
|
package/lib/ast.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@ts-graphviz/ast';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const common = require('@ts-graphviz/common');
|
|
6
|
+
const core = require('@ts-graphviz/core');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.keys(common).forEach(k => {
|
|
11
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: () => common[k]
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
Object.keys(core).forEach(k => {
|
|
17
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: () => core[k]
|
|
20
|
+
});
|
|
21
|
+
});
|
package/media/Makefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="172pt" height="211pt" viewBox="0 0 172.44 211.09"><g class="graph" transform="translate(4 207.09)"><path fill="#fff" stroke="transparent" d="M-4 4v-211.09h172.44V4H-4z"/><g class="node"><circle cx="89.85" cy="-171.89" r="31.4" fill="none" stroke="#000"/><text x="89.85" y="-168.19" font-family="Times,serif" font-size="14" text-anchor="middle">DOT</text></g><g class="node"><circle cx="44.85" cy="-44.85" r="44.69" fill="none" stroke="#000"/><text x="44.85" y="-41.15" font-family="Times,serif" font-size="14" text-anchor="middle">Stream</text></g><g class="edge"><path fill="none" stroke="#000" d="M66.46-151.09c-7.72 7.95-15.4 17.76-19.61 28.4-2.87 7.24-4.54 15.17-5.4 23.11"/><path stroke="#000" d="m44.94-99.32-4.18 9.73-2.8-10.21 6.98.48z"/><text x="80.35" y="-111.49" font-family="Times,serif" font-size="14" text-anchor="middle">toStream</text></g><g class="node"><circle cx="135.85" cy="-44.85" r="28.7" fill="none" stroke="#000"/><text x="135.85" y="-41.15" font-family="Times,serif" font-size="14" text-anchor="middle">File</text></g><g class="edge"><path fill="none" stroke="#000" d="M104.32-144.01c3.38 6.84 6.79 14.26 9.53 21.32 4.95 12.76 9.35 27.09 12.89 39.89"/><path stroke="#000" d="m130.18-83.48-.79 10.56-5.97-8.75 6.76-1.81z"/><text x="139.85" y="-111.49" font-family="Times,serif" font-size="14" text-anchor="middle">toFile</text></g></g></svg>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
digraph state_machine {
|
|
2
|
+
newrank=true;
|
|
3
|
+
|
|
4
|
+
node [ shape = circle ]
|
|
5
|
+
|
|
6
|
+
Model -> DOT [ label = "toDot", constraint = false ]
|
|
7
|
+
AST -> DOT [ label = "stringify" ]
|
|
8
|
+
DOT -> AST [ label = "parse" ]
|
|
9
|
+
Model -> AST [ label = "fromModel" ]
|
|
10
|
+
AST -> Model [ label = "toModel" ]
|
|
11
|
+
DOT -> Model [ label = "fromDot", constraint = false ]
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="404" height="197pt" viewBox="0 0 302.59 196.79" xmlns="http://www.w3.org/2000/svg"><g class="graph" transform="translate(4 192.79)"><path fill="#fff" stroke="transparent" d="M-4 4v-196.79h302.59V4H-4z"/><g class="node"><circle fill="none" stroke="#000" cx="52.59" cy="-149.14" r="39.79"/><text text-anchor="middle" x="52.59" y="-145.44" font-family="Times,serif" font-size="14">Model</text></g><g class="node"><circle fill="none" stroke="#000" cx="218.59" cy="-149.14" r="31.4"/><text text-anchor="middle" x="218.59" y="-145.44" font-family="Times,serif" font-size="14">DOT</text></g><g class="edge"><path fill="none" stroke="#000" d="M90.64-137.1c9.44 2.47 19.6 4.7 29.18 5.96 17.63 2.32 22.42 2.63 40 0 6.37-.96 13.01-2.46 19.43-4.2"/><path stroke="#000" d="m178.51-138.77 10.58.54-8.61 6.17-1.97-6.71z"/><text text-anchor="middle" x="139.82" y="-134.94" font-family="Times,serif" font-size="14">toDot</text></g><g class="node"><circle fill="none" stroke="#000" cx="146.59" cy="-29.25" r="29.5"/><text text-anchor="middle" x="146.59" y="-25.55" font-family="Times,serif" font-size="14">AST</text></g><g class="edge"><path fill="none" stroke="#000" d="M21.2-124.93C5.91-110.76-6.93-92.37 4.59-76.49c23.16 31.9 68.9 42.22 102.23 45.34"/><path stroke="#000" d="m107.45-34.61 9.71 4.24-10.23 2.74.52-6.98z"/><text text-anchor="middle" x="44.09" y="-80.29" font-family="Times,serif" font-size="14">fromModel</text></g><g class="edge"><path fill="none" stroke="#000" d="M187.19-149.14h-84.61"/><path stroke="#000" d="m102.36-145.64-10-3.5 10-3.5v7z"/><text text-anchor="middle" x="139.82" y="-155.94" font-family="Times,serif" font-size="14">fromDot</text></g><g class="edge"><path fill="none" stroke="#000" d="M202.62-121.98c-10.54 17.26-24.44 40.01-35.75 58.54"/><path stroke="#000" d="m169.75-61.44-8.2 6.71 2.22-10.36 5.98 3.65z"/><text text-anchor="middle" x="202.59" y="-80.29" font-family="Times,serif" font-size="14">parse</text></g><g class="edge"><path fill="none" stroke="#000" d="M128.8-52.57c-12.81-16.06-30.42-38.14-45.48-57.03"/><path stroke="#000" d="m80.54-107.47-3.49-10 8.97 5.63-5.48 4.37z"/><text text-anchor="middle" x="138.09" y="-80.29" font-family="Times,serif" font-size="14">toModel</text></g><g class="edge"><path fill="none" stroke="#000" d="M174.74-37.96c18.87-6.8 42.31-18.78 53.85-38.53 5.88-10.07 6.19-22.25 4.18-33.7"/><path stroke="#000" d="m229.35-109.45 1.15-10.53 5.67 8.95-6.82 1.58z"/><text text-anchor="middle" x="264.09" y="-80.29" font-family="Times,serif" font-size="14">stringify</text></g></g></svg>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
digraph state_machine {
|
|
2
|
+
rankdir = LR;
|
|
3
|
+
node [ shape = circle ]
|
|
4
|
+
|
|
5
|
+
// { rank = same; factory_fn; Model; DOT; }
|
|
6
|
+
|
|
7
|
+
factory_fn [
|
|
8
|
+
shape = record,
|
|
9
|
+
label = "{{Model Factory Functions | strict.digraph(...)\lstrict.graph(...)\ldigraph(...)\lgraph(...)\l}}"
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
oop [
|
|
13
|
+
shape = record,
|
|
14
|
+
label = "{{Object Oriented Programing | new Digraph(...)\lnew Graph(...)\l...\l}}"
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
{factory_fn, oop} -> Model;
|
|
18
|
+
|
|
19
|
+
Model -> DOT [ label = "toDot" ]
|
|
20
|
+
DOT -> Model [ label = "fromDot" ]
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="503pt" height="196pt" viewBox="0 0 502.69 195.5" xmlns="http://www.w3.org/2000/svg"><g class="graph" transform="translate(4 191.5)"><path fill="#fff" stroke="transparent" d="M-4 4v-195.5h502.69V4H-4z"/><g class="node"><path fill="none" stroke="#000" d="M13-96v-91h194v91H13z"/><text text-anchor="middle" x="110" y="-171.8" font-family="Times,serif" font-size="14">Model Factory Functions</text><path fill="none" stroke="#000" d="M13-164h194"/><text x="21" y="-148.8" font-family="Times,serif" font-size="14">strict.digraph(...)</text><text x="21" y="-133.8" font-family="Times,serif" font-size="14">strict.graph(...)</text><text x="21" y="-118.8" font-family="Times,serif" font-size="14">digraph(...)</text><text x="21" y="-103.8" font-family="Times,serif" font-size="14">graph(...)</text></g><g class="node"><circle fill="none" stroke="#000" cx="296.65" cy="-89.5" r="39.79"/><text text-anchor="middle" x="296.65" y="-85.8" font-family="Times,serif" font-size="14">Model</text></g><g class="edge"><path fill="none" stroke="#000" d="M207.11-114.43c14.38 4.05 28.64 8.06 41.38 11.65"/><path stroke="#000" d="m249.67-106.08 8.68 6.08-10.57.65 1.89-6.73z"/></g><g class="node"><path fill="none" stroke="#000" d="M0-.5v-76h220v76H0z"/><text text-anchor="middle" x="110" y="-61.3" font-family="Times,serif" font-size="14">Object Oriented Programing</text><path fill="none" stroke="#000" d="M0-53.5h220"/><text x="8" y="-38.3" font-family="Times,serif" font-size="14">new Digraph(...)</text><text x="8" y="-23.3" font-family="Times,serif" font-size="14">new Graph(...)</text><text x="8" y="-8.3" font-family="Times,serif" font-size="14">...</text></g><g class="edge"><path fill="none" stroke="#000" d="M220.01-68.61c9.87-2.73 19.48-5.38 28.35-7.83"/><path stroke="#000" d="m247.47-79.82 10.57.71-8.7 6.03-1.87-6.74z"/></g><g class="node"><circle fill="none" stroke="#000" cx="463.49" cy="-89.5" r="31.4"/><text text-anchor="middle" x="463.49" y="-85.8" font-family="Times,serif" font-size="14">DOT</text></g><g class="edge"><path fill="none" stroke="#000" d="M336.3-89.5h85.43"/><path stroke="#000" d="m422.05-93 10 3.5-10 3.5v-7z"/><text text-anchor="middle" x="384.29" y="-93.3" font-family="Times,serif" font-size="14">toDot</text></g><g class="edge"><path fill="none" stroke="#000" d="M434.99-76.62c-6.64 2.54-13.8 4.81-20.7 6.12-26.2 4.98-33.68 4.3-60 0-3.48-.57-7.04-1.32-10.59-2.2"/><path stroke="#000" d="m342.47-69.41-8.7-6.05 10.58-.69-1.88 6.74z"/><text text-anchor="middle" x="384.29" y="-74.3" font-family="Times,serif" font-size="14">fromDot</text></g></g></svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ts-graphviz",
|
|
3
|
+
"version": "0.0.0-pr956-20240225073457",
|
|
4
|
+
"author": "kamiazya <yuki@kamiazya.tech>",
|
|
5
|
+
"description": "Graphviz library for TypeScript.",
|
|
6
|
+
"homepage": "https://ts-graphviz.github.io/ts-graphviz/",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/ts-graphviz/ts-graphviz.git",
|
|
11
|
+
"directory": "packages/ts-graphviz"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public",
|
|
15
|
+
"provenance": true
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"graphviz",
|
|
19
|
+
"dot"
|
|
20
|
+
],
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/ts-graphviz/ts-graphviz/issues"
|
|
23
|
+
},
|
|
24
|
+
"funding": {
|
|
25
|
+
"type": "github",
|
|
26
|
+
"url": "https://github.com/sponsors/ts-graphviz"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"lib",
|
|
30
|
+
"media",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"main": "./lib/ts-graphviz.cjs",
|
|
35
|
+
"module": "./lib/ts-graphviz.js",
|
|
36
|
+
"types": "lib/ts-graphviz.d.ts",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./lib/ts-graphviz.d.ts",
|
|
41
|
+
"default": "./lib/ts-graphviz.cjs"
|
|
42
|
+
},
|
|
43
|
+
"import": {
|
|
44
|
+
"types": "./lib/ts-graphviz.d.ts",
|
|
45
|
+
"default": "./lib/ts-graphviz.js"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"./ast": {
|
|
49
|
+
"types": "./lib/ast.d.ts",
|
|
50
|
+
"require": "./lib/ast.cjs",
|
|
51
|
+
"default": "./lib/ast.js"
|
|
52
|
+
},
|
|
53
|
+
"./adapter": {
|
|
54
|
+
"types": "./lib/adapter.d.ts",
|
|
55
|
+
"require": "./lib/adapter.cjs",
|
|
56
|
+
"default": "./lib/adapter.js"
|
|
57
|
+
},
|
|
58
|
+
"./package.json": "./package.json"
|
|
59
|
+
},
|
|
60
|
+
"license": "MIT",
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=18"
|
|
63
|
+
},
|
|
64
|
+
"runkitExampleFilename": "example/runkit.cjs",
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"@ts-graphviz/adapter": "^0.0.0-pr956-20240225073457",
|
|
67
|
+
"@ts-graphviz/ast": "^0.0.0-pr956-20240225073457",
|
|
68
|
+
"@ts-graphviz/core": "^0.0.0-pr956-20240225073457",
|
|
69
|
+
"@ts-graphviz/common": "^0.0.0-pr956-20240225073457"
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"peggy": "^3.0.2",
|
|
73
|
+
"ts-pegjs": "^4.2.1",
|
|
74
|
+
"typescript": "^5.3.3",
|
|
75
|
+
"vite": "^5.1.3",
|
|
76
|
+
"vite-plugin-dts": "^3.7.2"
|
|
77
|
+
},
|
|
78
|
+
"scripts": {
|
|
79
|
+
"build": "vite build"
|
|
80
|
+
}
|
|
81
|
+
}
|