@thi.ng/rstream-dot 3.0.36 → 3.0.38
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 +1 -1
- package/README.md +1 -1
- package/api.js +0 -1
- package/index.js +75 -85
- package/package.json +10 -7
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/api.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/index.js
CHANGED
|
@@ -4,98 +4,88 @@ import { StreamSync } from "@thi.ng/rstream/sync";
|
|
|
4
4
|
import { truncate } from "@thi.ng/strings/truncate";
|
|
5
5
|
import { map } from "@thi.ng/transducers/map";
|
|
6
6
|
export * from "./api.js";
|
|
7
|
-
const getNodeType = (sub) => sub instanceof Stream
|
|
8
|
-
? "Stream"
|
|
9
|
-
: sub instanceof StreamSync
|
|
10
|
-
? "StreamSync"
|
|
11
|
-
: sub instanceof StreamMerge
|
|
12
|
-
? "StreamMerge"
|
|
13
|
-
: undefined;
|
|
7
|
+
const getNodeType = (sub) => sub instanceof Stream ? "Stream" : sub instanceof StreamSync ? "StreamSync" : sub instanceof StreamMerge ? "StreamMerge" : void 0;
|
|
14
8
|
const getChildren = (sub) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
let children = [];
|
|
10
|
+
if (sub.subs)
|
|
11
|
+
children.push(...sub.subs);
|
|
12
|
+
if (sub.__owner)
|
|
13
|
+
children.push(sub.__owner);
|
|
14
|
+
if (sub.wrapped)
|
|
15
|
+
children.push(...getChildren(sub.wrapped));
|
|
16
|
+
return children;
|
|
23
17
|
};
|
|
24
18
|
const dotNode = (s, opts) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
(s.label === "<noid>" ? opts.color.noid : opts.color.default);
|
|
34
|
-
return res + `"];`;
|
|
19
|
+
let res = `s${s.id}[label="`;
|
|
20
|
+
res += s.type ? `${s.label}\\n(${s.type})` : `${s.label}`;
|
|
21
|
+
if (s.body !== void 0) {
|
|
22
|
+
res += `\\n${s.body.replace(/"/g, `'`).replace(/\n/g, "\\n")}`;
|
|
23
|
+
}
|
|
24
|
+
res += `", color="`;
|
|
25
|
+
res += s.type && opts.color[s.type.toLowerCase()] || (s.label === "<noid>" ? opts.color.noid : opts.color.default);
|
|
26
|
+
return res + `"];`;
|
|
35
27
|
};
|
|
36
28
|
const dotEdge = (a, b, _) => `s${a.id} -> s${b.id}${b.xform ? `[label="xform"]` : ""};`;
|
|
37
29
|
const subValue = (sub) => {
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
const res = JSON.stringify(sub.deref ? sub.deref() : void 0);
|
|
31
|
+
return res ? truncate(64, "...")(res) : res;
|
|
40
32
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
33
|
+
const traverse = (subs, opts, state) => {
|
|
34
|
+
opts || (opts = {});
|
|
35
|
+
state || (state = { id: 0, subs: /* @__PURE__ */ new Map(), rels: [] });
|
|
36
|
+
for (let sub of subs) {
|
|
37
|
+
if (state.subs.get(sub))
|
|
38
|
+
return state;
|
|
39
|
+
const id = state.id;
|
|
40
|
+
const desc = {
|
|
41
|
+
id,
|
|
42
|
+
label: sub.id || "<noid>",
|
|
43
|
+
type: getNodeType(sub),
|
|
44
|
+
xform: !!sub.xform,
|
|
45
|
+
body: opts.values ? subValue(sub) : void 0
|
|
46
|
+
};
|
|
47
|
+
state.subs.set(sub, desc);
|
|
48
|
+
state.id++;
|
|
49
|
+
const children = getChildren(sub);
|
|
50
|
+
if (children.length) {
|
|
51
|
+
traverse(children, opts, state);
|
|
52
|
+
for (let c of children) {
|
|
53
|
+
const childNode = state.subs.get(c);
|
|
54
|
+
childNode && state.rels.push([desc, childNode]);
|
|
55
|
+
}
|
|
65
56
|
}
|
|
66
|
-
|
|
57
|
+
}
|
|
58
|
+
return state;
|
|
67
59
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
60
|
+
const toDot = (state, opts) => {
|
|
61
|
+
opts = {
|
|
62
|
+
dir: "LR",
|
|
63
|
+
font: "sans-serif",
|
|
64
|
+
fontsize: 10,
|
|
65
|
+
text: "white",
|
|
66
|
+
...opts
|
|
67
|
+
};
|
|
68
|
+
opts.color = {
|
|
69
|
+
default: "black",
|
|
70
|
+
noid: "gray",
|
|
71
|
+
stream: "blue",
|
|
72
|
+
streammerge: "red",
|
|
73
|
+
streamsync: "red",
|
|
74
|
+
...opts.color || {}
|
|
75
|
+
};
|
|
76
|
+
return [
|
|
77
|
+
"digraph g {",
|
|
78
|
+
`rankdir=${opts.dir};`,
|
|
79
|
+
`node[fontname="${opts.font}",fontsize=${opts.fontsize},style=filled,fontcolor=${opts.text}];`,
|
|
80
|
+
`edge[fontname="${opts.font}",fontsize=${opts.fontsize}];`,
|
|
81
|
+
...map((n) => dotNode(n, opts), state.subs.values()),
|
|
82
|
+
...map((r) => dotEdge(r[0], r[1], opts), state.rels),
|
|
83
|
+
"}"
|
|
84
|
+
].join("\n");
|
|
85
|
+
};
|
|
86
|
+
const serialize = (subs, opts) => toDot(traverse(subs, opts), opts);
|
|
87
|
+
export {
|
|
88
|
+
serialize,
|
|
89
|
+
toDot,
|
|
90
|
+
traverse
|
|
93
91
|
};
|
|
94
|
-
/**
|
|
95
|
-
* Syntax sugar for the composition {@link traverse} and {@link toDot},
|
|
96
|
-
* serializing the traversable graph topology to Graphviz DOT format.
|
|
97
|
-
*
|
|
98
|
-
* @param subs
|
|
99
|
-
* @param opts
|
|
100
|
-
*/
|
|
101
|
-
export const serialize = (subs, opts) => toDot(traverse(subs, opts), opts);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/rstream-dot",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.38",
|
|
4
4
|
"description": "Graphviz DOT conversion of @thi.ng/rstream dataflow graph topologies",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
"author": "Karsten Schmidt (https://thi.ng)",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "yarn
|
|
27
|
+
"build": "yarn build:esbuild && yarn build:decl",
|
|
28
|
+
"build:decl": "tsc --declaration --emitDeclarationOnly",
|
|
29
|
+
"build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
|
|
28
30
|
"clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc",
|
|
29
31
|
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
30
32
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
@@ -33,12 +35,13 @@
|
|
|
33
35
|
"test": "bun test"
|
|
34
36
|
},
|
|
35
37
|
"dependencies": {
|
|
36
|
-
"@thi.ng/rstream": "^8.2.
|
|
37
|
-
"@thi.ng/strings": "^3.7.
|
|
38
|
-
"@thi.ng/transducers": "^8.8.
|
|
38
|
+
"@thi.ng/rstream": "^8.2.15",
|
|
39
|
+
"@thi.ng/strings": "^3.7.4",
|
|
40
|
+
"@thi.ng/transducers": "^8.8.16"
|
|
39
41
|
},
|
|
40
42
|
"devDependencies": {
|
|
41
43
|
"@microsoft/api-extractor": "^7.38.3",
|
|
44
|
+
"esbuild": "^0.19.8",
|
|
42
45
|
"rimraf": "^5.0.5",
|
|
43
46
|
"tools": "^0.0.1",
|
|
44
47
|
"typedoc": "^0.25.4",
|
|
@@ -61,7 +64,7 @@
|
|
|
61
64
|
"access": "public"
|
|
62
65
|
},
|
|
63
66
|
"engines": {
|
|
64
|
-
"node": ">=
|
|
67
|
+
"node": ">=18"
|
|
65
68
|
},
|
|
66
69
|
"files": [
|
|
67
70
|
"./*.js",
|
|
@@ -83,5 +86,5 @@
|
|
|
83
86
|
],
|
|
84
87
|
"year": 2018
|
|
85
88
|
},
|
|
86
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "25a42a81fac8603a1e440a7aa8bc343276211ff4\n"
|
|
87
90
|
}
|