ts-graphviz 1.8.3-dev.273c1f434 → 2.1.0

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +344 -0
  2. package/README.md +40 -13
  3. package/lib/adapter.cjs +1 -0
  4. package/lib/adapter.d.ts +1 -0
  5. package/lib/adapter.js +1 -0
  6. package/lib/ast.cjs +1 -0
  7. package/lib/ast.d.ts +1 -0
  8. package/lib/ast.js +1 -0
  9. package/lib/attribute.d.ts +2 -0
  10. package/lib/from-dot.d.ts +10 -0
  11. package/lib/model-factory-builder.d.ts +7 -0
  12. package/lib/model-factory.d.ts +6 -0
  13. package/lib/to-dot.d.ts +7 -0
  14. package/lib/ts-graphviz.cjs +1 -0
  15. package/lib/ts-graphviz.d.ts +7 -0
  16. package/lib/ts-graphviz.js +55 -0
  17. package/lib/types.d.ts +14 -0
  18. package/media/adapter-state-machine.svg +1 -1
  19. package/media/state-machine.svg +1 -1
  20. package/media/ts-graphviz.svg +1 -1
  21. package/package.json +69 -119
  22. package/SECURITY.md +0 -5
  23. package/lib/adapter/browser/index.cjs +0 -12
  24. package/lib/adapter/browser/index.d.ts +0 -15
  25. package/lib/adapter/browser/index.js +0 -9
  26. package/lib/adapter/deno/mod.d.ts +0 -13
  27. package/lib/adapter/deno/mod.js +0 -36
  28. package/lib/adapter/node/index.cjs +0 -45
  29. package/lib/adapter/node/index.d.ts +0 -15
  30. package/lib/adapter/node/index.js +0 -42
  31. package/lib/adapter/types/index.cjs +0 -1
  32. package/lib/adapter/types/index.d.ts +0 -134
  33. package/lib/adapter/types/index.js +0 -0
  34. package/lib/adapter/utils/index.cjs +0 -58
  35. package/lib/adapter/utils/index.d.ts +0 -11
  36. package/lib/adapter/utils/index.js +0 -56
  37. package/lib/ast/index.cjs +0 -5775
  38. package/lib/ast/index.d.ts +0 -946
  39. package/lib/ast/index.js +0 -5770
  40. package/lib/common/index.cjs +0 -58
  41. package/lib/common/index.d.ts +0 -4981
  42. package/lib/common/index.js +0 -58
  43. package/lib/core/index.cjs +0 -359
  44. package/lib/core/index.d.ts +0 -347
  45. package/lib/core/index.js +0 -364
  46. package/lib/index.cjs +0 -23
  47. package/lib/index.d.ts +0 -3
  48. package/lib/index.js +0 -2
  49. package/lib/utils/index.cjs +0 -41
  50. package/lib/utils/index.d.ts +0 -34
  51. package/lib/utils/index.js +0 -37
