@ts-graphviz/adapter 2.0.6-next-f7881a94c6de8c3385e5fef675608e505da10c5f → 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 +156 -2
- package/LICENSE +1 -2
- package/README.md +138 -45
- package/lib/browser.d.ts +2 -2
- package/lib/browser.js +2 -2
- package/lib/deno.d.ts +0 -1
- package/lib/node.d.ts +2 -2
- package/lib/node.js +2 -2
- package/package.json +11 -14
- package/tsconfig.json +13 -0
- package/lib/browser.cjs +0 -11
- package/lib/create-command-and-args.cjs +0 -73
- package/lib/node.cjs +0 -50
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,165 @@
|
|
|
1
1
|
# @ts-graphviz/adapter
|
|
2
2
|
|
|
3
|
-
##
|
|
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)! - New GitHub Action main workflow and tests
|
|
153
|
+
|
|
154
|
+
- 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)]:
|
|
155
|
+
- @ts-graphviz/common@3.0.0
|
|
156
|
+
|
|
157
|
+
## 2.0.6
|
|
4
158
|
|
|
5
159
|
### Patch Changes
|
|
6
160
|
|
|
7
161
|
- Updated dependencies [[`d7ff421`](https://github.com/ts-graphviz/ts-graphviz/commit/d7ff421ec861ca8fdede1a6bdf256f3455fb9797)]:
|
|
8
|
-
- @ts-graphviz/common@2.1.5
|
|
162
|
+
- @ts-graphviz/common@2.1.5
|
|
9
163
|
|
|
10
164
|
## 2.0.5
|
|
11
165
|
|
package/LICENSE
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
1
|
The MIT License (MIT)
|
|
3
2
|
|
|
4
|
-
Copyright (c) 2019-
|
|
3
|
+
Copyright (c) 2019-2025 Yuki Yamazaki
|
|
5
4
|
|
|
6
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,62 +1,155 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
> It is part of the ts-graphviz library, which is split into modular packages to improve maintainability, flexibility, and ease of use.
|
|
1
|
+
<div align="center">
|
|
4
2
|
|
|
5
|
-
|
|
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-)
|
|
6
7
|
|
|
7
|
-
[
|
|
8
|
-
|
|
9
|
-
|
|
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)
|
|
10
11
|
|
|
11
|
-
](https://badge.fury.io/js/ts-graphviz)
|
|
13
|
+

|
|
14
|
+
[](https://github.com/denoland/deno)
|
|
15
|
+
[](https://npmtrends.com/ts-graphviz)
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
# @ts-graphviz/adapter
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
Cross-platform interfaces for executing Graphviz DOT commands in various JavaScript runtimes.
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
```ts
|
|
19
|
-
import { toStream } from '@ts-graphviz/adapter';
|
|
21
|
+
🔗
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
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)
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
stream.pipe(process.stdout);
|
|
32
|
-
// Deno
|
|
33
|
-
await stream.pipeTo(Deno.stdout.writable);
|
|
34
|
-
```
|
|
35
|
-
- Writes **DOT** to a file at the specified path `toFile` function
|
|
36
|
-
```ts
|
|
37
|
-
import { toFile } from '@ts-graphviz/adapter';
|
|
28
|
+
[](https://github.com/sponsors/ts-graphviz)
|
|
29
|
+
[](https://opencollective.com/ts-graphviz)
|
|
38
30
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
label = "My Node",
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
`;
|
|
31
|
+
[](https://biomejs.dev/)
|
|
32
|
+
[](https://vitest.dev/)
|
|
33
|
+
[](https://rollupjs.org/)
|
|
46
34
|
|
|
47
|
-
|
|
48
|
-
```
|
|
35
|
+
</div>
|
|
49
36
|
|
|
50
|
-
|
|
37
|
+
---
|
|
51
38
|
|
|
52
|
-
|
|
39
|
+
> It is part of the ts-graphviz library, which is split into modular packages to improve maintainability, flexibility, and ease of use.
|
|
53
40
|
|
|
54
|
-
|
|
41
|
+
This library enables rendering DOT language strings into different output formats through platform-specific implementations for Node.js, and Deno.
|
|
55
42
|
|
|
56
|
-
|
|
43
|
+
[Graphviz](https://graphviz.gitlab.io/) must be installed so that the dot command can be executed.
|
|
57
44
|
|
|
58
|
-
|
|
45
|
+
Execute the dot command to output a DOT language string to a stream or file.
|
|
59
46
|
|
|
60
|
-
|
|
47
|
+

|
|
61
48
|
|
|
62
|
-
|
|
49
|
+
## Core Functions
|
|
50
|
+
|
|
51
|
+
The adapter provides two main functions for working with DOT language strings:
|
|
52
|
+
|
|
53
|
+
### `toStream`
|
|
54
|
+
|
|
55
|
+
The `toStream` function converts a DOT language string to a readable stream of the specified output format.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { toStream } from '@ts-graphviz/adapter';
|
|
60
|
+
|
|
61
|
+
const dot = `
|
|
62
|
+
digraph example {
|
|
63
|
+
node1 [
|
|
64
|
+
label = "My Node",
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
const stream = await toStream(dot, { format: 'svg' });
|
|
70
|
+
// Node.js
|
|
71
|
+
stream.pipe(process.stdout);
|
|
72
|
+
// Deno
|
|
73
|
+
await stream.pipeTo(Deno.stdout.writable);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### `toFile`
|
|
77
|
+
|
|
78
|
+
The `toFile` function writes the rendered output directly to a file at the specified path.
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { toFile } from '@ts-graphviz/adapter';
|
|
82
|
+
|
|
83
|
+
const dot = `
|
|
84
|
+
digraph example {
|
|
85
|
+
node1 [
|
|
86
|
+
label = "My Node",
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
await toFile(dot, './result.svg', { format: 'svg' });
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Both functions accept configuration options to customize the rendering process.
|
|
95
|
+
|
|
96
|
+
## Contributors 👥
|
|
97
|
+
|
|
98
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
99
|
+
|
|
100
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
101
|
+
<!-- prettier-ignore-start -->
|
|
102
|
+
<!-- markdownlint-disable -->
|
|
103
|
+
<table>
|
|
104
|
+
<tbody>
|
|
105
|
+
<tr>
|
|
106
|
+
<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>
|
|
107
|
+
<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>
|
|
108
|
+
<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>
|
|
109
|
+
<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>
|
|
110
|
+
<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>
|
|
111
|
+
<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>
|
|
112
|
+
<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>
|
|
113
|
+
</tr>
|
|
114
|
+
<tr>
|
|
115
|
+
<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>
|
|
116
|
+
<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>
|
|
117
|
+
<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>
|
|
118
|
+
<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>
|
|
119
|
+
<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>
|
|
120
|
+
<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>
|
|
121
|
+
<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>
|
|
122
|
+
</tr>
|
|
123
|
+
<tr>
|
|
124
|
+
<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>
|
|
125
|
+
<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>
|
|
126
|
+
<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>
|
|
127
|
+
<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>
|
|
128
|
+
<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>
|
|
129
|
+
<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>
|
|
130
|
+
<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>
|
|
131
|
+
</tr>
|
|
132
|
+
<tr>
|
|
133
|
+
<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>
|
|
134
|
+
<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>
|
|
135
|
+
<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>
|
|
136
|
+
<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>
|
|
137
|
+
</tr>
|
|
138
|
+
</tbody>
|
|
139
|
+
</table>
|
|
140
|
+
|
|
141
|
+
<!-- markdownlint-restore -->
|
|
142
|
+
<!-- prettier-ignore-end -->
|
|
143
|
+
|
|
144
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
145
|
+
|
|
146
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors)
|
|
147
|
+
specification. Contributions of any kind welcome!
|
|
148
|
+
|
|
149
|
+
## Changelog 📜
|
|
150
|
+
|
|
151
|
+
See [CHANGELOG.md](https://github.com/ts-graphviz/ts-graphviz/blob/main/packages/adapter/CHANGELOG.md) for more details.
|
|
152
|
+
|
|
153
|
+
## License ⚖️
|
|
154
|
+
|
|
155
|
+
This software is released under the MIT License, see [LICENSE](https://github.com/ts-graphviz/ts-graphviz/blob/main/LICENSE).
|
package/lib/browser.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export type Options = any;
|
|
|
5
5
|
/**
|
|
6
6
|
* Execute the Graphviz dot command and make a Stream of the results.
|
|
7
7
|
*/
|
|
8
|
-
export declare function toStream(
|
|
8
|
+
export declare function toStream(_dot: string, _options?: Options): never;
|
|
9
9
|
/**
|
|
10
10
|
* Execute the Graphviz dot command and output the results to a file.
|
|
11
11
|
*/
|
|
12
|
-
export declare function toFile(
|
|
12
|
+
export declare function toFile(_dot: string, _path: string, _options?: Options): never;
|
package/lib/browser.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const ERROR_MESSAGE = "This module cannot be run in a browser.";
|
|
2
|
-
function toStream(
|
|
2
|
+
function toStream(_dot, _options) {
|
|
3
3
|
throw new Error(ERROR_MESSAGE);
|
|
4
4
|
}
|
|
5
|
-
function toFile(
|
|
5
|
+
function toFile(_dot, _path, _options) {
|
|
6
6
|
throw new Error(ERROR_MESSAGE);
|
|
7
7
|
}
|
|
8
8
|
export {
|
package/lib/deno.d.ts
CHANGED
package/lib/node.d.ts
CHANGED
package/lib/node.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { createWriteStream } from "node:fs";
|
|
2
|
+
import { pipeline } from "node:stream/promises";
|
|
1
3
|
import { spawn } from "node:child_process";
|
|
2
4
|
import { PassThrough, Readable } from "node:stream";
|
|
3
|
-
import { pipeline } from "node:stream/promises";
|
|
4
5
|
import { createCommandAndArgs } from "./create-command-and-args.js";
|
|
5
|
-
import { createWriteStream } from "node:fs";
|
|
6
6
|
async function toStream(dot, options) {
|
|
7
7
|
const [command, args] = createCommandAndArgs(options ?? {});
|
|
8
8
|
return new Promise(function toStreamInternal(resolve, reject) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-graphviz/adapter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Graphviz Runtime adapters for Cross Platform",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphviz",
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
".": {
|
|
33
33
|
"browser": {
|
|
34
34
|
"types": "./lib/browser.d.ts",
|
|
35
|
-
"require": "./lib/browser.cjs",
|
|
36
35
|
"default": "./lib/browser.js"
|
|
37
36
|
},
|
|
38
37
|
"deno": {
|
|
@@ -41,32 +40,30 @@
|
|
|
41
40
|
},
|
|
42
41
|
"default": {
|
|
43
42
|
"types": "./lib/node.d.ts",
|
|
44
|
-
"require": "./lib/node.cjs",
|
|
45
43
|
"default": "./lib/node.js"
|
|
46
44
|
}
|
|
47
45
|
},
|
|
48
46
|
"./package.json": "./package.json"
|
|
49
47
|
},
|
|
50
|
-
"main": "./lib/node.cjs",
|
|
51
|
-
"module": "./lib/node.js",
|
|
52
|
-
"types": "./lib/node.d.ts",
|
|
53
48
|
"dependencies": {
|
|
54
|
-
"@ts-graphviz/common": "^
|
|
49
|
+
"@ts-graphviz/common": "^3.0.0"
|
|
55
50
|
},
|
|
56
51
|
"devDependencies": {
|
|
57
|
-
"@types/node": "^
|
|
58
|
-
"typescript": "^5.
|
|
59
|
-
"vite": "^
|
|
60
|
-
"vite-plugin-dts": "^4.
|
|
52
|
+
"@types/node": "^22.15.30",
|
|
53
|
+
"typescript": "^5.8.2",
|
|
54
|
+
"vite": "^7.0.2",
|
|
55
|
+
"vite-plugin-dts": "^4.5.3"
|
|
61
56
|
},
|
|
62
57
|
"engines": {
|
|
63
|
-
"node": ">=
|
|
58
|
+
"node": ">=20"
|
|
64
59
|
},
|
|
65
60
|
"publishConfig": {
|
|
66
61
|
"access": "public",
|
|
67
62
|
"provenance": true
|
|
68
63
|
},
|
|
69
64
|
"scripts": {
|
|
70
|
-
"build": "vite build
|
|
71
|
-
}
|
|
65
|
+
"build": "vite build"
|
|
66
|
+
},
|
|
67
|
+
"module": "./lib/node.js",
|
|
68
|
+
"types": "./lib/node.d.ts"
|
|
72
69
|
}
|
package/tsconfig.json
ADDED
package/lib/browser.cjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const ERROR_MESSAGE = "This module cannot be run in a browser.";
|
|
4
|
-
function toStream(dot, options) {
|
|
5
|
-
throw new Error(ERROR_MESSAGE);
|
|
6
|
-
}
|
|
7
|
-
function toFile(dot, path, options) {
|
|
8
|
-
throw new Error(ERROR_MESSAGE);
|
|
9
|
-
}
|
|
10
|
-
exports.toFile = toFile;
|
|
11
|
-
exports.toStream = toStream;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
function escapeValue(value) {
|
|
4
|
-
if (value !== true) {
|
|
5
|
-
if (typeof value === "string" && /\s/g.test(value)) {
|
|
6
|
-
return `="${value}"`;
|
|
7
|
-
}
|
|
8
|
-
return `=${value}`;
|
|
9
|
-
}
|
|
10
|
-
return "";
|
|
11
|
-
}
|
|
12
|
-
function* createCommandArgs(options) {
|
|
13
|
-
const {
|
|
14
|
-
suppressWarnings = true,
|
|
15
|
-
format = "svg",
|
|
16
|
-
attributes = {},
|
|
17
|
-
library = [],
|
|
18
|
-
y = false,
|
|
19
|
-
scale
|
|
20
|
-
} = options;
|
|
21
|
-
if (suppressWarnings) yield "-q";
|
|
22
|
-
yield `-T${format}`;
|
|
23
|
-
if (attributes.graph) {
|
|
24
|
-
for (const [key, value] of Object.entries(attributes.graph)) {
|
|
25
|
-
yield `-G${key}${escapeValue(value)}`;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (attributes.node) {
|
|
29
|
-
for (const [key, value] of Object.entries(attributes.node)) {
|
|
30
|
-
yield `-N${key}${escapeValue(value)}`;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (attributes.edge) {
|
|
34
|
-
for (const [key, value] of Object.entries(attributes.edge)) {
|
|
35
|
-
yield `-E${key}${escapeValue(value)}`;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (typeof scale === "number" && !Number.isNaN(scale)) yield `-s${scale}`;
|
|
39
|
-
if (Array.isArray(library)) for (const lib of library) yield `-l${lib}`;
|
|
40
|
-
if (y === true) yield "-y";
|
|
41
|
-
if (typeof options.layout === "string") {
|
|
42
|
-
yield `-K${options.layout}`;
|
|
43
|
-
switch (options.layout) {
|
|
44
|
-
case "neato": {
|
|
45
|
-
const { reduce, noop } = options;
|
|
46
|
-
if (reduce === true) yield "-x";
|
|
47
|
-
if (typeof noop === "number") yield `-n${noop}`;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
case "fdp": {
|
|
51
|
-
const {
|
|
52
|
-
grid,
|
|
53
|
-
oldAttractive,
|
|
54
|
-
iterations,
|
|
55
|
-
unscaledFactor,
|
|
56
|
-
overlapExpansionFactor,
|
|
57
|
-
temperature
|
|
58
|
-
} = options;
|
|
59
|
-
yield ["-L", grid ? "" : "g", oldAttractive ? "O" : ""].join("");
|
|
60
|
-
if (typeof iterations === "number") yield `-Ln${iterations}`;
|
|
61
|
-
if (typeof unscaledFactor === "number") yield `-LU${unscaledFactor}`;
|
|
62
|
-
if (typeof overlapExpansionFactor === "number")
|
|
63
|
-
yield `-LC${overlapExpansionFactor}`;
|
|
64
|
-
if (typeof temperature === "number") yield `-LT${temperature}`;
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function createCommandAndArgs(options) {
|
|
71
|
-
return [options.dotCommand ?? "dot", Array.from(createCommandArgs(options))];
|
|
72
|
-
}
|
|
73
|
-
exports.createCommandAndArgs = createCommandAndArgs;
|
package/lib/node.cjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const node_child_process = require("node:child_process");
|
|
4
|
-
const node_stream = require("node:stream");
|
|
5
|
-
const promises = require("node:stream/promises");
|
|
6
|
-
const createCommandAndArgs = require("./create-command-and-args.cjs");
|
|
7
|
-
const node_fs = require("node:fs");
|
|
8
|
-
async function toStream(dot, options) {
|
|
9
|
-
const [command, args] = createCommandAndArgs.createCommandAndArgs(options ?? {});
|
|
10
|
-
return new Promise(function toStreamInternal(resolve, reject) {
|
|
11
|
-
const p = node_child_process.spawn(command, args, { stdio: "pipe" });
|
|
12
|
-
p.on("error", (e) => {
|
|
13
|
-
reject(
|
|
14
|
-
new Error(`Command "${command}" failed.
|
|
15
|
-
MESSAGE:${e.message}`, {
|
|
16
|
-
cause: e
|
|
17
|
-
})
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
const stderrChunks = [];
|
|
21
|
-
p.stdout.on("pause", () => p.stdout.resume());
|
|
22
|
-
p.stderr.on("data", (chunk) => stderrChunks.push(chunk));
|
|
23
|
-
p.stderr.on("pause", () => p.stderr.resume());
|
|
24
|
-
const dist = p.stdout.pipe(new node_stream.PassThrough());
|
|
25
|
-
p.on("close", async (code, signal) => {
|
|
26
|
-
if (code === 0) {
|
|
27
|
-
resolve(dist);
|
|
28
|
-
} else {
|
|
29
|
-
const message = Buffer.concat(
|
|
30
|
-
stderrChunks
|
|
31
|
-
).toString();
|
|
32
|
-
reject(
|
|
33
|
-
new Error(
|
|
34
|
-
`Command "${command}" failed.
|
|
35
|
-
CODE: ${code}
|
|
36
|
-
SIGNAL: ${signal}
|
|
37
|
-
MESSAGE: ${message}`
|
|
38
|
-
)
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
promises.pipeline(node_stream.Readable.from([dot]), p.stdin);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
async function toFile(dot, path, options) {
|
|
46
|
-
const stream = await toStream(dot, options);
|
|
47
|
-
await promises.pipeline(stream, node_fs.createWriteStream(path));
|
|
48
|
-
}
|
|
49
|
-
exports.toFile = toFile;
|
|
50
|
-
exports.toStream = toStream;
|