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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # ts-graphviz
2
2
 
3
- ## 0.0.0-pr956-20240225160253
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-20240225160253
301
- - @ts-graphviz/common@0.0.0-pr956-20240225160253
302
- - @ts-graphviz/core@0.0.0-pr956-20240225160253
303
- - @ts-graphviz/ast@0.0.0-pr956-20240225160253
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);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@ts-graphviz/common"),g=require("@ts-graphviz/core"),u=require("@ts-graphviz/ast");class f{}class l extends f{#e=new Map;constructor(t){super(),t!==void 0&&this.apply(t)}get values(){return Array.from(this.#e.entries())}get size(){return this.#e.size}get(t){return this.#e.get(t)}set(t,e){e!=null&&this.#e.set(t,e)}delete(t){this.#e.delete(t)}apply(t){const e=Array.isArray(t)?t:Object.entries(t);for(const[s,n]of e)this.set(s,n)}clear(){this.#e.clear()}}class p extends l{constructor(t,e){super(e),this.$$kind=t}get $$type(){return"AttributeList"}comment}class y extends l{#e=a.RootModelsContext;id;comment;attributes=Object.freeze({graph:new p("Graph"),edge:new p("Edge"),node:new p("Node")});get nodes(){return Array.from(this.#t.nodes.values())}get edges(){return Array.from(this.#t.edges.values())}get subgraphs(){return Array.from(this.#t.subgraphs.values())}#t={nodes:new Map,edges:new Set,subgraphs:new Set};with(t){this.#e=a.createModelsContext(t)}addNode(t){this.#t.nodes.set(t.id,t)}addEdge(t){this.#t.edges.add(t)}addSubgraph(t){this.#t.subgraphs.add(t)}existNode(t){return this.#t.nodes.has(t)}existEdge(t){return this.#t.edges.has(t)}existSubgraph(t){return this.#t.subgraphs.has(t)}createSubgraph(...t){const e=new this.#e.Subgraph(...t);return e.with(this.#e),this.addSubgraph(e),e}removeNode(t){this.#t.nodes.delete(typeof t=="string"?t:t.id)}removeEdge(t){this.#t.edges.delete(t)}removeSubgraph(t){this.#t.subgraphs.delete(t)}createNode(t,e){const s=new this.#e.Node(t,e);return this.addNode(s),s}getSubgraph(t){return Array.from(this.#t.subgraphs.values()).find(e=>e.id===t)}getNode(t){return this.#t.nodes.get(t)}createEdge(t,e){const s=t.map(i=>a.isNodeRefGroupLike(i)?a.toNodeRefGroup(i):a.toNodeRef(i)),n=new this.#e.Edge(s,e);return this.addEdge(n),n}subgraph(...t){const e=t.find(o=>typeof o=="string"),s=t.find(o=>typeof o=="object"&&o!==null),n=t.find(o=>typeof o=="function"),i=e?this.getSubgraph(e)??this.createSubgraph(e):this.createSubgraph();return s!==void 0&&i.apply(s),n!==void 0&&n(i),i}node(t,...e){if(typeof t=="string"){const s=t,n=e.find(d=>typeof d=="object"&&d!==null),i=e.find(d=>typeof d=="function"),o=this.getNode(s)??this.createNode(s);return n!==void 0&&o.attributes.apply(n),i!==void 0&&i(o),o}typeof t=="object"&&t!==null&&this.attributes.node.apply(t)}edge(t,...e){if(Array.isArray(t)){const s=t,n=e.find(d=>typeof d=="object"),i=e.find(d=>typeof d=="function"),o=this.createEdge(s,n);return i!==void 0&&i(o),o}typeof t=="object"&&t!==null&&this.attributes.edge.apply(t)}graph(t){this.attributes.graph.apply(t)}}class m extends y{get $$type(){return"Graph"}id;strict;constructor(...t){super(),this.id=t.find(s=>typeof s=="string"),this.strict=t.find(s=>typeof s=="boolean")??!1;const e=t.find(s=>typeof s=="object"&&s!==null);e!==void 0&&this.apply(e)}}class x extends m{get directed(){return!0}}class w extends l{comment}class v extends f{constructor(t,e){if(super(),this.targets=t,t.length<2&&(a.isNodeRefLike(t[0])&&a.isNodeRefLike(t[1]))===!1)throw Error("The element of Edge target is missing or not satisfied as Edge target.");this.attributes=new w(e)}get $$type(){return"Edge"}comment;attributes}class N extends m{get directed(){return!1}}class S extends f{constructor(t,e){super(),this.id=t,this.attributes=new w(e)}get $$type(){return"Node"}comment;attributes;port(t){return typeof t=="string"?{id:this.id,port:t}:{id:this.id,...t}}}class E extends y{get $$type(){return"Subgraph"}id;constructor(...t){super(),this.id=t.find(s=>typeof s=="string");const e=t.find(s=>typeof s=="object"&&s!==null);e!==void 0&&this.apply(e)}isSubgraphCluster(){return typeof this.id=="string"?this.id.startsWith("cluster"):!1}}Object.assign(a.RootModelsContext,{Graph:N,Digraph:x,Subgraph:E,Node:S,Edge:v});const O=new Proxy(Object.freeze({}),{get:(r,t)=>t});function b(r,t){return(...e)=>{const s=r?this.Digraph:this.Graph,n=e.find(c=>typeof c=="string"),i=e.find(c=>typeof c=="object"),o=e.find(c=>typeof c=="function"),d=new s(n,t,i);return d.with(this),typeof o=="function"&&o(d),d}}function h(r,t=a.RootModelsContext){return Object.freeze({digraph:b.call(t,!0,r),graph:b.call(t,!1,r)})}const j=h(!1),$=j.digraph,M=j.graph,G=h(!0);function R(r){const t=a.createModelsContext(r);return Object.freeze({...h(!1,t),strict:h(!0,t)})}function A(r,t){const e=u.parse(r,t?.parse);if(Array.isArray(e)||e.type==="Attribute"||e.type==="AttributeList"||e.type==="Comment"||e.type==="NodeRef"||e.type==="NodeRefGroup"||e.type==="Literal")throw new Error;return u.toModel(e,t?.convert)}function C(r,t){const e=u.fromModel(r,t?.convert);return u.stringify(e,t?.print)}exports.attribute=O;exports.digraph=$;exports.fromDot=A;exports.graph=M;exports.strict=G;exports.toDot=C;exports.withContext=R;Object.keys(a).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(exports,r)&&Object.defineProperty(exports,r,{enumerable:!0,get:()=>a[r]})});Object.keys(g).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(exports,r)&&Object.defineProperty(exports,r,{enumerable:!0,get:()=>g[r]})});
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]})});
@@ -1,284 +1,55 @@
1
- import { RootModelsContext as p, createModelsContext as b, isNodeRefGroupLike as v, toNodeRefGroup as N, toNodeRef as j, isNodeRefLike as l } from "@ts-graphviz/common";
2
- export * from "@ts-graphviz/common";
1
+ import { registerDefault as l } from "@ts-graphviz/core";
3
2
  export * from "@ts-graphviz/core";
