ts-graphviz 1.4.1-dev.5b3016beb → 1.4.1-dev.d42db466f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -528,13 +528,16 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
528
528
  <table>
529
529
  <tbody>
530
530
  <tr>
531
- <td align="center"><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>
532
- <td align="center"><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>
533
- <td align="center"><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>
534
- <td align="center"><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>
535
- <td align="center"><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>
536
- <td align="center"><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>
537
- <td align="center"><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>
531
+ <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>
532
+ <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>
533
+ <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>
534
+ <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>
535
+ <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>
536
+ <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>
537
+ <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>
538
+ </tr>
539
+ <tr>
540
+ <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>
538
541
  </tr>
539
542
  </tbody>
540
543
  </table>
@@ -20,9 +20,29 @@ const pipeline = node_util.promisify(node_stream.pipeline);
20
20
  */
21
21
  async function toStream(dot, options) {
22
22
  const [command, args] = index_js.commandBuilder(options ?? {});
23
- const p = node_child_process.spawn(command, args, { stdio: 'pipe' });
24
- await pipeline(node_stream.Readable.from([dot]), p.stdin);
25
- return p.stdout;
23
+ return new Promise(async function toStreamInternal(resolve, reject) {
24
+ const p = node_child_process.spawn(command, args, { stdio: 'pipe' });
25
+ // error handling
26
+ p.on('error', (e) => {
27
+ reject(
28
+ new Error(`Command "${command}" failed.\nMESSAGE:${e.message}`, {
29
+ cause: e,
30
+ }),
31
+ );
32
+ });
33
+ const stderrChunks = [];
34
+ p.stderr.on('data', (chunk) => stderrChunks.push(chunk));
35
+ const dist = p.stdout.pipe(new node_stream.PassThrough());
36
+ p.on('close', async (code, signal) => {
37
+ if (code === 0) {
38
+ resolve(dist);
39
+ } else {
40
+ const message = Buffer.concat(stderrChunks).toString();
41
+ reject(new Error(`Command "${command}" failed.\nCODE: ${code}\nSIGNAL: ${signal}\nMESSAGE: ${message}`));
42
+ }
43
+ });
44
+ await pipeline(node_stream.Readable.from([dot]), p.stdin);
45
+ });
26
46
  }
27
47
 
28
48
  /**
@@ -1,4 +1,4 @@
1
- import { pipeline as pipeline$1, Readable } from 'node:stream';
1
+ import { pipeline as pipeline$1, PassThrough, Readable } from 'node:stream';
2
2
  import { spawn } from 'node:child_process';
3
3
  import { commandBuilder } from '../utils/index.js';
4
4
  import { promisify } from 'node:util';
@@ -16,9 +16,29 @@ const pipeline = promisify(pipeline$1);
16
16
  */
17
17
  async function toStream(dot, options) {
18
18
  const [command, args] = commandBuilder(options ?? {});
19
- const p = spawn(command, args, { stdio: 'pipe' });
20
- await pipeline(Readable.from([dot]), p.stdin);
21
- return p.stdout;
19
+ return new Promise(async function toStreamInternal(resolve, reject) {
20
+ const p = spawn(command, args, { stdio: 'pipe' });
21
+ // error handling
22
+ p.on('error', (e) => {
23
+ reject(
24
+ new Error(`Command "${command}" failed.\nMESSAGE:${e.message}`, {
25
+ cause: e,
26
+ }),
27
+ );
28
+ });
29
+ const stderrChunks = [];
30
+ p.stderr.on('data', (chunk) => stderrChunks.push(chunk));
31
+ const dist = p.stdout.pipe(new PassThrough());
32
+ p.on('close', async (code, signal) => {
33
+ if (code === 0) {
34
+ resolve(dist);
35
+ } else {
36
+ const message = Buffer.concat(stderrChunks).toString();
37
+ reject(new Error(`Command "${command}" failed.\nCODE: ${code}\nSIGNAL: ${signal}\nMESSAGE: ${message}`));
38
+ }
39
+ });
40
+ await pipeline(Readable.from([dot]), p.stdin);
41
+ });
22
42
  }
23
43
 
24
44
  /**
@@ -5,7 +5,7 @@ import {
5
5
  SubgraphAttributesObject,
6
6
  } from '../../common/index.js';
7
7
 
8
- type Format = 'png' | 'svg' | 'json' | 'jpg' | 'pdf' | 'xdot' | 'plain' | 'dot_json';
8
+ type Format = 'png' | 'svg' | 'json' | 'jpg' | 'pdf' | 'xdot' | 'dot' | 'plain' | 'dot_json';
9
9
  type Layout = 'dot' | 'neato' | 'fdp' | 'sfdp' | 'circo' | 'twopi' | 'nop' | 'nop2' | 'osage' | 'patchwork';
10
10
  interface NeatoOptions {
11
11
  layout: 'neato';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-graphviz",
3
- "version": "1.4.1-dev.5b3016beb",
3
+ "version": "1.4.1-dev.d42db466f",
4
4
  "author": "kamiazya <yuki@kamiazya.tech>",
5
5
  "description": "Graphviz library for TypeScript.",
6
6
  "homepage": "https://ts-graphviz.github.io/ts-graphviz/",