ts-graphviz 1.2.0 → 1.2.2-1

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/lib/ast/index.cjs CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var utils = require('#lib/utils');
6
- var common = require('#lib/common');
5
+ var index_js = require('../utils/index.js');
6
+ var index_js$1 = require('../common/index.js');
7
7
 
8
8
  /**
9
9
  * @group Create AST
@@ -49,7 +49,7 @@ function leftPadWith(left) {
49
49
  const escape = (value) => value.replace(/\r/g, '\\r').replace(/\n/g, '\\n').replace(/"/g, '\\"');
50
50
  const splitByLine = (value) => value.split(EOL);
51
51
  const indent = (style, size, eol) =>
52
- utils.pipe(splitByLine, utils.map(leftPadWith(style === 'space' ? ' '.repeat(size) : '\n')), joinBy(eol));
52
+ index_js.pipe(splitByLine, index_js.map(leftPadWith(style === 'space' ? ' '.repeat(size) : '\n')), joinBy(eol));
53
53
  const endOfLine = (eol) => {
54
54
  switch (eol) {
55
55
  case 'crlf':
@@ -68,8 +68,8 @@ const AttributeListPrintPlugin = {
68
68
  return `${ast.kind.toLocaleLowerCase()} [];`;
69
69
  }
70
70
  const eol = endOfLine(context.endOfLine);
71
- return utils.pipe(
72
- utils.map(context.print),
71
+ return index_js.pipe(
72
+ index_js.map(context.print),
73
73
  joinBy(eol),
74
74
  indent(context.indentStyle, context.indentSize, eol),
75
75
  wrapByPair(`${ast.kind.toLocaleLowerCase()} [${eol}`, `${eol}];`),
@@ -94,17 +94,17 @@ const CommentPrintPlugin = {
94
94
  const eol = endOfLine(context.endOfLine);
95
95
  switch (ast.kind) {
96
96
  case 'Block':
97
- return utils.pipe(
97
+ return index_js.pipe(
98
98
  splitByLine,
99
- utils.map(leftPadWith(' * ')),
99
+ index_js.map(leftPadWith(' * ')),
100
100
  joinBy(eol),
101
101
  wrapByPair(`/**${eol}`, `${eol} */`),
102
102
  )(ast.value);
103
103
  case 'Macro':
104
- return utils.pipe(splitByLine, utils.map(leftPadWith('# ')), joinBy(eol))(ast.value);
104
+ return index_js.pipe(splitByLine, index_js.map(leftPadWith('# ')), joinBy(eol))(ast.value);
105
105
  case 'Slash':
106
106
  default:
107
- return utils.pipe(splitByLine, utils.map(leftPadWith('// ')), joinBy(eol))(ast.value);
107
+ return index_js.pipe(splitByLine, index_js.map(leftPadWith('// ')), joinBy(eol))(ast.value);
108
108
  }
109
109
  },
110
110
  };
@@ -123,13 +123,13 @@ const EdgePrintPlugin = {
123
123
  return ast.type === 'Edge';
124
124
  },
125
125
  print(context, ast) {
126
- const targets = utils.pipe(utils.map(context.print), joinBy(context.directed ? ' -> ' : ' -- '))(ast.targets);
126
+ const targets = index_js.pipe(index_js.map(context.print), joinBy(context.directed ? ' -> ' : ' -- '))(ast.targets);
127
127
  if (ast.children.length === 0) {
128
128
  return `${targets};`;
129
129
  }
130
130
  const eol = endOfLine(context.endOfLine);
131
- const contents = utils.pipe(
132
- utils.map(context.print),
131
+ const contents = index_js.pipe(
132
+ index_js.map(context.print),
133
133
  joinBy(eol),
134
134
  indent(context.indentStyle, context.indentSize, eol),
135
135
  wrapByPair(`[${eol}`, `${eol}];`),
@@ -156,8 +156,8 @@ const GraphPrintPlugin = {
156
156
  return `${parts.join(' ')} {}`;
157
157
  }
158
158
  const eol = endOfLine(context.endOfLine);
159
- const contents = utils.pipe(
160
- utils.map(context.print),
159
+ const contents = index_js.pipe(
160
+ index_js.map(context.print),
161
161
  joinBy(eol),
162
162
  indent(context.indentStyle, context.indentSize, eol),
163
163
  wrapByPair(`{${eol}`, `${eol}}`),
@@ -166,7 +166,7 @@ const GraphPrintPlugin = {
166
166
  },
167
167
  };
168
168
 
169
- const quoteLiteralValue = utils.pipe(escape, wrapWith('"'));
169
+ const quoteLiteralValue = index_js.pipe(escape, wrapWith('"'));
170
170
  const quoteHTMLLikeLiteralValue = wrapByPair('<', '>');
171
171
  const LiteralPrintPlugin = {
172
172
  match(ast) {
@@ -195,8 +195,8 @@ const NodePrintPlugin = {
195
195
  return `${id};`;
196
196
  }
197
197
  const eol = endOfLine(context.endOfLine);
198
- const contents = utils.pipe(
199
- utils.map(context.print),
198
+ const contents = index_js.pipe(
199
+ index_js.map(context.print),
200
200
  joinBy(eol),
201
201
  indent(context.indentStyle, context.indentSize, eol),
202
202
  wrapByPair(`[${eol}`, `${eol}];`),
@@ -210,7 +210,7 @@ const NodeRefGroupPrintPlugin = {
210
210
  return ast.type === 'NodeRefGroup';
211
211
  },
212
212
  print(context, ast) {
213
- return utils.pipe(utils.map(context.print), joinBy(' '), wrapByPair('{', '}'))(ast.children);
213
+ return index_js.pipe(index_js.map(context.print), joinBy(' '), wrapByPair('{', '}'))(ast.children);
214
214
  },
215
215
  };
216
216
 
@@ -243,8 +243,8 @@ const SubgraphPrintPlugin = {
243
243
  return `${parts.join(' ')} {}`;
244
244
  }
245
245
  const eol = endOfLine(context.endOfLine);
246
- const contents = utils.pipe(
247
- utils.map(context.print),
246
+ const contents = index_js.pipe(
247
+ index_js.map(context.print),
248
248
  joinBy(eol),
249
249
  indent(context.indentStyle, context.indentSize, eol),
250
250
  wrapByPair(`{${eol}`, `${eol}}`),
@@ -5366,7 +5366,7 @@ const EdgePlugin$1 = {
5366
5366
  'Edge',
5367
5367
  {
5368
5368
  targets: model.targets.map((target) => {
5369
- if (common.isNodeModel(target)) {
5369
+ if (index_js$1.isNodeModel(target)) {
5370
5370
  return createElement(
5371
5371
  'NodeRef',
5372
5372
  {
@@ -5381,7 +5381,7 @@ const EdgePlugin$1 = {
5381
5381
  },
5382
5382
  [],
5383
5383
  );
5384
- } else if (common.isForwardRefNode(target)) {
5384
+ } else if (index_js$1.isForwardRefNode(target)) {
5385
5385
  return createElement(
5386
5386
  'NodeRef',
5387
5387
  {
@@ -5733,7 +5733,7 @@ class ToModelConverter {
5733
5733
  convert(ast) {
5734
5734
  const plugins = [...this.plugins];
5735
5735
  const context = {
5736
- models: common.createModelsContext(this.options.models ?? {}),
5736
+ models: index_js$1.createModelsContext(this.options.models ?? {}),
5737
5737
  convert(m) {
5738
5738
  for (const plugin of plugins) {
5739
5739
  if (plugin.match(m)) {
@@ -8,7 +8,7 @@ import {
8
8
  NodeModel,
9
9
  SubgraphModel,
10
10
  ModelsContext,
11
- } from '#lib/common';
11
+ } from '../common/index.js';
12
12
 
13
13
  /**
14
14
  * @group AST
package/lib/ast/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { pipe, map } from '#lib/utils';
2
- import { isNodeModel, isForwardRefNode, createModelsContext } from '#lib/common';
1
+ import { pipe, map } from '../utils/index.js';
2
+ import { isNodeModel, isForwardRefNode, createModelsContext } from '../common/index.js';
3
3
 
4
4
  /**
5
5
  * @group Create AST
@@ -2,8 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- require('#lib/core');
6
-
7
5
  /** @hidden */
8
6
  function isForwardRefNode(object) {
9
7
  return typeof object === 'object' && object !== null && typeof object.id === 'string';
@@ -52,7 +50,7 @@ function toNodeRefGroup(targets) {
52
50
  * @alpha
53
51
  */
54
52
  const RootModelsContext = Object.seal({
55
- // NOTE: RootModelsContext is also initialized after the model class is declared in the '#lib/core' module.
53
+ // NOTE: RootModelsContext is also initialized after the model class is declared in the 'core/index.js' module.
56
54
  Graph: null,
57
55
  Digraph: null,
58
56
  Subgraph: null,
@@ -1,5 +1,3 @@
1
- import '#lib/core';
2
-
3
1
  /** @hidden */
4
2
  function isForwardRefNode(object) {
5
3
  return typeof object === 'object' && object !== null && typeof object.id === 'string';
@@ -48,7 +46,7 @@ function toNodeRefGroup(targets) {
48
46
  * @alpha
49
47
  */
50
48
  const RootModelsContext = Object.seal({
51
- // NOTE: RootModelsContext is also initialized after the model class is declared in the '#lib/core' module.
49
+ // NOTE: RootModelsContext is also initialized after the model class is declared in the 'core/index.js' module.
52
50
  Graph: null,
53
51
  Digraph: null,
54
52
  Subgraph: null,
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var common = require('#lib/common');
6
- var ast = require('#lib/ast');
5
+ var index_js = require('../common/index.js');
6
+ var index_js$1 = require('../ast/index.js');
7
7
 
8
8
  /**
9
9
  * @group Attribute
@@ -81,7 +81,7 @@ class AttributeList extends AttributesBase {
81
81
  */
82
82
  class GraphBase extends AttributesBase {
83
83
  /** @hidden */
84
- #models = common.RootModelsContext;
84
+ #models = index_js.RootModelsContext;
85
85
  id;
86
86
  comment;
87
87
  attributes = Object.freeze({
@@ -105,7 +105,7 @@ class GraphBase extends AttributesBase {
105
105
  subgraphs: new Set(),
106
106
  };
107
107
  with(models) {
108
- this.#models = common.createModelsContext(models);
108
+ this.#models = index_js.createModelsContext(models);
109
109
  }
110
110
  addNode(node) {
111
111
  this.#objects.nodes.set(node.id, node);
@@ -152,7 +152,9 @@ class GraphBase extends AttributesBase {
152
152
  return this.#objects.nodes.get(id);
153
153
  }
154
154
  createEdge(targets, attributes) {
155
- const ts = targets.map((t) => (common.isNodeRefGroupLike(t) ? common.toNodeRefGroup(t) : common.toNodeRef(t)));
155
+ const ts = targets.map((t) =>
156
+ index_js.isNodeRefGroupLike(t) ? index_js.toNodeRefGroup(t) : index_js.toNodeRef(t),
157
+ );
156
158
  const edge = new this.#models.Edge(ts, attributes);
157
159
  this.addEdge(edge);
158
160
  return edge;
@@ -320,14 +322,14 @@ class Edge extends DotObject {
320
322
  constructor(targets, attributes) {
321
323
  super();
322
324
  this.targets = targets;
323
- if (targets.length < 2 && (common.isNodeRefLike(targets[0]) && common.isNodeRefLike(targets[1])) === false) {
325
+ if (targets.length < 2 && (index_js.isNodeRefLike(targets[0]) && index_js.isNodeRefLike(targets[1])) === false) {
324
326
  throw Error('The element of Edge target is missing or not satisfied as Edge target.');
325
327
  }
326
328
  this.attributes = new AttributesGroup(attributes);
327
329
  }
328
330
  }
329
331
 
330
- Object.assign(common.RootModelsContext, {
332
+ Object.assign(index_js.RootModelsContext, {
331
333
  Graph,
332
334
  Digraph,
333
335
  Subgraph,
@@ -350,7 +352,7 @@ function ModelFactoryBuilder(directed, strictMode) {
350
352
  return g;
351
353
  };
352
354
  }
353
- function createModelFactories(strict, context = common.RootModelsContext) {
355
+ function createModelFactories(strict, context = index_js.RootModelsContext) {
354
356
  return Object.freeze({
355
357
  digraph: ModelFactoryBuilder.call(context, true, strict),
356
358
  graph: ModelFactoryBuilder.call(context, false, strict),
@@ -377,7 +379,7 @@ const strict = createModelFactories(true);
377
379
  * @group Model Factory
378
380
  */
379
381
  function withContext(models) {
380
- const context = common.createModelsContext(models);
382
+ const context = index_js.createModelsContext(models);
381
383
  return Object.freeze({
382
384
  ...createModelFactories(false, context),
383
385
  strict: createModelFactories(true, context),
@@ -394,24 +396,24 @@ function withContext(models) {
394
396
  * @returns DOT string
395
397
  */
396
398
  function toDot(model, options) {
397
- const ast$1 = ast.fromModel(model, options?.convert);
398
- return ast.stringify(ast$1, options?.print);
399
+ const ast = index_js$1.fromModel(model, options?.convert);
400
+ return index_js$1.stringify(ast, options?.print);
399
401
  }
400
402
 
401
403
  function fromDot(dot, options) {
402
- const ast$1 = ast.parse(dot, options?.parse);
404
+ const ast = index_js$1.parse(dot, options?.parse);
403
405
  if (
404
- Array.isArray(ast$1) ||
405
- ast$1.type === 'Attribute' ||
406
- ast$1.type === 'AttributeList' ||
407
- ast$1.type === 'Comment' ||
408
- ast$1.type === 'NodeRef' ||
409
- ast$1.type === 'NodeRefGroup' ||
410
- ast$1.type === 'Literal'
406
+ Array.isArray(ast) ||
407
+ ast.type === 'Attribute' ||
408
+ ast.type === 'AttributeList' ||
409
+ ast.type === 'Comment' ||
410
+ ast.type === 'NodeRef' ||
411
+ ast.type === 'NodeRefGroup' ||
412
+ ast.type === 'Literal'
411
413
  ) {
412
414
  throw new Error();
413
415
  }
414
- return ast.toModel(ast$1, options?.convert);
416
+ return index_js$1.toModel(ast, options?.convert);
415
417
  }
416
418
 
417
419
  exports.AttributeList = AttributeList;
@@ -28,8 +28,8 @@ import {
28
28
  SubgraphAttributeKey,
29
29
  ClusterSubgraphAttributeKey,
30
30
  DotObjectModel,
31
- } from '#lib/common';
32
- import { ConvertFromModelOptions, PrintOptions, ParseOptions, ConvertToModelOptions } from '#lib/ast';
31
+ } from '../common/index.js';
32
+ import { ConvertFromModelOptions, PrintOptions, ParseOptions, ConvertToModelOptions } from '../ast/index.js';
33
33
 
34
34
  /**
35
35
  * @group Attribute
package/lib/core/index.js CHANGED
@@ -5,8 +5,8 @@ import {
5
5
  toNodeRefGroup,
6
6
  toNodeRef,
7
7
  isNodeRefLike,
8
- } from '#lib/common';
9
- import { fromModel, stringify, parse, toModel } from '#lib/ast';
8
+ } from '../common/index.js';
9
+ import { fromModel, stringify, parse, toModel } from '../ast/index.js';
10
10
 
11
11
  /**
12
12
  * @group Attribute
package/lib/index.cjs CHANGED
@@ -2,24 +2,24 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var common = require('#lib/common');
6
- var core = require('#lib/core');
5
+ var index_js = require('./common/index.js');
6
+ var index_js$1 = require('./core/index.js');
7
7
 
8
- Object.keys(common).forEach(function (k) {
8
+ Object.keys(index_js).forEach(function (k) {
9
9
  if (k !== 'default' && !exports.hasOwnProperty(k))
10
10
  Object.defineProperty(exports, k, {
11
11
  enumerable: true,
12
12
  get: function () {
13
- return common[k];
13
+ return index_js[k];
14
14
  },
15
15
  });
16
16
  });
17
- Object.keys(core).forEach(function (k) {
17
+ Object.keys(index_js$1).forEach(function (k) {
18
18
  if (k !== 'default' && !exports.hasOwnProperty(k))
19
19
  Object.defineProperty(exports, k, {
20
20
  enumerable: true,
21
21
  get: function () {
22
- return core[k];
22
+ return index_js$1[k];
23
23
  },
24
24
  });
25
25
  });
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from '#lib/common';
2
- export * from '#lib/core';
1
+ export * from './common/index.js';
2
+ export * from './core/index.js';
package/lib/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from '#lib/common';
2
- export * from '#lib/core';
1
+ export * from './common/index.js';
2
+ export * from './core/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-graphviz",
3
- "version": "1.2.0",
3
+ "version": "1.2.2-1",
4
4
  "author": "kamiazya <yuki@kamiazya.tech>",
5
5
  "description": "Graphviz library for TypeScript.",
6
6
  "homepage": "https://ts-graphviz.github.io/ts-graphviz/",
@@ -1,4 +1,4 @@
1
- import { pipe } from '#lib/utils';
1
+ import { pipe } from '../../src/utils/index.js';
2
2
  import { wrap } from 'jest-snapshot-serializer-raw';
3
3
  import { toDot as _toDot } from 'ts-graphviz';
4
4