ts-graphviz 0.15.1 → 1.0.0-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/LICENSE +1 -1
- package/README.ja.md +379 -0
- package/README.md +280 -174
- package/lib/ast/index.cjs +5543 -0
- package/lib/ast/index.d.ts +387 -0
- package/lib/ast/index.js +5527 -0
- package/lib/common/index.cjs +47 -0
- package/lib/common/index.d.ts +2092 -0
- package/lib/common/index.js +45 -0
- package/lib/core/index.cjs +446 -0
- package/lib/core/index.d.ts +3027 -0
- package/lib/core/index.js +444 -0
- package/lib/index.cjs +25 -0
- package/lib/index.d.ts +2 -3456
- package/lib/index.js +2 -16
- package/lib/utils/index.cjs +43 -0
- package/lib/utils/index.d.ts +22 -0
- package/lib/utils/index.js +37 -0
- package/media/state-machine.dot +10 -0
- package/media/state-machine.svg +1 -0
- package/media/ts-graphviz.dot +20 -0
- package/media/ts-graphviz.svg +1 -0
- package/package.json +58 -35
- package/tsconfig.build.json +8 -0
- package/lib/bundle.min.js +0 -16
- package/lib/index.mjs +0 -16
- package/scripts/build.ts +0 -42
package/lib/index.js
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Copyright (c) Microsoft Corporation.
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted.
|
|
7
|
-
|
|
8
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */
|
|
16
|
-
var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function o(t,e){for(var r=0,n=e.length,o=t.length;r<n;r++,o++)t[o]=e[r];return t}var i=function(){},a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(i),s=function(t){function e(e){var r=t.call(this)||this;return r.attrs=new Map,void 0!==e&&r.apply(e),r}return r(e,t),Object.defineProperty(e.prototype,"values",{get:function(){return Array.from(this.attrs.entries())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.attrs.size},enumerable:!1,configurable:!0}),e.prototype.get=function(t){return this.attrs.get(t)},e.prototype.set=function(t,e){null!=e&&this.attrs.set(t,e)},e.prototype.delete=function(t){this.attrs.delete(t)},e.prototype.apply=function(t){for(var e=0,r=Array.isArray(t)?t:Object.entries(t);e<r.length;e++){var n=r[e],o=n[0],i=n[1];this.set(o,i)}},e.prototype.clear=function(){this.attrs.clear()},e}(a),u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(s),p=function(t){function e(e,r){var n=t.call(this)||this;return n.id=e,n.attributes=new u(r),n}return r(e,t),e.prototype.port=function(t){return"string"==typeof t?{id:this.id,port:t}:n({id:this.id},t)},e}(a);function l(t){return"object"==typeof t&&null!==t&&"string"==typeof t.id}function c(t){return t instanceof p||l(t)}function f(t){return"string"==typeof t||c(t)}function d(t){return Array.isArray(t)&&t.every(f)}var h=function(t){function e(e,r){var n=t.call(this)||this;if(n.targets=e,e.length<2&&!1===(f(e[0])&&f(e[1])))throw Error("The element of Edge target is missing or not satisfied as Edge target.");return n.attributes=new u(r),n}return r(e,t),e}(a),g=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.objects={nodes:new Map,edges:new Set,subgraphs:new Set},e}return r(e,t),Object.defineProperty(e.prototype,"nodes",{get:function(){return Array.from(this.objects.nodes.values())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"edges",{get:function(){return Array.from(this.objects.edges.values())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subgraphs",{get:function(){return Array.from(this.objects.subgraphs.values())},enumerable:!1,configurable:!0}),e.prototype.addNode=function(t){this.objects.nodes.set(t.id,t)},e.prototype.addEdge=function(t){this.objects.edges.add(t)},e.prototype.addSubgraph=function(t){this.objects.subgraphs.add(t)},e.prototype.existNode=function(t){return this.objects.nodes.has(t)},e.prototype.existEdge=function(t){return this.objects.edges.has(t)},e.prototype.existSubgraph=function(t){return this.objects.subgraphs.has(t)},e.prototype.createSubgraph=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=t.find((function(t){return"string"==typeof t})),n=t.find((function(t){return"object"==typeof t})),o=new b(r,n);return this.objects.subgraphs.add(o),o},e.prototype.removeNode=function(t){this.objects.nodes.delete("string"==typeof t?t:t.id)},e.prototype.removeEdge=function(t){this.objects.edges.delete(t)},e.prototype.removeSubgraph=function(t){this.objects.subgraphs.delete(t)},e.prototype.createNode=function(t,e){var r=new p(t,e);return this.objects.nodes.set(t,r),r},e.prototype.getSubgraph=function(t){return Array.from(this.objects.subgraphs.values()).find((function(e){return e.id===t}))},e.prototype.getNode=function(t){return this.objects.nodes.get(t)},e.prototype.createEdge=function(t,e){var r=this,n=new h(t.map((function(t){return d(t)?r.toEdgeTargets(t):r.toEdgeTarget(t)})),e);return this.objects.edges.add(n),n},e.prototype.toEdgeTarget=function(t){if(c(t))return t;var e=t.split(":"),r=e[0],n=e[1],o=e[2],i=this.getNode(r);return void 0!==i?n&&(void 0===o||exports.Compass.is(o))?i.port({port:n,compass:o}):i:exports.Compass.is(o)?{id:r,port:n,compass:o}:{id:r,port:n}},e.prototype.toEdgeTargets=function(t){var e=this;if(t.length<2&&!1===(f(t[0])&&f(t[1])))throw Error("EdgeTargets must have at least 2 elements.");return t.map((function(t){return e.toEdgeTarget(t)}))},e.prototype.subgraph=function(){for(var t,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=e.find((function(t){return"string"==typeof t})),o=e.find((function(t){return"object"==typeof t&&null!==t})),i=e.find((function(t){return"function"==typeof t})),a=n?null!==(t=this.getSubgraph(n))&&void 0!==t?t:this.createSubgraph(n):this.createSubgraph();return void 0!==o&&a.apply(o),void 0!==i&&i(a),a},e.prototype.node=function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("string"==typeof t){var o=t,i=r.find((function(t){return"object"==typeof t&&null!==t})),a=r.find((function(t){return"function"==typeof t})),s=null!==(e=this.getNode(o))&&void 0!==e?e:this.createNode(o);return void 0!==i&&s.attributes.apply(i),void 0!==a&&a(s),s}"object"==typeof t&&null!==t&&this.attributes.node.apply(t)},e.prototype.edge=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(Array.isArray(t)){var n=o([],t),i=e.find((function(t){return"object"==typeof t})),a=e.find((function(t){return"function"==typeof t})),s=this.createEdge(n,i);return void 0!==a&&a(s),s}"object"==typeof t&&null!==t&&this.attributes.edge.apply(t)},e.prototype.graph=function(t){this.attributes.graph.apply(t)},e}(s),b=function(t){function e(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=t.call(this)||this;n.attributes={graph:new u,edge:new u,node:new u},n.id=e.find((function(t){return"string"==typeof t}));var o=e.find((function(t){return"object"==typeof t}));return void 0!==o&&n.apply(o),n}return r(e,t),e.prototype.isSubgraphCluster=function(){return"string"==typeof this.id&&this.id.startsWith("cluster")},e}(g),y=function(t){function e(){for(var e,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var o=t.call(this)||this;o.attributes={graph:new u,edge:new u,node:new u},o.id=r.find((function(t){return"string"==typeof t})),o.strict=null!==(e=r.find((function(t){return"boolean"==typeof t})))&&void 0!==e&&e;var i=r.find((function(t){return"object"==typeof t&&null!==t}));return void 0!==i&&o.apply(i),o}return r(e,t),e}(g),v=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(y),m=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(y);function w(t,e){return void 0===e&&(e=!1),function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var o=r.find((function(t){return"string"==typeof t})),i=r.find((function(t){return"object"==typeof t})),a=r.find((function(t){return"function"==typeof t})),s=new t(o,i,e);return"function"==typeof a&&a(s),s}}var j=w(m),x=w(v),k={digraph:w(m,!0),graph:w(v,!0)};var _,z,E=(_='"',function(t){return function(t,e){return""+e+t+e}(t,_)}),O=(z=" ",function(t){if("string"==typeof t)return function(t,e){return""+e+t}(t,z)});function S(t){return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return e.filter((function(t){return"string"==typeof t})).join(t)}}var A=S(" "),C=S(":"),R=S("\n"),N=S("");function L(t){return t.split("\n").map((function(t){return N(" ",t)})).join("\n")}function T(t){return"string"==typeof t?function(t){return t.split("\n").map((function(t){return N("// ",t).trim()})).join("\n")}(t):void 0}function U(t){return t instanceof b}function P(t){return t instanceof p}function D(t){return t instanceof v}function q(t){return t instanceof m?"digraph":D(t)?"graph":U(t)?"subgraph":void 0}function M(t){var e="string"!=typeof t,r=!1,n=!1,o="string"==typeof t?t:t.toString();if(e)r=!1;else{var i=o.trim();(r=/^<.+>$/ms.test(i))?o=i:n=!0}return e||r?o:n?E(o.replace(/\n/g,"\\n").replace(/"/g,'\\"')):o}function G(t){return function(e){var r=e[0],n=e[1];return N(r," = ",M(n),t)}}var K=G(";"),B=G(",");function F(t){return 0===t.size?"":R("[",L(R.apply(void 0,o([T(t.comment)],t.values.map(B)))),"]")}function W(t){if(P(t))return M(t.id);if(l(t)){var e=t.port,r=t.compass;return C(M(t.id),void 0!==e?M(e):void 0,void 0!==r?M(r):void 0)}}var $=function(){function t(){}return t.prototype.renderNode=function(t){var e=T(t.comment),r=W(t),n=t.attributes.size>0?O(F(t.attributes)):void 0,o=N(r,n,";");return R(e,o)},t.prototype.renderEdge=function(t){var e,r=T(t.comment),n=(e=D(this.root)?" -- ":" -> ",t.targets.map((function(t){return f(t)?W(t):(e=t,"{"+A.apply(void 0,e.map(W))+"}");var e})).filter((function(t){return"string"==typeof t})).join(e)),o=t.attributes.size>0?O(F(t.attributes)):void 0,i=N(n,o,";");return R(r,i)},t.prototype.renderCluster=function(t){var e=q(t),r=void 0!==t.id?M(t.id):void 0,n=t.values.map(K),i=Object.entries(t.attributes).filter((function(t){return t[1].size>0})).map((function(t){var e=t[0],r=t[1];return N(e," ",F(r),";")})),a=t.nodes.map(this.renderNode.bind(this)),s=t.subgraphs.map(this.renderSubgraph.bind(this)),u=t.edges.map(this.renderEdge.bind(this)),p=R.apply(void 0,o(o(o(o(o([],n),i),a),s),u));return R(A(e,r,"{"),p.length>0?L(p):void 0,"}")},t.prototype.renderRootCluster=function(t){var e=T(t.comment),r=this.renderCluster(t);return R(e,A(t.strict?"strict":void 0,r))},t.prototype.renderSubgraph=function(t){var e=T(t.comment),r=this.renderCluster(t);return R(e,r)},t.prototype.render=function(t){return P(t)?this.renderNode(t):function(t){return t instanceof h}(t)?this.renderEdge(t):function(t){return t instanceof u}(t)?F(t):U(t)?this.renderSubgraph(t):function(t){return t instanceof y}(t)?(this.root=t,this.renderRootCluster(t)):M(t)},t}();exports.Attributes=u,exports.AttributesBase=s,exports.Cluster=g,exports.Digraph=m,exports.DotObject=a,exports.Edge=h,exports.Graph=v,exports.GraphvizObject=i,exports.Node=p,exports.RootCluster=y,exports.Subgraph=b,exports.digraph=j,exports.graph=x,exports.isEdgeTarget=c,exports.isEdgeTargetLike=f,exports.isEdgeTargetsLike=d,exports.isForwardRefNode=l,exports.strict=k,exports.toDot=function(t){return(new $).render(t)};
|
|
1
|
+
export * from '#/lib/common';
|
|
2
|
+
export * from '#/lib/core';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _pipe(...args) {
|
|
6
|
+
const [o1, ...operations] = args;
|
|
7
|
+
return (...t) => operations.reduce((acc, f) => f(acc), o1(...t));
|
|
8
|
+
}
|
|
9
|
+
function pipe(o1, ...operations) {
|
|
10
|
+
return _pipe(o1, ...operations);
|
|
11
|
+
}
|
|
12
|
+
const defer =
|
|
13
|
+
(fn) =>
|
|
14
|
+
(...args) =>
|
|
15
|
+
(src) =>
|
|
16
|
+
fn(src, ...args);
|
|
17
|
+
const toIterable = (f) => ({
|
|
18
|
+
[Symbol.iterator]: f,
|
|
19
|
+
});
|
|
20
|
+
const map = defer((src, selector) =>
|
|
21
|
+
Array.from(
|
|
22
|
+
toIterable(function* () {
|
|
23
|
+
for (const v of src) {
|
|
24
|
+
yield selector(v);
|
|
25
|
+
}
|
|
26
|
+
}),
|
|
27
|
+
),
|
|
28
|
+
);
|
|
29
|
+
const filter = defer((src, pred) =>
|
|
30
|
+
Array.from(
|
|
31
|
+
toIterable(function* () {
|
|
32
|
+
for (const x of src) {
|
|
33
|
+
if (pred(x)) {
|
|
34
|
+
yield x;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
exports.filter = filter;
|
|
42
|
+
exports.map = map;
|
|
43
|
+
exports.pipe = pipe;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare type F<A extends any[], O> = (...args: A) => O;
|
|
2
|
+
declare type IO<I, O> = F<[I], O>;
|
|
3
|
+
declare function pipe<I extends any[], O>(f0: F<I, O>): F<I, O>;
|
|
4
|
+
declare function pipe<I extends any[], T1, O>(f0: F<I, T1>, f1: IO<T1, O>): F<I, O>;
|
|
5
|
+
declare function pipe<I extends any[], T1, T2, O>(f0: F<I, T1>, f1: IO<T1, T2>, f2: IO<T2, O>): F<I, O>;
|
|
6
|
+
declare function pipe<I extends any[], T1, T2, T3, O>(
|
|
7
|
+
f0: F<I, T1>,
|
|
8
|
+
f1: IO<T1, T2>,
|
|
9
|
+
f2: IO<T2, T3>,
|
|
10
|
+
f3: IO<T3, O>,
|
|
11
|
+
): F<I, O>;
|
|
12
|
+
declare function pipe<I extends any[], T1, T2, T3, T4, O>(
|
|
13
|
+
f0: F<I, T1>,
|
|
14
|
+
f1: IO<T1, T2>,
|
|
15
|
+
f2: IO<T2, T3>,
|
|
16
|
+
f3: IO<T3, T4>,
|
|
17
|
+
f4: IO<T4, O>,
|
|
18
|
+
): F<I, O>;
|
|
19
|
+
declare const map: <T, O>(selector: (item: T) => O) => (src: Iterable<T>) => O[];
|
|
20
|
+
declare const filter: <T>(pred: (item: T) => boolean) => (src: Iterable<T>) => T[];
|
|
21
|
+
|
|
22
|
+
export { F, IO, filter, map, pipe };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
function _pipe(...args) {
|
|
2
|
+
const [o1, ...operations] = args;
|
|
3
|
+
return (...t) => operations.reduce((acc, f) => f(acc), o1(...t));
|
|
4
|
+
}
|
|
5
|
+
function pipe(o1, ...operations) {
|
|
6
|
+
return _pipe(o1, ...operations);
|
|
7
|
+
}
|
|
8
|
+
const defer =
|
|
9
|
+
(fn) =>
|
|
10
|
+
(...args) =>
|
|
11
|
+
(src) =>
|
|
12
|
+
fn(src, ...args);
|
|
13
|
+
const toIterable = (f) => ({
|
|
14
|
+
[Symbol.iterator]: f,
|
|
15
|
+
});
|
|
16
|
+
const map = defer((src, selector) =>
|
|
17
|
+
Array.from(
|
|
18
|
+
toIterable(function* () {
|
|
19
|
+
for (const v of src) {
|
|
20
|
+
yield selector(v);
|
|
21
|
+
}
|
|
22
|
+
}),
|
|
23
|
+
),
|
|
24
|
+
);
|
|
25
|
+
const filter = defer((src, pred) =>
|
|
26
|
+
Array.from(
|
|
27
|
+
toIterable(function* () {
|
|
28
|
+
for (const x of src) {
|
|
29
|
+
if (pred(x)) {
|
|
30
|
+
yield x;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}),
|
|
34
|
+
),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export { filter, map, pipe };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="383pt" height="152pt" viewBox="0 0 382.84 152.44" xmlns="http://www.w3.org/2000/svg"><g class="graph" transform="translate(4 148.44)"><path fill="#fff" stroke="transparent" d="M-4 4v-152.44h382.84V4H-4z"/><g class="node"><circle fill="none" stroke="#000" cx="39.65" cy="-39.65" r="39.79"/><text text-anchor="middle" x="39.65" y="-35.95" font-family="Times,serif" font-size="14">Model</text></g><g class="node"><circle fill="none" stroke="#000" cx="204.65" cy="-39.65" r="29.5"/><text text-anchor="middle" x="204.65" y="-35.95" font-family="Times,serif" font-size="14">AST</text></g><g class="edge"><path fill="none" stroke="#000" d="M79.59-39.65h85.36"/><path stroke="#000" d="m165.16-43.15 10 3.5-10 3.5v-7z"/><text text-anchor="middle" x="127.35" y="-46.45" font-family="Times,serif" font-size="14">fromModel</text></g><g class="node"><circle fill="none" stroke="#000" cx="343.65" cy="-39.65" r="31.4"/><text text-anchor="middle" x="343.65" y="-35.95" font-family="Times,serif" font-size="14">DOT</text></g><g class="edge"><path fill="none" stroke="#000" d="M71.74-62.96c34.78-22.43 92.24-51.3 143.91-39.33 33.48 7.75 68.33 25.54 93.19 40.19"/><path stroke="#000" d="m310.76-65.03 6.76 8.16-10.37-2.16 3.61-6z"/><text text-anchor="middle" x="195.65" y="-101.09" font-family="Times,serif" font-size="14">toDot</text></g><g class="edge"><path fill="none" stroke="#000" d="M234.12-39.65h68.13"/><path stroke="#000" d="m302.28-43.15 10 3.5-10 3.5v-7z"/><text text-anchor="middle" x="273.17" y="-46.45" font-family="Times,serif" font-size="14">stringify</text></g><g class="edge"><path fill="none" stroke="#000" d="M314.74-27.44c-6.94 2.4-14.42 4.56-21.57 5.79-17.52 3.03-22.5 3.14-40 0-3.92-.7-7.93-1.7-11.89-2.87"/><path stroke="#000" d="m240.02-21.25-8.39-6.46 10.59-.18-2.2 6.64z"/><text text-anchor="middle" x="273.17" y="-25.45" font-family="Times,serif" font-size="14">parse</text></g></g></svg>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
digraph state_machine {
|
|
2
|
+
rankdir = LR;
|
|
3
|
+
node [ shape = circle ]
|
|
4
|
+
|
|
5
|
+
// { rank = same; builder_fn; Model; DOT; }
|
|
6
|
+
|
|
7
|
+
builder_fn [
|
|
8
|
+
shape = record,
|
|
9
|
+
label = "{{Builder Functions | strict.digraph(...)\lstrict.graph(...)\ldigraph(...)\lgraph(...)\l}}"
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
oop [
|
|
13
|
+
shape = record,
|
|
14
|
+
label = "{{Object Oriented Programing | new Digraph(...)\lnew Graph(...)\l...\l}}"
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
{builder_fn, oop} -> Model;
|
|
18
|
+
|
|
19
|
+
Model -> DOT [ label = "toDot" ]
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="644" height="196pt" viewBox="0 0 482.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.5h482.69V4H-4z"/><g class="node"><path fill="none" stroke="#000" d="M38-96v-91h144v91H38z"/><text text-anchor="middle" x="110" y="-171.8" font-family="Times,serif" font-size="14">Builder Functions</text><path fill="none" stroke="#000" d="M38-164h144"/><text x="46" y="-148.8" font-family="Times,serif" font-size="14">strict.digraph(...)</text><text x="46" y="-133.8" font-family="Times,serif" font-size="14">strict.graph(...)</text><text x="46" y="-118.8" font-family="Times,serif" font-size="14">digraph(...)</text><text x="46" 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="M182.13-121.47c22.24 6.27 46.23 13.02 66.39 18.7"/><path stroke="#000" d="m249.71-106.07 8.68 6.08-10.57.66 1.89-6.74z"/></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="443.49" cy="-89.5" r="31.4"/><text text-anchor="middle" x="443.49" y="-85.8" font-family="Times,serif" font-size="14">DOT</text></g><g class="edge"><path fill="none" stroke="#000" d="M336.46-89.5h65.12"/><path stroke="#000" d="m401.83-93 10 3.5-10 3.5v-7z"/><text text-anchor="middle" x="374.29" y="-93.3" font-family="Times,serif" font-size="14">toDot</text></g></g></svg>
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-graphviz",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-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/",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
10
|
"url": "https://github.com/ts-graphviz/ts-graphviz.git"
|
|
@@ -19,45 +20,67 @@
|
|
|
19
20
|
"type": "github",
|
|
20
21
|
"url": "https://github.com/sponsors/kamiazya"
|
|
21
22
|
},
|
|
22
|
-
"main": "./lib/index.
|
|
23
|
+
"main": "./lib/index.cjs",
|
|
24
|
+
"module": "./lib/index.js",
|
|
25
|
+
"types": "lib/index.d.ts",
|
|
23
26
|
"exports": {
|
|
24
|
-
"
|
|
25
|
-
|
|
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
|
+
}
|
|
26
44
|
},
|
|
27
|
-
"unpkg": "lib/bundle.min.js",
|
|
28
|
-
"types": "lib/index.d.ts",
|
|
29
45
|
"license": "MIT",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"test": "jest",
|
|
33
|
-
"format": "eslint -c .eslintrc.json --ext ts src --fix && prettier --write './src/**/*.ts'",
|
|
34
|
-
"lint": "eslint -c .eslintrc.json --ext ts src",
|
|
35
|
-
"doc": "typedoc src/index.ts"
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=14.16"
|
|
36
48
|
},
|
|
37
|
-
"
|
|
38
|
-
"
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build:peggy": "peggy --plugin ts-pegjs --extra-options-file src/ast/parser/peggy.options.json -o src/ast/parser/index.ts src/ast/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"
|
|
39
60
|
},
|
|
40
61
|
"devDependencies": {
|
|
41
|
-
"@types/jest": "^
|
|
42
|
-
"@types/
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
44
|
-
"@typescript-eslint/parser": "^
|
|
45
|
-
"eslint": "^
|
|
46
|
-
"eslint-config-prettier": "^8.
|
|
47
|
-
"eslint-plugin-import": "^2.
|
|
48
|
-
"eslint-plugin-jest": "^
|
|
49
|
-
"eslint-plugin-prettier": "^
|
|
50
|
-
"jest": "^
|
|
51
|
-
"jest-
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"rollup
|
|
57
|
-
"rollup-plugin-
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
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.22.4",
|
|
84
|
+
"typescript": "^4.7.4"
|
|
62
85
|
}
|
|
63
86
|
}
|
package/lib/bundle.min.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).graphviz={})}(this,(function(t){"use strict";var e;t.attribute=void 0,(e=t.attribute||(t.attribute={})).Damping="Damping",e.K="K",e.URL="URL",e._background="_background",e.area="area",e.arrowhead="arrowhead",e.arrowsize="arrowsize",e.arrowtail="arrowtail",e.bb="bb",e.bgcolor="bgcolor",e.center="center",e.charset="charset",e.clusterrank="clusterrank",e.color="color",e.colorscheme="colorscheme",e.comment="comment",e.compound="compound",e.concentrate="concentrate",e.constraint="constraint",e.decorate="decorate",e.defaultdist="defaultdist",e.dim="dim",e.dimen="dimen",e.dir="dir",e.diredgeconstraints="diredgeconstraints",e.distortion="distortion",e.dpi="dpi",e.edgeURL="edgeURL",e.edgehref="edgehref",e.edgetarget="edgetarget",e.edgetooltip="edgetooltip",e.epsilon="epsilon",e.esep="esep",e.fillcolor="fillcolor",e.fixedsize="fixedsize",e.fontcolor="fontcolor",e.fontname="fontname",e.fontnames="fontnames",e.fontpath="fontpath",e.fontsize="fontsize",e.forcelabels="forcelabels",e.gradientangle="gradientangle",e.group="group",e.headURL="headURL",e.head_lp="head_lp",e.headclip="headclip",e.headhref="headhref",e.headlabel="headlabel",e.headport="headport",e.headtarget="headtarget",e.headtooltip="headtooltip",e.height="height",e.href="href",e.id="id",e.image="image",e.imagepath="imagepath",e.imagepos="imagepos",e.imagescale="imagescale",e.inputscale="inputscale",e.label="label",e.labelURL="labelURL",e.label_scheme="label_scheme",e.labelangle="labelangle",e.labeldistance="labeldistance",e.labelfloat="labelfloat",e.labelfontcolor="labelfontcolor",e.labelfontname="labelfontname",e.labelfontsize="labelfontsize",e.labelhref="labelhref",e.labeljust="labeljust",e.labelloc="labelloc",e.labeltarget="labeltarget",e.labeltooltip="labeltooltip",e.landscape="landscape",e.layer="layer",e.layerlistsep="layerlistsep",e.layers="layers",e.layerselect="layerselect",e.layersep="layersep",e.layout="layout",e.len="len",e.levels="levels",e.levelsgap="levelsgap",e.lhead="lhead",e.lheight="lheight",e.lp="lp",e.ltail="ltail",e.lwidth="lwidth",e.margin="margin",e.maxiter="maxiter",e.mclimit="mclimit",e.mindist="mindist",e.minlen="minlen",e.mode="mode",e.model="model",e.mosek="mosek",e.newrank="newrank",e.nodesep="nodesep",e.nojustify="nojustify",e.normalize="normalize",e.notranslate="notranslate",e.nslimit="nslimit",e.nslimit1="nslimit1",e.ordering="ordering",e.orientation="orientation",e.outputorder="outputorder",e.overlap="overlap",e.overlap_scaling="overlap_scaling",e.overlap_shrink="overlap_shrink",e.pack="pack",e.packmode="packmode",e.pad="pad",e.page="page",e.pagedir="pagedir",e.pencolor="pencolor",e.penwidth="penwidth",e.peripheries="peripheries",e.pin="pin",e.pos="pos",e.quadtree="quadtree",e.quantum="quantum",e.rank="rank",e.rankdir="rankdir",e.ranksep="ranksep",e.ratio="ratio",e.rects="rects",e.regular="regular",e.remincross="remincross",e.repulsiveforce="repulsiveforce",e.resolution="resolution",e.root="root",e.rotate="rotate",e.rotation="rotation",e.samehead="samehead",e.sametail="sametail",e.samplepoints="samplepoints",e.scale="scale",e.searchsize="searchsize",e.sep="sep",e.shape="shape",e.shapefile="shapefile",e.showboxes="showboxes",e.sides="sides",e.size="size",e.skew="skew",e.smoothing="smoothing",e.sortv="sortv",e.splines="splines",e.start="start",e.style="style",e.stylesheet="stylesheet",e.tailURL="tailURL",e.tail_lp="tail_lp",e.tailclip="tailclip",e.tailhref="tailhref",e.taillabel="taillabel",e.tailport="tailport",e.tailtarget="tailtarget",e.tailtooltip="tailtooltip",e.target="target",e.tooltip="tooltip",e.truecolor="truecolor",e.vertices="vertices",e.viewport="viewport",e.voro_margin="voro_margin",e.weight="weight",e.width="width",e.xdotversion="xdotversion",e.xlabel="xlabel",e.xlp="xlp",e.z="z",t.Compass=void 0,function(t){t.n="n",t.ne="ne",t.e="e",t.se="se",t.s="s",t.sw="sw",t.w="w",t.nw="nw",t.c="c";var e=[t.n,t.ne,t.e,t.se,t.s,t.sw,t.w,t.nw,t.c];t.is=function(t){return e.includes(t)}}(t.Compass||(t.Compass={}));
|
|
2
|
-
/*! *****************************************************************************
|
|
3
|
-
Copyright (c) Microsoft Corporation.
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted.
|
|
7
|
-
|
|
8
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */
|
|
16
|
-
var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return(o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function i(t,e){for(var r=0,n=e.length,o=t.length;r<n;r++,o++)t[o]=e[r];return t}var a=function(){},s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(a),u=function(t){function e(e){var r=t.call(this)||this;return r.attrs=new Map,void 0!==e&&r.apply(e),r}return n(e,t),Object.defineProperty(e.prototype,"values",{get:function(){return Array.from(this.attrs.entries())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.attrs.size},enumerable:!1,configurable:!0}),e.prototype.get=function(t){return this.attrs.get(t)},e.prototype.set=function(t,e){null!=e&&this.attrs.set(t,e)},e.prototype.delete=function(t){this.attrs.delete(t)},e.prototype.apply=function(t){for(var e=0,r=Array.isArray(t)?t:Object.entries(t);e<r.length;e++){var n=r[e],o=n[0],i=n[1];this.set(o,i)}},e.prototype.clear=function(){this.attrs.clear()},e}(s),l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(u),p=function(t){function e(e,r){var n=t.call(this)||this;return n.id=e,n.attributes=new l(r),n}return n(e,t),e.prototype.port=function(t){return"string"==typeof t?{id:this.id,port:t}:o({id:this.id},t)},e}(s);function c(t){return"object"==typeof t&&null!==t&&"string"==typeof t.id}function f(t){return t instanceof p||c(t)}function d(t){return"string"==typeof t||f(t)}function h(t){return Array.isArray(t)&&t.every(d)}var g=function(t){function e(e,r){var n=t.call(this)||this;if(n.targets=e,e.length<2&&!1===(d(e[0])&&d(e[1])))throw Error("The element of Edge target is missing or not satisfied as Edge target.");return n.attributes=new l(r),n}return n(e,t),e}(s),b=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.objects={nodes:new Map,edges:new Set,subgraphs:new Set},t}return n(r,e),Object.defineProperty(r.prototype,"nodes",{get:function(){return Array.from(this.objects.nodes.values())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"edges",{get:function(){return Array.from(this.objects.edges.values())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subgraphs",{get:function(){return Array.from(this.objects.subgraphs.values())},enumerable:!1,configurable:!0}),r.prototype.addNode=function(t){this.objects.nodes.set(t.id,t)},r.prototype.addEdge=function(t){this.objects.edges.add(t)},r.prototype.addSubgraph=function(t){this.objects.subgraphs.add(t)},r.prototype.existNode=function(t){return this.objects.nodes.has(t)},r.prototype.existEdge=function(t){return this.objects.edges.has(t)},r.prototype.existSubgraph=function(t){return this.objects.subgraphs.has(t)},r.prototype.createSubgraph=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=t.find((function(t){return"string"==typeof t})),n=t.find((function(t){return"object"==typeof t})),o=new y(r,n);return this.objects.subgraphs.add(o),o},r.prototype.removeNode=function(t){this.objects.nodes.delete("string"==typeof t?t:t.id)},r.prototype.removeEdge=function(t){this.objects.edges.delete(t)},r.prototype.removeSubgraph=function(t){this.objects.subgraphs.delete(t)},r.prototype.createNode=function(t,e){var r=new p(t,e);return this.objects.nodes.set(t,r),r},r.prototype.getSubgraph=function(t){return Array.from(this.objects.subgraphs.values()).find((function(e){return e.id===t}))},r.prototype.getNode=function(t){return this.objects.nodes.get(t)},r.prototype.createEdge=function(t,e){var r=this,n=new g(t.map((function(t){return h(t)?r.toEdgeTargets(t):r.toEdgeTarget(t)})),e);return this.objects.edges.add(n),n},r.prototype.toEdgeTarget=function(e){if(f(e))return e;var r=e.split(":"),n=r[0],o=r[1],i=r[2],a=this.getNode(n);return void 0!==a?o&&(void 0===i||t.Compass.is(i))?a.port({port:o,compass:i}):a:t.Compass.is(i)?{id:n,port:o,compass:i}:{id:n,port:o}},r.prototype.toEdgeTargets=function(t){var e=this;if(t.length<2&&!1===(d(t[0])&&d(t[1])))throw Error("EdgeTargets must have at least 2 elements.");return t.map((function(t){return e.toEdgeTarget(t)}))},r.prototype.subgraph=function(){for(var t,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=e.find((function(t){return"string"==typeof t})),o=e.find((function(t){return"object"==typeof t&&null!==t})),i=e.find((function(t){return"function"==typeof t})),a=n?null!==(t=this.getSubgraph(n))&&void 0!==t?t:this.createSubgraph(n):this.createSubgraph();return void 0!==o&&a.apply(o),void 0!==i&&i(a),a},r.prototype.node=function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("string"==typeof t){var o=t,i=r.find((function(t){return"object"==typeof t&&null!==t})),a=r.find((function(t){return"function"==typeof t})),s=null!==(e=this.getNode(o))&&void 0!==e?e:this.createNode(o);return void 0!==i&&s.attributes.apply(i),void 0!==a&&a(s),s}"object"==typeof t&&null!==t&&this.attributes.node.apply(t)},r.prototype.edge=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(Array.isArray(t)){var n=i([],t),o=e.find((function(t){return"object"==typeof t})),a=e.find((function(t){return"function"==typeof t})),s=this.createEdge(n,o);return void 0!==a&&a(s),s}"object"==typeof t&&null!==t&&this.attributes.edge.apply(t)},r.prototype.graph=function(t){this.attributes.graph.apply(t)},r}(u),y=function(t){function e(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=t.call(this)||this;n.attributes={graph:new l,edge:new l,node:new l},n.id=e.find((function(t){return"string"==typeof t}));var o=e.find((function(t){return"object"==typeof t}));return void 0!==o&&n.apply(o),n}return n(e,t),e.prototype.isSubgraphCluster=function(){return"string"==typeof this.id&&this.id.startsWith("cluster")},e}(b),m=function(t){function e(){for(var e,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var o=t.call(this)||this;o.attributes={graph:new l,edge:new l,node:new l},o.id=r.find((function(t){return"string"==typeof t})),o.strict=null!==(e=r.find((function(t){return"boolean"==typeof t})))&&void 0!==e&&e;var i=r.find((function(t){return"object"==typeof t&&null!==t}));return void 0!==i&&o.apply(i),o}return n(e,t),e}(b),v=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(m),w=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(m);function j(t,e){return void 0===e&&(e=!1),function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var o=r.find((function(t){return"string"==typeof t})),i=r.find((function(t){return"object"==typeof t})),a=r.find((function(t){return"function"==typeof t})),s=new t(o,i,e);return"function"==typeof a&&a(s),s}}var k=j(w),z=j(v),_={digraph:j(w,!0),graph:j(v,!0)};var E,x,O=(E='"',function(t){return function(t,e){return""+e+t+e}(t,E)}),S=(x=" ",function(t){if("string"==typeof t)return function(t,e){return""+e+t}(t,x)});function A(t){return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return e.filter((function(t){return"string"==typeof t})).join(t)}}var C=A(" "),R=A(":"),N=A("\n"),T=A("");function L(t){return t.split("\n").map((function(t){return T(" ",t)})).join("\n")}function U(t){return"string"==typeof t?function(t){return t.split("\n").map((function(t){return T("// ",t).trim()})).join("\n")}(t):void 0}function P(t){return t instanceof y}function D(t){return t instanceof p}function q(t){return t instanceof v}function M(t){return t instanceof w?"digraph":q(t)?"graph":P(t)?"subgraph":void 0}function G(t){var e="string"!=typeof t,r=!1,n=!1,o="string"==typeof t?t:t.toString();if(e)r=!1;else{var i=o.trim();(r=/^<.+>$/ms.test(i))?o=i:n=!0}return e||r?o:n?O(o.replace(/\n/g,"\\n").replace(/"/g,'\\"')):o}function K(t){return function(e){var r=e[0],n=e[1];return T(r," = ",G(n),t)}}var B=K(";"),F=K(",");function W(t){return 0===t.size?"":N("[",L(N.apply(void 0,i([U(t.comment)],t.values.map(F)))),"]")}function $(t){if(D(t))return G(t.id);if(c(t)){var e=t.port,r=t.compass;return R(G(t.id),void 0!==e?G(e):void 0,void 0!==r?G(r):void 0)}}var H=function(){function t(){}return t.prototype.renderNode=function(t){var e=U(t.comment),r=$(t),n=t.attributes.size>0?S(W(t.attributes)):void 0,o=T(r,n,";");return N(e,o)},t.prototype.renderEdge=function(t){var e,r=U(t.comment),n=(e=q(this.root)?" -- ":" -> ",t.targets.map((function(t){return d(t)?$(t):(e=t,"{"+C.apply(void 0,e.map($))+"}");var e})).filter((function(t){return"string"==typeof t})).join(e)),o=t.attributes.size>0?S(W(t.attributes)):void 0,i=T(n,o,";");return N(r,i)},t.prototype.renderCluster=function(t){var e=M(t),r=void 0!==t.id?G(t.id):void 0,n=t.values.map(B),o=Object.entries(t.attributes).filter((function(t){return t[1].size>0})).map((function(t){var e=t[0],r=t[1];return T(e," ",W(r),";")})),a=t.nodes.map(this.renderNode.bind(this)),s=t.subgraphs.map(this.renderSubgraph.bind(this)),u=t.edges.map(this.renderEdge.bind(this)),l=N.apply(void 0,i(i(i(i(i([],n),o),a),s),u));return N(C(e,r,"{"),l.length>0?L(l):void 0,"}")},t.prototype.renderRootCluster=function(t){var e=U(t.comment),r=this.renderCluster(t);return N(e,C(t.strict?"strict":void 0,r))},t.prototype.renderSubgraph=function(t){var e=U(t.comment),r=this.renderCluster(t);return N(e,r)},t.prototype.render=function(t){return D(t)?this.renderNode(t):function(t){return t instanceof g}(t)?this.renderEdge(t):function(t){return t instanceof l}(t)?W(t):P(t)?this.renderSubgraph(t):function(t){return t instanceof m}(t)?(this.root=t,this.renderRootCluster(t)):G(t)},t}();t.Attributes=l,t.AttributesBase=u,t.Cluster=b,t.Digraph=w,t.DotObject=s,t.Edge=g,t.Graph=v,t.GraphvizObject=a,t.Node=p,t.RootCluster=m,t.Subgraph=y,t.digraph=k,t.graph=z,t.isEdgeTarget=f,t.isEdgeTargetLike=d,t.isEdgeTargetsLike=h,t.isForwardRefNode=c,t.strict=_,t.toDot=function(t){return(new H).render(t)},Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/lib/index.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
var t,e;!function(t){t.Damping="Damping",t.K="K",t.URL="URL",t._background="_background",t.area="area",t.arrowhead="arrowhead",t.arrowsize="arrowsize",t.arrowtail="arrowtail",t.bb="bb",t.bgcolor="bgcolor",t.center="center",t.charset="charset",t.clusterrank="clusterrank",t.color="color",t.colorscheme="colorscheme",t.comment="comment",t.compound="compound",t.concentrate="concentrate",t.constraint="constraint",t.decorate="decorate",t.defaultdist="defaultdist",t.dim="dim",t.dimen="dimen",t.dir="dir",t.diredgeconstraints="diredgeconstraints",t.distortion="distortion",t.dpi="dpi",t.edgeURL="edgeURL",t.edgehref="edgehref",t.edgetarget="edgetarget",t.edgetooltip="edgetooltip",t.epsilon="epsilon",t.esep="esep",t.fillcolor="fillcolor",t.fixedsize="fixedsize",t.fontcolor="fontcolor",t.fontname="fontname",t.fontnames="fontnames",t.fontpath="fontpath",t.fontsize="fontsize",t.forcelabels="forcelabels",t.gradientangle="gradientangle",t.group="group",t.headURL="headURL",t.head_lp="head_lp",t.headclip="headclip",t.headhref="headhref",t.headlabel="headlabel",t.headport="headport",t.headtarget="headtarget",t.headtooltip="headtooltip",t.height="height",t.href="href",t.id="id",t.image="image",t.imagepath="imagepath",t.imagepos="imagepos",t.imagescale="imagescale",t.inputscale="inputscale",t.label="label",t.labelURL="labelURL",t.label_scheme="label_scheme",t.labelangle="labelangle",t.labeldistance="labeldistance",t.labelfloat="labelfloat",t.labelfontcolor="labelfontcolor",t.labelfontname="labelfontname",t.labelfontsize="labelfontsize",t.labelhref="labelhref",t.labeljust="labeljust",t.labelloc="labelloc",t.labeltarget="labeltarget",t.labeltooltip="labeltooltip",t.landscape="landscape",t.layer="layer",t.layerlistsep="layerlistsep",t.layers="layers",t.layerselect="layerselect",t.layersep="layersep",t.layout="layout",t.len="len",t.levels="levels",t.levelsgap="levelsgap",t.lhead="lhead",t.lheight="lheight",t.lp="lp",t.ltail="ltail",t.lwidth="lwidth",t.margin="margin",t.maxiter="maxiter",t.mclimit="mclimit",t.mindist="mindist",t.minlen="minlen",t.mode="mode",t.model="model",t.mosek="mosek",t.newrank="newrank",t.nodesep="nodesep",t.nojustify="nojustify",t.normalize="normalize",t.notranslate="notranslate",t.nslimit="nslimit",t.nslimit1="nslimit1",t.ordering="ordering",t.orientation="orientation",t.outputorder="outputorder",t.overlap="overlap",t.overlap_scaling="overlap_scaling",t.overlap_shrink="overlap_shrink",t.pack="pack",t.packmode="packmode",t.pad="pad",t.page="page",t.pagedir="pagedir",t.pencolor="pencolor",t.penwidth="penwidth",t.peripheries="peripheries",t.pin="pin",t.pos="pos",t.quadtree="quadtree",t.quantum="quantum",t.rank="rank",t.rankdir="rankdir",t.ranksep="ranksep",t.ratio="ratio",t.rects="rects",t.regular="regular",t.remincross="remincross",t.repulsiveforce="repulsiveforce",t.resolution="resolution",t.root="root",t.rotate="rotate",t.rotation="rotation",t.samehead="samehead",t.sametail="sametail",t.samplepoints="samplepoints",t.scale="scale",t.searchsize="searchsize",t.sep="sep",t.shape="shape",t.shapefile="shapefile",t.showboxes="showboxes",t.sides="sides",t.size="size",t.skew="skew",t.smoothing="smoothing",t.sortv="sortv",t.splines="splines",t.start="start",t.style="style",t.stylesheet="stylesheet",t.tailURL="tailURL",t.tail_lp="tail_lp",t.tailclip="tailclip",t.tailhref="tailhref",t.taillabel="taillabel",t.tailport="tailport",t.tailtarget="tailtarget",t.tailtooltip="tailtooltip",t.target="target",t.tooltip="tooltip",t.truecolor="truecolor",t.vertices="vertices",t.viewport="viewport",t.voro_margin="voro_margin",t.weight="weight",t.width="width",t.xdotversion="xdotversion",t.xlabel="xlabel",t.xlp="xlp",t.z="z"}(t||(t={})),function(t){t.n="n",t.ne="ne",t.e="e",t.se="se",t.s="s",t.sw="sw",t.w="w",t.nw="nw",t.c="c";var e=[t.n,t.ne,t.e,t.se,t.s,t.sw,t.w,t.nw,t.c];t.is=function(t){return e.includes(t)}}(e||(e={}));
|
|
2
|
-
/*! *****************************************************************************
|
|
3
|
-
Copyright (c) Microsoft Corporation.
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted.
|
|
7
|
-
|
|
8
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */
|
|
16
|
-
var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return(o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function i(t,e){for(var r=0,n=e.length,o=t.length;r<n;r++,o++)t[o]=e[r];return t}var a=function(){},s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(a),u=function(t){function e(e){var r=t.call(this)||this;return r.attrs=new Map,void 0!==e&&r.apply(e),r}return n(e,t),Object.defineProperty(e.prototype,"values",{get:function(){return Array.from(this.attrs.entries())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.attrs.size},enumerable:!1,configurable:!0}),e.prototype.get=function(t){return this.attrs.get(t)},e.prototype.set=function(t,e){null!=e&&this.attrs.set(t,e)},e.prototype.delete=function(t){this.attrs.delete(t)},e.prototype.apply=function(t){for(var e=0,r=Array.isArray(t)?t:Object.entries(t);e<r.length;e++){var n=r[e],o=n[0],i=n[1];this.set(o,i)}},e.prototype.clear=function(){this.attrs.clear()},e}(s),l=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(u),p=function(t){function e(e,r){var n=t.call(this)||this;return n.id=e,n.attributes=new l(r),n}return n(e,t),e.prototype.port=function(t){return"string"==typeof t?{id:this.id,port:t}:o({id:this.id},t)},e}(s);function c(t){return"object"==typeof t&&null!==t&&"string"==typeof t.id}function f(t){return t instanceof p||c(t)}function d(t){return"string"==typeof t||f(t)}function h(t){return Array.isArray(t)&&t.every(d)}var g=function(t){function e(e,r){var n=t.call(this)||this;if(n.targets=e,e.length<2&&!1===(d(e[0])&&d(e[1])))throw Error("The element of Edge target is missing or not satisfied as Edge target.");return n.attributes=new l(r),n}return n(e,t),e}(s),b=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.objects={nodes:new Map,edges:new Set,subgraphs:new Set},e}return n(r,t),Object.defineProperty(r.prototype,"nodes",{get:function(){return Array.from(this.objects.nodes.values())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"edges",{get:function(){return Array.from(this.objects.edges.values())},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"subgraphs",{get:function(){return Array.from(this.objects.subgraphs.values())},enumerable:!1,configurable:!0}),r.prototype.addNode=function(t){this.objects.nodes.set(t.id,t)},r.prototype.addEdge=function(t){this.objects.edges.add(t)},r.prototype.addSubgraph=function(t){this.objects.subgraphs.add(t)},r.prototype.existNode=function(t){return this.objects.nodes.has(t)},r.prototype.existEdge=function(t){return this.objects.edges.has(t)},r.prototype.existSubgraph=function(t){return this.objects.subgraphs.has(t)},r.prototype.createSubgraph=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=t.find((function(t){return"string"==typeof t})),n=t.find((function(t){return"object"==typeof t})),o=new y(r,n);return this.objects.subgraphs.add(o),o},r.prototype.removeNode=function(t){this.objects.nodes.delete("string"==typeof t?t:t.id)},r.prototype.removeEdge=function(t){this.objects.edges.delete(t)},r.prototype.removeSubgraph=function(t){this.objects.subgraphs.delete(t)},r.prototype.createNode=function(t,e){var r=new p(t,e);return this.objects.nodes.set(t,r),r},r.prototype.getSubgraph=function(t){return Array.from(this.objects.subgraphs.values()).find((function(e){return e.id===t}))},r.prototype.getNode=function(t){return this.objects.nodes.get(t)},r.prototype.createEdge=function(t,e){var r=this,n=new g(t.map((function(t){return h(t)?r.toEdgeTargets(t):r.toEdgeTarget(t)})),e);return this.objects.edges.add(n),n},r.prototype.toEdgeTarget=function(t){if(f(t))return t;var r=t.split(":"),n=r[0],o=r[1],i=r[2],a=this.getNode(n);return void 0!==a?o&&(void 0===i||e.is(i))?a.port({port:o,compass:i}):a:e.is(i)?{id:n,port:o,compass:i}:{id:n,port:o}},r.prototype.toEdgeTargets=function(t){var e=this;if(t.length<2&&!1===(d(t[0])&&d(t[1])))throw Error("EdgeTargets must have at least 2 elements.");return t.map((function(t){return e.toEdgeTarget(t)}))},r.prototype.subgraph=function(){for(var t,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=e.find((function(t){return"string"==typeof t})),o=e.find((function(t){return"object"==typeof t&&null!==t})),i=e.find((function(t){return"function"==typeof t})),a=n?null!==(t=this.getSubgraph(n))&&void 0!==t?t:this.createSubgraph(n):this.createSubgraph();return void 0!==o&&a.apply(o),void 0!==i&&i(a),a},r.prototype.node=function(t){for(var e,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];if("string"==typeof t){var o=t,i=r.find((function(t){return"object"==typeof t&&null!==t})),a=r.find((function(t){return"function"==typeof t})),s=null!==(e=this.getNode(o))&&void 0!==e?e:this.createNode(o);return void 0!==i&&s.attributes.apply(i),void 0!==a&&a(s),s}"object"==typeof t&&null!==t&&this.attributes.node.apply(t)},r.prototype.edge=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(Array.isArray(t)){var n=i([],t),o=e.find((function(t){return"object"==typeof t})),a=e.find((function(t){return"function"==typeof t})),s=this.createEdge(n,o);return void 0!==a&&a(s),s}"object"==typeof t&&null!==t&&this.attributes.edge.apply(t)},r.prototype.graph=function(t){this.attributes.graph.apply(t)},r}(u),y=function(t){function e(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var n=t.call(this)||this;n.attributes={graph:new l,edge:new l,node:new l},n.id=e.find((function(t){return"string"==typeof t}));var o=e.find((function(t){return"object"==typeof t}));return void 0!==o&&n.apply(o),n}return n(e,t),e.prototype.isSubgraphCluster=function(){return"string"==typeof this.id&&this.id.startsWith("cluster")},e}(b),v=function(t){function e(){for(var e,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var o=t.call(this)||this;o.attributes={graph:new l,edge:new l,node:new l},o.id=r.find((function(t){return"string"==typeof t})),o.strict=null!==(e=r.find((function(t){return"boolean"==typeof t})))&&void 0!==e&&e;var i=r.find((function(t){return"object"==typeof t&&null!==t}));return void 0!==i&&o.apply(i),o}return n(e,t),e}(b),m=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(v),w=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(v);function j(t,e){return void 0===e&&(e=!1),function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var o=r.find((function(t){return"string"==typeof t})),i=r.find((function(t){return"object"==typeof t})),a=r.find((function(t){return"function"==typeof t})),s=new t(o,i,e);return"function"==typeof a&&a(s),s}}var k=j(w),z=j(m),_={digraph:j(w,!0),graph:j(m,!0)};var E,x,S=(E='"',function(t){return function(t,e){return""+e+t+e}(t,E)}),O=(x=" ",function(t){if("string"==typeof t)return function(t,e){return""+e+t}(t,x)});function A(t){return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return e.filter((function(t){return"string"==typeof t})).join(t)}}var R=A(" "),N=A(":"),L=A("\n"),U=A("");function P(t){return t.split("\n").map((function(t){return U(" ",t)})).join("\n")}function T(t){return"string"==typeof t?function(t){return t.split("\n").map((function(t){return U("// ",t).trim()})).join("\n")}(t):void 0}function C(t){return t instanceof y}function q(t){return t instanceof p}function D(t){return t instanceof m}function K(t){return t instanceof w?"digraph":D(t)?"graph":C(t)?"subgraph":void 0}function M(t){var e="string"!=typeof t,r=!1,n=!1,o="string"==typeof t?t:t.toString();if(e)r=!1;else{var i=o.trim();(r=/^<.+>$/ms.test(i))?o=i:n=!0}return e||r?o:n?S(o.replace(/\n/g,"\\n").replace(/"/g,'\\"')):o}function W(t){return function(e){var r=e[0],n=e[1];return U(r," = ",M(n),t)}}var $=W(";"),B=W(",");function F(t){return 0===t.size?"":L("[",P(L.apply(void 0,i([T(t.comment)],t.values.map(B)))),"]")}function G(t){if(q(t))return M(t.id);if(c(t)){var e=t.port,r=t.compass;return N(M(t.id),void 0!==e?M(e):void 0,void 0!==r?M(r):void 0)}}var H=function(){function t(){}return t.prototype.renderNode=function(t){var e=T(t.comment),r=G(t),n=t.attributes.size>0?O(F(t.attributes)):void 0,o=U(r,n,";");return L(e,o)},t.prototype.renderEdge=function(t){var e,r=T(t.comment),n=(e=D(this.root)?" -- ":" -> ",t.targets.map((function(t){return d(t)?G(t):(e=t,"{"+R.apply(void 0,e.map(G))+"}");var e})).filter((function(t){return"string"==typeof t})).join(e)),o=t.attributes.size>0?O(F(t.attributes)):void 0,i=U(n,o,";");return L(r,i)},t.prototype.renderCluster=function(t){var e=K(t),r=void 0!==t.id?M(t.id):void 0,n=t.values.map($),o=Object.entries(t.attributes).filter((function(t){return t[1].size>0})).map((function(t){var e=t[0],r=t[1];return U(e," ",F(r),";")})),a=t.nodes.map(this.renderNode.bind(this)),s=t.subgraphs.map(this.renderSubgraph.bind(this)),u=t.edges.map(this.renderEdge.bind(this)),l=L.apply(void 0,i(i(i(i(i([],n),o),a),s),u));return L(R(e,r,"{"),l.length>0?P(l):void 0,"}")},t.prototype.renderRootCluster=function(t){var e=T(t.comment),r=this.renderCluster(t);return L(e,R(t.strict?"strict":void 0,r))},t.prototype.renderSubgraph=function(t){var e=T(t.comment),r=this.renderCluster(t);return L(e,r)},t.prototype.render=function(t){return q(t)?this.renderNode(t):function(t){return t instanceof g}(t)?this.renderEdge(t):function(t){return t instanceof l}(t)?F(t):C(t)?this.renderSubgraph(t):function(t){return t instanceof v}(t)?(this.root=t,this.renderRootCluster(t)):M(t)},t}();function I(t){return(new H).render(t)}export{l as Attributes,u as AttributesBase,b as Cluster,e as Compass,w as Digraph,s as DotObject,g as Edge,m as Graph,a as GraphvizObject,p as Node,v as RootCluster,y as Subgraph,t as attribute,k as digraph,z as graph,f as isEdgeTarget,d as isEdgeTargetLike,h as isEdgeTargetsLike,c as isForwardRefNode,_ as strict,I as toDot};
|
package/scripts/build.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { rollup } from 'rollup';
|
|
3
|
-
import typescript from 'rollup-plugin-typescript2';
|
|
4
|
-
import dts from 'rollup-plugin-dts';
|
|
5
|
-
import { terser } from 'rollup-plugin-terser';
|
|
6
|
-
import rimraf from 'rimraf';
|
|
7
|
-
|
|
8
|
-
async function build(): Promise<void> {
|
|
9
|
-
await rollup({
|
|
10
|
-
input: path.resolve(__dirname, '../src/index.ts'),
|
|
11
|
-
plugins: [typescript(), terser()],
|
|
12
|
-
}).then((result) =>
|
|
13
|
-
Promise.all([
|
|
14
|
-
result.write({
|
|
15
|
-
format: 'cjs',
|
|
16
|
-
file: path.resolve(__dirname, '../lib/index.js'),
|
|
17
|
-
}),
|
|
18
|
-
result.write({
|
|
19
|
-
format: 'esm',
|
|
20
|
-
file: path.resolve(__dirname, '../lib/index.mjs'),
|
|
21
|
-
}),
|
|
22
|
-
result.write({
|
|
23
|
-
format: 'umd',
|
|
24
|
-
name: 'graphviz',
|
|
25
|
-
file: path.resolve(__dirname, '../lib/bundle.min.js'),
|
|
26
|
-
}),
|
|
27
|
-
]),
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
await rollup({
|
|
31
|
-
input: path.resolve(__dirname, '../lib/index.d.ts'),
|
|
32
|
-
plugins: [dts()],
|
|
33
|
-
}).then(async (result) => {
|
|
34
|
-
rimraf.sync(path.resolve(__dirname, '../lib/**/*.d.ts'));
|
|
35
|
-
await result.write({
|
|
36
|
-
format: 'esm',
|
|
37
|
-
file: path.resolve(__dirname, '../lib/index.d.ts'),
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
build();
|