4
- import { parse as S, toModel as E, fromModel as $, stringify as G } from "@ts-graphviz/ast";
5
- class h {
6
- }
7
- class f extends h {
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 g(r, t) {
12
+ function f(r, t) {
243
13
  return (...e) => {
244
- const s = r ? this.Digraph : this.Graph, n = e.find((a) => typeof a == "string"), o = e.find(
245
- (a) => typeof a == "object"
246
- ), i = e.find(
247
- (a) => typeof a == "function"
248
- ), d = new s(n, t, o);
249
- return d.with(this), typeof i == "function" && i(d), d;
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 u(r, t = p) {
22
+ function n(r, t = d) {
253
23
  return Object.freeze({
254
- digraph: g.call(t, !0, r),
255
- graph: g.call(t, !1, r)
24
+ digraph: f.call(t, !0, r),
25
+ graph: f.call(t, !1, r)
256
26
  });
257
27
  }
258
- const x = u(!1), D = x.digraph, B = x.graph, F = u(!0);
259
- function P(r) {
260
- const t = b(r);
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
- ...u(!1, t),
263
- strict: u(!0, t)
32
+ ...n(!1, t),
33
+ strict: n(!0, t)
264
34
  });
265
35
  }
266
- function T(r, t) {
267
- const e = S(r, t?.parse);
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 E(e, t?.convert);
40
+ return m(e, t?.convert);
271
41
  }
272
- function W(r, t) {
273
- const e = $(r, t?.convert);
274
- return G(e, t?.print);
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
- C as attribute,
278
- D as digraph,
279
- T as fromDot,
280
- B as graph,
281
- F as strict,
282
- W as toDot,
283
- P as withContext
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-20240225160253",
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-20240225160253",
66
- "@ts-graphviz/ast": "^0.0.0-pr956-20240225160253",
67
- "@ts-graphviz/common": "^0.0.0-pr956-20240225160253",
68
- "@ts-graphviz/core": "^0.0.0-pr956-20240225160253"
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",