ts-graphviz 1.5.5 → 1.5.6-dev.afd5830bd
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 +80 -2
- package/lib/adapter/node/index.d.ts +1 -1
- package/lib/adapter/types/index.d.ts +12 -2
- package/lib/common/index.d.ts +3861 -1281
- package/lib/core/index.d.ts +5 -2482
- package/lib/index.d.ts +1 -0
- package/lib/utils/index.d.ts +8 -1
- package/package.json +120 -120
package/README.md
CHANGED
|
@@ -503,6 +503,80 @@ const ast = parse(`
|
|
|
503
503
|
|
|
504
504
|
</details>
|
|
505
505
|
|
|
506
|
+
### Extending the Type System 🧰
|
|
507
|
+
|
|
508
|
+
> The status of this feature is .
|
|
509
|
+
|
|
510
|
+
With ts-graphviz, you can extend the library's type system to customize graph visualization solutions to meet specific needs.
|
|
511
|
+
|
|
512
|
+
> **Note** To allow for customization, types are named with the `$` symbol.
|
|
513
|
+
>
|
|
514
|
+
> 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 `$...`.
|
|
515
|
+
>
|
|
516
|
+
> If not, please create an issue or pull request.
|
|
517
|
+
|
|
518
|
+
#### Use Case: Specifying Custom Graph Layout and Output Formats
|
|
519
|
+
|
|
520
|
+
```ts
|
|
521
|
+
import { $keywords } from 'ts-graphviz';
|
|
522
|
+
import { toFile } from 'ts-graphviz/adapter';
|
|
523
|
+
|
|
524
|
+
// 1. Declare the 'ts-graphviz/adapter' module.
|
|
525
|
+
declare module 'ts-graphviz/adapter' {
|
|
526
|
+
export namespace Layout {
|
|
527
|
+
// 2. Define the $values interface in the Layout namespace.
|
|
528
|
+
// 3. Inherit from $keywords<'my-custom-algorithm'> and specify the name of the new layout engine in <...>.
|
|
529
|
+
export interface $values extends $keywords<'my-custom-algorithm'> {}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
export namespace Format {
|
|
533
|
+
// 4. Define the $values interface in the Format namespace.
|
|
534
|
+
// 5. Inherit from $keywords<'mp4'> and specify the name of the new output format in <...>.
|
|
535
|
+
export interface $values extends $keywords<'mp4'> {}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
toFile('digraph { a -> b }', '/path/to/file', {
|
|
540
|
+
layout: 'my-custom-algorithm',
|
|
541
|
+
format: 'mp4',
|
|
542
|
+
});
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
#### Use Case: Adding Custom Attributes
|
|
546
|
+
|
|
547
|
+
```ts
|
|
548
|
+
import { digraph, toDot, attribute as _, $keywords } from 'ts-graphviz';
|
|
549
|
+
|
|
550
|
+
// 1. Declare the 'ts-graphviz' module.
|
|
551
|
+
declare module 'ts-graphviz' {
|
|
552
|
+
export namespace GraphAttributeKey {
|
|
553
|
+
// 2. Define the $values interface in the GraphAttributeKey namespace.
|
|
554
|
+
// 3. Inherit from $keywords<'hoge'> and specify the name of the new attribute in <...>.
|
|
555
|
+
export interface $values extends $keywords<'hoge'> {}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export namespace Attribute {
|
|
559
|
+
// 4. Define the $keys interface in the Attribute namespace.
|
|
560
|
+
// 5. Inherit from $keywords<'hoge'> and specify the name of the new attribute in <...>.
|
|
561
|
+
export interface $keys extends $keywords<'hoge'> {}
|
|
562
|
+
|
|
563
|
+
// 6. Define the $types interface in the Attribute namespace.
|
|
564
|
+
// 7. Specify the new attribute in the key and define its corresponding value in the value.
|
|
565
|
+
export interface $types {
|
|
566
|
+
hoge: string;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
console.log(
|
|
572
|
+
toDot(
|
|
573
|
+
digraph((g) => {
|
|
574
|
+
g.set(_.hoge, 'fuga');
|
|
575
|
+
}),
|
|
576
|
+
),
|
|
577
|
+
);
|
|
578
|
+
```
|
|
579
|
+
|
|
506
580
|
## Who's using `ts-graphviz` 📜
|
|
507
581
|
|
|
508
582
|
- [Apollo GraphQL](https://github.com/apollographql)
|
|
@@ -576,9 +650,13 @@ See [CONTRIBUTING.md](https://github.com/ts-graphviz/ts-graphviz/blob/main/CONTR
|
|
|
576
650
|
|
|
577
651
|
### Financial Support 💸
|
|
578
652
|
|
|
579
|
-
Please support
|
|
653
|
+
Please support [ts-graphviz](https://github.com/sponsors/ts-graphviz).
|
|
654
|
+
|
|
655
|
+
Our goal for ts-graphviz is to attract 10 sponsors who can provide ongoing support to help cover development and maintenance costs,
|
|
656
|
+
and help us continue expanding and improving the library. By achieving this goal, we can ensure that ts-graphviz remains a valuable resource
|
|
657
|
+
for developers who need to analyze and visualize complex graph structures, while also fostering a strong and supportive community of users and sponsors.
|
|
580
658
|
|
|
581
|
-
> **Note** Even just a dollar is enough motivation
|
|
659
|
+
> **Note** Even just a dollar is enough motivation to develop 😊
|
|
582
660
|
|
|
583
661
|
## License ⚖️
|
|
584
662
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Layout, Options } from '../types/index.js';
|
|
3
|
-
export { Format, Options } from '../types/index.js';
|
|
3
|
+
export { Format, Layout, Options } from '../types/index.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Execute the Graphviz dot command and make a Stream of the results.
|
|
@@ -4,9 +4,19 @@ import {
|
|
|
4
4
|
GraphAttributesObject,
|
|
5
5
|
SubgraphAttributesObject,
|
|
6
6
|
} from '../../common/index.js';
|
|
7
|
+
import { $keywords } from '../../utils/index.js';
|
|
7
8
|
|
|
8
|
-
type Format =
|
|
9
|
-
|
|
9
|
+
type Format = Format.values;
|
|
10
|
+
declare namespace Format {
|
|
11
|
+
type values = keyof $values;
|
|
12
|
+
interface $values extends $keywords<'png' | 'svg' | 'json' | 'jpg' | 'pdf' | 'xdot' | 'dot' | 'plain' | 'dot_json'> {}
|
|
13
|
+
}
|
|
14
|
+
type Layout = Layout.values;
|
|
15
|
+
declare namespace Layout {
|
|
16
|
+
type values = keyof $values;
|
|
17
|
+
interface $values
|
|
18
|
+
extends $keywords<'dot' | 'neato' | 'fdp' | 'sfdp' | 'circo' | 'twopi' | 'nop' | 'nop2' | 'osage' | 'patchwork'> {}
|
|
19
|
+
}
|
|
10
20
|
/**
|
|
11
21
|
* NeatoOptions interface provides options for the neato layout.
|
|
12
22
|
*/
|