ts-graphviz 0.0.0-pr956-20240225160253 → 0.0.0-pr956-20240225163634
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/CHANGELOG.md +5 -5
- package/example/runkit.cjs +25 -0
- package/lib/ts-graphviz.cjs +1 -1
- package/lib/ts-graphviz.js +34 -263
- package/package.json +6 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ts-graphviz
|
|
2
2
|
|
|
3
|
-
## 0.0.0-pr956-
|
|
3
|
+
## 0.0.0-pr956-20240225163634
|
|
4
4
|
|
|
5
5
|
### Major Changes
|
|
6
6
|
|
|
@@ -297,7 +297,7 @@
|
|
|
297
297
|
### Patch Changes
|
|
298
298
|
|
|
299
299
|
- Updated dependencies [[`6b2f0e8`](https://github.com/ts-graphviz/ts-graphviz/commit/6b2f0e8349605b4fe0dd950147ba3a8285b24b24)]:
|
|
300
|
-
- @ts-graphviz/adapter@0.0.0-pr956-
|
|
301
|
-
- @ts-graphviz/common@0.0.0-pr956-
|
|
302
|
-
- @ts-graphviz/core@0.0.0-pr956-
|
|
303
|
-
- @ts-graphviz/ast@0.0.0-pr956-
|
|
300
|
+
- @ts-graphviz/adapter@0.0.0-pr956-20240225163634
|
|
301
|
+
- @ts-graphviz/common@0.0.0-pr956-20240225163634
|
|
302
|
+
- @ts-graphviz/core@0.0.0-pr956-20240225163634
|
|
303
|
+
- @ts-graphviz/ast@0.0.0-pr956-20240225163634
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const { attribute: _, digraph, toDot } = require('ts-graphviz');
|
|
2
|
+
|
|
3
|
+
const G = digraph('G', (g) => {
|
|
4
|
+
const a = g.node('aa');
|
|
5
|
+
const b = g.node('bb');
|
|
6
|
+
const c = g.node('cc');
|
|
7
|
+
g.edge([a, b, c], {
|
|
8
|
+
[_.color]: 'red',
|
|
9
|
+
});
|
|
10
|
+
g.subgraph('A', (A) => {
|
|
11
|
+
const Aa = A.node('Aaa', {
|
|
12
|
+
[_.color]: 'pink',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const Ab = A.node('Abb', {
|
|
16
|
+
[_.color]: 'violet',
|
|
17
|
+
});
|
|
18
|
+
const Ac = A.node('Acc');
|
|
19
|
+
A.edge([Aa.port('a'), Ab, Ac, 'E'], {
|
|
20
|
+
[_.color]: 'red',
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
toDot(G);
|
package/lib/ts-graphviz.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@ts-graphviz/core"),n=require("@ts-graphviz/common"),c=require("@ts-graphviz/ast"),h=new Proxy(Object.freeze({}),{get:(t,e)=>e});function u(t,e){return(...r)=>{const l=t?this.Digraph:this.Graph,y=r.find(o=>typeof o=="string"),d=r.find(o=>typeof o=="object"),f=r.find(o=>typeof o=="function"),a=new l(y,e,d);return a.with(this),typeof f=="function"&&f(a),a}}function i(t,e=n.RootModelsContext){return Object.freeze({digraph:u.call(e,!0,t),graph:u.call(e,!1,t)})}const p=i(!1),b=p.digraph,g=p.graph,O=i(!0);function j(t){const e=n.createModelsContext(t);return Object.freeze({...i(!1,e),strict:i(!0,e)})}function m(t,e){const r=c.parse(t,e?.parse);if(Array.isArray(r)||r.type==="Attribute"||r.type==="AttributeList"||r.type==="Comment"||r.type==="NodeRef"||r.type==="NodeRefGroup"||r.type==="Literal")throw new Error;return c.toModel(r,e?.convert)}function w(t,e){const r=c.fromModel(t,e?.convert);return c.stringify(r,e?.print)}s.registerDefault();exports.attribute=h;exports.digraph=b;exports.fromDot=m;exports.graph=g;exports.strict=O;exports.toDot=w;exports.withContext=j;Object.keys(s).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>s[t]})});Object.keys(n).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>n[t]})});
|
package/lib/ts-graphviz.js
CHANGED
|
@@ -1,284 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export * from "@ts-graphviz/common";
|
|
1
|
+
import { registerDefault as l } from "@ts-graphviz/core";
|
|
3
2
|
export * from "@ts-graphviz/core";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/** @hidden */
|
|
9
|
-
#e = /* @__PURE__ */ new Map();
|
|
10
|
-
constructor(t) {
|
|
11
|
-
super(), t !== void 0 && this.apply(t);
|
|
12
|
-
}
|
|
13
|
-
get values() {
|
|
14
|
-
return Array.from(this.#e.entries());
|
|
15
|
-
}
|
|
16
|
-
get size() {
|
|
17
|
-
return this.#e.size;
|
|
18
|
-
}
|
|
19
|
-
get(t) {
|
|
20
|
-
return this.#e.get(t);
|
|
21
|
-
}
|
|
22
|
-
set(t, e) {
|
|
23
|
-
e != null && this.#e.set(t, e);
|
|
24
|
-
}
|
|
25
|
-
delete(t) {
|
|
26
|
-
this.#e.delete(t);
|
|
27
|
-
}
|
|
28
|
-
apply(t) {
|
|
29
|
-
const e = Array.isArray(t) ? t : Object.entries(t);
|
|
30
|
-
for (const [s, n] of e)
|
|
31
|
-
this.set(s, n);
|
|
32
|
-
}
|
|
33
|
-
clear() {
|
|
34
|
-
this.#e.clear();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
class c extends f {
|
|
38
|
-
constructor(t, e) {
|
|
39
|
-
super(e), this.$$kind = t;
|
|
40
|
-
}
|
|
41
|
-
get $$type() {
|
|
42
|
-
return "AttributeList";
|
|
43
|
-
}
|
|
44
|
-
comment;
|
|
45
|
-
}
|
|
46
|
-
class y extends f {
|
|
47
|
-
/** @hidden */
|
|
48
|
-
#e = p;
|
|
49
|
-
id;
|
|
50
|
-
comment;
|
|
51
|
-
attributes = Object.freeze({
|
|
52
|
-
graph: new c("Graph"),
|
|
53
|
-
edge: new c("Edge"),
|
|
54
|
-
node: new c("Node")
|
|
55
|
-
});
|
|
56
|
-
get nodes() {
|
|
57
|
-
return Array.from(this.#t.nodes.values());
|
|
58
|
-
}
|
|
59
|
-
get edges() {
|
|
60
|
-
return Array.from(this.#t.edges.values());
|
|
61
|
-
}
|
|
62
|
-
get subgraphs() {
|
|
63
|
-
return Array.from(this.#t.subgraphs.values());
|
|
64
|
-
}
|
|
65
|
-
/** @hidden */
|
|
66
|
-
#t = {
|
|
67
|
-
nodes: /* @__PURE__ */ new Map(),
|
|
68
|
-
edges: /* @__PURE__ */ new Set(),
|
|
69
|
-
subgraphs: /* @__PURE__ */ new Set()
|
|
70
|
-
};
|
|
71
|
-
with(t) {
|
|
72
|
-
this.#e = b(t);
|
|
73
|
-
}
|
|
74
|
-
addNode(t) {
|
|
75
|
-
this.#t.nodes.set(t.id, t);
|
|
76
|
-
}
|
|
77
|
-
addEdge(t) {
|
|
78
|
-
this.#t.edges.add(t);
|
|
79
|
-
}
|
|
80
|
-
addSubgraph(t) {
|
|
81
|
-
this.#t.subgraphs.add(t);
|
|
82
|
-
}
|
|
83
|
-
existNode(t) {
|
|
84
|
-
return this.#t.nodes.has(t);
|
|
85
|
-
}
|
|
86
|
-
existEdge(t) {
|
|
87
|
-
return this.#t.edges.has(t);
|
|
88
|
-
}
|
|
89
|
-
existSubgraph(t) {
|
|
90
|
-
return this.#t.subgraphs.has(t);
|
|
91
|
-
}
|
|
92
|
-
createSubgraph(...t) {
|
|
93
|
-
const e = new this.#e.Subgraph(...t);
|
|
94
|
-
return e.with(this.#e), this.addSubgraph(e), e;
|
|
95
|
-
}
|
|
96
|
-
removeNode(t) {
|
|
97
|
-
this.#t.nodes.delete(typeof t == "string" ? t : t.id);
|
|
98
|
-
}
|
|
99
|
-
removeEdge(t) {
|
|
100
|
-
this.#t.edges.delete(t);
|
|
101
|
-
}
|
|
102
|
-
removeSubgraph(t) {
|
|
103
|
-
this.#t.subgraphs.delete(t);
|
|
104
|
-
}
|
|
105
|
-
createNode(t, e) {
|
|
106
|
-
const s = new this.#e.Node(t, e);
|
|
107
|
-
return this.addNode(s), s;
|
|
108
|
-
}
|
|
109
|
-
getSubgraph(t) {
|
|
110
|
-
return Array.from(this.#t.subgraphs.values()).find(
|
|
111
|
-
(e) => e.id === t
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
getNode(t) {
|
|
115
|
-
return this.#t.nodes.get(t);
|
|
116
|
-
}
|
|
117
|
-
createEdge(t, e) {
|
|
118
|
-
const s = t.map(
|
|
119
|
-
(o) => v(o) ? N(o) : j(o)
|
|
120
|
-
), n = new this.#e.Edge(s, e);
|
|
121
|
-
return this.addEdge(n), n;
|
|
122
|
-
}
|
|
123
|
-
subgraph(...t) {
|
|
124
|
-
const e = t.find(
|
|
125
|
-
(i) => typeof i == "string"
|
|
126
|
-
), s = t.find(
|
|
127
|
-
(i) => typeof i == "object" && i !== null
|
|
128
|
-
), n = t.find(
|
|
129
|
-
(i) => typeof i == "function"
|
|
130
|
-
), o = e ? this.getSubgraph(e) ?? this.createSubgraph(e) : this.createSubgraph();
|
|
131
|
-
return s !== void 0 && o.apply(s), n !== void 0 && n(o), o;
|
|
132
|
-
}
|
|
133
|
-
node(t, ...e) {
|
|
134
|
-
if (typeof t == "string") {
|
|
135
|
-
const s = t, n = e.find(
|
|
136
|
-
(d) => typeof d == "object" && d !== null
|
|
137
|
-
), o = e.find(
|
|
138
|
-
(d) => typeof d == "function"
|
|
139
|
-
), i = this.getNode(s) ?? this.createNode(s);
|
|
140
|
-
return n !== void 0 && i.attributes.apply(n), o !== void 0 && o(i), i;
|
|
141
|
-
}
|
|
142
|
-
typeof t == "object" && t !== null && this.attributes.node.apply(t);
|
|
143
|
-
}
|
|
144
|
-
edge(t, ...e) {
|
|
145
|
-
if (Array.isArray(t)) {
|
|
146
|
-
const s = t, n = e.find(
|
|
147
|
-
(d) => typeof d == "object"
|
|
148
|
-
), o = e.find(
|
|
149
|
-
(d) => typeof d == "function"
|
|
150
|
-
), i = this.createEdge(s, n);
|
|
151
|
-
return o !== void 0 && o(i), i;
|
|
152
|
-
}
|
|
153
|
-
typeof t == "object" && t !== null && this.attributes.edge.apply(t);
|
|
154
|
-
}
|
|
155
|
-
graph(t) {
|
|
156
|
-
this.attributes.graph.apply(t);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
class m extends y {
|
|
160
|
-
get $$type() {
|
|
161
|
-
return "Graph";
|
|
162
|
-
}
|
|
163
|
-
id;
|
|
164
|
-
strict;
|
|
165
|
-
constructor(...t) {
|
|
166
|
-
super(), this.id = t.find((s) => typeof s == "string"), this.strict = t.find((s) => typeof s == "boolean") ?? !1;
|
|
167
|
-
const e = t.find(
|
|
168
|
-
(s) => typeof s == "object" && s !== null
|
|
169
|
-
);
|
|
170
|
-
e !== void 0 && this.apply(e);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
class A extends m {
|
|
174
|
-
get directed() {
|
|
175
|
-
return !0;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
class w extends f {
|
|
179
|
-
comment;
|
|
180
|
-
}
|
|
181
|
-
class k extends h {
|
|
182
|
-
constructor(t, e) {
|
|
183
|
-
if (super(), this.targets = t, t.length < 2 && (l(t[0]) && l(t[1])) === !1)
|
|
184
|
-
throw Error(
|
|
185
|
-
"The element of Edge target is missing or not satisfied as Edge target."
|
|
186
|
-
);
|
|
187
|
-
this.attributes = new w(e);
|
|
188
|
-
}
|
|
189
|
-
get $$type() {
|
|
190
|
-
return "Edge";
|
|
191
|
-
}
|
|
192
|
-
comment;
|
|
193
|
-
attributes;
|
|
194
|
-
}
|
|
195
|
-
class M extends m {
|
|
196
|
-
get directed() {
|
|
197
|
-
return !1;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
class R extends h {
|
|
201
|
-
constructor(t, e) {
|
|
202
|
-
super(), this.id = t, this.attributes = new w(e);
|
|
203
|
-
}
|
|
204
|
-
get $$type() {
|
|
205
|
-
return "Node";
|
|
206
|
-
}
|
|
207
|
-
comment;
|
|
208
|
-
attributes;
|
|
209
|
-
port(t) {
|
|
210
|
-
return typeof t == "string" ? { id: this.id, port: t } : { id: this.id, ...t };
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
class O extends y {
|
|
214
|
-
get $$type() {
|
|
215
|
-
return "Subgraph";
|
|
216
|
-
}
|
|
217
|
-
id;
|
|
218
|
-
constructor(...t) {
|
|
219
|
-
super(), this.id = t.find((s) => typeof s == "string");
|
|
220
|
-
const e = t.find(
|
|
221
|
-
(s) => typeof s == "object" && s !== null
|
|
222
|
-
);
|
|
223
|
-
e !== void 0 && this.apply(e);
|
|
224
|
-
}
|
|
225
|
-
isSubgraphCluster() {
|
|
226
|
-
return typeof this.id == "string" ? this.id.startsWith("cluster") : !1;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
Object.assign(p, {
|
|
230
|
-
Graph: M,
|
|
231
|
-
Digraph: A,
|
|
232
|
-
Subgraph: O,
|
|
233
|
-
Node: R,
|
|
234
|
-
Edge: k
|
|
235
|
-
});
|
|
236
|
-
const C = new Proxy(
|
|
3
|
+
import { RootModelsContext as d, createModelsContext as y } from "@ts-graphviz/common";
|
|
4
|
+
export * from "@ts-graphviz/common";
|
|
5
|
+
import { parse as h, toModel as m, fromModel as g, stringify as b } from "@ts-graphviz/ast";
|
|
6
|
+
const j = new Proxy(
|
|
237
7
|
Object.freeze({}),
|
|
238
8
|
{
|
|
239
9
|
get: (r, t) => t
|
|
240
10
|
}
|
|
241
11
|
);
|
|
242
|
-
function
|
|
12
|
+
function f(r, t) {
|
|
243
13
|
return (...e) => {
|
|
244
|
-
const
|
|
245
|
-
(
|
|
246
|
-
),
|
|
247
|
-
(
|
|
248
|
-
),
|
|
249
|
-
return
|
|
14
|
+
const a = r ? this.Digraph : this.Graph, p = e.find((o) => typeof o == "string"), u = e.find(
|
|
15
|
+
(o) => typeof o == "object"
|
|
16
|
+
), c = e.find(
|
|
17
|
+
(o) => typeof o == "function"
|
|
18
|
+
), i = new a(p, t, u);
|
|
19
|
+
return i.with(this), typeof c == "function" && c(i), i;
|
|
250
20
|
};
|
|
251
21
|
}
|
|
252
|
-
function
|
|
22
|
+
function n(r, t = d) {
|
|
253
23
|
return Object.freeze({
|
|
254
|
-
digraph:
|
|
255
|
-
graph:
|
|
24
|
+
digraph: f.call(t, !0, r),
|
|
25
|
+
graph: f.call(t, !1, r)
|
|
256
26
|
});
|
|
257
27
|
}
|
|
258
|
-
const
|
|
259
|
-
function
|
|
260
|
-
const t =
|
|
28
|
+
const s = n(!1), A = s.digraph, C = s.graph, D = n(!0);
|
|
29
|
+
function z(r) {
|
|
30
|
+
const t = y(r);
|
|
261
31
|
return Object.freeze({
|
|
262
|
-
...
|
|
263
|
-
strict:
|
|
32
|
+
...n(!1, t),
|
|
33
|
+
strict: n(!0, t)
|
|
264
34
|
});
|
|
265
35
|
}
|
|
266
|
-
function
|
|
267
|
-
const e =
|
|
36
|
+
function G(r, t) {
|
|
37
|
+
const e = h(r, t?.parse);
|
|
268
38
|
if (Array.isArray(e) || e.type === "Attribute" || e.type === "AttributeList" || e.type === "Comment" || e.type === "NodeRef" || e.type === "NodeRefGroup" || e.type === "Literal")
|
|
269
39
|
throw new Error();
|
|
270
|
-
return
|
|
40
|
+
return m(e, t?.convert);
|
|
271
41
|
}
|
|
272
|
-
function
|
|
273
|
-
const e =
|
|
274
|
-
return
|
|
42
|
+
function O(r, t) {
|
|
43
|
+
const e = g(r, t?.convert);
|
|
44
|
+
return b(e, t?.print);
|
|
275
45
|
}
|
|
46
|
+
l();
|
|
276
47
|
export {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
48
|
+
j as attribute,
|
|
49
|
+
A as digraph,
|
|
50
|
+
G as fromDot,
|
|
51
|
+
C as graph,
|
|
52
|
+
D as strict,
|
|
53
|
+
O as toDot,
|
|
54
|
+
z as withContext
|
|
284
55
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-graphviz",
|
|
3
|
-
"version": "0.0.0-pr956-
|
|
3
|
+
"version": "0.0.0-pr956-20240225163634",
|
|
4
4
|
"description": "Graphviz library for TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphviz",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"author": "kamiazya <yuki@kamiazya.tech>",
|
|
30
|
+
"sideEffects": true,
|
|
30
31
|
"type": "module",
|
|
31
32
|
"exports": {
|
|
32
33
|
".": {
|
|
@@ -54,18 +55,11 @@
|
|
|
54
55
|
"main": "./lib/ts-graphviz.cjs",
|
|
55
56
|
"module": "./lib/ts-graphviz.js",
|
|
56
57
|
"types": "lib/ts-graphviz.d.ts",
|
|
57
|
-
"files": [
|
|
58
|
-
"lib",
|
|
59
|
-
"media",
|
|
60
|
-
"README.md",
|
|
61
|
-
"CHANGELOG.md",
|
|
62
|
-
"LICENSE"
|
|
63
|
-
],
|
|
64
58
|
"dependencies": {
|
|
65
|
-
"@ts-graphviz/adapter": "^0.0.0-pr956-
|
|
66
|
-
"@ts-graphviz/ast": "^0.0.0-pr956-
|
|
67
|
-
"@ts-graphviz/common": "^0.0.0-pr956-
|
|
68
|
-
"@ts-graphviz/core": "^0.0.0-pr956-
|
|
59
|
+
"@ts-graphviz/adapter": "^0.0.0-pr956-20240225163634",
|
|
60
|
+
"@ts-graphviz/ast": "^0.0.0-pr956-20240225163634",
|
|
61
|
+
"@ts-graphviz/common": "^0.0.0-pr956-20240225163634",
|
|
62
|
+
"@ts-graphviz/core": "^0.0.0-pr956-20240225163634"
|
|
69
63
|
},
|
|
70
64
|
"devDependencies": {
|
|
71
65
|
"peggy": "^3.0.2",
|