ts-graphviz 1.2.3-dev.e6969d40a → 1.2.3

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 index_js = require('../utils/index.js');
6
- var index_js$1 = require('../common/index.js');
5
+ var index_js = require('../utils/index.cjs');
6
+ var index_js$1 = require('../common/index.cjs');
7
7
 
8
8
  /**
9
9
  * @group Create AST
@@ -5416,6 +5416,63 @@ const EdgePlugin$1 = {
5416
5416
  },
5417
5417
  [],
5418
5418
  );
5419
+ } else {
5420
+ return createElement(
5421
+ 'NodeRefGroup',
5422
+ {},
5423
+ target.map((n) => {
5424
+ if (index_js$1.isNodeModel(n)) {
5425
+ return createElement(
5426
+ 'NodeRef',
5427
+ {
5428
+ id: createElement(
5429
+ 'Literal',
5430
+ {
5431
+ value: n.id,
5432
+ quoted: true,
5433
+ },
5434
+ [],
5435
+ ),
5436
+ },
5437
+ [],
5438
+ );
5439
+ }
5440
+ return createElement(
5441
+ 'NodeRef',
5442
+ {
5443
+ id: createElement(
5444
+ 'Literal',
5445
+ {
5446
+ value: n.id,
5447
+ quoted: true,
5448
+ },
5449
+ [],
5450
+ ),
5451
+ port: n.port
5452
+ ? createElement(
5453
+ 'Literal',
5454
+ {
5455
+ value: n.port,
5456
+ quoted: true,
5457
+ },
5458
+ [],
5459
+ )
5460
+ : undefined,
5461
+ compass: n.compass
5462
+ ? createElement(
5463
+ 'Literal',
5464
+ {
5465
+ value: n.compass,
5466
+ quoted: true,
5467
+ },
5468
+ [],
5469
+ )
5470
+ : undefined,
5471
+ },
5472
+ [],
5473
+ );
5474
+ }),
5475
+ );
5419
5476
  }
5420
5477
  }),
5421
5478
  },
package/lib/ast/index.js CHANGED
@@ -5407,6 +5407,63 @@ const EdgePlugin$1 = {
5407
5407
  },
5408
5408
  [],
5409
5409
  );
5410
+ } else {
5411
+ return createElement(
5412
+ 'NodeRefGroup',
5413
+ {},
5414
+ target.map((n) => {
5415
+ if (isNodeModel(n)) {
5416
+ return createElement(
5417
+ 'NodeRef',
5418
+ {
5419
+ id: createElement(
5420
+ 'Literal',
5421
+ {
5422
+ value: n.id,
5423
+ quoted: true,
5424
+ },
5425
+ [],
5426
+ ),
5427
+ },
5428
+ [],
5429
+ );
5430
+ }
5431
+ return createElement(
5432
+ 'NodeRef',
5433
+ {
5434
+ id: createElement(
5435
+ 'Literal',
5436
+ {
5437
+ value: n.id,
5438
+ quoted: true,
5439
+ },
5440
+ [],
5441
+ ),
5442
+ port: n.port
5443
+ ? createElement(
5444
+ 'Literal',
5445
+ {
5446
+ value: n.port,
5447
+ quoted: true,
5448
+ },
5449
+ [],
5450
+ )
5451
+ : undefined,
5452
+ compass: n.compass
5453
+ ? createElement(
5454
+ 'Literal',
5455
+ {
5456
+ value: n.compass,
5457
+ quoted: true,
5458
+ },
5459
+ [],
5460
+ )
5461
+ : undefined,
5462
+ },
5463
+ [],
5464
+ );
5465
+ }),
5466
+ );
5410
5467
  }
5411
5468
  }),
5412
5469
  },
@@ -50,7 +50,7 @@ function toNodeRefGroup(targets) {
50
50
  * @alpha
51
51
  */
