@ts-graphviz/core 2.0.7 → 3.0.1
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 +232 -0
- package/README.md +221 -23
- package/lib/Digraph.d.ts +4 -2
- package/lib/Graph.d.ts +4 -2
- package/lib/GraphBase.d.ts +3 -1
- package/lib/GraphBase.js +1 -1
- package/lib/RootGraph.d.ts +4 -2
- package/lib/Subgraph.d.ts +4 -2
- package/lib/core.d.ts +15 -9
- package/lib/core.js +1 -1
- package/package.json +10 -13
- package/lib/AttributeList.cjs +0 -14
- package/lib/AttributesBase.cjs +0 -40
- package/lib/AttributesGroup.cjs +0 -7
- package/lib/Digraph.cjs +0 -9
- package/lib/DotObject.cjs +0 -5
- package/lib/Edge.cjs +0 -23
- package/lib/Graph.cjs +0 -9
- package/lib/GraphBase.cjs +0 -152
- package/lib/Node.cjs +0 -23
- package/lib/RootGraph.cjs +0 -22
- package/lib/Subgraph.cjs +0 -26
- package/lib/core.cjs +0 -26
- package/lib/register-default.cjs +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,237 @@
|
|
|
1
1
|
# @ts-graphviz/core
|
|
2
2
|
|
|
3
|
+
## 3.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1480](https://github.com/ts-graphviz/ts-graphviz/pull/1480) [`ab5d0c7`](https://github.com/ts-graphviz/ts-graphviz/commit/ab5d0c75620a0fd1bf36373716b26c2d433a0bc6) Thanks [@kamiazya](https://github.com/kamiazya)! - Fix CI workflow to prevent publishing stable releases with @next tag
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`ab5d0c7`](https://github.com/ts-graphviz/ts-graphviz/commit/ab5d0c75620a0fd1bf36373716b26c2d433a0bc6)]:
|
|
10
|
+
- @ts-graphviz/ast@3.0.1
|
|
11
|
+
- @ts-graphviz/common@3.0.1
|
|
12
|
+
|
|
13
|
+
## 3.0.0
|
|
14
|
+
|
|
15
|
+
### Major Changes
|
|
16
|
+
|
|
17
|
+
- [#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
|
|
18
|
+
|
|
19
|
+
Minimum required version is now Node.js 20+
|
|
20
|
+
|
|
21
|
+
### ESM-Only Distribution
|
|
22
|
+
|
|
23
|
+
- **Remove CommonJS builds**: All packages now distribute only ESM (ECMAScript Modules)
|
|
24
|
+
- **Package exports**: Removed `require` fields from `package.json` exports
|
|
25
|
+
- **Module type**: All packages are now `"type": "module"`
|
|
26
|
+
|
|
27
|
+
## 🔄 Migration Guide
|
|
28
|
+
|
|
29
|
+
### For ESM Projects (Recommended)
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"type": "module"
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
// Import syntax remains unchanged
|
|
39
|
+
import { Digraph, Node, Edge, toDot } from "ts-graphviz";
|
|
40
|
+
import { toFile } from "ts-graphviz/adapter";
|
|
41
|
+
import { parse } from "ts-graphviz/ast";
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### For CommonJS Projects
|
|
45
|
+
|
|
46
|
+
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.
|
|
47
|
+
|
|
48
|
+
### Before (CJS)
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
// JavaScript (CommonJS)
|
|
52
|
+
function createGraph() {
|
|
53
|
+
// Dynamic import is required because the packages no longer provide CommonJS builds.
|
|
54
|
+
const { Digraph, Node, Edge, toDot } = require("ts-graphviz");
|
|
55
|
+
const graph = new Digraph();
|
|
56
|
+
return toDot(graph);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### After (ESM)
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
async function createGraph() {
|
|
64
|
+
const { Digraph, Node, Edge, toDot } = await import("ts-graphviz");
|
|
65
|
+
|
|
66
|
+
const graph = new Digraph();
|
|
67
|
+
// Create your graph...
|
|
68
|
+
return toDot(graph);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
// TypeScript (CommonJS)
|
|
74
|
+
// Update tsconfig.json
|
|
75
|
+
{
|
|
76
|
+
"compilerOptions": {
|
|
77
|
+
"module": "Node16",
|
|
78
|
+
"moduleResolution": "Node16"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Use dynamic imports
|
|
83
|
+
async function createGraph() {
|
|
84
|
+
const tsGraphviz = await import('ts-graphviz');
|
|
85
|
+
const { Digraph, Node, Edge, toDot } = tsGraphviz;
|
|
86
|
+
|
|
87
|
+
const graph = new Digraph();
|
|
88
|
+
// Create your graph...
|
|
89
|
+
return toDot(graph);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## 🎯 Benefits
|
|
94
|
+
|
|
95
|
+
- **Modern JavaScript**: Leveraging native ES modules for better performance
|
|
96
|
+
- **Smaller bundle sizes**: ESM enables better tree-shaking
|
|
97
|
+
- **Future-proof**: Aligning with the JavaScript ecosystem direction
|
|
98
|
+
- **Better TypeScript support**: Enhanced module resolution
|
|
99
|
+
|
|
100
|
+
### Minor Changes
|
|
101
|
+
|
|
102
|
+
- [#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
|
|
103
|
+
|
|
104
|
+
To provide clarity on the environments in which ts-graphviz operates, we have categorized support levels:
|
|
105
|
+
|
|
106
|
+
## Support Levels
|
|
107
|
+
|
|
108
|
+
### Tier 1: Full Support
|
|
109
|
+
|
|
110
|
+
- **Definition**: Environments that are fully supported, with comprehensive automated testing and maintenance.
|
|
111
|
+
- **Environments**:
|
|
112
|
+
- **Node.js LTS versions**: All active Long-Term Support (LTS) versions.
|
|
113
|
+
- If a Node.js LTS version is released, we will ensure compatibility with it.
|
|
114
|
+
- If a Node.js LTS version is deprecated, we will drop support for it in the next major release.
|
|
115
|
+
- **Details**:
|
|
116
|
+
- We run automated tests on all LTS versions of Node.js.
|
|
117
|
+
- Full compatibility and performance are ensured.
|
|
118
|
+
- Critical issues are prioritized for fixes.
|
|
119
|
+
|
|
120
|
+
### Tier 2: Active Support
|
|
121
|
+
|
|
122
|
+
- **Definition**: Environments that receive active support with limited automated testing.
|
|
123
|
+
- **Environments**:
|
|
124
|
+
- **Deno Latest LTS version**: The latest Long-Term Support (LTS) version of Deno.
|
|
125
|
+
- If a new Deno LTS version is released, we will ensure compatibility with it.
|
|
126
|
+
- If a Deno LTS version is deprecated, we will drop support for it in the next minor release.
|
|
127
|
+
- **Node.js Current Release**: The latest Node.js release outside the LTS schedule.
|
|
128
|
+
- If a new Node.js current release is available, we will ensure compatibility with it.
|
|
129
|
+
- If a Node.js current release is deprecated, we will drop support for it in the next minor release.
|
|
130
|
+
- **Details**:
|
|
131
|
+
- Compatibility is maintained, and issues are addressed.
|
|
132
|
+
|
|
133
|
+
### Tier 3: Community Support
|
|
134
|
+
|
|
135
|
+
- **Definition**: Environments that are not officially tested but are supported on a best-effort basis.
|
|
136
|
+
- **Environments**:
|
|
137
|
+
- **Modern Browsers**: Latest versions of major browsers, including:
|
|
138
|
+
- Google Chrome
|
|
139
|
+
- Mozilla Firefox
|
|
140
|
+
- Microsoft Edge
|
|
141
|
+
- Apple Safari
|
|
142
|
+
- **Deno Current Release**: The latest Deno release outside the LTS schedule.
|
|
143
|
+
- **Details**:
|
|
144
|
+
- Installation methods are provided.
|
|
145
|
+
- No automated testing is performed.
|
|
146
|
+
- Issues reported by users will be addressed.
|
|
147
|
+
- Targeting the latest versions ensures compatibility with modern web standards.
|
|
148
|
+
- We will not actively test or maintain compatibility with older versions of browsers.
|
|
149
|
+
|
|
150
|
+
### Patch Changes
|
|
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)! - Update Develop Environment
|
|
153
|
+
|
|
154
|
+
- Drop turbo
|
|
155
|
+
- Upgrade biome to 2.0
|
|
156
|
+
- Upgrade TypeScript to 5.8
|
|
157
|
+
- Upgrade Vite to 7.0
|
|
158
|
+
- Upgrade Vitest to 3.2
|
|
159
|
+
- Upgrade Peggy to 5.0 and drop ts-pegjs
|
|
160
|
+
- Implement new E2E test workflow
|
|
161
|
+
|
|
162
|
+
- [#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
|
|
163
|
+
|
|
164
|
+
## 🔧 FIXES
|
|
165
|
+
|
|
166
|
+
### GraphBase Class Type Compatibility
|
|
167
|
+
|
|
168
|
+
**Fixed GraphBase class type compatibility issues:**
|
|
169
|
+
|
|
170
|
+
- **BREAKING INTERNAL**: Updated `GraphBase<T>` to `GraphBase<T, K>` to properly implement `GraphBaseModel<T, K>` interface
|
|
171
|
+
- First generic parameter `T extends DotObjectType` represents the object type ('Graph', 'Subgraph', etc.)
|
|
172
|
+
- Second generic parameter `K extends AttributeKey` represents the attribute key constraints
|
|
173
|
+
- **Added missing `$type` property**: Abstract `$type` property ensures proper implementation across subclasses
|
|
174
|
+
- **Enhanced type constraints**: Proper separation between object types and attribute types for better type safety
|
|
175
|
+
|
|
176
|
+
**Updated class hierarchy:**
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
// Before
|
|
180
|
+
export abstract class GraphBase<T extends AttributeKey>
|
|
181
|
+
extends AttributesBase<T>
|
|
182
|
+
implements GraphBaseModel<T>
|
|
183
|
+
|
|
184
|
+
// After
|
|
185
|
+
export abstract class GraphBase<T extends DotObjectType, K extends AttributeKey = AttributeKey>
|
|
186
|
+
extends AttributesBase<K>
|
|
187
|
+
implements GraphBaseModel<T, K>
|
|
188
|
+
{
|
|
189
|
+
public abstract get $type(): T;
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Cascading updates to subclasses:**
|
|
194
|
+
|
|
195
|
+
- `RootGraph`: Updated to `GraphBase<'Graph', GraphAttributeKey>`
|
|
196
|
+
- `Subgraph`: Updated to `GraphBase<'Subgraph', SubgraphAttributeKey | ClusterSubgraphAttributeKey>`
|
|
197
|
+
- Test classes: Added required `$type` implementation
|
|
198
|
+
|
|
199
|
+
## 🚀 IMPROVEMENTS
|
|
200
|
+
|
|
201
|
+
### Type Safety Enhancement
|
|
202
|
+
|
|
203
|
+
- **Eliminated type compatibility errors**: All GraphBase-related type issues resolved using proper generic constraints
|
|
204
|
+
- **Maintained library TypeScript value**: Strong typing preserved throughout the core type system
|
|
205
|
+
- **Interface-implementation alignment**: GraphBase class now correctly implements GraphBaseModel interface requirements
|
|
206
|
+
|
|
207
|
+
### Enhanced Developer Experience
|
|
208
|
+
|
|
209
|
+
- **Better IntelliSense support**: Improved autocomplete and type checking for core graph classes
|
|
210
|
+
- **Clearer error messages**: More precise TypeScript errors when GraphBase subclasses are misused
|
|
211
|
+
- **Consistent type patterns**: Unified approach to handling object types vs attribute types
|
|
212
|
+
|
|
213
|
+
## 📊 TECHNICAL DETAILS
|
|
214
|
+
|
|
215
|
+
### Architecture Improvements
|
|
216
|
+
|
|
217
|
+
- **Generic type system enhancement**: Proper separation of concerns between object types (`DotObjectType`) and attribute constraints (`AttributeKey`)
|
|
218
|
+
- **Abstract property enforcement**: All GraphBase subclasses must properly implement `$type` property
|
|
219
|
+
- **Type parameter ordering**: Consistent `<ObjectType, AttributeType>` pattern across the inheritance hierarchy
|
|
220
|
+
|
|
221
|
+
### Compatibility Notes
|
|
222
|
+
|
|
223
|
+
- **Runtime behavior unchanged**: All functional behavior remains identical
|
|
224
|
+
- **API surface unchanged**: No public API modifications for end users
|
|
225
|
+
- **Internal type system modernized**: Enhanced type safety without breaking changes
|
|
226
|
+
|
|
227
|
+
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.
|
|
228
|
+
|
|
229
|
+
- [#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
|
|
230
|
+
|
|
231
|
+
- 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)]:
|
|
232
|
+
- @ts-graphviz/common@3.0.0
|
|
233
|
+
- @ts-graphviz/ast@3.0.0
|
|
234
|
+
|
|
3
235
|
## 2.0.7
|
|
4
236
|
|
|
5
237
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,47 +1,245 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
[](https://github.com/ts-graphviz/ts-graphviz/actions/workflows/main.yaml)
|
|
4
|
+
[](https://github.com/ts-graphviz/ts-graphviz/actions/workflows/codeql-analysis.yml)
|
|
5
|
+
[](https://github.com/ts-graphviz/ts-graphviz/blob/main/LICENSE)
|
|
6
|
+
[](#contributors-)
|
|
7
|
+
|
|
8
|
+
[](https://www.bestpractices.dev/projects/8396)
|
|
9
|
+
[](https://scorecard.dev/viewer/?uri=github.com/ts-graphviz/ts-graphviz)
|
|
10
|
+
[](https://tidelift.com/subscription/pkg/npm-ts-graphviz?utm_source=npm-ts-graphviz&utm_medium=readme)
|
|
11
|
+
|
|
12
|
+
[](https://badge.fury.io/js/ts-graphviz)
|
|
13
|
+

|
|
14
|
+
[](https://github.com/denoland/deno)
|
|
15
|
+
[](https://npmtrends.com/ts-graphviz)
|
|
16
|
+
|
|
1
17
|
# @ts-graphviz/core
|
|
2
18
|
|
|
3
|
-
|
|
19
|
+
Models and functions provided to users for the ts-graphviz library.
|
|
20
|
+
|
|
21
|
+
🔗
|
|
22
|
+
|
|
23
|
+
[](https://github.com/ts-graphviz/ts-graphviz)
|
|
24
|
+
[](https://www.npmjs.com/package/ts-graphviz)
|
|
25
|
+
[](https://ts-graphviz.github.io/ts-graphviz/)
|
|
26
|
+
[](https://deepwiki.com/ts-graphviz/ts-graphviz)
|
|
27
|
+
|
|
28
|
+
[](https://github.com/sponsors/ts-graphviz)
|
|
29
|
+
[](https://opencollective.com/ts-graphviz)
|
|
30
|
+
|
|
31
|
+
[](https://biomejs.dev/)
|
|
32
|
+
[](https://vitest.dev/)
|
|
33
|
+
[](https://rollupjs.org/)
|
|
34
|
+
|
|
35
|
+
</div>
|
|
4
36
|
|
|
5
|
-
|
|
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
|
-
-
|
|
10
|
-
|
|
11
|
-
-
|
|
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
|
-
|
|
54
|
+
### Basic Object Creation
|
|
14
55
|
|
|
15
|
-
|
|
56
|
+
The most straightforward approach is to instantiate the model classes directly:
|
|
16
57
|
|
|
17
58
|
```ts
|
|
18
|
-
|
|
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
|
-
|
|
75
|
+
### Factory Methods
|
|
76
|
+
|
|
77
|
+
Graph models provide factory methods to create and automatically add elements:
|
|
22
78
|
|
|
23
79
|
```ts
|
|
24
|
-
|
|
25
|
-
const
|
|
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
|
-
|
|
30
|
-
graph.
|
|
31
|
-
graph.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
120
|
+
You can create custom graph element classes by extending the base classes:
|
|
40
121
|
|
|
41
|
-
|
|
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
|
-
|
|
147
|
+
### Models Context API
|
|
44
148
|
|
|
45
|
-
|
|
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
|
-
|
|
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<
|
|
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<
|
|
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/GraphBase.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';
|
|
@@ -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<
|
|
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,
|
|
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 {
|
package/lib/RootGraph.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';
|
|
@@ -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<
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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<
|
|
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": "
|
|
3
|
+
"version": "3.0.1",
|
|
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": "^
|
|
48
|
-
"@ts-graphviz/common": "^
|
|
42
|
+
"@ts-graphviz/ast": "^3.0.1",
|
|
43
|
+
"@ts-graphviz/common": "^3.0.1"
|
|
49
44
|
},
|
|
50
45
|
"devDependencies": {
|
|
51
|
-
"typescript": "^5.
|
|
52
|
-
"vite": "^
|
|
53
|
-
"vite-plugin-dts": "^4.
|
|
46
|
+
"typescript": "^5.8.2",
|
|
47
|
+
"vite": "^7.0.2",
|
|
48
|
+
"vite-plugin-dts": "^4.5.3"
|
|
54
49
|
},
|
|
55
50
|
"engines": {
|
|
56
|
-
"node": ">=
|
|
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
|
}
|
package/lib/AttributeList.cjs
DELETED
|
@@ -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;
|
package/lib/AttributesBase.cjs
DELETED
|
@@ -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;
|
package/lib/AttributesGroup.cjs
DELETED
|
@@ -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
package/lib/DotObject.cjs
DELETED
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
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;
|
package/lib/register-default.cjs
DELETED
|
@@ -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;
|