ts-graphviz 1.5.6-dev.29eb2444f → 1.5.6-dev.d45e33d3b
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 +0 -74
- package/lib/adapter/node/index.d.ts +1 -1
- package/lib/adapter/types/index.d.ts +2 -12
- package/lib/common/index.d.ts +1281 -3861
- package/lib/core/index.d.ts +2482 -5
- package/lib/index.d.ts +0 -1
- package/lib/utils/index.d.ts +1 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -503,80 +503,6 @@ 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
|
-
|
|
580
506
|
## Who's using `ts-graphviz` 📜
|
|
581
507
|
|
|
582
508
|
- [Apollo GraphQL](https://github.com/apollographql)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Layout, Options } from '../types/index.js';
|
|
3
|
-
export { Format,
|
|
3
|
+
export { Format, Options } from '../types/index.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Execute the Graphviz dot command and make a Stream of the results.
|
|
@@ -4,19 +4,9 @@ import {
|
|
|
4
4
|
GraphAttributesObject,
|
|
5
5
|
SubgraphAttributesObject,
|
|
6
6
|
} from '../../common/index.js';
|
|
7
|
-
import { $keywords } from '../../utils/index.js';
|
|
8
7
|
|
|
9
|
-
type Format =
|
|
10
|
-
|
|
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
|
-
}
|
|
8
|
+
type Format = 'png' | 'svg' | 'json' | 'jpg' | 'pdf' | 'xdot' | 'dot' | 'plain' | 'dot_json';
|
|
9
|
+
type Layout = 'dot' | 'neato' | 'fdp' | 'sfdp' | 'circo' | 'twopi' | 'nop' | 'nop2' | 'osage' | 'patchwork';
|
|
20
10
|
/**
|
|
21
11
|
* NeatoOptions interface provides options for the neato layout.
|
|
22
12
|
*/
|