@@ -1 +1 @@
1
- <svg width="404" height="197pt" viewBox="0 0 302.59 196.79" xmlns="http://www.w3.org/2000/svg"><g class="graph" transform="translate(4 192.79)"><path fill="#fff" stroke="transparent" d="M-4 4v-196.79h302.59V4H-4z"/><g class="node"><circle fill="none" stroke="#000" cx="52.59" cy="-149.14" r="39.79"/><text text-anchor="middle" x="52.59" y="-145.44" font-family="Times,serif" font-size="14">Model</text></g><g class="node"><circle fill="none" stroke="#000" cx="218.59" cy="-149.14" r="31.4"/><text text-anchor="middle" x="218.59" y="-145.44" font-family="Times,serif" font-size="14">DOT</text></g><g class="edge"><path fill="none" stroke="#000" d="M90.64-137.1c9.44 2.47 19.6 4.7 29.18 5.96 17.63 2.32 22.42 2.63 40 0 6.37-.96 13.01-2.46 19.43-4.2"/><path stroke="#000" d="m178.51-138.77 10.58.54-8.61 6.17-1.97-6.71z"/><text text-anchor="middle" x="139.82" y="-134.94" font-family="Times,serif" font-size="14">toDot</text></g><g class="node"><circle fill="none" stroke="#000" cx="146.59" cy="-29.25" r="29.5"/><text text-anchor="middle" x="146.59" y="-25.55" font-family="Times,serif" font-size="14">AST</text></g><g class="edge"><path fill="none" stroke="#000" d="M21.2-124.93C5.91-110.76-6.93-92.37 4.59-76.49c23.16 31.9 68.9 42.22 102.23 45.34"/><path stroke="#000" d="m107.45-34.61 9.71 4.24-10.23 2.74.52-6.98z"/><text text-anchor="middle" x="44.09" y="-80.29" font-family="Times,serif" font-size="14">fromModel</text></g><g class="edge"><path fill="none" stroke="#000" d="M187.19-149.14h-84.61"/><path stroke="#000" d="m102.36-145.64-10-3.5 10-3.5v7z"/><text text-anchor="middle" x="139.82" y="-155.94" font-family="Times,serif" font-size="14">fromDot</text></g><g class="edge"><path fill="none" stroke="#000" d="M202.62-121.98c-10.54 17.26-24.44 40.01-35.75 58.54"/><path stroke="#000" d="m169.75-61.44-8.2 6.71 2.22-10.36 5.98 3.65z"/><text text-anchor="middle" x="202.59" y="-80.29" font-family="Times,serif" font-size="14">parse</text></g><g class="edge"><path fill="none" stroke="#000" d="M128.8-52.57c-12.81-16.06-30.42-38.14-45.48-57.03"/><path stroke="#000" d="m80.54-107.47-3.49-10 8.97 5.63-5.48 4.37z"/><text text-anchor="middle" x="138.09" y="-80.29" font-family="Times,serif" font-size="14">toModel</text></g><g class="edge"><path fill="none" stroke="#000" d="M174.74-37.96c18.87-6.8 42.31-18.78 53.85-38.53 5.88-10.07 6.19-22.25 4.18-33.7"/><path stroke="#000" d="m229.35-109.45 1.15-10.53 5.67 8.95-6.82 1.58z"/><text text-anchor="middle" x="264.09" y="-80.29" font-family="Times,serif" font-size="14">stringify</text></g></g></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="404" height="197pt" viewBox="0 0 302.59 196.79"><g class="graph" transform="translate(4 192.79)"><path fill="#fff" stroke="transparent" d="M-4 4v-196.79h302.59V4z"/><g class="node"><circle cx="52.59" cy="-149.14" r="39.79" fill="none" stroke="#000"/><text x="52.59" y="-145.44" font-family="Times,serif" font-size="14" text-anchor="middle">Model</text></g><g class="node"><circle cx="218.59" cy="-149.14" r="31.4" fill="none" stroke="#000"/><text x="218.59" y="-145.44" font-family="Times,serif" font-size="14" text-anchor="middle">DOT</text></g><g class="edge"><path fill="none" stroke="#000" d="M90.64-137.1c9.44 2.47 19.6 4.7 29.18 5.96 17.63 2.32 22.42 2.63 40 0 6.37-.96 13.01-2.46 19.43-4.2"/><path stroke="#000" d="m178.51-138.77 10.58.54-8.61 6.17z"/><text x="139.82" y="-134.94" font-family="Times,serif" font-size="14" text-anchor="middle">toDot</text></g><g class="node"><circle cx="146.59" cy="-29.25" r="29.5" fill="none" stroke="#000"/><text x="146.59" y="-25.55" font-family="Times,serif" font-size="14" text-anchor="middle">AST</text></g><g class="edge"><path fill="none" stroke="#000" d="M21.2-124.93C5.91-110.76-6.93-92.37 4.59-76.49c23.16 31.9 68.9 42.22 102.23 45.34"/><path stroke="#000" d="m107.45-34.61 9.71 4.24-10.23 2.74z"/><text x="44.09" y="-80.29" font-family="Times,serif" font-size="14" text-anchor="middle">fromModel</text></g><g class="edge"><path fill="none" stroke="#000" d="M187.19-149.14h-84.61"/><path stroke="#000" d="m102.36-145.64-10-3.5 10-3.5z"/><text x="139.82" y="-155.94" font-family="Times,serif" font-size="14" text-anchor="middle">fromDot</text></g><g class="edge"><path fill="none" stroke="#000" d="M202.62-121.98c-10.54 17.26-24.44 40.01-35.75 58.54"/><path stroke="#000" d="m169.75-61.44-8.2 6.71 2.22-10.36z"/><text x="202.59" y="-80.29" font-family="Times,serif" font-size="14" text-anchor="middle">parse</text></g><g class="edge"><path fill="none" stroke="#000" d="M128.8-52.57c-12.81-16.06-30.42-38.14-45.48-57.03"/><path stroke="#000" d="m80.54-107.47-3.49-10 8.97 5.63z"/><text x="138.09" y="-80.29" font-family="Times,serif" font-size="14" text-anchor="middle">toModel</text></g><g class="edge"><path fill="none" stroke="#000" d="M174.74-37.96c18.87-6.8 42.31-18.78 53.85-38.53 5.88-10.07 6.19-22.25 4.18-33.7"/><path stroke="#000" d="m229.35-109.45 1.15-10.53 5.67 8.95z"/><text x="264.09" y="-80.29" font-family="Times,serif" font-size="14" text-anchor="middle">stringify</text></g></g></svg>
@@ -1 +1 @@
1
- <svg width="503pt" height="196pt" viewBox="0 0 502.69 195.5" xmlns="http://www.w3.org/2000/svg"><g class="graph" transform="translate(4 191.5)"><path fill="#fff" stroke="transparent" d="M-4 4v-195.5h502.69V4H-4z"/><g class="node"><path fill="none" stroke="#000" d="M13-96v-91h194v91H13z"/><text text-anchor="middle" x="110" y="-171.8" font-family="Times,serif" font-size="14">Model Factory Functions</text><path fill="none" stroke="#000" d="M13-164h194"/><text x="21" y="-148.8" font-family="Times,serif" font-size="14">strict.digraph(...)</text><text x="21" y="-133.8" font-family="Times,serif" font-size="14">strict.graph(...)</text><text x="21" y="-118.8" font-family="Times,serif" font-size="14">digraph(...)</text><text x="21" y="-103.8" font-family="Times,serif" font-size="14">graph(...)</text></g><g class="node"><circle fill="none" stroke="#000" cx="296.65" cy="-89.5" r="39.79"/><text text-anchor="middle" x="296.65" y="-85.8" font-family="Times,serif" font-size="14">Model</text></g><g class="edge"><path fill="none" stroke="#000" d="M207.11-114.43c14.38 4.05 28.64 8.06 41.38 11.65"/><path stroke="#000" d="m249.67-106.08 8.68 6.08-10.57.65 1.89-6.73z"/></g><g class="node"><path fill="none" stroke="#000" d="M0-.5v-76h220v76H0z"/><text text-anchor="middle" x="110" y="-61.3" font-family="Times,serif" font-size="14">Object Oriented Programing</text><path fill="none" stroke="#000" d="M0-53.5h220"/><text x="8" y="-38.3" font-family="Times,serif" font-size="14">new Digraph(...)</text><text x="8" y="-23.3" font-family="Times,serif" font-size="14">new Graph(...)</text><text x="8" y="-8.3" font-family="Times,serif" font-size="14">...</text></g><g class="edge"><path fill="none" stroke="#000" d="M220.01-68.61c9.87-2.73 19.48-5.38 28.35-7.83"/><path stroke="#000" d="m247.47-79.82 10.57.71-8.7 6.03-1.87-6.74z"/></g><g class="node"><circle fill="none" stroke="#000" cx="463.49" cy="-89.5" r="31.4"/><text text-anchor="middle" x="463.49" y="-85.8" font-family="Times,serif" font-size="14">DOT</text></g><g class="edge"><path fill="none" stroke="#000" d="M336.3-89.5h85.43"/><path stroke="#000" d="m422.05-93 10 3.5-10 3.5v-7z"/><text text-anchor="middle" x="384.29" y="-93.3" font-family="Times,serif" font-size="14">toDot</text></g><g class="edge"><path fill="none" stroke="#000" d="M434.99-76.62c-6.64 2.54-13.8 4.81-20.7 6.12-26.2 4.98-33.68 4.3-60 0-3.48-.57-7.04-1.32-10.59-2.2"/><path stroke="#000" d="m342.47-69.41-8.7-6.05 10.58-.69-1.88 6.74z"/><text text-anchor="middle" x="384.29" y="-74.3" font-family="Times,serif" font-size="14">fromDot</text></g></g></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="512pt" height="202pt" viewBox="0 0 511.69 201.5"><g class="graph" transform="translate(4 197.5)"><path fill="#fff" stroke="transparent" d="M-4 4v-201.5h511.69V4z"/><g class="node"><path fill="#f0f0f0" stroke="transparent" d="M22.5-169v-21h184v21z"/><path fill="none" stroke="#000" d="M22.5-169v-21h184v21z"/><text x="25.5" y="-175.8" font-family="Times,serif" font-size="14">Model Factory Functions</text><path fill="none" stroke="#000" d="M22.5-101v-66h184v66z"/><text x="25.5" y="-152.8" font-family="Times,serif" font-size="14">strict.digraph(...)</text><text x="25.5" y="-137.8" font-family="Times,serif" font-size="14">strict.graph(...)</text><text x="25.5" y="-122.8" font-family="Times,serif" font-size="14">digraph(...)</text><text x="25.5" y="-107.8" font-family="Times,serif" font-size="14">graph(...)</text><path fill="none" stroke="#000" d="M19.5-98.5v-95h190v95z"/></g><g class="node"><circle cx="305.65" cy="-93" r="39.79" fill="none" stroke="#000"/><text x="305.65" y="-89.3" font-family="Times,serif" font-size="14" text-anchor="middle">Model</text></g><g class="edge"><path fill="none" stroke="#000" d="M209.52-119.66c16.57 4.65 33.17 9.3 47.75 13.38"/><path stroke="#000" d="m258.33-109.61 8.69 6.07-10.57.67z"/></g><g class="node"><path fill="#f0f0f0" stroke="transparent" d="M3.5-56v-21h223v21z"/><path fill="none" stroke="#000" d="M3.5-56v-21h223v21z"/><text x="6.5" y="-62.8" font-family="Times,serif" font-size="14">Object-Oriented Programming</text><path fill="none" stroke="#000" d="M3.5-3v-51h223v51z"/><text x="6.5" y="-39.8" font-family="Times,serif" font-size="14">new Digraph(...)</text><text x="6.5" y="-24.8" font-family="Times,serif" font-size="14">new Graph(...)</text><text x="6.5" y="-9.8" font-family="Times,serif" font-size="14">...</text><path fill="none" stroke="#000" d="M0 0v-80h229V0z"/></g><g class="edge"><path fill="none" stroke="#000" d="m229.08-71.82 28.42-7.97"/><path stroke="#000" d="m256.6-83.17 10.58.67-8.69 6.07z"/></g><g class="node"><circle cx="472.49" cy="-93" r="31.4" fill="none" stroke="#000"/><text x="472.49" y="-89.3" font-family="Times,serif" font-size="14" text-anchor="middle">DOT</text></g><g class="edge"><path fill="none" stroke="#000" d="M345.3-93h85.43"/><path stroke="#000" d="m431.05-96.5 10 3.5-10 3.5z"/><text x="393.29" y="-96.8" font-family="Times,serif" font-size="14" text-anchor="middle">toDot</text></g><g class="edge"><path fill="none" stroke="#000" d="M443.99-80.12c-6.64 2.54-13.8 4.81-20.7 6.12-26.2 4.98-33.68 4.3-60 0-3.48-.57-7.04-1.32-10.59-2.2"/><path stroke="#000" d="m351.47-72.91-8.7-6.05 10.58-.69z"/><text x="393.29" y="-77.8" font-family="Times,serif" font-size="14" text-anchor="middle">fromDot</text></g></g></svg>
package/package.json CHANGED
@@ -1,125 +1,75 @@
1
1
  {
2
- "name": "ts-graphviz",
3
- "version": "1.8.3-dev.273c1f434",
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": "2.1.0",
4
+ "description": "Graphviz library for TypeScript",
5
+ "keywords": [
6
+ "graphviz",
7
+ "dot"
8
+ ],
9
+ "homepage": "https://ts-graphviz.github.io/ts-graphviz/",
10
+ "bugs": {
11
+ "url": "https://github.com/ts-graphviz/ts-graphviz/issues"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/ts-graphviz/ts-graphviz.git",
16
+ "directory": "packages/ts-graphviz"
17
+ },
18
+ "funding": [
19
+ {
20
+ "type": "github",
21
+ "url": "https://github.com/sponsors/ts-graphviz"
11
22
  },
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/ts-graphviz"
22
- },
23
- "main": "./lib/index.cjs",
24
- "module": "./lib/index.js",
25
- "types": "lib/index.d.ts",
26
- "exports": {
27
- ".": {
28
- "require": {
29
- "types": "./lib/index.d.ts",
30
- "default": "./lib/index.cjs"
31
- },
32
- "import": {
33
- "types": "./lib/index.d.ts",
34
- "default": "./lib/index.js"
35
- }
36
- },
37
- "./ast": {
38
- "require": {
39
- "types": "./lib/ast/index.d.ts",
40
- "default": "./lib/ast/index.cjs"
41
- },
42
- "import": {
43
- "types": "./lib/ast/index.d.ts",
44
- "default": "./lib/ast/index.js"
45
- }
46
- },
47
- "./adapter": {
48
- "browser": {
49
- "require": "./lib/adapter/browser/index.cjs",
50
- "import": "./lib/adapter/browser/index.js",
51
- "types": "./lib/adapter/browser/index.d.ts"
52
- },
53
- "deno": {
54
- "types": "./lib/adapter/deno/mod.d.ts",
55
- "default": "./lib/adapter/deno/mod.js"
56
- },
57
- "node": {
58
- "require": "./lib/adapter/node/index.cjs",
59
- "import": "./lib/adapter/node/index.js",
60
- "types": "./lib/adapter/node/index.d.ts"
61
- },
62
- "default": {
63
- "types": "./lib/adapter/node/index.d.ts",
64
- "require": "./lib/adapter/node/index.cjs",
65
- "import": "./lib/adapter/node/index.js"
66
- }
67
- },
68
- "./package.json": "./package.json"
69
- },
70
- "typesVersions": {
71
- "*": {
72
- "ast": [
73
- "lib/ast"
74
- ],
75
- "adapter": [
76
- "lib/adapter/node"
77
- ]
78
- }
23
+ {
24
+ "type": "opencollective",
25
+ "url": "https://opencollective.com/ts-graphviz"
26
+ }
27
+ ],
28
+ "license": "MIT",
29
+ "author": "kamiazya <yuki@kamiazya.tech>",
30
+ "sideEffects": true,
31
+ "type": "module",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./lib/ts-graphviz.d.ts",
35
+ "require": "./lib/ts-graphviz.cjs",
36
+ "default": "./lib/ts-graphviz.js"
79
37
  },
