Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-graphviz

Package Overview
Dependencies
Maintainers
1
Versions
183
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-graphviz - npm Package Compare versions

Comparing version 1.4.1-dev.c60d6bfba to 1.4.1-dev.d42db466f

lib/adapter/types/index.cjs

14

lib/adapter/deno/mod.d.ts

@@ -1,13 +0,7 @@

export type Format = 'png' | 'svg' | 'json' | 'jpg' | 'pdf' | 'xdot' | 'plain' | 'dot_json';
import { Options, Format, Layout } from '../types/index.d.ts';
export interface Options {
format?: Format;
suppressWarnings?: boolean;
dotCommand?: string;
}
/**
* Execute the Graphviz dot command and make a Stream of the results.
*/
export function toStream(dot: string, options?: Options): Promise<ReadableStream<Uint8Array>>;
export function toStream<T extends Layout>(dot: string, options?: Options<T>): Promise<ReadableStream<Uint8Array>>;

@@ -17,2 +11,4 @@ /**

*/
export function toFile(dot: string, path: string, options?: Options): Promise<void>;
export function toFile<T extends Layout>(dot: string, path: string, options?: Options<T>): Promise<void>;
export { Options, Format, Layout };

@@ -1,11 +0,2 @@

function commandBuilder({ dotCommand = 'dot', suppressWarnings = true, format = 'svg' } = {}) {
const args = [
...(function* () {
if (suppressWarnings) yield '-q';
yield `-T${format}`;
})(),
];
return [dotCommand, args];
}
import { commandBuilder } from '../utils/index.js';
/**

@@ -12,0 +3,0 @@ * Execute the Graphviz dot command and make a Stream of the results.

/// <reference types="node" />
type Format = 'png' | 'svg' | 'json' | 'jpg' | 'pdf' | 'xdot' | 'plain' | 'dot_json';
interface Options {
format?: Format;
suppressWarnings?: boolean;
dotCommand?: string;
}
import { Layout, Options } from '../types/index.js';
export { Format, Options } from '../types/index.js';
/**
* Execute the Graphviz dot command and make a Stream of the results.
*/
declare function toStream(dot: string, options?: Options): Promise<NodeJS.ReadableStream>;
declare function toStream<T extends Layout>(dot: string, options?: Options<T>): Promise<NodeJS.ReadableStream>;
/**
* Execute the Graphviz dot command and output the results to a file.
*/
declare function toFile(dot: string, path: string, options?: Options): Promise<void>;
declare function toFile<T extends Layout>(dot: string, path: string, options?: Options<T>): Promise<void>;
export { Format, Options, toFile, toStream };
export { toFile, toStream };

@@ -0,20 +1,8 @@

import { pipeline as pipeline$1, PassThrough, Readable } from 'node:stream';
import { spawn } from 'node:child_process';
import { commandBuilder } from '../utils/index.js';
import { promisify } from 'node:util';
import { createWriteStream } from 'node:fs';
import { pipeline as pipeline$1, Readable } from 'node:stream';
import { promisify } from 'node:util';
import { spawn } from 'node:child_process';
/**
* @module ts-graphviz/adapter
* @beta
*/
function commandBuilder({ dotCommand = 'dot', suppressWarnings = true, format = 'svg' } = {}) {
const args = [
...(function* () {
if (suppressWarnings) yield '-q';
yield `-T${format}`;
})(),
];
return [dotCommand, args];
}
/**
* NOTE:

@@ -25,2 +13,3 @@ * The node:stream/promises standard module is not provided in Node 14.

const pipeline = promisify(pipeline$1);
/**

@@ -30,7 +19,28 @@ * Execute the Graphviz dot command and make a Stream of the results.

async function toStream(dot, options) {
const [command, args] = commandBuilder(options);
const p = spawn(command, args, { stdio: 'pipe' });
await pipeline(Readable.from([dot]), p.stdin);
return p.stdout;
const [command, args] = commandBuilder(options ?? {});
return new Promise(async function toStreamInternal(resolve, reject) {
const p = spawn(command, args, { stdio: 'pipe' });
// error handling
p.on('error', (e) => {
reject(
new Error(`Command "${command}" failed.\nMESSAGE:${e.message}`, {
cause: e,
}),
);
});
const stderrChunks = [];
p.stderr.on('data', (chunk) => stderrChunks.push(chunk));
const dist = p.stdout.pipe(new PassThrough());
p.on('close', async (code, signal) => {
if (code === 0) {
resolve(dist);
} else {
const message = Buffer.concat(stderrChunks).toString();
reject(new Error(`Command "${command}" failed.\nCODE: ${code}\nSIGNAL: ${signal}\nMESSAGE: ${message}`));
}
});
await pipeline(Readable.from([dot]), p.stdin);
});
}
/**

@@ -37,0 +47,0 @@ * Execute the Graphviz dot command and output the results to a file.

{
"name": "ts-graphviz",
"version": "1.4.1-dev.c60d6bfba",
"version": "1.4.1-dev.d42db466f",
"author": "kamiazya <yuki@kamiazya.tech>",

@@ -87,6 +87,6 @@ "description": "Graphviz library for TypeScript.",

"prebuild": "yarn build:peggy",
"build:deno": "cp -r src/adapter/deno lib/adapter/deno",
"build:deno": "mkdir -p lib/adapter/deno && cp -r src/adapter/deno/* lib/adapter/deno && sed -i \"s/index.ts/index.js/g\" lib/adapter/deno/mod.js && sed -i \"s/index.ts/index.d.ts/g\" lib/adapter/deno/mod.d.ts",
"build:node": "tsc -p tsconfig.build.json && rollup -c",
"build": "yarn build:node && yarn build:deno",
"postbuild": "prettier --write ./lib/**/index.{js,cjs,d.ts}",
"postbuild": "prettier --write ./lib/**/*.{js,cjs,d.ts}",
"pretest": "yarn build:peggy",

@@ -93,0 +93,0 @@ "test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest",

@@ -531,10 +531,13 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/d6485f9858ed4b3e8ef76611a2896bc4)](https://app.codacy.com/gh/ts-graphviz/ts-graphviz?utm_source=github.com&utm_medium=referral&utm_content=ts-graphviz/ts-graphviz&utm_campaign=Badge_Grade_Settings)

<tr>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
</tr>
<tr>
<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>
</tr>
</tbody>

@@ -541,0 +544,0 @@ </table>

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc