ts-graphviz
Advanced tools
Comparing version 1.5.5-dev.02afc3340 to 1.5.5-dev.27273c787
@@ -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); |
@@ -7,12 +7,4 @@ import { pipeline as pipeline$1, PassThrough, Readable } from 'node:stream'; | ||
/** | ||
* 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) { | ||
@@ -22,3 +14,2 @@ const [command, args] = createCommandAndArgs(options ?? {}); | ||
const p = spawn(command, args, { stdio: 'pipe' }); | ||
// error handling | ||
p.on('error', (e) => { | ||
@@ -48,5 +39,2 @@ reject( | ||
/** | ||
* Execute the Graphviz dot command and output the results to a file. | ||
*/ | ||
async function toFile(dot, path, options) { | ||
@@ -53,0 +41,0 @@ const stream = await toStream(dot, options); |
@@ -1,8 +0,1 @@ | ||
/** | ||
* escapeValue is a function that escapes a given Attribute value of a given AttributeKey. | ||
* It checks the type of the value and adds quotes if the value is of type string and contains whitespace. | ||
* | ||
* @param value The value of an Attribute of type T that extends AttributeKey | ||
* @returns The escaped Attribute value | ||
*/ | ||
function escapeValue(value) { | ||
@@ -18,9 +11,2 @@ if (value !== true) { | ||
} | ||
/** | ||
* createCommandArgs is a function that creates command arguments from a given Options object. | ||
* It reads the properties of the Options object and creates corresponding command line arguments accordingly. | ||
* | ||
* @param options The Options object used to create command arguments | ||
* @returns A generator that yields strings for command arguments | ||
*/ | ||
function* createCommandArgs(options) { | ||
@@ -67,8 +53,2 @@ const { suppressWarnings = true, format = 'svg', attributes = {}, library = [], y = false, scale } = options; | ||
/** | ||
* 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. | ||
*/ | ||
function createCommandAndArgs(options) { | ||
@@ -75,0 +55,0 @@ return [options.dotCommand ?? 'dot', Array.from(createCommandArgs(options))]; |
@@ -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,10 +303,2 @@ targets; | ||
/** | ||
* ModelFactoryBuilder is a function that takes two parameters, directed and strictMode, and returns a ModelFactory. | ||
* | ||
* @param directed A boolean value indicating whether the graph should be directed or not. | ||
* @param strictMode A boolean value indicating whether the graph should be in strict mode or not. | ||
* @returns A ModelFactory that takes an array of unknowns as parameters and returns a RootGraphModel. | ||
* @hidden | ||
*/ | ||
function ModelFactoryBuilder(directed, strictMode) { | ||
@@ -376,9 +318,2 @@ return (...args) => { | ||
} | ||
/** | ||
* createModelFactories is a function that takes a boolean value, strict, and an optional ModelsContext parameter, context, and returns an object containing two ModelFactories. | ||
* | ||
* @param strict A boolean value indicating whether the graph should be in strict mode or not. | ||
* @param context An optional ModelsContext parameter. | ||
* @returns An object containing two ModelFactories, one for directed graphs and one for undirected graphs. | ||
*/ | ||
function createModelFactories(strict, context = RootModelsContext) { | ||
@@ -392,24 +327,5 @@ return Object.freeze({ | ||
const noStrict = createModelFactories(false); | ||
/** | ||
* digraph is a factory for creating Digraph objects. | ||
* @group Model Factory | ||
*/ | ||
const digraph = noStrict.digraph; | ||
/** | ||
* graph is a factory for creating Graph objects. | ||
* @group Model Factory | ||
*/ | ||
const graph = noStrict.graph; | ||
/** | ||
* Provides a strict mode API. | ||
* @group Model Factory | ||
*/ | ||
const strict = createModelFactories(true); | ||
/** | ||
* withContext creates a {@link ModelFactoriesWithStrict} object with the given context. | ||
* | ||
* @param models - An object containing the models to be used in the context. | ||
* | ||
* @returns A ModelFactoriesWithStrict object containing the factories. * @group Model Factory | ||
*/ | ||
function withContext(models) { | ||
@@ -423,11 +339,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 Optional options for the conversion. | ||
* @returns DOT string | ||
*/ | ||
function toDot(model, options) { | ||
@@ -434,0 +341,0 @@ const ast = fromModel(model, options?.convert); |
{ | ||
"name": "ts-graphviz", | ||
"version": "1.5.5-dev.02afc3340", | ||
"version": "1.5.5-dev.27273c787", | ||
"author": "kamiazya <yuki@kamiazya.tech>", | ||
@@ -89,3 +89,3 @@ "description": "Graphviz library for TypeScript.", | ||
"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:node": "tsc -p tsconfig.build.json --declaration && tsc -p tsconfig.build.json --removeComments && rollup -c", | ||
"build": "yarn build:node && yarn build:deno", | ||
@@ -92,0 +92,0 @@ "postbuild": "prettier --write ./lib/**/*.{js,cjs,d.ts}", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
580768
18986