@ts-graphviz/core 2.0.7-next-f8ba9a89f3ac9e916ded16f0a0618113a5eb4928 → 3.0.0

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 CHANGED
@@ -1,11 +1,233 @@
1
1
  # @ts-graphviz/core
2
2
 
3
- ## 2.0.7-next-f8ba9a89f3ac9e916ded16f0a0618113a5eb4928
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#1363](https://github.com/ts-graphviz/ts-graphviz/pull/1363) [`9328563`](https://github.com/ts-graphviz/ts-graphviz/commit/932856396ed0dede1dfc6737344a628f9667d07c) Thanks [@kamiazya](https://github.com/kamiazya)! - 🚨 Breaking Changes: Drop Node.js 18 support
8
+
9
+ Minimum required version is now Node.js 20+
10
+
11
+ ### ESM-Only Distribution
12
+
13
+ - **Remove CommonJS builds**: All packages now distribute only ESM (ECMAScript Modules)
14
+ - **Package exports**: Removed `require` fields from `package.json` exports
15
+ - **Module type**: All packages are now `"type": "module"`
16
+
17
+ ## 🔄 Migration Guide
18
+
19
+ ### For ESM Projects (Recommended)
20
+
21
+ ```json
22
+ {
23
+ "type": "module"
24
+ }
25
+ ```
26
+
27
+ ```typescript
28
+ // Import syntax remains unchanged
29
+ import { Digraph, Node, Edge, toDot } from "ts-graphviz";
30
+ import { toFile } from "ts-graphviz/adapter";
31
+ import { parse } from "ts-graphviz/ast";
32
+ ```
33
+
34
+ ### For CommonJS Projects
35
+
36
+ If you are using CommonJS (CJS) and need to migrate to ESM, you will need to update your project to support dynamic imports. This is necessary because the packages no longer provide CommonJS builds.
37
+
38
+ ### Before (CJS)
39
+
40
+ ```javascript
41
+ // JavaScript (CommonJS)
42
+ function createGraph() {
43
+ // Dynamic import is required because the packages no longer provide CommonJS builds.
44
+ const { Digraph, Node, Edge, toDot } = require("ts-graphviz");
45
+ const graph = new Digraph();
46
+ return toDot(graph);
47
+ }
48
+ ```
49
+
50
+ ### After (ESM)
51
+
52
+ ```javascript
53
+ async function createGraph() {
54
+ const { Digraph, Node, Edge, toDot } = await import("ts-graphviz");
55
+
56
+ const graph = new Digraph();
57
+ // Create your graph...
58
+ return toDot(graph);
59
+ }
60
+ ```
61
+
62
+ ```typescript
63
+ // TypeScript (CommonJS)
64
+ // Update tsconfig.json
65
+ {
66
+ "compilerOptions": {
67
+ "module": "Node16",
68
+ "moduleResolution": "Node16"
69
+ }
70
+ }
71
+
72
+ // Use dynamic imports
73
+ async function createGraph() {
74
+ const tsGraphviz = await import('ts-graphviz');
75
+ const { Digraph, Node, Edge, toDot } = tsGraphviz;
76
+
77
+ const graph = new Digraph();
78
+ // Create your graph...
79
+ return toDot(graph);
80
+ }
81
+ ```
82
+
83
+ ## 🎯 Benefits
84
+
85
+ - **Modern JavaScript**: Leveraging native ES modules for better performance
86
+ - **Smaller bundle sizes**: ESM enables better tree-shaking
87
+ - **Future-proof**: Aligning with the JavaScript ecosystem direction
88
+ - **Better TypeScript support**: Enhanced module resolution
89
+
90
+ ### Minor Changes
91
+
92
+ - [#1363](https://github.com/ts-graphviz/ts-graphviz/pull/1363) [`9328563`](https://github.com/ts-graphviz/ts-graphviz/commit/932856396ed0dede1dfc6737344a628f9667d07c) Thanks [@kamiazya](https://github.com/kamiazya)! - Define Supported environment and Support levels
93
+
94
+ To provide clarity on the environments in which ts-graphviz operates, we have categorized support levels:
95
+
96
+ ## Support Levels
97
+
98
+ ### Tier 1: Full Support
99
+
100
+ - **Definition**: Environments that are fully supported, with comprehensive automated testing and maintenance.
101
+ - **Environments**:
102
+ - **Node.js LTS versions**: All active Long-Term Support (LTS) versions.
103
+ - If a Node.js LTS version is released, we will ensure compatibility with it.
104
+ - If a Node.js LTS version is deprecated, we will drop support for it in the next major release.
105
+ - **Details**:
106
+ - We run automated tests on all LTS versions of Node.js.
107
+ - Full compatibility and performance are ensured.
108
+ - Critical issues are prioritized for fixes.
109
+
110
+ ### Tier 2: Active Support
111
+
112
+ - **Definition**: Environments that receive active support with limited automated testing.
113
+ - **Environments**:
114
+ - **Deno Latest LTS version**: The latest Long-Term Support (LTS) version of Deno.
115
+ - If a new Deno LTS version is released, we will ensure compatibility with it.
116
+ - If a Deno LTS version is deprecated, we will drop support for it in the next minor release.
117
+ - **Node.js Current Release**: The latest Node.js release outside the LTS schedule.
118
+ - If a new Node.js current release is available, we will ensure compatibility with it.
119
+ - If a Node.js current release is deprecated, we will drop support for it in the next minor release.
120
+ - **Details**:
121
+ - Compatibility is maintained, and issues are addressed.
122
+
123
+ ### Tier 3: Community Support
124
+
125
+ - **Definition**: Environments that are not officially tested but are supported on a best-effort basis.
126
+ - **Environments**:
127
+ - **Modern Browsers**: Latest versions of major browsers, including:
128
+ - Google Chrome
129
+ - Mozilla Firefox
130
+ - Microsoft Edge
131
+ - Apple Safari
132
+ - **Deno Current Release**: The latest Deno release outside the LTS schedule.
133
+ - **Details**:
134
+ - Installation methods are provided.
135
+ - No automated testing is performed.
136
+ - Issues reported by users will be addressed.
137
+ - Targeting the latest versions ensures compatibility with modern web standards.
138
+ - We will not actively test or maintain compatibility with older versions of browsers.
139
+
140
+ ### Patch Changes
141
+
142
+ - [#1363](https://github.com/ts-graphviz/ts-graphviz/pull/1363) [`9328563`](https://github.com/ts-graphviz/ts-graphviz/commit/932856396ed0dede1dfc6737344a628f9667d07c) Thanks [@kamiazya](https://github.com/kamiazya)! - Update Develop Environment
143
+
144
+ - Drop turbo
145
+ - Upgrade biome to 2.0
146
+ - Upgrade TypeScript to 5.8
147
+ - Upgrade Vite to 7.0
148
+ - Upgrade Vitest to 3.2
149
+ - Upgrade Peggy to 5.0 and drop ts-pegjs
150
+ - Implement new E2E test workflow
151
+
152
+ - [#1363](https://github.com/ts-graphviz/ts-graphviz/pull/1363) [`9328563`](https://github.com/ts-graphviz/ts-graphviz/commit/932856396ed0dede1dfc6737344a628f9667d07c) Thanks [@kamiazya](https://github.com/kamiazya)! - ## Core Package TypeScript Type System Modernization
153
+
154
+ ## 🔧 FIXES
155
+
156
+ ### GraphBase Class Type Compatibility
157
+
158
+ **Fixed GraphBase class type compatibility issues:**
159
+
160
+ - **BREAKING INTERNAL**: Updated `GraphBase<T>` to `GraphBase<T, K>` to properly implement `GraphBaseModel<T, K>` interface
161
+ - First generic parameter `T extends DotObjectType` represents the object type ('Graph', 'Subgraph', etc.)
162
+ - Second generic parameter `K extends AttributeKey` represents the attribute key constraints
163
+ - **Added missing `$type` property**: Abstract `$type` property ensures proper implementation across subclasses
164
+ - **Enhanced type constraints**: Proper separation between object types and attribute types for better type safety
165
+
166
+ **Updated class hierarchy:**
167
+
168
+ ```typescript
169
+ // Before
170
+ export abstract class GraphBase<T extends AttributeKey>
171
+ extends AttributesBase<T>
172
+ implements GraphBaseModel<T>
173
+
174
+ // After
175
+ export abstract class GraphBase<T extends DotObjectType, K extends AttributeKey = AttributeKey>
176
+ extends AttributesBase<K>
177
+ implements GraphBaseModel<T, K>
178
+ {
179
+ public abstract get $type(): T;
180
+ }
181
+ ```
182
+
183
+ **Cascading updates to subclasses:**
184
+
185
+ - `RootGraph`: Updated to `GraphBase<'Graph', GraphAttributeKey>`
186
+ - `Subgraph`: Updated to `GraphBase<'Subgraph', SubgraphAttributeKey | ClusterSubgraphAttributeKey>`
187
+ - Test classes: Added required `$type` implementation
188
+
189
+ ## 🚀 IMPROVEMENTS
190
+
191
+ ### Type Safety Enhancement
192
+
193
+ - **Eliminated type compatibility errors**: All GraphBase-related type issues resolved using proper generic constraints
194
+ - **Maintained library TypeScript value**: Strong typing preserved throughout the core type system
195
+ - **Interface-implementation alignment**: GraphBase class now correctly implements GraphBaseModel interface requirements
196
+
197
+ ### Enhanced Developer Experience
198
+
199
+ - **Better IntelliSense support**: Improved autocomplete and type checking for core graph classes
200
+ - **Clearer error messages**: More precise TypeScript errors when GraphBase subclasses are misused
201
+ - **Consistent type patterns**: Unified approach to handling object types vs attribute types
202
+
203
+ ## 📊 TECHNICAL DETAILS
204
+
205
+ ### Architecture Improvements
206
+
207
+ - **Generic type system enhancement**: Proper separation of concerns between object types (`DotObjectType`) and attribute constraints (`AttributeKey`)
208
+ - **Abstract property enforcement**: All GraphBase subclasses must properly implement `$type` property
209
+ - **Type parameter ordering**: Consistent `<ObjectType, AttributeType>` pattern across the inheritance hierarchy
210
+
211
+ ### Compatibility Notes
212
+
213
+ - **Runtime behavior unchanged**: All functional behavior remains identical
214
+ - **API surface unchanged**: No public API modifications for end users
215
+ - **Internal type system modernized**: Enhanced type safety without breaking changes
216
+
217
+ This update resolves TypeScript strict mode compilation errors in the core package while maintaining full backward compatibility and establishing a solid foundation for type-safe graph model development.
218
+
219
+ - [#1363](https://github.com/ts-graphviz/ts-graphviz/pull/1363) [`9328563`](https://github.com/ts-graphviz/ts-graphviz/commit/932856396ed0dede1dfc6737344a628f9667d07c) Thanks [@kamiazya](https://github.com/kamiazya)! - New GitHub Action main workflow and tests
220
+
221
+ - Updated dependencies [[`9328563`](https://github.com/ts-graphviz/ts-graphviz/commit/932856396ed0dede1dfc6737344a628f9667d07c), [`9328563`](https://github.com/ts-graphviz/ts-graphviz/commit/932856396ed0dede1dfc6737344a628f9667d07c), [`9328563`](https://github.com/ts-graphviz/ts-graphviz/commit/932856396ed0dede1dfc6737344a628f9667d07c), [`9328563`](https://github.com/ts-graphviz/ts-graphviz/commit/932856396ed0dede1dfc6737344a628f9667d07c), [`9328563`](https://github.com/ts-graphviz/ts-graphviz/commit/932856396ed0dede1dfc6737344a628f9667d07c), [`9328563`](https://github.com/ts-graphviz/ts-graphviz/commit/932856396ed0dede1dfc6737344a628f9667d07c)]:
222
+ - @ts-graphviz/common@3.0.0
223
+ - @ts-graphviz/ast@3.0.0
224
+
225
+ ## 2.0.7
4
226
 
5
227
  ### Patch Changes
6
228
 
7
229
  - Updated dependencies [[`c043ba9`](https://github.com/ts-graphviz/ts-graphviz/commit/c043ba9bcc5194a89b976df1609c4e9875300f1e)]:
8
- - @ts-graphviz/ast@2.0.7-next-f8ba9a89f3ac9e916ded16f0a0618113a5eb4928
230
+ - @ts-graphviz/ast@2.0.7
9
231
 
10
232
  ## 2.0.6
11
233
 
package/README.md CHANGED
@@ -1,47 +1,245 @@
1
+ <div align="center">
2
+
3
+ [![Main](https://github.com/ts-graphviz/ts-graphviz/actions/workflows/main.yaml/badge.svg)](https://github.com/ts-graphviz/ts-graphviz/actions/workflows/main.yaml)
4
+ [![CodeQL](https://github.com/ts-graphviz/ts-graphviz/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/ts-graphviz/ts-graphviz/actions/workflows/codeql-analysis.yml)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/ts-graphviz/ts-graphviz/blob/main/LICENSE)
6
+ [![All Contributors](https://img.shields.io/github/all-contributors/ts-graphviz/ts-graphviz?color=orange)](#contributors-)
7
+
8
+ [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8396/badge)](https://www.bestpractices.dev/projects/8396)
9
+ [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/ts-graphviz/ts-graphviz/badge)](https://scorecard.dev/viewer/?uri=github.com/ts-graphviz/ts-graphviz)
10
+ [![Tidelift](https://tidelift.com/badges/package/npm/ts-graphviz?style=flat)](https://tidelift.com/subscription/pkg/npm-ts-graphviz?utm_source=npm-ts-graphviz&utm_medium=readme)
11
+
12
+ [![npm version](https://badge.fury.io/js/ts-graphviz.svg)](https://badge.fury.io/js/ts-graphviz)
13
+ ![node version](https://img.shields.io/node/v/ts-graphviz)
14
+ [![deno version](https://img.shields.io/badge/deno-lts-black?logo=deno)](https://github.com/denoland/deno)
15
+ [![npm](https://img.shields.io/npm/dm/ts-graphviz)](https://npmtrends.com/ts-graphviz)
16
+
1
17
  # @ts-graphviz/core
2
18
 
3
- > It is part of the ts-graphviz library, which is split into modular packages to improve maintainability, flexibility, and ease of use.
19
+ Models and functions provided to users for the ts-graphviz library.
20
+
21
+ 🔗
22
+
23
+ [![GitHub](https://img.shields.io/badge/-GitHub-181717?logo=GitHub&style=flat)](https://github.com/ts-graphviz/ts-graphviz)
24
+ [![npm](https://img.shields.io/badge/-npm-CB3837?logo=npm&style=flat)](https://www.npmjs.com/package/ts-graphviz)
25
+ [![Reference](https://img.shields.io/badge/-API_Reference-3178C6?logo=TypeScript&style=flat&logoColor=fff)](https://ts-graphviz.github.io/ts-graphviz/)
26
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/ts-graphviz/ts-graphviz)
27
+
28
+ [![Sponsor](https://img.shields.io/badge/-GitHub%20Sponsor-fff?logo=GitHub%20Sponsors&style=flat)](https://github.com/sponsors/ts-graphviz)
29
+ [![OpenCollective](https://img.shields.io/badge/-OpenCollective-7FADF2?logo=opencollective&style=flat&logoColor=white)](https://opencollective.com/ts-graphviz)
30
+
31
+ [![format: Biome](https://img.shields.io/badge/format%20with-Biome-F7B911?logo=biome&style=flat)](https://biomejs.dev/)
32
+ [![test: Vitest](https://img.shields.io/badge/tested%20with-Vitest-6E9F18?logo=vitest&style=flat)](https://vitest.dev/)
33
+ [![build: Vite](https://img.shields.io/badge/build%20with-Vite-646CFF?logo=vite&style=flat)](https://rollupjs.org/)
34
+
35
+ </div>
4
36
 
5
- This package contains the core implementation of models and functions provided to users for the ts-graphviz library.
37
+ ---
38
+
39
+ > It is part of the ts-graphviz library, which is split into modular packages to improve maintainability, flexibility, and ease of use.
6
40
 
7
41
  ## Features
8
42
 
9
- - Graph, Node, and Edge model implementations
10
- - High-level APIs for creating and manipulating DOT language elements
11
- - Extensible design for custom implementations
43
+ The package adheres to object-oriented programming principles, allowing for:
44
+
45
+ - Creation and manipulation of graph elements
46
+ - Composition of complex graph structures
47
+ - Extension through inheritance and customization
48
+ - Type-safe graph construction with TypeScript
49
+
50
+ ## Usage Patterns
51
+
52
+ **@ts-graphviz/core** supports several patterns for creating and manipulating graphs:
12
53
 
13
- ## Usage
54
+ ### Basic Object Creation
14
55
 
15
- Import the necessary classes and functions from the @ts-graphviz/core package:
56
+ The most straightforward approach is to instantiate the model classes directly:
16
57
 
17
58
  ```ts
18
- import { Graph, Node, Edge } from '@ts-graphviz/core';
59
+ // Create a directed graph
60
+ const graph = new Digraph();
61
+
62
+ // Create nodes with attributes
63
+ const node1 = new Node('node1', { color: 'red' });
64
+ const node2 = new Node('node2', { color: 'blue' });
65
+
66
+ // Create an edge between nodes with attributes
67
+ const edge = new Edge([node1, node2], { label: 'Edge Label' });
68
+
69
+ // Add elements to the graph
70
+ graph.addNode(node1);
71
+ graph.addNode(node2);
72
+ graph.addEdge(edge);
19
73
  ```
20
74
 
21
- Use the imported items in your project to create and manipulate DOT language elements:
75
+ ### Factory Methods
76
+
77
+ Graph models provide factory methods to create and automatically add elements:
22
78
 
23
79
  ```ts
24
- const graph = new Graph('G');
25
- const nodeA = new Node('A', { label: 'Node A' });
26
- const nodeB = new Node('B', { label: 'Node B' });
27
- const edge = new Edge([nodeA, nodeB], { label: 'A -> B' });
80
+ // Create a directed graph
81
+ const graph = new Digraph();
28
82
 
29
- graph.addNode(nodeA);
30
- graph.addNode(nodeB);
31
- graph.addEdge(edge);
83
+ // Create and add nodes using factory methods
84
+ const node1 = graph.createNode('node1', { color: 'red' });
85
+ const node2 = graph.createNode('node2', { color: 'blue' });
86
+
87
+ // Create and add an edge using factory method
88
+ graph.createEdge([node1, node2], { label: 'Edge Label' });
89
+ ```
90
+
91
+ ### Composition with Subgraphs
92
+
93
+ Graphs can be composed with subgraphs to create hierarchical structures:
94
+
95
+ ```ts
96
+ // Create a directed graph
97
+ const graph = new Digraph();
98
+
99
+ // Create a subgraph
100
+ const subgraph = new Subgraph('cluster_0');
32
101
 
33
- console.log(graph.toDot());
102
+ // Create nodes in the subgraph
103
+ const node1 = new Node('node1');
104
+ const node2 = new Node('node2');
105
+
106
+ // Add nodes to the subgraph
107
+ subgraph.addNode(node1);
108
+ subgraph.addNode(node2);
109
+
110
+ // Add the subgraph to the main graph
111
+ graph.addSubgraph(subgraph);
34
112
  ```
35
113
 
36
- For more examples and usage details, please refer to the ts-graphviz documentation.
114
+ ### Customization and Extension
115
+
116
+ **@ts-graphviz/core** provides several mechanisms for customizing and extending its functionality:
37
117
 
118
+ ### Class Inheritance
38
119
 
39
- ## Contributing
120
+ You can create custom graph element classes by extending the base classes:
40
121
 
41
- Contributions to the ts-graphviz project are welcome.
122
+ ```ts
123
+ class MyCustomNode extends Node {
124
+ constructor(id: string) {
125
+ super(`node_${id}`, {
126
+ label: `Custom Node ${id}`,
127
+ shape: 'box'
128
+ });
129
+ }
130
+ }
131
+
132
+ class MyCustomEdge extends Edge {
133
+ constructor(targets: EdgeTargetTuple) {
134
+ super(targets, {
135
+ color: 'blue',
136
+ penwidth: '2.0'
137
+ });
138
+ }
139
+ }
140
+
141
+ // Use custom classes
142
+ const node1 = new MyCustomNode('A');
143
+ const node2 = new MyCustomNode('B');
144
+ const edge = new MyCustomEdge([node1, node2]);
145
+ ```
42
146
 
43
- Please refer to the main ts-graphviz repository for guidelines on how to contribute.
147
+ ### Models Context API
44
148
 
45
- ## License
149
+ The Models Context API allows you to specify which model classes should be used when creating graph element.
150
+
151
+ This is implemented through the with method on graph models:
152
+
153
+ ```ts
154
+ // Create a directed graph
155
+ const graph = new Digraph();
156
+
157
+ // Set up the context with custom classes
158
+ graph.with({
159
+ Node: MyCustomNode,
160
+ Edge: MyCustomEdge
161
+ });
162
+
163
+ // Now factory methods will use the custom classes
164
+ const nodeA = graph.createNode('A'); // Creates a MyCustomNode
165
+ const nodeB = graph.createNode('B'); // Creates a MyCustomNode
166
+ const edge = graph.createEdge([nodeA, nodeB]); // Creates a MyCustomEdge
167
+ ```
46
168
 
47
- This package is released under the MIT License.
169
+ ### Integration with AST
170
+
171
+ **@ts-graphviz/core** integrates with **[@ts-graphviz/ast](https://www.npmjs.com/package/@ts-graphviz/ast)** to convert between the object model and the DOT language.
172
+
173
+ This integration enables:
174
+
175
+ - Converting graph models to DOT strings
176
+ - Parsing DOT strings into graph models
177
+ - Working with the abstract syntax tree directly
178
+
179
+ The main conversion functions that link **@ts-graphviz/core** with **@ts-graphviz/ast** are:
180
+
181
+ - **`fromModel`**: Converts a graph model to an AST
182
+ - **`toModel`**: Converts an AST to a graph model
183
+
184
+ These are then used by the main ts-graphviz package to implement the toDot and fromDot functions.
185
+
186
+ ## Contributors 👥
187
+
188
+ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
189
+
190
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
191
+ <!-- prettier-ignore-start -->
192
+ <!-- markdownlint-disable -->
193
+ <table>
194
+ <tbody>
195
+ <tr>
196
+ <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>
197
+ <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>
198
+ <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>
199
+ <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>
200
+ <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>
201
+ <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>
202
+ <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>
203
+ </tr>
204
+ <tr>
205
+ <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>
206
+ <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>
207
+ <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>
208
+ <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>
209
+ <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>
210
+ <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>
211
+ <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>
212
+ </tr>
213
+ <tr>
214
+ <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>
215
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/nagasawaryoya"><img src="https://avatars.githubusercontent.com/u/53528726?v=4?s=100" width="100px;" alt="nagasawaryoya"/><br /><sub><b>nagasawaryoya</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/commits?author=nagasawaryoya" title="Code">💻</a> <a href="https://github.com/ts-graphviz/ts-graphviz/commits?author=nagasawaryoya" title="Tests">⚠️</a></td>
216
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/tokidrill"><img src="https://avatars.githubusercontent.com/u/42460318?v=4?s=100" width="100px;" alt="YukiSasaki"/><br /><sub><b>YukiSasaki</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/commits?author=tokidrill" title="Code">💻</a> <a href="https://github.com/ts-graphviz/ts-graphviz/commits?author=tokidrill" title="Tests">⚠️</a></td>
217
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/Madd0g"><img src="https://avatars.githubusercontent.com/u/1171003?v=4?s=100" width="100px;" alt="Madd0g"/><br /><sub><b>Madd0g</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3AMadd0g" title="Bug reports">🐛</a></td>
218
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/j4k0xb"><img src="https://avatars.githubusercontent.com/u/55899582?v=4?s=100" width="100px;" alt="j4k0xb"/><br /><sub><b>j4k0xb</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Aj4k0xb" title="Bug reports">🐛</a></td>
219
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/haved"><img src="https://avatars.githubusercontent.com/u/3748845?v=4?s=100" width="100px;" alt="HKrogstie"/><br /><sub><b>HKrogstie</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Ahaved" title="Bug reports">🐛</a></td>
220
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/septatrix"><img src="https://avatars.githubusercontent.com/u/24257556?v=4?s=100" width="100px;" alt="Nils K"/><br /><sub><b>Nils K</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Aseptatrix" title="Bug reports">🐛</a></td>
221
+ </tr>
222
+ <tr>
223
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/hao2013"><img src="https://avatars.githubusercontent.com/u/67059492?v=4?s=100" width="100px;" alt="hao2013"/><br /><sub><b>hao2013</b></sub></a><br /><a href="#maintenance-hao2013" title="Maintenance">🚧</a> <a href="https://github.com/ts-graphviz/ts-graphviz/pulls?q=is%3Apr+reviewed-by%3Ahao2013" title="Reviewed Pull Requests">👀</a></td>
224
+ <td align="center" valign="top" width="14.28%"><a href="http://www.walterra.dev"><img src="https://avatars.githubusercontent.com/u/230104?v=4?s=100" width="100px;" alt="Walter Rafelsberger"/><br /><sub><b>Walter Rafelsberger</b></sub></a><br /><a href="#question-walterra" title="Answering Questions">💬</a></td>
225
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/grsjst"><img src="https://avatars.githubusercontent.com/u/4739018?v=4?s=100" width="100px;" alt="grsjst"/><br /><sub><b>grsjst</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Agrsjst" title="Bug reports">🐛</a></td>
226
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/stephenirven"><img src="https://avatars.githubusercontent.com/u/4293560?v=4?s=100" width="100px;" alt="Steve"/><br /><sub><b>Steve</b></sub></a><br /><a href="https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Astephenirven" title="Bug reports">🐛</a></td>
227
+ </tr>
228
+ </tbody>
229
+ </table>
230
+
231
+ <!-- markdownlint-restore -->
232
+ <!-- prettier-ignore-end -->
233
+
234
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
235
+
236
+ This project follows the [all-contributors](https://github.com/all-contributors/all-contributors)
237
+ specification. Contributions of any kind welcome!
238
+
239
+ ## Changelog 📜
240
+
241
+ See [CHANGELOG.md](https://github.com/ts-graphviz/ts-graphviz/blob/main/packages/core/CHANGELOG.md) for more details.
242
+
243
+ ## License ⚖️
244
+
245
+ This software is released under the MIT License, see [LICENSE](https://github.com/ts-graphviz/ts-graphviz/blob/main/LICENSE).
package/lib/Digraph.d.ts CHANGED
@@ -3,6 +3,7 @@ import { AttributeKey } from '@ts-graphviz/common';
3
3
  import { Attributes } from '@ts-graphviz/common';
4
4
  import { AttributesEntities } from '@ts-graphviz/common';
5
5
  import { AttributesObject } from '@ts-graphviz/common';
6
+ import { DotObjectType } from '@ts-graphviz/common';
6
7
  import { EdgeAttributesObject } from '@ts-graphviz/common';
7
8
  import { EdgeModel } from '@ts-graphviz/common';
8
9
  import { EdgeTargetLikeTuple } from '@ts-graphviz/common';
@@ -52,8 +53,9 @@ declare abstract class DotObject {
52
53
  * Base class for Graph objects.
53
54
  * @group Models
54
55
  */
55
- declare abstract class GraphBase<T extends AttributeKey> extends AttributesBase<T> implements GraphBaseModel<T> {
56
+ declare abstract class GraphBase<T extends DotObjectType, K extends AttributeKey = AttributeKey> extends AttributesBase<K> implements GraphBaseModel<T, K> {
56
57
  #private;
58
+ abstract get $$type(): T;
57
59
  readonly id?: string;
58
60
  comment?: string;
59
61
  readonly attributes: Readonly<GraphCommonAttributes>;
@@ -93,7 +95,7 @@ declare abstract class GraphBase<T extends AttributeKey> extends AttributesBase<
93
95
  * Base class representing a root graph(digraph, graph).
94
96
  * @group Models
95
97
  */
96
- declare abstract class RootGraph extends GraphBase<GraphAttributeKey> implements RootGraphModel {
98
+ declare abstract class RootGraph extends GraphBase<'Graph', GraphAttributeKey> implements RootGraphModel {
97
99
  get $$type(): 'Graph';
98
100
  readonly id?: string;
99
101
  abstract readonly directed: boolean;
package/lib/Graph.d.ts CHANGED
@@ -3,6 +3,7 @@ import { AttributeKey } from '@ts-graphviz/common';
3
3
  import { Attributes } from '@ts-graphviz/common';
4
4
  import { AttributesEntities } from '@ts-graphviz/common';
5
5
  import { AttributesObject } from '@ts-graphviz/common';
6
+ import { DotObjectType } from '@ts-graphviz/common';
6
7
  import { EdgeAttributesObject } from '@ts-graphviz/common';
7
8
  import { EdgeModel } from '@ts-graphviz/common';
8
9
  import { EdgeTargetLikeTuple } from '@ts-graphviz/common';
@@ -52,8 +53,9 @@ export declare class Graph extends RootGraph {
52
53
  * Base class for Graph objects.
53
54
  * @group Models
54
55
  */
55
- declare abstract class GraphBase<T extends AttributeKey> extends AttributesBase<T> implements GraphBaseModel<T> {
56
+ declare abstract class GraphBase<T extends DotObjectType, K extends AttributeKey = AttributeKey> extends AttributesBase<K> implements GraphBaseModel<T, K> {
56
57
  #private;
58
+ abstract get $$type(): T;
57
59
  readonly id?: string;
58
60
  comment?: string;
59
61
  readonly attributes: Readonly<GraphCommonAttributes>;
@@ -93,7 +95,7 @@ declare abstract class GraphBase<T extends AttributeKey> extends AttributesBase<
93
95
  * Base class representing a root graph(digraph, graph).
94
96
  * @group Models
95
97
  */
96
- declare abstract class RootGraph extends GraphBase<GraphAttributeKey> implements RootGraphModel {
98
+ declare abstract class RootGraph extends GraphBase<'Graph', GraphAttributeKey> implements RootGraphModel {
97
99
  get $$type(): 'Graph';
98
100
  readonly id?: string;
99
101
  abstract readonly directed: boolean;
@@ -3,6 +3,7 @@ import { AttributeKey } from '@ts-graphviz/common';
3
3
  import { Attributes } from '@ts-graphviz/common';
4
4
  import { AttributesEntities } from '@ts-graphviz/common';
5
5
  import { AttributesObject } from '@ts-graphviz/common';
6
+ import { DotObjectType } from '@ts-graphviz/common';
6
7
  import { EdgeAttributesObject } from '@ts-graphviz/common';
7
8
  import { EdgeModel } from '@ts-graphviz/common';
8
9
  import { EdgeTargetLikeTuple } from '@ts-graphviz/common';
@@ -41,8 +42,9 @@ declare abstract class DotObject {
41
42
  * Base class for Graph objects.
42
43
  * @group Models
43
44
  */
44
- export declare abstract class GraphBase<T extends AttributeKey> extends AttributesBase<T> implements GraphBaseModel<T> {
45
+ export declare abstract class GraphBase<T extends DotObjectType, K extends AttributeKey = AttributeKey> extends AttributesBase<K> implements GraphBaseModel<T, K> {
45
46
  #private;
47
+ abstract get $$type(): T;
46
48
  readonly id?: string;
47
49
  comment?: string;
48
50
  readonly attributes: Readonly<GraphCommonAttributes>;
package/lib/GraphBase.js CHANGED
@@ -1,4 +1,4 @@
1
- import { RootModelsContext, createModelsContext, isNodeRefGroupLike, toNodeRefGroup, toNodeRef } from "@ts-graphviz/common";
1
+ import { RootModelsContext, createModelsContext, toNodeRefGroup, toNodeRef, isNodeRefGroupLike } from "@ts-graphviz/common";
2
2
  import { AttributeList } from "./AttributeList.js";
3
3
  import { AttributesBase } from "./AttributesBase.js";
4
4
  class GraphBase extends AttributesBase {
@@ -3,6 +3,7 @@ import { AttributeKey } from '@ts-graphviz/common';
3
3
  import { Attributes } from '@ts-graphviz/common';
4
4
  import { AttributesEntities } from '@ts-graphviz/common';
5
5
  import { AttributesObject } from '@ts-graphviz/common';
6
+ import { DotObjectType } from '@ts-graphviz/common';
6
7
  import { EdgeAttributesObject } from '@ts-graphviz/common';
7
8
  import { EdgeModel } from '@ts-graphviz/common';
8
9
  import { EdgeTargetLikeTuple } from '@ts-graphviz/common';
@@ -44,8 +45,9 @@ declare abstract class DotObject {
44
45
  * Base class for Graph objects.
45
46
  * @group Models
46
47
  */
47
- declare abstract class GraphBase<T extends AttributeKey> extends AttributesBase<T> implements GraphBaseModel<T> {
48
+ declare abstract class GraphBase<T extends DotObjectType, K extends AttributeKey = AttributeKey> extends AttributesBase<K> implements GraphBaseModel<T, K> {
48
49
  #private;
50
+ abstract get $$type(): T;
49
51
  readonly id?: string;
50
52
  comment?: string;
51
53
  readonly attributes: Readonly<GraphCommonAttributes>;
@@ -85,7 +87,7 @@ declare abstract class GraphBase<T extends AttributeKey> extends AttributesBase<
85
87
  * Base class representing a root graph(digraph, graph).
86
88
  * @group Models
87
89
  */
88
- export declare abstract class RootGraph extends GraphBase<GraphAttributeKey> implements RootGraphModel {
90
+ export declare abstract class RootGraph extends GraphBase<'Graph', GraphAttributeKey> implements RootGraphModel {
89
91
  get $$type(): 'Graph';
90
92
  readonly id?: string;
91
93
  abstract readonly directed: boolean;
package/lib/Subgraph.d.ts CHANGED
@@ -4,6 +4,7 @@ import { Attributes } from '@ts-graphviz/common';
4
4
  import { AttributesEntities } from '@ts-graphviz/common';
5
5
  import { AttributesObject } from '@ts-graphviz/common';
6
6
  import { ClusterSubgraphAttributeKey } from '@ts-graphviz/common';
7
+ import { DotObjectType } from '@ts-graphviz/common';
7
8
  import { EdgeAttributesObject } from '@ts-graphviz/common';
8
9
  import { EdgeModel } from '@ts-graphviz/common';
9
10
  import { EdgeTargetLikeTuple } from '@ts-graphviz/common';
@@ -43,8 +44,9 @@ declare abstract class DotObject {
43
44
  * Base class for Graph objects.
44
45
  * @group Models
45
46
  */
46
- declare abstract class GraphBase<T extends AttributeKey> extends AttributesBase<T> implements GraphBaseModel<T> {
47
+ declare abstract class GraphBase<T extends DotObjectType, K extends AttributeKey = AttributeKey> extends AttributesBase<K> implements GraphBaseModel<T, K> {
47
48
  #private;
49
+ abstract get $$type(): T;
48
50
  readonly id?: string;
49
51
  comment?: string;
50
52
  readonly attributes: Readonly<GraphCommonAttributes>;
@@ -84,7 +86,7 @@ declare abstract class GraphBase<T extends AttributeKey> extends AttributesBase<
84
86
  * DOT object class representing a subgraph.
85
87
  * @group Models
86
88
  */
87
- export declare class Subgraph extends GraphBase<SubgraphAttributeKey | ClusterSubgraphAttributeKey> implements SubgraphModel {
89
+ export declare class Subgraph extends GraphBase<'Subgraph', SubgraphAttributeKey | ClusterSubgraphAttributeKey> implements SubgraphModel {
88
90
  get $$type(): 'Subgraph';
89
91
  readonly id?: string;
90
92
  constructor(id?: string, attributes?: SubgraphAttributesObject);
package/lib/core.d.ts CHANGED
@@ -7,6 +7,7 @@ import { AttributesEntities } from '@ts-graphviz/common';
7
7
  import { AttributesGroupModel } from '@ts-graphviz/common';
8
8
  import { AttributesObject } from '@ts-graphviz/common';
9
9
  import { ClusterSubgraphAttributeKey } from '@ts-graphviz/common';
10
+ import { DotObjectType } from '@ts-graphviz/common';
10
11
  import { EdgeAttributeKey } from '@ts-graphviz/common';
11
12
  import { EdgeAttributesObject } from '@ts-graphviz/common';
12
13
  import { EdgeModel } from '@ts-graphviz/common';
@@ -314,8 +315,9 @@ export declare class Graph extends RootGraph_3 {
314
315
  * Base class for Graph objects.
315
316
  * @group Models
316
317
  */
317
- export declare abstract class GraphBase<T extends AttributeKey> extends AttributesBase_6<T> implements GraphBaseModel<T> {
318
+ export declare abstract class GraphBase<T extends DotObjectType, K extends AttributeKey = AttributeKey> extends AttributesBase_6<K> implements GraphBaseModel<T, K> {
318
319
  #private;
320
+ abstract get $$type(): T;
319
321
  readonly id?: string;
320
322
  comment?: string;
321
323
  readonly attributes: Readonly<GraphCommonAttributes>;
@@ -355,8 +357,9 @@ export declare abstract class GraphBase<T extends AttributeKey> extends Attribut
355
357
  * Base class for Graph objects.
356
358
  * @group Models
357
359
  */
358
- declare abstract class GraphBase_2<T extends AttributeKey> extends AttributesBase_4<T> implements GraphBaseModel<T> {
360
+ declare abstract class GraphBase_2<T extends DotObjectType, K extends AttributeKey = AttributeKey> extends AttributesBase_4<K> implements GraphBaseModel<T, K> {
359
361
  #private;
362
+ abstract get $$type(): T;
360
363
  readonly id?: string;
361
364
  comment?: string;
362
365
  readonly attributes: Readonly<GraphCommonAttributes>;
@@ -396,8 +399,9 @@ declare abstract class GraphBase_2<T extends AttributeKey> extends AttributesBas
396
399
  * Base class for Graph objects.
397
400
  * @group Models
398
401
  */
399
- declare abstract class GraphBase_3<T extends AttributeKey> extends AttributesBase_5<T> implements GraphBaseModel<T> {
402
+ declare abstract class GraphBase_3<T extends DotObjectType, K extends AttributeKey = AttributeKey> extends AttributesBase_5<K> implements GraphBaseModel<T, K> {
400
403
  #private;
404
+ abstract get $$type(): T;
401
405
  readonly id?: string;
402
406
  comment?: string;
403
407
  readonly attributes: Readonly<GraphCommonAttributes>;
@@ -437,8 +441,9 @@ declare abstract class GraphBase_3<T extends AttributeKey> extends AttributesBas
437
441
  * Base class for Graph objects.
438
442
  * @group Models
439
443
  */
440
- declare abstract class GraphBase_4<T extends AttributeKey> extends AttributesBase_8<T> implements GraphBaseModel<T> {
444
+ declare abstract class GraphBase_4<T extends DotObjectType, K extends AttributeKey = AttributeKey> extends AttributesBase_8<K> implements GraphBaseModel<T, K> {
441
445
  #private;
446
+ abstract get $$type(): T;
442
447
  readonly id?: string;
443
448
  comment?: string;
444
449
  readonly attributes: Readonly<GraphCommonAttributes>;
@@ -478,8 +483,9 @@ declare abstract class GraphBase_4<T extends AttributeKey> extends AttributesBas
478
483
  * Base class for Graph objects.
479
484
  * @group Models
480
485
  */
481
- declare abstract class GraphBase_5<T extends AttributeKey> extends AttributesBase_9<T> implements GraphBaseModel<T> {
486
+ declare abstract class GraphBase_5<T extends DotObjectType, K extends AttributeKey = AttributeKey> extends AttributesBase_9<K> implements GraphBaseModel<T, K> {
482
487
  #private;
488
+ abstract get $$type(): T;
483
489
  readonly id?: string;
484
490
  comment?: string;
485
491
  readonly attributes: Readonly<GraphCommonAttributes>;
@@ -534,7 +540,7 @@ export declare function registerDefault(): void;
534
540
  * Base class representing a root graph(digraph, graph).
535
541
  * @group Models
536
542
  */
537
- export declare abstract class RootGraph extends GraphBase_4<GraphAttributeKey> implements RootGraphModel {
543
+ export declare abstract class RootGraph extends GraphBase_4<'Graph', GraphAttributeKey> implements RootGraphModel {
538
544
  get $$type(): 'Graph';
539
545
  readonly id?: string;
540
546
  abstract readonly directed: boolean;
@@ -549,7 +555,7 @@ export declare abstract class RootGraph extends GraphBase_4<GraphAttributeKey> i
549
555
  * Base class representing a root graph(digraph, graph).
550
556
  * @group Models
551
557
  */
552
- declare abstract class RootGraph_2 extends GraphBase_2<GraphAttributeKey> implements RootGraphModel {
558
+ declare abstract class RootGraph_2 extends GraphBase_2<'Graph', GraphAttributeKey> implements RootGraphModel {
553
559
  get $$type(): 'Graph';
554
560
  readonly id?: string;
555
561
  abstract readonly directed: boolean;
@@ -564,7 +570,7 @@ declare abstract class RootGraph_2 extends GraphBase_2<GraphAttributeKey> implem
564
570
  * Base class representing a root graph(digraph, graph).
565
571
  * @group Models
566
572
  */
567
- declare abstract class RootGraph_3 extends GraphBase_3<GraphAttributeKey> implements RootGraphModel {
573
+ declare abstract class RootGraph_3 extends GraphBase_3<'Graph', GraphAttributeKey> implements RootGraphModel {
568
574
  get $$type(): 'Graph';
569
575
  readonly id?: string;
570
576
  abstract readonly directed: boolean;
@@ -579,7 +585,7 @@ declare abstract class RootGraph_3 extends GraphBase_3<GraphAttributeKey> implem
579
585
  * DOT object class representing a subgraph.
580
586
  * @group Models
581
587
  */
582
- export declare class Subgraph extends GraphBase_5<SubgraphAttributeKey | ClusterSubgraphAttributeKey> implements SubgraphModel {
588
+ export declare class Subgraph extends GraphBase_5<'Subgraph', SubgraphAttributeKey | ClusterSubgraphAttributeKey> implements SubgraphModel {
583
589
  get $$type(): 'Subgraph';
584
590
  readonly id?: string;
585
591
  constructor(id?: string, attributes?: SubgraphAttributesObject);
package/lib/core.js CHANGED
@@ -1,4 +1,3 @@
1
- import { registerDefault } from "./register-default.js";
2
1
  import { AttributeList } from "./AttributeList.js";
3
2
  import { AttributesBase } from "./AttributesBase.js";
4
3
  import { AttributesGroup } from "./AttributesGroup.js";
@@ -9,6 +8,7 @@ import { Graph } from "./Graph.js";
9
8
  import { GraphBase } from "./GraphBase.js";
10
9
  import { Node } from "./Node.js";
11
10
  import { RootGraph } from "./RootGraph.js";
11
+ import { registerDefault } from "./register-default.js";
12
12
  import { Subgraph } from "./Subgraph.js";
13
13
  export {
14
14
  AttributeList,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-graphviz/core",
3
- "version": "2.0.7-next-f8ba9a89f3ac9e916ded16f0a0618113a5eb4928",
3
+ "version": "3.0.0",
4
4
  "description": "Graphviz Models for Object-Oriented Programming",
5
5
  "keywords": [
6
6
  "graphviz",
@@ -31,29 +31,24 @@
31
31
  "exports": {
32
32
  ".": {
33
33
  "types": "./lib/core.d.ts",
34
- "require": "./lib/core.cjs",
35
34
  "default": "./lib/core.js"
36
35
  },
37
36
  "./register-default": {
38
- "require": "./lib/register-default.cjs",
39
37
  "default": "./lib/register-default.js"
40
38
  },
41
39
  "./package.json": "./package.json"
42
40
  },
43
- "main": "lib/core.cjs",
44
- "module": "lib/core.js",
45
- "types": "lib/core.d.ts",
46
41
  "dependencies": {
47
- "@ts-graphviz/ast": "^2.0.7-next-f8ba9a89f3ac9e916ded16f0a0618113a5eb4928",
48
- "@ts-graphviz/common": "^2.1.5"
42
+ "@ts-graphviz/ast": "^3.0.0",
43
+ "@ts-graphviz/common": "^3.0.0"
49
44
  },
50
45
  "devDependencies": {
51
- "typescript": "^5.4.5",
52
- "vite": "^5.4.8",
53
- "vite-plugin-dts": "^4.2.1"
46
+ "typescript": "^5.8.2",
47
+ "vite": "^7.0.2",
48
+ "vite-plugin-dts": "^4.5.3"
54
49
  },
55
50
  "engines": {
56
- "node": ">=18"
51
+ "node": ">=20"
57
52
  },
58
53
  "publishConfig": {
59
54
  "access": "public",
@@ -61,5 +56,7 @@
61
56
  },
62
57
  "scripts": {
63
58
  "build": "vite build"
64
- }
59
+ },
60
+ "module": "lib/core.js",
61
+ "types": "lib/core.d.ts"
65
62
  }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const AttributesBase = require("./AttributesBase.cjs");
4
- class AttributeList extends AttributesBase.AttributesBase {
5
- constructor($$kind, attributes) {
6
- super(attributes);
7
- this.$$kind = $$kind;
8
- }
9
- get $$type() {
10
- return "AttributeList";
11
- }
12
- comment;
13
- }
14
- exports.AttributeList = AttributeList;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const DotObject = require("./DotObject.cjs");
4
- class AttributesBase extends DotObject.DotObject {
5
- /** @hidden */
6
- #attrs = /* @__PURE__ */ new Map();
7
- constructor(attributes) {
8
- super();
9
- if (attributes !== void 0) {
10
- this.apply(attributes);
11
- }
12
- }
13
- get values() {
14
- return Array.from(this.#attrs.entries());
15
- }
16
- get size() {
17
- return this.#attrs.size;
18
- }
19
- get(key) {
20
- return this.#attrs.get(key);
21
- }
22
- set(key, value) {
23
- if (value !== null && value !== void 0) {
24
- this.#attrs.set(key, value);
25
- }
26
- }
27
- delete(key) {
28
- this.#attrs.delete(key);
29
- }
30
- apply(attributes) {
31
- const entries = Array.isArray(attributes) ? attributes : Object.entries(attributes);
32
- for (const [key, value] of entries) {
33
- this.set(key, value);
34
- }
35
- }
36
- clear() {
37
- this.#attrs.clear();
38
- }
39
- }
40
- exports.AttributesBase = AttributesBase;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const AttributesBase = require("./AttributesBase.cjs");
4
- class AttributesGroup extends AttributesBase.AttributesBase {
5
- comment;
6
- }
7
- exports.AttributesGroup = AttributesGroup;
package/lib/Digraph.cjs DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const RootGraph = require("./RootGraph.cjs");
4
- class Digraph extends RootGraph.RootGraph {
5
- get directed() {
6
- return true;
7
- }
8
- }
9
- exports.Digraph = Digraph;
package/lib/DotObject.cjs DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- class DotObject {
4
- }
5
- exports.DotObject = DotObject;
package/lib/Edge.cjs DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const common = require("@ts-graphviz/common");
4
- const AttributesGroup = require("./AttributesGroup.cjs");
5
- const DotObject = require("./DotObject.cjs");
6
- class Edge extends DotObject.DotObject {
7
- constructor(targets, attributes) {
8
- super();
9
- this.targets = targets;
10
- if (targets.length < 2 && (common.isNodeRefLike(targets[0]) && common.isNodeRefLike(targets[1])) === false) {
11
- throw Error(
12
- "The element of Edge target is missing or not satisfied as Edge target."
13
- );
14
- }
15
- this.attributes = new AttributesGroup.AttributesGroup(attributes);
16
- }
17
- get $$type() {
18
- return "Edge";
19
- }
20
- comment;
21
- attributes;
22
- }
23
- exports.Edge = Edge;
package/lib/Graph.cjs DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const RootGraph = require("./RootGraph.cjs");
4
- class Graph extends RootGraph.RootGraph {
5
- get directed() {
6
- return false;
7
- }
8
- }
9
- exports.Graph = Graph;
package/lib/GraphBase.cjs DELETED
@@ -1,152 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const common = require("@ts-graphviz/common");
4
- const AttributeList = require("./AttributeList.cjs");
5
- const AttributesBase = require("./AttributesBase.cjs");
6
- class GraphBase extends AttributesBase.AttributesBase {
7
- /** @hidden */
8
- #models = common.RootModelsContext;
9
- id;
10
- comment;
11
- attributes = Object.freeze({
12
- graph: new AttributeList.AttributeList("Graph"),
13
- edge: new AttributeList.AttributeList("Edge"),
14
- node: new AttributeList.AttributeList("Node")
15
- });
16
- get nodes() {
17
- return Array.from(this.#objects.nodes.values());
18
- }
19
- get edges() {
20
- return Array.from(this.#objects.edges.values());
21
- }
22
- get subgraphs() {
23
- return Array.from(this.#objects.subgraphs.values());
24
- }
25
- /** @hidden */
26
- #objects = {
27
- nodes: /* @__PURE__ */ new Map(),
28
- edges: /* @__PURE__ */ new Set(),
29
- subgraphs: /* @__PURE__ */ new Set()
30
- };
31
- with(models) {
32
- this.#models = common.createModelsContext(models);
33
- }
34
- addNode(node) {
35
- this.#objects.nodes.set(node.id, node);
36
- }
37
- addEdge(edge) {
38
- this.#objects.edges.add(edge);
39
- }
40
- addSubgraph(subgraph) {
41
- this.#objects.subgraphs.add(subgraph);
42
- }
43
- existNode(nodeId) {
44
- return this.#objects.nodes.has(nodeId);
45
- }
46
- existEdge(edge) {
47
- return this.#objects.edges.has(edge);
48
- }
49
- existSubgraph(subgraph) {
50
- return this.#objects.subgraphs.has(subgraph);
51
- }
52
- createSubgraph(...args) {
53
- const subgraph = new this.#models.Subgraph(...args);
54
- subgraph.with(this.#models);
55
- this.addSubgraph(subgraph);
56
- return subgraph;
57
- }
58
- removeNode(node) {
59
- this.#objects.nodes.delete(typeof node === "string" ? node : node.id);
60
- }
61
- removeEdge(edge) {
62
- this.#objects.edges.delete(edge);
63
- }
64
- removeSubgraph(subgraph) {
65
- this.#objects.subgraphs.delete(subgraph);
66
- }
67
- createNode(id, attributes) {
68
- const node = new this.#models.Node(id, attributes);
69
- this.addNode(node);
70
- return node;
71
- }
72
- getSubgraph(id) {
73
- return Array.from(this.#objects.subgraphs.values()).find(
74
- (subgraph) => subgraph.id === id
75
- );
76
- }
77
- getNode(id) {
78
- return this.#objects.nodes.get(id);
79
- }
80
- createEdge(targets, attributes) {
81
- const ts = targets.map(
82
- (t) => common.isNodeRefGroupLike(t) ? common.toNodeRefGroup(t) : common.toNodeRef(t)
83
- );
84
- const edge = new this.#models.Edge(ts, attributes);
85
- this.addEdge(edge);
86
- return edge;
87
- }
88
- subgraph(...args) {
89
- const id = args.find(
90
- (arg) => typeof arg === "string"
91
- );
92
- const attributes = args.find(
93
- (arg) => typeof arg === "object" && arg !== null
94
- );
95
- const callback = args.find(
96
- (arg) => typeof arg === "function"
97
- );
98
- const subgraph = id ? this.getSubgraph(id) ?? this.createSubgraph(id) : this.createSubgraph();
99
- if (attributes !== void 0) {
100
- subgraph.apply(attributes);
101
- }
102
- if (callback !== void 0) {
103
- callback(subgraph);
104
- }
105
- return subgraph;
106
- }
107
- node(firstArg, ...args) {
108
- if (typeof firstArg === "string") {
109
- const id = firstArg;
110
- const attributes = args.find(
111
- (arg) => typeof arg === "object" && arg !== null
112
- );
113
- const callback = args.find(
114
- (arg) => typeof arg === "function"
115
- );
116
- const node = this.getNode(id) ?? this.createNode(id);
117
- if (attributes !== void 0) {
118
- node.attributes.apply(attributes);
119
- }
120
- if (callback !== void 0) {
121
- callback(node);
122
- }
123
- return node;
124
- }
125
- if (typeof firstArg === "object" && firstArg !== null) {
126
- this.attributes.node.apply(firstArg);
127
- }
128
- }
129
- edge(firstArg, ...args) {
130
- if (Array.isArray(firstArg)) {
131
- const targets = firstArg;
132
- const attributes = args.find(
133
- (arg) => typeof arg === "object"
134
- );
135
- const callback = args.find(
136
- (arg) => typeof arg === "function"
137
- );
138
- const edge = this.createEdge(targets, attributes);
139
- if (callback !== void 0) {
140
- callback(edge);
141
- }
142
- return edge;
143
- }
144
- if (typeof firstArg === "object" && firstArg !== null) {
145
- this.attributes.edge.apply(firstArg);
146
- }
147
- }
148
- graph(attributes) {
149
- this.attributes.graph.apply(attributes);
150
- }
151
- }
152
- exports.GraphBase = GraphBase;
package/lib/Node.cjs DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const AttributesGroup = require("./AttributesGroup.cjs");
4
- const DotObject = require("./DotObject.cjs");
5
- class Node extends DotObject.DotObject {
6
- constructor(id, attributes) {
7
- super();
8
- this.id = id;
9
- this.attributes = new AttributesGroup.AttributesGroup(attributes);
10
- }
11
- get $$type() {
12
- return "Node";
13
- }
14
- comment;
15
- attributes;
16
- port(port) {
17
- if (typeof port === "string") {
18
- return { id: this.id, port };
19
- }
20
- return { id: this.id, ...port };
21
- }
22
- }
23
- exports.Node = Node;
package/lib/RootGraph.cjs DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const GraphBase = require("./GraphBase.cjs");
4
- class RootGraph extends GraphBase.GraphBase {
5
- get $$type() {
6
- return "Graph";
7
- }
8
- id;
9
- strict;
10
- constructor(...args) {
11
- super();
12
- this.id = args.find((arg) => typeof arg === "string");
13
- this.strict = args.find((arg) => typeof arg === "boolean") ?? false;
14
- const attributes = args.find(
15
- (arg) => typeof arg === "object" && arg !== null
16
- );
17
- if (attributes !== void 0) {
18
- this.apply(attributes);
19
- }
20
- }
21
- }
22
- exports.RootGraph = RootGraph;
package/lib/Subgraph.cjs DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const GraphBase = require("./GraphBase.cjs");
4
- class Subgraph extends GraphBase.GraphBase {
5
- get $$type() {
6
- return "Subgraph";
7
- }
8
- id;
9
- constructor(...args) {
10
- super();
11
- this.id = args.find((arg) => typeof arg === "string");
12
- const attributes = args.find(
13
- (arg) => typeof arg === "object" && arg !== null
14
- );
15
- if (attributes !== void 0) {
16
- this.apply(attributes);
17
- }
18
- }
19
- isSubgraphCluster() {
20
- if (typeof this.id === "string") {
21
- return this.id.startsWith("cluster");
22
- }
23
- return false;
24
- }
25
- }
26
- exports.Subgraph = Subgraph;
package/lib/core.cjs DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const registerDefault = require("./register-default.cjs");
4
- const AttributeList = require("./AttributeList.cjs");
5
- const AttributesBase = require("./AttributesBase.cjs");
6
- const AttributesGroup = require("./AttributesGroup.cjs");
7
- const Digraph = require("./Digraph.cjs");
8
- const DotObject = require("./DotObject.cjs");
9
- const Edge = require("./Edge.cjs");
10
- const Graph = require("./Graph.cjs");
11
- const GraphBase = require("./GraphBase.cjs");
12
- const Node = require("./Node.cjs");
13
- const RootGraph = require("./RootGraph.cjs");
14
- const Subgraph = require("./Subgraph.cjs");
15
- exports.registerDefault = registerDefault.registerDefault;
16
- exports.AttributeList = AttributeList.AttributeList;
17
- exports.AttributesBase = AttributesBase.AttributesBase;
18
- exports.AttributesGroup = AttributesGroup.AttributesGroup;
19
- exports.Digraph = Digraph.Digraph;
20
- exports.DotObject = DotObject.DotObject;
21
- exports.Edge = Edge.Edge;
22
- exports.Graph = Graph.Graph;
23
- exports.GraphBase = GraphBase.GraphBase;
24
- exports.Node = Node.Node;
25
- exports.RootGraph = RootGraph.RootGraph;
26
- exports.Subgraph = Subgraph.Subgraph;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const common = require("@ts-graphviz/common");
4
- const Digraph = require("./Digraph.cjs");
5
- const Edge = require("./Edge.cjs");
6
- const Graph = require("./Graph.cjs");
7
- const Node = require("./Node.cjs");
8
- const Subgraph = require("./Subgraph.cjs");
9
- function registerDefault() {
10
- Object.assign(common.RootModelsContext, {
11
- Graph: Graph.Graph,
12
- Digraph: Digraph.Digraph,
13
- Subgraph: Subgraph.Subgraph,
14
- Node: Node.Node,
15
- Edge: Edge.Edge
16
- });
17
- }
18
- exports.registerDefault = registerDefault;