80
- "license": "MIT",
81
- "engines": {
82
- "node": ">=14.16"
38
+ "./ast": {
39
+ "types": "./lib/ast.d.ts",
40
+ "require": "./lib/ast.cjs",
41
+ "default": "./lib/ast.js"
83
42
  },
84
- "runkitExampleFilename": "example/runkit.cjs",
85
- "scripts": {
86
- "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",
87
- "prebuild": "yarn build:peggy",
88
- "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",
89
- "build:node": "tsc -p tsconfig.build.json --declaration && tsc -p tsconfig.build.json --removeComments && rollup -c",
90
- "build": "yarn build:node && yarn build:deno",
91
- "postbuild": "prettier --write ./lib/**/*.{js,cjs,d.ts}",
92
- "pretest": "yarn build:peggy",
93
- "test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest",
94
- "format": "eslint --ext ts src --fix && prettier --write './**/*.{ts,js,json,yaml}' '!lib'",
95
- "lint": "eslint --ext ts src",
96
- "predoc": "yarn build:peggy",
97
- "doc": "typedoc"
43
+ "./adapter": {
44
+ "types": "./lib/adapter.d.ts",
45
+ "require": "./lib/adapter.cjs",
46
+ "default": "./lib/adapter.js"
98
47
  },
99
- "devDependencies": {
100
- "@rollup/plugin-replace": "^5.0.2",
101
- "@types/jest": "^29.4.0",
102
- "@types/jest-specific-snapshot": "^0.5.6",
103
- "@typescript-eslint/eslint-plugin": "^5.49.0",
104
- "@typescript-eslint/parser": "^5.49.0",
105
- "eslint": "^8.32.0",
106
- "eslint-config-prettier": "^8.6.0",
107
- "eslint-plugin-import": "^2.27.5",
108
- "eslint-plugin-jest": "^27.2.1",
109
- "eslint-plugin-prettier": "^4.2.1",
110
- "jest": "^29.4.1",
111
- "jest-snapshot-serializer-raw": "^1.2.0",
112
- "jest-specific-snapshot": "^7.0.0",
113
- "peggy": "^2.0.1",
114
- "prettier": "^2.8.3",
115
- "prettier-plugin-pegjs": "^0.5.0",
116
- "rollup": "^3.11.0",
117
- "rollup-plugin-delete": "^2.0.0",
118
- "rollup-plugin-dts": "5.1.1",
119
- "svgo": "^3.0.2",
120
- "ts-jest": "^29.0.5",
121
- "ts-pegjs": "^3.0.0",
122
- "typedoc": "^0.23.15",
123
- "typescript": "^4.7.4"
124
- }
48
+ "./package.json": "./package.json"
49
+ },
50
+ "main": "./lib/ts-graphviz.cjs",
51
+ "module": "./lib/ts-graphviz.js",
52
+ "types": "lib/ts-graphviz.d.ts",
53
+ "dependencies": {
54
+ "@ts-graphviz/adapter": "^2.0.1",
55
+ "@ts-graphviz/common": "^2.1.0",
56
+ "@ts-graphviz/ast": "^2.0.1",
57
+ "@ts-graphviz/core": "^2.0.1"
58
+ },
59
+ "devDependencies": {
60
+ "typescript": "^5.3.3",
61
+ "vite": "^5.1.3",
62
+ "vite-plugin-dts": "^3.7.3"
63
+ },
64
+ "engines": {
65
+ "node": ">=18"
66
+ },
67
+ "publishConfig": {
68
+ "access": "public",
69
+ "provenance": true
70
+ },
71
+ "runkitExampleFilename": "example/runkit.cjs",
72
+ "scripts": {
73
+ "build": "vite build"
74
+ }
125
75
  }
