ts-graphviz 1.5.5-dev.bdbba8a60 → 1.5.6-dev.29eb2444f

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.
@@ -1,28 +1,21 @@
1
- /** @hidden */
2
1
  function isForwardRefNode(object) {
3
2
  return typeof object === 'object' && object !== null && typeof object.id === 'string';
4
3
  }
5
- /** @hidden */
6
4
  function isNodeModel(object) {
7
5
  return typeof object === 'object' && object !== null && object.$$type === 'Node' && typeof object.id === 'string';
8
6
  }
9
- /** @hidden */
10
7
  function isNodeRef(node) {
11
8
  return isNodeModel(node) || isForwardRefNode(node);
12
9
  }
13
- /** @hidden */
14
10
  function isNodeRefLike(node) {
15
11
  return typeof node === 'string' || isNodeRef(node);
16
12
  }
17
- /** @hidden */
18
13
  function isNodeRefGroupLike(target) {
19
14
  return Array.isArray(target) && target.every(isNodeRefLike);
20
15
  }
21
- /** @hidden */
22
16
  function isCompass(c) {
23
17
  return ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'c'].includes(c);
24
18
  }
25
- /** @hidden */
26
19
  function toNodeRef(target) {
27
20
  if (isNodeRef(target)) {
28
21
  return target;
@@ -33,7 +26,6 @@ function toNodeRef(target) {
33
26
  }
34
27
  return { id, port };
35
28
  }
36
- /** @hidden */
37
29
  function toNodeRefGroup(targets) {
38
30
  if (targets.length < 2 && (isNodeRefLike(targets[0]) && isNodeRefLike(targets[1])) === false) {
39
31
  throw Error('EdgeTargets must have at least 2 elements.');
@@ -41,22 +33,13 @@ function toNodeRefGroup(targets) {
41
33
  return targets.map((t) => toNodeRef(t));
42
34
  }
43
35
 
44
- /**
45
- * @group Models Context
46
- * @alpha
47
- */
48
36
  const RootModelsContext = Object.seal({
49
- // NOTE: RootModelsContext is also initialized after the model class is declared in the 'core/index.js' module.
50
37
  Graph: null,
51
38
  Digraph: null,
52
39
  Subgraph: null,
53
40
  Node: null,
54
41
  Edge: null,
55
42
  });
56
- /**
57
- * @group Models Context
58
- * @alpha
59
- */
60
43
  function createModelsContext(models) {
61
44
  return Object.assign(Object.seal(Object.assign({}, RootModelsContext)), models);
62
45
  }
@@ -3,25 +3,13 @@
3
3
  var index_js = require('../common/index.cjs');
4
4
  var index_js$1 = require('../ast/index.cjs');
5
5
 
6
- /**
7
- * @group Attribute
8
- */
9
6
  const attribute = new Proxy(Object.freeze({}), {
10
7
  get: (_, key) => key,
11
8
  });
12
9
 
13
- /**
14
- * Base class for DOT objects.
15
- * @group Models
16
- */
17
10
  class DotObject {}
18
11
 
19
- /**
20
- * Base class for DOT objects with attributes.
21
- * @group Models
22
- */
23
12
  class AttributesBase extends DotObject {
24
- /** @hidden */
25
13
  #attrs = new Map();
26
14
  constructor(attributes) {
27
15
  super();
@@ -57,10 +45,6 @@ class AttributesBase extends DotObject {
57
45
  }
58
46
  }
59
47
 
60
- /**
61
- * A set of attribute values for any object.
62
- * @group Models
63
- */
64
48
  class AttributeList extends AttributesBase {
65
49
  $$kind;
66
50
  get $$type() {
@@ -73,12 +57,7 @@ class AttributeList extends AttributesBase {
73
57
  }
74
58
  }
75
59
 
76
- /**
77
- * Base class for Graph objects.
78
- * @group Models
79
- */
80
60
  class GraphBase extends AttributesBase {
81
- /** @hidden */
82
61
  #models = index_js.RootModelsContext;
83
62
  id;
84
63
  comment;
@@ -96,7 +75,6 @@ class GraphBase extends AttributesBase {
96
75
  get subgraphs() {
97
76
  return Array.from(this.#objects.subgraphs.values());
98
77
  }
99
- /** @hidden */
100
78
  #objects = {
101
79
  nodes: new Map(),
102
80
  edges: new Set(),
@@ -208,10 +186,6 @@ class GraphBase extends AttributesBase {
208
186
  }
209
187
  }
210
188
 
211
- /**
212
- * Base class representing a root graph(digraph, graph).
213
- * @group Models
214
- */
215
189
  class RootGraph extends GraphBase {
216
190
  get $$type() {
217
191
  return 'Graph';
@@ -229,30 +203,18 @@ class RootGraph extends GraphBase {
229
203
  }
230
204
  }
231
205
 
232
- /**
233
- * DOT object class representing a digraph.
234
- * @group Models
235
- */
236
206
  class Digraph extends RootGraph {
237
207
  get directed() {
238
208
  return true;
239
209
  }
240
210
  }
241
211
 
242
- /**
243
- * DOT object class representing a graph.
244
- * @group Models
245
- */
246
212
  class Graph extends RootGraph {
247
213
  get directed() {
248
214
  return false;
249
215
  }
250
216
  }
251
217
 
252
- /**
253
- * DOT object class representing a subgraph.
254
- * @group Models
255
- */
256
218
  class Subgraph extends GraphBase {
257
219
  get $$type() {
258
220
  return 'Subgraph';
@@ -274,18 +236,10 @@ class Subgraph extends GraphBase {
274
236
  }
275
237
  }
276
238
 
277
- /**
278
- * A set of attribute values for any object.
279
- * @group Models
280
- */
281
239
  class AttributesGroup extends AttributesBase {
282
240
  comment;
283
241
  }
284
242
 
285
- /**
286
- * DOT object class representing a node.
287
- * @group Models
288
- */
289
243
  class Node extends DotObject {
290
244
  id;
291
245
  get $$type() {
@@ -306,10 +260,6 @@ class Node extends DotObject {
306
260
  }
307
261
  }
308
262
 
309
- /**
310
- * DOT object class representing a edge.
311
- * @group Models
312
- */
313
263
  class Edge extends DotObject {
314
264
  targets;
315
265
  get $$type() {
@@ -335,7 +285,6 @@ Object.assign(index_js.RootModelsContext, {
335
285
  Edge,
336
286
  });
337
287
 
338
- /** @hidden */
339
288
  function ModelFactoryBuilder(directed, strictMode) {
340
289
  return (...args) => {
341
290
  const G = directed ? this.Digraph : this.Graph;
@@ -358,24 +307,9 @@ function createModelFactories(strict, context = index_js.RootModelsContext) {
358
307
  }
359
308
 
360
309
  const noStrict = createModelFactories(false);
361
- /**
362
- * API for creating directional graph objects.
363
- * @group Model Factory
364
- */
365
310
  const digraph = noStrict.digraph;
366
- /**
367
- * API for creating omnidirectional graph objects.
368
- * @group Model Factory
369
- */
370
311
  const graph = noStrict.graph;
371
- /**
372
- * Provides a strict mode API.
373
- * @group Model Factory
374
- */
375
312
  const strict = createModelFactories(true);
376
- /**
377
- * @group Model Factory
378
- */
379
313
  function withContext(models) {
380
314
  const context = index_js.createModelsContext(models);
381
315
  return Object.freeze({
@@ -384,15 +318,6 @@ function withContext(models) {
384
318
  });
385
319
  }
386
320
 
387
- /**
388
- * Convert Model to DOT string.
389
- *
390
- * @group Convert Model to DOT
391
- *
392
- * @param model Dot Object Model, like {@link Digraph}, {@link Graph}, {@link Subgraph}, {@link Node}, and {@link Edge}
393
- * @param options
394
- * @returns DOT string
395
- */
396
321
  function toDot(model, options) {
397
322
  const ast = index_js$1.fromModel(model, options?.convert);
398
323
  return index_js$1.stringify(ast, options?.print);