52
52
  const RootModelsContext = Object.seal({
53
- // NOTE: RootModelsContext is also initialized after the model class is declared in the 'core/index.js' module.
53
+ // NOTE: RootModelsContext is also initialized after the model class is declared in the 'core/index.cjs' module.
54
54
  Graph: null,
55
55
  Digraph: null,
56
56
  Subgraph: null,
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index_js = require('../common/index.js');
6
- var index_js$1 = require('../ast/index.js');
5
+ var index_js = require('../common/index.cjs');
6
+ var index_js$1 = require('../ast/index.cjs');
7
7
 
8
8
  /**
9
9
  * @group Attribute
package/lib/index.cjs CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index_js = require('./common/index.js');
6
- var index_js$1 = require('./core/index.js');
5
+ var index_js = require('./common/index.cjs');
6
+ var index_js$1 = require('./core/index.cjs');
7
7
 
8
8
  Object.keys(index_js).forEach(function (k) {
9
9
  if (k !== 'default' && !exports.hasOwnProperty(k))
package/package.json CHANGED
@@ -1,86 +1,87 @@
1
1
  {
2
- "name": "ts-graphviz",
3
- "version": "1.2.3-dev.e6969d40a",
4
- "author": "kamiazya <yuki@kamiazya.tech>",
5
- "description": "Graphviz library for TypeScript.",
6
- "homepage": "https://ts-graphviz.github.io/ts-graphviz/",
7
- "type": "module",
8
- "repository": {
9
- "type": "git",
10
- "url": "https://github.com/ts-graphviz/ts-graphviz.git"
2
+ "name": "ts-graphviz",
3
+ "version": "1.2.3",
4
+ "author": "kamiazya <yuki@kamiazya.tech>",
5
+ "description": "Graphviz library for TypeScript.",
6
+ "homepage": "https://ts-graphviz.github.io/ts-graphviz/",
7
+ "type": "module",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/ts-graphviz/ts-graphviz.git"
11
+ },
12
+ "keywords": [
13
+ "graphviz",
14
+ "dot"
15
+ ],
16
+ "bugs": {
17
+ "url": "https://github.com/ts-graphviz/ts-graphviz/issues"
18
+ },
19
+ "funding": {
20
+ "type": "github",
21
+ "url": "https://github.com/sponsors/kamiazya"
22
+ },
23
+ "main": "./lib/index.cjs",
24
+ "module": "./lib/index.js",
25
+ "types": "lib/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "import": "./lib/index.js",
29
+ "require": "./lib/index.cjs",
30
+ "types": "./lib/index.d.ts"
11
31
  },
12
- "keywords": [
13
- "graphviz",
14
- "dot"
15
- ],
16
- "bugs": {
17
- "url": "https://github.com/ts-graphviz/ts-graphviz/issues"
18
- },
19
- "funding": {
20
- "type": "github",
21
- "url": "https://github.com/sponsors/kamiazya"
22
- },
23
- "main": "./lib/index.cjs",
24
- "module": "./lib/index.js",
25
- "types": "lib/index.d.ts",
26
- "exports": {
27
- ".": {
28
- "import": "./lib/index.js",
29
- "require": "./lib/index.cjs",
30
- "types": "./lib/index.d.ts"
31
- },
32
- "./ast": {
33
- "import": "./lib/ast/index.js",
34
- "require": "./lib/ast/index.cjs",
35
- "types": "./lib/ast/index.d.ts"
36
- }
37
- },
38
- "imports": {
39
- "#lib/*": {
40
- "import": "./lib/*/index.js",
41
- "require": "./lib/*/index.cjs",
42
- "types": "./lib/*/index.d.ts"
43
- }
44
- },
45
- "license": "MIT",
46
- "engines": {
47
- "node": ">=14.16"
48
- },
49
- "scripts": {
50
- "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",
51
- "prebuild": "yarn build:peggy",
52
- "build": "tsc -p tsconfig.build.json && rollup -c",
53
- "postbuild": "prettier --write ./lib/**/index.{js,cjs,d.ts}",
54
- "pretest": "yarn build:peggy",
55
- "test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest",
56
- "format": "eslint --ext ts src --fix && prettier --write './**/*.{ts,js,json,yaml}' '!lib'",
57
- "lint": "eslint --ext ts src",
58
- "predoc": "yarn build:peggy",
59
- "doc": "typedoc"
60
- },
61
- "devDependencies": {
62
- "@types/jest": "^28.1.6",
63
- "@types/jest-specific-snapshot": "^0.5.6",
64
- "@typescript-eslint/eslint-plugin": "^5.33.0",
65
- "@typescript-eslint/parser": "^5.33.0",
66
- "eslint": "^8.22.0",
67
- "eslint-config-prettier": "^8.5.0",
68
- "eslint-plugin-import": "^2.26.0",
69
- "eslint-plugin-jest": "^26.8.2",
70
- "eslint-plugin-prettier": "^4.2.1",
71
- "jest": "^28.1.3",
72
- "jest-snapshot-serializer-raw": "^1.2.0",
73
- "jest-specific-snapshot": "^5.0.0",
74
- "peggy": "^2.0.1",
75
- "prettier": "^2.7.1",
76
- "prettier-plugin-pegjs": "^0.5.0",
77
- "rollup": "^2.77.3",
78
- "rollup-plugin-delete": "^2.0.0",
79
- "rollup-plugin-dts": "^4.2.2",
80
- "svgo": "^2.8.0",
81
- "ts-jest": "^28.0.7",
82
- "ts-pegjs": "^2.1.0",
83
- "typedoc": "^0.23.15",
84
- "typescript": "^4.7.4"
32
+ "./ast": {
33
+ "import": "./lib/ast/index.js",
34
+ "require": "./lib/ast/index.cjs",
35
+ "types": "./lib/ast/index.d.ts"
36
+ }
37
+ },
38
+ "imports": {
39
+ "#lib/*": {
40
+ "import": "./lib/*/index.js",
41
+ "require": "./lib/*/index.cjs",
42
+ "types": "./lib/*/index.d.ts"
85
43
  }
86
- }
44
+ },
45
+ "license": "MIT",
46
+ "engines": {
47
+ "node": ">=14.16"
48
+ },
49
+ "scripts": {
50
+ "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",
51
+ "prebuild": "yarn build:peggy",
52
+ "build": "tsc -p tsconfig.build.json && rollup -c",
53
+ "postbuild": "prettier --write ./lib/**/index.{js,cjs,d.ts}",
54
+ "pretest": "yarn build:peggy",
55
+ "test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest",
56
+ "format": "eslint --ext ts src --fix && prettier --write './**/*.{ts,js,json,yaml}' '!lib'",
57
+ "lint": "eslint --ext ts src",
58
+ "predoc": "yarn build:peggy",
59
+ "doc": "typedoc"
60
+ },
61
+ "devDependencies": {
62
+ "@rollup/plugin-replace": "^4.0.0",
63
+ "@types/jest": "^28.1.6",
64
+ "@types/jest-specific-snapshot": "^0.5.6",
65
+ "@typescript-eslint/eslint-plugin": "^5.33.0",
66
+ "@typescript-eslint/parser": "^5.33.0",
67
+ "eslint": "^8.22.0",
68
+ "eslint-config-prettier": "^8.5.0",
69
+ "eslint-plugin-import": "^2.26.0",
70
+ "eslint-plugin-jest": "^26.8.2",
71
+ "eslint-plugin-prettier": "^4.2.1",
72
+ "jest": "^28.1.3",
73
+ "jest-snapshot-serializer-raw": "^1.2.0",
74
+ "jest-specific-snapshot": "^5.0.0",
75
+ "peggy": "^2.0.1",
76
+ "prettier": "^2.7.1",
77
+ "prettier-plugin-pegjs": "^0.5.0",
78
+ "rollup": "^2.77.3",
79
+ "rollup-plugin-delete": "^2.0.0",
80
+ "rollup-plugin-dts": "^4.2.2",
81
+ "svgo": "^2.8.0",
82
+ "ts-jest": "^28.0.7",
83
+ "ts-pegjs": "^2.1.0",
84
+ "typedoc": "^0.23.15",
85
+ "typescript": "^4.7.4"
86
+ }
87
+ }
@@ -0,0 +1,96 @@
1
+ import { digraph } from 'ts-graphviz';
2
+ import { fromModel } from 'ts-graphviz/ast';
3
+
4
+ import { toDot } from '#test/utils';
5
+
6
+ test('edge group', () => {
7
+ expect(
8
+ fromModel(
9
+ digraph((g) => {
10
+ g.edge(['a', ['b', 'c']]);
11
+ }),
12
+ ),
13
+ ).toMatchInlineSnapshot(`
14
+ Object {
15
+ "children": Array [
16
+ Object {
17
+ "children": Array [
18
+ Object {
19
+ "children": Array [],
20
+ "location": null,
21
+ "targets": Array [
22
+ Object {
23
+ "children": Array [],
24
+ "compass": undefined,
25
+ "id": Object {
26
+ "children": Array [],
27
+ "location": null,
28
+ "quoted": true,
29
+ "type": "Literal",
30
+ "value": "a",
31
+ },
32
+ "location": null,
33
+ "port": undefined,
34
+ "type": "NodeRef",
35
+ },
36
+ Object {
37
+ "children": Array [
38
+ Object {
39
+ "children": Array [],
40
+ "compass": undefined,
41
+ "id": Object {
42
+ "children": Array [],
43
+ "location": null,
44
+ "quoted": true,
45
+ "type": "Literal",
46
+ "value": "b",
47
+ },
48
+ "location": null,
49
+ "port": undefined,
50
+ "type": "NodeRef",
51
+ },
52
+ Object {
53
+ "children": Array [],
54
+ "compass": undefined,
55
+ "id": Object {
56
+ "children": Array [],
57
+ "location": null,
58
+ "quoted": true,
59
+ "type": "Literal",
60
+ "value": "c",
61
+ },
62
+ "location": null,
63
+ "port": undefined,
64
+ "type": "NodeRef",
65
+ },
66
+ ],
67
+ "location": null,
68
+ "type": "NodeRefGroup",
69
+ },
70
+ ],
71
+ "type": "Edge",
72
+ },
73
+ ],
74
+ "directed": true,
75
+ "id": undefined,
76
+ "location": null,
77
+ "strict": false,
78
+ "type": "Graph",
79
+ },
80
+ ],
81
+ "location": null,
82
+ "type": "Dot",
83
+ }
84
+ `);
85
+ expect(
86
+ toDot(
87
+ digraph((g) => {
88
+ g.edge(['a', ['b', 'c']]);
89
+ }),
90
+ ),
91
+ ).toMatchInlineSnapshot(`
92
+ digraph {
93
+ "a" -> {"b" "c"};
94
+ }
95
+ `);
96
+ });