package/SECURITY.md DELETED
@@ -1,5 +0,0 @@
1
- ## Security contact information
2
-
3
- To report a security vulnerability, please use the
4
- [Tidelift security contact](https://tidelift.com/security).
5
- Tidelift will coordinate the fix and disclosure.
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- const ERROR_MESSAGE = 'This module cannot be run in a browser.';
4
- function toStream(dot, options) {
5
- throw new Error(ERROR_MESSAGE);
6
- }
7
- function toFile(dot, path, options) {
8
- throw new Error(ERROR_MESSAGE);
9
- }
10
-
11
- exports.toFile = toFile;
12
- exports.toStream = toStream;
@@ -1,15 +0,0 @@
1
- /**
2
- * @module ts-graphviz/adapter
3
- * @beta
4
- */
5
- type Options = any;
6
- /**
7
- * Execute the Graphviz dot command and make a Stream of the results.
8
- */
9
- declare function toStream(dot: string, options?: Options): never;
10
- /**
11
- * Execute the Graphviz dot command and output the results to a file.
12
- */
13
- declare function toFile(dot: string, path: string, options?: Options): never;
14
-
15
- export { Options, toFile, toStream };
@@ -1,9 +0,0 @@
1
- const ERROR_MESSAGE = 'This module cannot be run in a browser.';
2
- function toStream(dot, options) {
3
- throw new Error(ERROR_MESSAGE);
4
- }
5
- function toFile(dot, path, options) {
6
- throw new Error(ERROR_MESSAGE);
7
- }
8
-
9
- export { toFile, toStream };
@@ -1,13 +0,0 @@
1
- import { Options, Format, Layout } from '../types/index.d.ts';
2
-
3
- /**
4
- * Execute the Graphviz dot command and make a Stream of the results.
5
- */
6
- export function toStream<T extends Layout>(dot: string, options?: Options<T>): Promise<ReadableStream<Uint8Array>>;
7
-
8
- /**
9
- * Execute the Graphviz dot command and output the results to a file.
10
- */
11
- export function toFile<T extends Layout>(dot: string, path: string, options?: Options<T>): Promise<void>;
12
-
13
- export { Options, Format, Layout };
@@ -1,36 +0,0 @@
1
- import { createCommandAndArgs } from '../utils/index.js';
2
- /**
3
- * Execute the Graphviz dot command and make a Stream of the results.
4
- */
5
- export async function toStream(dot, options) {
6
- const [command, args] = createCommandAndArgs(options);
7
- const cp = new Deno.Command(command, {
8
- args: args,
9
- stdin: 'piped',
10
- stdout: 'piped',
11
- }).spawn();
12
- const stdin = cp.stdin.getWriter();
13
- await stdin.write(new TextEncoder().encode(dot));
14
- await stdin.close();
15
- return cp.stdout;
16
- }
17
-
18
- function open(path) {
19
- try {
20
- return Deno.open(path, { write: true });
21
- } catch (e) {
22
- if (e instanceof Deno.errors.NotFound) {
23
- return Deno.open(path, { createNew: true, write: true });
24
- }
25
- throw e;
26
- }
27
- }
28
-
29
- /**
30
- * Execute the Graphviz dot command and output the results to a file.
31
- */
32
- export async function toFile(dot, path, options) {
33
- const output = await open(path);
34
- const stream = await toStream(dot, options);
35
- await stream.pipeTo(output.writable);
36
- }
@@ -1,45 +0,0 @@
1
- 'use strict';
2
-
3
- var node_stream = require('node:stream');
4
- var node_child_process = require('node:child_process');
5
- var index_js = require('../utils/index.cjs');
6
- var node_util = require('node:util');
7
- var node_fs = require('node:fs');
8
-
9
- const pipeline = node_util.promisify(node_stream.pipeline);
10
-
11
- async function toStream(dot, options) {
12
- const [command, args] = index_js.createCommandAndArgs(options ?? {});
13
- return new Promise(async function toStreamInternal(resolve, reject) {
14
- const p = node_child_process.spawn(command, args, { stdio: 'pipe' });
15
- p.on('error', (e) => {
16
- reject(
17
- new Error(`Command "${command}" failed.\nMESSAGE:${e.message}`, {
18
- cause: e,
19
- }),
20
- );
21
- });
22
- const stderrChunks = [];
23
- p.stdout.on('pause', () => p.stdout.resume());
24
- p.stderr.on('data', (chunk) => stderrChunks.push(chunk));
25
- p.stderr.on('pause', () => p.stderr.resume());
26
- const dist = p.stdout.pipe(new node_stream.PassThrough());
27
- p.on('close', async (code, signal) => {
28
- if (code === 0) {
29
- resolve(dist);
30
- } else {
31
- const message = Buffer.concat(stderrChunks).toString();
32
- reject(new Error(`Command "${command}" failed.\nCODE: ${code}\nSIGNAL: ${signal}\nMESSAGE: ${message}`));
33
- }
34
- });
35
- await pipeline(node_stream.Readable.from([dot]), p.stdin);
36
- });
37
- }
38
-
39
- async function toFile(dot, path, options) {
40
- const stream = await toStream(dot, options);
41
- await pipeline(stream, node_fs.createWriteStream(path));
42
- }
43
-
44
- exports.toFile = toFile;
45
- exports.toStream = toStream;
@@ -1,15 +0,0 @@
1
- /// <reference types="node" />
2
- import { Layout, Options } from '../types/index.js';
3
- export { Format, Layout, Options } from '../types/index.js';
4
-
5
- /**
6
- * Execute the Graphviz dot command and make a Stream of the results.
7
- */
8
- declare function toStream<T extends Layout>(dot: string, options?: Options<T>): Promise<NodeJS.ReadableStream>;
9
-
10
- /**
11
- * Execute the Graphviz dot command and output the results to a file.
12
- */
13
- declare function toFile<T extends Layout>(dot: string, path: string, options?: Options<T>): Promise<void>;
14
-
15
- export { toFile, toStream };
@@ -1,42 +0,0 @@
1
- import { pipeline as pipeline$1, PassThrough, Readable } from 'node:stream';
2
- import { spawn } from 'node:child_process';
3
- import { createCommandAndArgs } from '../utils/index.js';
4
- import { promisify } from 'node:util';
5
- import { createWriteStream } from 'node:fs';
6
-
7
- const pipeline = promisify(pipeline$1);
8
-
9
- async function toStream(dot, options) {
10
- const [command, args] = createCommandAndArgs(options ?? {});
11
- return new Promise(async function toStreamInternal(resolve, reject) {
12
- const p = spawn(command, args, { stdio: 'pipe' });
13
- p.on('error', (e) => {
14
- reject(
15
- new Error(`Command "${command}" failed.\nMESSAGE:${e.message}`, {
16
- cause: e,
17
- }),
18
- );
19
- });
20
- const stderrChunks = [];
21
- p.stdout.on('pause', () => p.stdout.resume());
22
- p.stderr.on('data', (chunk) => stderrChunks.push(chunk));
23
- p.stderr.on('pause', () => p.stderr.resume());
24
- const dist = p.stdout.pipe(new PassThrough());
25
- p.on('close', async (code, signal) => {
26
- if (code === 0) {
27
- resolve(dist);
28
- } else {
29
- const message = Buffer.concat(stderrChunks).toString();
30
- reject(new Error(`Command "${command}" failed.\nCODE: ${code}\nSIGNAL: ${signal}\nMESSAGE: ${message}`));
31
- }
32
- });
33
- await pipeline(Readable.from([dot]), p.stdin);
34
- });
35
- }
36
-
37
- async function toFile(dot, path, options) {
38
- const stream = await toStream(dot, options);
39
- await pipeline(stream, createWriteStream(path));
40
- }
41
-
42
- export { toFile, toStream };
@@ -1 +0,0 @@
1
- 'use strict';
@@ -1,134 +0,0 @@
1
- import {
2
- EdgeAttributesObject,
3
- NodeAttributesObject,
4
- GraphAttributesObject,
5
- SubgraphAttributesObject,
6
- } from '../../common/index.js';
7
- import { $keywords, $keywordsValidation } from '../../utils/index.js';
8
-
9
- type Format = Format.values;
10
- declare namespace Format {
11
- type values = Exclude<keyof $values, keyof $exclude | symbol | number>;
12
- interface $values extends $keywords<'png' | 'svg' | 'json' | 'jpg' | 'pdf' | 'xdot' | 'dot' | 'plain' | 'dot_json'> {}
13
- interface $exclude extends $keywordsValidation {}
14
- }
15
- type Layout = Layout.values;
16
- declare namespace Layout {
17
- type values = Exclude<keyof $values, keyof $exclude | symbol | number>;
18
- interface $values
19
- extends $keywords<'dot' | 'neato' | 'fdp' | 'sfdp' | 'circo' | 'twopi' | 'nop' | 'nop2' | 'osage' | 'patchwork'> {}
20
- interface $exclude extends $keywordsValidation {}
21
- }
22
- /**
23
- * NeatoOptions interface provides options for the neato layout.
24
- */
25
- interface NeatoOptions {
26
- layout: 'neato';
27
- /**
28
- * Sets no-op flag in neato.
29
- */
30
- noop?: number;
31
- /**
32
- * Reduce graph.
33
- */
34
- reduce?: boolean;
35
- }
36
- /**
37
- * FdpOptions interface provides options for the fdp layout.
38
- */
39
- interface FdpOptions {
40
- layout: 'fdp';
41
- /**
42
- * Use grid.
43
- *
44
- * @default true
45
- */
46
- grid?: boolean;
47
- /**
48
- * Use old attractive force
49
- *
50
- * @default true
51
- */
52
- oldAttractive?: boolean;
53
- /**
54
- * Set number of iterations.
55
- */
56
- iterations?: number;
57
- /**
58
- * Set unscaled factor
59
- */
60
- unscaledFactor?: number;
61
- /**
62
- * Set overlap expansion factor.
63
- */
64
- overlapExpansionFactor?: number;
65
- /**
66
- * Set temperature.
67
- */
68
- temperature?: number;
69
- }
70
- /**
71
- * @description
72
- * This interface describes an optional parameter called "layout" which is used to set a layout engine.
73
- * The default value for this parameter is 'dot', and it must be an option of the Layout type,
74
- * excluding 'neato' and 'fdp'.
75
- */
76
- interface OtherOptions {
77
- /**
78
- * Set layout engine.
79
- *
80
- * @default 'dot'
81
- */
82
- layout?: Exclude<Layout, 'neato' | 'fdp'>;
83
- }
84
- /**
85
- * This interface represents the CommonOptions for setting output format.
86
- */
87
- interface CommonOptions {
88
- /**
89
- * Set output format.
90
- *
91
- * @default 'svg'
92
- */
93
- format?: Format;
94
- /**
95
- * If true, set level of message suppression (=1).
96
- *
97
- * @default true
98
- */
99
- suppressWarnings?: boolean;
100
- /**
101
- * Path of graphviz dot command.
102
- */
103
- dotCommand?: string;
104
- attributes?: {
105
- /**
106
- * Set edge attribute.
107
- */
108
- edge?: EdgeAttributesObject;
109
- /**
110
- * Set node attribute.
111
- */
112
- node?: NodeAttributesObject;
113
- /**
114
- * Set graph attribute.
115
- */
116
- graph?: GraphAttributesObject & SubgraphAttributesObject;
117
- };
118
- /**
119
- * Scale input
120
- */
121
- scale?: number;
122
- /**
123
- * Use external library.
124
- */
125
- library?: string[];
126
- /**
127
- * Invert y coordinate in output.
128
- */
129
- y?: boolean;
130
- }
131
- type Options<T extends Layout = Layout> = CommonOptions &
132
- (T extends 'neato' ? NeatoOptions : T extends 'fdp' ? FdpOptions : OtherOptions);
133
-
134
- export { CommonOptions, FdpOptions, Format, Layout, NeatoOptions, Options, OtherOptions };
File without changes
@@ -1,58 +0,0 @@
1
- 'use strict';
2
-
3
- function escapeValue(value) {
4
- if (value !== true) {
5
- if (typeof value === 'string' && /\s/g.test(value)) {
6
- return `="${value}"`;
7
- } else {
8
- return `=${value}`;
9
- }
10
- }
11
- return '';
12
- }
13
- function* createCommandArgs(options) {
14
- const { suppressWarnings = true, format = 'svg', attributes = {}, library = [], y = false, scale } = options;
15
- if (suppressWarnings) yield '-q';
16
- yield `-T${format}`;
17
- if (attributes.graph) {
18
- for (const [key, value] of Object.entries(attributes.graph)) {
19
- yield `-G${key}${escapeValue(value)}`;
20
- }
21
- }
22
- if (attributes.node) {
23
- for (const [key, value] of Object.entries(attributes.node)) {
24
- yield `-N${key}${escapeValue(value)}`;
25
- }
26
- }
27
- if (attributes.edge) {
28
- for (const [key, value] of Object.entries(attributes.edge)) {
29
- yield `-E${key}${escapeValue(value)}`;
30
- }
31
- }
32
- if (typeof scale === 'number' && !Number.isNaN(scale)) yield `-s${scale}`;
33
- if (Array.isArray(library)) for (const lib of library) yield `-l${lib}`;
34
- if (y === true) yield `-y`;
35
- if (typeof options.layout === 'string') {
36
- yield `-K${options.layout}`;
37
- switch (options.layout) {
38
- case 'neato':
39
- const { reduce, noop } = options;
40
- if (reduce === true) yield '-x';
41
- if (typeof noop === 'number') yield `-n${noop}`;
42
- break;
43
- case 'fdp':
44
- const { grid, oldAttractive, iterations, unscaledFactor, overlapExpansionFactor, temperature } = options;
45
- yield ['-L', grid ? '' : 'g', oldAttractive ? 'O' : ''].join('');
46
- if (typeof iterations === 'number') yield `-Ln${iterations}`;
47
- if (typeof unscaledFactor === 'number') yield `-LU${unscaledFactor}`;
48
- if (typeof overlapExpansionFactor === 'number') yield `-LC${overlapExpansionFactor}`;
49
- if (typeof temperature === 'number') yield `-LT${temperature}`;
50
- }
51
- }
52
- }
53
-
54
- function createCommandAndArgs(options) {
55
- return [options.dotCommand ?? 'dot', Array.from(createCommandArgs(options))];
56
- }
57
-
58
- exports.createCommandAndArgs = createCommandAndArgs;