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.5.5-dev.bdbba8a60 to 1.5.5

11

lib/adapter/browser/index.js

@@ -1,16 +0,5 @@

/**
* @module ts-graphviz/adapter
* @beta
*/
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any */
const ERROR_MESSAGE = 'This module cannot be run in a browser.';
/**
* Execute the Graphviz dot command and make a Stream of the results.
*/
function toStream(dot, options) {
throw new Error(ERROR_MESSAGE);
}
/**
* Execute the Graphviz dot command and output the results to a file.
*/
function toFile(dot, path, options) {

@@ -17,0 +6,0 @@ throw new Error(ERROR_MESSAGE);

4

lib/adapter/deno/mod.js

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

import { commandBuilder } from '../utils/index.js';
import { createCommandAndArgs } from '../utils/index.js';
/**

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

export async function toStream(dot, options) {
const [command, args] = commandBuilder(options);
const [command, args] = createCommandAndArgs(options);
const cp = new Deno.Command(command, {

@@ -9,0 +9,0 @@ args: args,

import { pipeline as pipeline$1, PassThrough, Readable } from 'node:stream';
import { spawn } from 'node:child_process';
import { commandBuilder } from '../utils/index.js';
import { createCommandAndArgs } from '../utils/index.js';
import { promisify } from 'node:util';
import { createWriteStream } from 'node:fs';
/**
* NOTE:
* The node:stream/promises standard module is not provided in Node 14.
* Fix Node 14 to use node:stream/promises after LTS ends.
*/
const pipeline = promisify(pipeline$1);
/**
* Execute the Graphviz dot command and make a Stream of the results.
*/
async function toStream(dot, options) {
const [command, args] = commandBuilder(options ?? {});
const [command, args] = createCommandAndArgs(options ?? {});
return new Promise(async function toStreamInternal(resolve, reject) {
const p = spawn(command, args, { stdio: 'pipe' });
// error handling
p.on('error', (e) => {

@@ -46,5 +37,2 @@ reject(

/**
* Execute the Graphviz dot command and output the results to a file.
*/
async function toFile(dot, path, options) {

@@ -51,0 +39,0 @@ const stream = await toStream(dot, options);

@@ -10,2 +10,5 @@ import {

type Layout = 'dot' | 'neato' | 'fdp' | 'sfdp' | 'circo' | 'twopi' | 'nop' | 'nop2' | 'osage' | 'patchwork';
/**
* NeatoOptions interface provides options for the neato layout.
*/
interface NeatoOptions {

@@ -22,2 +25,5 @@ layout: 'neato';

}
/**
* FdpOptions interface provides options for the fdp layout.
*/
interface FdpOptions {

@@ -54,2 +60,8 @@ layout: 'fdp';

}
/**
* @description
* This interface describes an optional parameter called "layout" which is used to set a layout engine.
* The default value for this parameter is 'dot', and it must be an option of the Layout type,
* excluding 'neato' and 'fdp'.
*/
interface OtherOptions {

@@ -63,2 +75,5 @@ /**

}
/**
* This interface represents the CommonOptions for setting output format.
*/
interface CommonOptions {

@@ -65,0 +80,0 @@ /**

import { Layout, Options } from '../types/index.js';
declare function commandBuilder<T extends Layout>(options: Options<T>): [command: string, args: string[]];
/**
* createCommandAndArgs creates a command and an array of arguments, based on the given {@link Options}.
*
* @param options Options to create the command and args from.
* @returns A tuple containing the command and an array of arguments.
*/
declare function createCommandAndArgs<T extends Layout>(options: Options<T>): [command: string, args: string[]];
export { commandBuilder };
export { createCommandAndArgs };

@@ -11,3 +11,3 @@ function escapeValue(value) {

}
function* args(options) {
function* createCommandArgs(options) {
const { suppressWarnings = true, format = 'svg', attributes = {}, library = [], y = false, scale } = options;

@@ -52,6 +52,7 @@ if (suppressWarnings) yield '-q';

}
function commandBuilder(options) {
return [options.dotCommand ?? 'dot', Array.from(args(options))];
function createCommandAndArgs(options) {
return [options.dotCommand ?? 'dot', Array.from(createCommandArgs(options))];
}
export { commandBuilder };
export { createCommandAndArgs };

@@ -14,61 +14,117 @@ import {

/**
* The FilePosition interface represents the position of a file in terms of its offset, line number, and column number.
*
* @group AST
*/
interface FilePosition$1 {
/**
* The offset of the file.
*/
offset: number;
/**
* The line number of the file.
*/
line: number;
/**
* The column number of the file.
*/
column: number;
}
/**
* FileRange interface represents a range of positions within a file.
* @group AST
*/
interface FileRange$1 {
/**
* The start position of the range.
*/
start: FilePosition$1;
/**
* The end position of the range.
*/
end: FilePosition$1;
}
/**
* AST common propaties.
* This interface provides common properties to be used across all abstract syntax tree (AST) objects.
*
* @group AST
*/
interface ASTCommonPropaties {
/**
* The start and end location of the AST object.
*/
location?: FileRange$1;
}
/**
* This interface represents the properties of a dot AST node.
* @group AST
*/
type DotASTPropaties = ASTCommonPropaties;
interface DotASTPropaties extends ASTCommonPropaties {}
/**
* This interface defines the properties of a Graph AST Node.
* @group AST
*/
interface GraphASTPropaties extends ASTCommonPropaties {
/**
* An optional identifier for the Graph AST Node.
*/
id?: LiteralASTNode;
/**
* A boolean indicating whether the graph is directed.
*/
directed: boolean;
/**
* A boolean indicating whether the graph is strict.
*/
strict: boolean;
}
/**
* LiteralASTPropaties defines interface for literal AST nodes.
*
* @group AST
*/
interface LiteralASTPropaties<T extends string = string> extends ASTCommonPropaties {
/**
* The value of the literal.
*/
value: T;
/**
* A flag indicating whether the literal was quoted or not.
* If 'html' then the literal is an html like value.
*/
quoted: boolean | 'html';
}
/**
* SubgraphASTPropaties describes the properties of an AST node representing a subgraph.
* @group AST
*/
interface SubgraphASTPropaties extends ASTCommonPropaties {
/**
* id is an optional {@link LiteralASTNode} that represents the identifier of the subgraph.
*/
id?: LiteralASTNode;
}
/**
* SubgraphASTPropaties describes the properties of an AST node representing a node.
* @group AST
*/
interface NodeASTPropaties extends ASTCommonPropaties {
/**
* The unique identifier of the node.
*/
id: LiteralASTNode;
}
/**
* EdgeASTPropaties is an interface that defines the properties of an {@link EdgeASTNode}.
* @group AST
*/
interface EdgeASTPropaties extends ASTCommonPropaties {
/**
* An array of EdgeTargetASTNodes.
* The {@link EdgeTargetASTNode} represents a node that is the target of an edge.
*/
targets: [from: EdgeTargetASTNode, to: EdgeTargetASTNode, ...rest: EdgeTargetASTNode[]];
}
/**
* NodeRefASTPropaties is an interface that defines the properties of a {@link NodeRefASTNode}.
* @group AST

@@ -82,6 +138,8 @@ */

/**
* NodeRefGroupASTPropaties is an interface that defines the properties of a {@link NodeRefGroupASTNode}.
* @group AST
*/
type NodeRefGroupASTPropaties = ASTCommonPropaties;
interface NodeRefGroupASTPropaties extends ASTCommonPropaties {}
/**
* AttributeASTPropaties interface defines the properties of an {@link AttributeASTNode}.
* @group AST

@@ -94,2 +152,3 @@ */

/**
* AttributeListASTPropaties interface defines the properties of an {@link AttributeListASTNode}.
* @group AST

@@ -101,2 +160,4 @@ */

/**
* CommentKind is an enum type that describes a type of comment.
*
* @group AST

@@ -109,7 +170,16 @@ */

interface CommentASTPropaties extends ASTCommonPropaties {
/**
* A string that specifies the kind of comment.
*/
kind: CommentKind;
/**
* A string that contains the actual content of the comment.
*/
value: string;
}
/**
* AST node.
* ASTBaseNode is an interface that serves as the base for all AST nodes.
* It requires all leaf interfaces to specify a type property,
* which is of type {@link ASTType}.
*
* @group AST

@@ -125,2 +195,5 @@ */

/**
* ASTBaseParentNode represents a parent node that has some child nodes.
*
* @template STMT The type of {@link ASTBaseNode} to be stored in the children array.
* @group AST

@@ -132,2 +205,4 @@ */

/**
* LiteralASTNode is a type of AST node that represents a literal value.
*
* @group AST

@@ -139,2 +214,4 @@ */

/**
* DotASTNode is a type of AST node that represents a dot in a graph.
*
* @group AST

@@ -146,3 +223,4 @@ */

/**
* Graph AST object.
* GraphASTNode is a type of AST node that represents a graph.
*
* @group AST

@@ -154,3 +232,3 @@ */

/**
* Attribute AST object.
* AttributeASTNode is a type of AST node that represents an attribute.
* @group AST

@@ -164,3 +242,3 @@ */

/**
* Comment AST object.
* CommentASTNode is a type of AST node that represents a comment.
* @group AST

@@ -172,3 +250,3 @@ */

/**
* Attributes AST object.
* AttributeListASTNode is a type of AST node that represents a list of attributes.
* @group AST

@@ -180,3 +258,3 @@ */

/**
* NodeRef AST object.
* NodeRefASTNode is a type of AST node that represents a reference to a node.
* @group AST

@@ -188,3 +266,3 @@ */

/**
* NodeRefGroup AST object.
* NodeRefGroupASTNode is a type of AST node that represents a group of nodes referenced together.
* @group AST

@@ -196,2 +274,4 @@ */

/**
* This type is used to represent a target of an edge in an AST (Abstract Syntax Tree).
*
* @group AST

@@ -201,3 +281,3 @@ */

/**
* Edge AST object.
* EdgeASTNode is a type of AST node that represents an edge in a graph.
* @group AST

@@ -209,3 +289,3 @@ */

/**
* Node AST object.
* NodeASTNode is a type of AST node that represents a node in a graph.
* @group AST

@@ -217,3 +297,3 @@ */

/**
* Subgraph AST object.
* SubgraphASTNode is a type of AST node that represents a subgraph.
* @group AST

@@ -229,2 +309,3 @@ */

/**
* ClusterStatementASTNode is a type used to represent a statement in a cluster graph.
* @group AST

@@ -240,2 +321,4 @@ */

/**
* ASTNode is a type used to define a set of different types of AST nodes that can be used in a graph.
*
* @group AST

@@ -256,2 +339,3 @@ */

/**
* ASTChildNode is a type alias used to represent the child nodes of a given {@link ASTBaseParentNode}.
* @group AST

@@ -262,2 +346,4 @@ */

/**
* This interface is used to define the options for the builder.
*
* @group Create AST

@@ -267,5 +353,10 @@ * @alpha

interface BuilderOptions {
/**
* This is a function that returns a {@link FileRange} object.
* It is used to specify the location of the builder.
*/
locationFunction: () => FileRange$1;
}
/**
* This interface provides a method for creating an Abstract Syntax Tree (AST) for a given type.
* @group Create AST

@@ -275,2 +366,10 @@ * @alpha

interface CreateElement {
/**
* Creates a LiteralASTNode with the given type, properties, and children.
*
* @param type The type of the AST node.
* @param props The properties of the AST node.
* @param children The children of the AST node.
* @returns A {@link LiteralASTNode} with the given type, properties, and children.
*/
<T extends string>(

@@ -281,7 +380,55 @@ type: 'Literal',

): LiteralASTNode<T>;
/**
* Creates a LiteralASTNode with the given type, properties, and children.
*
* @param type The type of the AST node.
* @param props The properties of the AST node.
* @param children The children of the AST node.
* @returns A {@link LiteralASTNode} with the given type, properties, and children.
*/
(type: 'Literal', props: LiteralASTPropaties, children: ASTChildNode<LiteralASTNode>[]): LiteralASTNode;
/**
* Creates a {@link DotASTNode} with the given type, properties, and children.
*
* @param type The type of the AST node.
* @param props The properties of the AST node.
* @param children The children of the AST node.
* @returns A {@link DotASTNode} with the given type, properties, and children.
*/
(type: 'Dot', props: DotASTPropaties, children: ASTChildNode<DotASTNode>[]): DotASTNode;
/**
* Creates a {@link GraphASTNode} with the given type, properties, and children.
*
* @param type The type of the AST node.
* @param props The properties of the AST node.
* @param children The children of the AST node.
* @returns A {GraphASTNode} with the given type, properties, and children.
*/
(type: 'Graph', props: GraphASTPropaties, children: ASTChildNode<GraphASTNode>[]): GraphASTNode;
/**
* Creates an {@link AttributeASTNode} with the given type, properties, and children.
*
* @param type The type of the AST node.
* @param props The properties of the AST node.
* @param children The children of the AST node.
* @returns An {@link AttributeASTNode} with the given type, properties, and children.
*/
(type: 'Attribute', props: AttributeASTPropaties, children: ASTChildNode<AttributeASTNode>[]): AttributeASTNode;
/**
* Creates a {@link CommentASTNode} with the given type, properties, and children.
*
* @param type The type of the AST node.
* @param props The properties of the AST node.
* @param children The children of the AST node.
* @returns A {@link CommentASTNode} with the given type, properties, and children.
*/
(type: 'Comment', props: CommentASTPropaties, children: ASTChildNode<CommentASTNode>[]): CommentASTNode;
/**
* Creates an {@link AttributeListASTNode} with the given type, properties, and children.
*
* @param type The type of the AST node.
* @param props The properties of the AST node.
* @param children The children of the AST node.
* @returns An {@link AttributeListASTNode} with the given type, properties, and children.
*/
(

@@ -292,3 +439,19 @@ type: 'AttributeList',

): AttributeListASTNode;
/**
* Creates a {@link NodeRefASTNode} with the given type, properties, and children.
*
* @param type The type of the AST node.
* @param props The properties of the AST node.
* @param children The children of the AST node.
* @returns A {@link NodeRefASTNode} with the given type, properties, and children.
*/
(type: 'NodeRef', props: NodeRefASTPropaties, children: ASTChildNode<NodeRefASTNode>[]): NodeRefASTNode;
/**
* Creates a {@link NodeRefGroupASTNode} with the given type, properties, and children.
*
* @param type The type of the AST node.
* @param props The properties of the AST node.
* @param children The children of the AST node.
* @returns A {@link NodeRefGroupASTNode} with the given type, properties, and children.
*/
(

@@ -299,7 +462,32 @@ type: 'NodeRefGroup',

): NodeRefGroupASTNode;
/**
* Creates an {@link EdgeASTNode} with the given type, properties, and children.
*
* @param type The type of the AST node.
* @param props The properties of the AST node.
* @param children The children of the AST node.
* @returns An {@link EdgeASTNode} with the given type, properties, and children.
*/
(type: 'Edge', props: EdgeASTPropaties, children: ASTChildNode<EdgeASTNode>[]): EdgeASTNode;
/**
* Creates a {@link NodeASTNode} with the given type, properties, and children.
*
* @param type The type of the AST node.
* @param props The properties of the AST node.
* @param children The children of the AST node.
* @returns A {@link NodeASTNode} with the given type, properties, and children.
*/
(type: 'Node', props: NodeASTPropaties, children: ASTChildNode<NodeASTNode>[]): NodeASTNode;
/**
* Creates a {@link SubgraphASTNode} with the given type, properties, and children.
*
* @param type The type of the AST node.
* @param props The properties of the AST node.
* @param children The children of the AST node.
* @returns A {@link SubgraphASTNode} with the given type, properties, and children.
*/
(type: 'Subgraph', props: SubgraphASTPropaties, children: ASTChildNode<SubgraphASTNode>[]): SubgraphASTNode;
}
/**
* This interface provides an ASTBuilder object with a createElement function.
* @group Create AST

@@ -313,2 +501,4 @@ * @alpha

/**
* Builder is an ASTBuilder that provides a method to create an ASTNode.
*
* @group Create AST

@@ -318,5 +508,20 @@ */

private options?;
/** @internal */
/**
* Get the current file range or null
* @internal
*/
private getLocation;
/**
* Constructor of Builder
* @param options - Options to initialize Builder
*/
constructor(options?: Partial<BuilderOptions> | undefined);
/**
* Create an {@link ASTNode} of the specified type
*
* @param type - Type of the {@link ASTNode}
* @param props - Properties of the {@link ASTNode}
* @param children - Children of the {@link ASTNode}
* @returns An {@link ASTNode}
*/
createElement<T extends ASTNode>(type: T['type'], props: any, children: ASTChildNode<T>[]): T;

@@ -326,3 +531,9 @@ }

/**
* Create an {@link ASTNode} of the specified type
*
* @param type - Type of the {@link ASTNode}
* @param props - Properties of the {@link ASTNode}
* @param children - Children of the {@link ASTNode}
* @group Create AST
* @returns An {@link ASTNode}
*/

@@ -332,2 +543,3 @@ declare const createElement: CreateElement;

/**
* The IndentStyle type represents an indentation style for text. It can either be a `"space"` or a `"tab"`.
* @group Convert AST to DOT

@@ -337,2 +549,3 @@ */

/**
* This type represents the EndOfLine type which is used to determine the type of line ending to be used when writing to a file.
* @group Convert AST to DOT

@@ -342,2 +555,3 @@ */

/**
* This interface provides options for converting an abstract syntax tree (AST) to a DOT representation.
* @group Convert AST to DOT

@@ -347,7 +561,23 @@ * @alpha

interface PrintOptions {
/**
* The style of indentation to use when printing the AST.
*
* @default "space"
*/
indentStyle?: IndentStyle;
/**
* The size of the indentation to use when printing the AST.
*
* @default 2
*/
indentSize?: number;
/**
* The type of line ending to use when printing the AST.
*
* @default lf
*/
endOfLine?: EndOfLine;
}
/**
* PrintContext interface provides an interface for printing an ASTNode with a set of options.
* @group Convert AST to DOT

@@ -357,6 +587,14 @@ * @alpha

interface PrintContext extends Required<PrintOptions> {
/**
* Indicates if the AST should be printed in a directed graph.
*/
directed: boolean;
/**
* A function to print an ASTNode, taking in an ASTNode as an argument. Returns a string.
*/
print(ast: ASTNode): string;
}
/**
* PrintPlugin is an interface for plugins used for printing an {@link ASTNode}.
* @template T T extends {@link ASTNode}
* @group Convert AST to DOT

@@ -366,3 +604,14 @@ * @alpha

interface PrintPlugin<T extends ASTNode = ASTNode> {
/**
* Checks if an ASTNode matches the plugin
* @returns {boolean} true if the ASTNode matches the plugin
*/
match(ast: ASTNode): boolean;
/**
* Prints an ASTNode
* @param context PrintContext object
* @param ast an ASTNode
* @returns printed string
* @memberof PrintPlugin
*/
print(context: PrintContext, ast: T): string;

@@ -372,2 +621,3 @@ }

/**
* Printer is a class responsible for converting an AST into a DOT string.
* @group Convert AST to DOT

@@ -378,3 +628,11 @@ */

private options;
/**
* @param options Options to be used when generating the DOT string.
*/
constructor(options?: PrintOptions);
/**
* Generates a DOT string from an ASTNode.
* @param ast The ASTNode to be converted into a DOT string.
* @returns The DOT string generated from the ASTNode.
*/
print(ast: ASTNode): string;

@@ -384,6 +642,7 @@ }

/**
* Stringify Graphviz AST Node.
* stringify is a function that converts a Graphviz AST Node into a string in DOT language.
*
* @param ast Graphviz AST node.
* @returns DOT language string.
* @param ast Graphviz AST node that is to be converted.
* @param options PrintOptions object containing formatting options.
* @returns A string in DOT language.
* @group Convert AST to DOT

@@ -447,8 +706,14 @@ */

/**
* CommonParseOptions is an interface that defines the properties needed in order to parse a file.
* @group Convert DOT to AST
*/
interface CommonParseOptions {
/**
* filename (optional): A string value that is used to identify the file to be parsed.
*/
filename?: string;
}
/**
* ParseOptions interface is used to provide additional information to the parser while parsing a rule.
* @template T The type of the rule to be parsed.
* @group Convert DOT to AST

@@ -460,2 +725,18 @@ */

/**
* parse is a function that takes a string input and optional parse options and
* returns an ASTNode or an array of ClusterStatementASTNodes.
*
* Depending on the type of parse option specified, the function will return different types of ASTNodes.
*
* The types of ASTNodes that can be returned are:
*
* - {@link DotASTNode}
* - {@link GraphASTNode}
* - {@link NodeASTNode}
* - {@link EdgeASTNode}
* - {@link AttributeListASTNode}
* - {@link AttributeASTNode}
* - {@link SubgraphASTNode}
* - {@link ClusterStatementASTNode}
*
* @throws {@link SyntaxError}

@@ -480,2 +761,14 @@ * @group Convert DOT to AST

/**
* ModelToAST is a type alias used to map a generic type T to a specific AST node type.
*
* If T is a DotObjectModel, the type U is inferred and used to determine which AST node type to map to.
*
* If U is 'Graph', the type is mapped to either a {@link GraphASTNode} or a {@link DotASTNode}.
* If U is 'AttributeList', the type is mapped to an {@link AttributeListASTNode}.
* If U is 'Edge', the type is mapped to an {@link EdgeASTNode}.
* If U is 'Node', the type is mapped to a {@link NodeASTNode}.
* If U is 'Subgraph', the type is mapped to a {@link SubgraphASTNode}.
*
* If T is not a DotObjectModel, the type is mapped to never.
*
* @group AST

@@ -520,2 +813,4 @@ */

/**
* FromModelConverter is a class used to convert a {@link DotObjectModel} into an ASTNode.
*
* @group Convert Model to AST

@@ -527,2 +822,8 @@ */

constructor(options?: ConvertFromModelOptions);
/**
* Converts a DotObjectModel into an AST.
*
* @param model The {@link DotObjectModel} to be converted.
* @returns The AST generated from the model.
*/
convert<T extends DotObjectModel>(model: T): ModelToAST<T>;

@@ -532,2 +833,8 @@ }

/**
* A function used to convert a DotObjectModel into an AST.
*
* @param model - The {@link DotObjectModel} to be converted.
* @param options - An optional {@link ConvertFromModelOptions} object.
* @returns ModelToAST - The AST representation of the {@link DotObjectModel}.
*
* @group Convert Model to AST

@@ -538,2 +845,3 @@ */

/**
* ModelOf is a type that determines the type of model to use depending on the value of T.
* @group AST

@@ -551,2 +859,4 @@ */

/**
* ASTToModel is a type that determines a model type from an AST.
*
* @group AST

@@ -560,2 +870,3 @@ */

/**
* This type is used to define what AST nodes can be converted to a model.
* @group Convert AST to Model

@@ -562,0 +873,0 @@ * @beta

@@ -1437,2 +1437,5 @@ /**

/**
* KeyValueMapping is an interface that defines a set of attributes that can be used to configure a graph.
*/
interface KeyValueMapping {

@@ -1613,2 +1616,5 @@ _background: string;

/**
* This type represents an Attribute, which is a key-value mapping of an {@link AttributeKey} to a value.
*
* @param T The {@link AttributeKey} to be mapped to a value.
* @group Attribute

@@ -1641,2 +1647,3 @@ */

/**
* ASTType is an enumeration of the different types of nodes that can be found in an AST(Abstract Syntax Tree ).
* @group Models

@@ -1731,5 +1738,11 @@ */

/**
* DotObjectModel is an interface that defines a generic type for a {@link DotObjectType}.
*
* @template T The type of the {@link DotObjectType}.
* @group Models
*/
interface DotObjectModel<T extends DotObjectType = DotObjectType> {
/**
* The type of the DotObjectType.
*/
$$type: T;

@@ -1736,0 +1749,0 @@ }

@@ -1,26 +0,19 @@

/** @hidden */
function isForwardRefNode(object) {
return typeof object === 'object' && object !== null && typeof object.id === 'string';
}
/** @hidden */
function isNodeModel(object) {
return typeof object === 'object' && object !== null && object.$$type === 'Node' && typeof object.id === 'string';
}
/** @hidden */
function isNodeRef(node) {
return isNodeModel(node) || isForwardRefNode(node);
}
/** @hidden */
function isNodeRefLike(node) {
return typeof node === 'string' || isNodeRef(node);
}
/** @hidden */
function isNodeRefGroupLike(target) {
return Array.isArray(target) && target.every(isNodeRefLike);
}
/** @hidden */
function isCompass(c) {
return ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'c'].includes(c);
}
/** @hidden */
function toNodeRef(target) {

@@ -36,3 +29,2 @@ if (isNodeRef(target)) {

}
/** @hidden */
function toNodeRefGroup(targets) {

@@ -45,8 +37,3 @@ if (targets.length < 2 && (isNodeRefLike(targets[0]) && isNodeRefLike(targets[1])) === false) {

/**
* @group Models Context
* @alpha
*/
const RootModelsContext = Object.seal({
// NOTE: RootModelsContext is also initialized after the model class is declared in the 'core/index.js' module.
Graph: null,

@@ -58,6 +45,2 @@ Digraph: null,

});
/**
* @group Models Context
* @alpha
*/
function createModelsContext(models) {

@@ -64,0 +47,0 @@ return Object.assign(Object.seal(Object.assign({}, RootModelsContext)), models);

@@ -11,5 +11,2 @@ import {

/**
* @group Attribute
*/
const attribute = new Proxy(Object.freeze({}), {

@@ -19,14 +16,5 @@ get: (_, key) => key,

/**
* Base class for DOT objects.
* @group Models
*/
class DotObject {}
/**
* Base class for DOT objects with attributes.
* @group Models
*/
class AttributesBase extends DotObject {
/** @hidden */
#attrs = new Map();

@@ -67,6 +55,2 @@ constructor(attributes) {

/**
* A set of attribute values for any object.
* @group Models
*/
class AttributeList extends AttributesBase {

@@ -84,8 +68,3 @@ $$kind;

/**
* Base class for Graph objects.
* @group Models
*/
class GraphBase extends AttributesBase {
/** @hidden */
#models = RootModelsContext;

@@ -108,3 +87,2 @@ id;

}
/** @hidden */
#objects = {

@@ -219,6 +197,2 @@ nodes: new Map(),

/**
* Base class representing a root graph(digraph, graph).
* @group Models
*/
class RootGraph extends GraphBase {

@@ -241,6 +215,2 @@ get $$type() {

/**
* DOT object class representing a digraph.
* @group Models
*/
class Digraph extends RootGraph {

@@ -252,6 +222,2 @@ get directed() {

/**
* DOT object class representing a graph.
* @group Models
*/
class Graph extends RootGraph {

@@ -263,6 +229,2 @@ get directed() {

/**
* DOT object class representing a subgraph.
* @group Models
*/
class Subgraph extends GraphBase {

@@ -289,6 +251,2 @@ get $$type() {

/**
* A set of attribute values for any object.
* @group Models
*/
class AttributesGroup extends AttributesBase {

@@ -298,6 +256,2 @@ comment;

/**
* DOT object class representing a node.
* @group Models
*/
class Node extends DotObject {

@@ -323,6 +277,2 @@ id;

/**
* DOT object class representing a edge.
* @group Models
*/
class Edge extends DotObject {

@@ -353,3 +303,2 @@ targets;

/** @hidden */
function ModelFactoryBuilder(directed, strictMode) {

@@ -377,20 +326,5 @@ return (...args) => {

const noStrict = createModelFactories(false);
/**
* API for creating directional graph objects.
* @group Model Factory
*/
const digraph = noStrict.digraph;
/**
* API for creating omnidirectional graph objects.
* @group Model Factory
*/
const graph = noStrict.graph;
/**
* Provides a strict mode API.
* @group Model Factory
*/
const strict = createModelFactories(true);
/**
* @group Model Factory
*/
function withContext(models) {

@@ -404,11 +338,2 @@ const context = createModelsContext(models);

/**
* Convert Model to DOT string.
*
* @group Convert Model to DOT
*
* @param model Dot Object Model, like {@link Digraph}, {@link Graph}, {@link Subgraph}, {@link Node}, and {@link Edge}
* @param options
* @returns DOT string
*/
function toDot(model, options) {

@@ -415,0 +340,0 @@ const ast = fromModel(model, options?.convert);

{
"name": "ts-graphviz",
"version": "1.5.5-dev.bdbba8a60",
"author": "kamiazya <yuki@kamiazya.tech>",
"description": "Graphviz library for TypeScript.",
"homepage": "https://ts-graphviz.github.io/ts-graphviz/",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/ts-graphviz/ts-graphviz.git"
"name": "ts-graphviz",
"version": "1.5.5",
"author": "kamiazya <yuki@kamiazya.tech>",
"description": "Graphviz library for TypeScript.",
"homepage": "https://ts-graphviz.github.io/ts-graphviz/",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/ts-graphviz/ts-graphviz.git"
},
"keywords": [
"graphviz",
"dot"
],
"bugs": {
"url": "https://github.com/ts-graphviz/ts-graphviz/issues"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/kamiazya"
},
"main": "./lib/index.cjs",
"module": "./lib/index.js",
"types": "lib/index.d.ts",
"exports": {
".": {
"require": {
"types": "./lib/index.d.ts",
"default": "./lib/index.cjs"
},
"import": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
}
},
"keywords": [
"graphviz",
"dot"
],
"bugs": {
"url": "https://github.com/ts-graphviz/ts-graphviz/issues"
"./ast": {
"require": {
"types": "./lib/ast/index.d.ts",
"default": "./lib/ast/index.cjs"
},
"import": {
"types": "./lib/ast/index.d.ts",
"default": "./lib/ast/index.js"
}
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/kamiazya"
"./adapter": {
"browser": {
"require": "./lib/adapter/browser/index.cjs",
"import": "./lib/adapter/browser/index.js",
"types": "./lib/adapter/browser/index.d.ts"
},
"deno": {
"types": "./lib/adapter/deno/mod.d.ts",
"default": "./lib/adapter/deno/mod.js"
},
"node": {
"require": "./lib/adapter/node/index.cjs",
"import": "./lib/adapter/node/index.js",
"types": "./lib/adapter/node/index.d.ts"
},
"default": {
"types": "./lib/adapter/node/index.d.ts",
"require": "./lib/adapter/node/index.cjs",
"import": "./lib/adapter/node/index.js"
}
},
"main": "./lib/index.cjs",
"module": "./lib/index.js",
"types": "lib/index.d.ts",
"exports": {
".": {
"require": {
"types": "./lib/index.d.ts",
"default": "./lib/index.cjs"
},
"import": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
}
},
"./ast": {
"require": {
"types": "./lib/ast/index.d.ts",
"default": "./lib/ast/index.cjs"
},
"import": {
"types": "./lib/ast/index.d.ts",
"default": "./lib/ast/index.js"
}
},
"./adapter": {
"browser": {
"require": "./lib/adapter/browser/index.cjs",
"import": "./lib/adapter/browser/index.js",
"types": "./lib/adapter/browser/index.d.ts"
},
"deno": {
"types": "./lib/adapter/deno/mod.d.ts",
"default": "./lib/adapter/deno/mod.js"
},
"node": {
"require": "./lib/adapter/node/index.cjs",
"import": "./lib/adapter/node/index.js",
"types": "./lib/adapter/node/index.d.ts"
},
"default": {
"types": "./lib/adapter/node/index.d.ts",
"require": "./lib/adapter/node/index.cjs",
"import": "./lib/adapter/node/index.js"
}
},
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"ast": [
"lib/ast"
],
"adapter": [
"lib/adapter/node"
]
}
},
"license": "MIT",
"engines": {
"node": ">=14.16"
},
"runkitExampleFilename": "example/runkit.cjs",
"scripts": {
"build:peggy": "peggy --plugin ts-pegjs --extra-options-file src/ast/dot-shim/parser/peggy.options.json -o src/ast/dot-shim/parser/_parse.ts src/ast/dot-shim/parser/dot.peggy",
"prebuild": "yarn build:peggy",
"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/**/*.{js,cjs,d.ts}",
"pretest": "yarn build:peggy",
"test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest",
"format": "eslint --ext ts src --fix && prettier --write './**/*.{ts,js,json,yaml}' '!lib'",
"lint": "eslint --ext ts src",
"predoc": "yarn build:peggy",
"doc": "typedoc"
},
"devDependencies": {
"@rollup/plugin-replace": "^5.0.2",
"@types/jest": "^29.4.0",
"@types/jest-specific-snapshot": "^0.5.6",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"eslint": "^8.32.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.4.1",
"jest-snapshot-serializer-raw": "^1.2.0",
"jest-specific-snapshot": "^7.0.0",
"peggy": "^2.0.1",
"prettier": "^2.8.3",
"prettier-plugin-pegjs": "^0.5.0",
"rollup": "^3.11.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-dts": "5.1.1",
"svgo": "^3.0.2",
"ts-jest": "^29.0.5",
"ts-pegjs": "^3.0.0",
"typedoc": "^0.23.15",
"typescript": "^4.7.4"
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"ast": [
"lib/ast"
],
"adapter": [
"lib/adapter/node"
]
}
}
},
"license": "MIT",
"engines": {
"node": ">=14.16"
},
"runkitExampleFilename": "example/runkit.cjs",
"scripts": {
"build:peggy": "peggy --plugin ts-pegjs --extra-options-file src/ast/dot-shim/parser/peggy.options.json -o src/ast/dot-shim/parser/_parse.ts src/ast/dot-shim/parser/dot.peggy",
"prebuild": "yarn build:peggy",
"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 --declaration && tsc -p tsconfig.build.json --removeComments && rollup -c",
"build": "yarn build:node && yarn build:deno",
"postbuild": "prettier --write ./lib/**/*.{js,cjs,d.ts}",
"pretest": "yarn build:peggy",
"test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest",
"format": "eslint --ext ts src --fix && prettier --write './**/*.{ts,js,json,yaml}' '!lib'",
"lint": "eslint --ext ts src",
"predoc": "yarn build:peggy",
"doc": "typedoc"
},
"devDependencies": {
"@rollup/plugin-replace": "^5.0.2",
"@types/jest": "^29.4.0",
"@types/jest-specific-snapshot": "^0.5.6",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"eslint": "^8.32.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.4.1",
"jest-snapshot-serializer-raw": "^1.2.0",
"jest-specific-snapshot": "^7.0.0",
"peggy": "^2.0.1",
"prettier": "^2.8.3",
"prettier-plugin-pegjs": "^0.5.0",
"rollup": "^3.11.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-dts": "5.1.1",
"svgo": "^3.0.2",
"ts-jest": "^29.0.5",
"ts-pegjs": "^3.0.0",
"typedoc": "^0.23.15",
"typescript": "^4.7.4"
}
}

@@ -548,2 +548,3 @@ [![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)

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

@@ -550,0 +551,0 @@ </tbody>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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