@thi.ng/rstream-dot 2.1.49 → 3.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/CHANGELOG.md +15 -1
- package/README.md +36 -39
- package/api.d.ts +1 -1
- package/index.d.ts +11 -3
- package/index.js +23 -6
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2023-
|
|
3
|
+
- **Last updated**: 2023-04-08T11:09:50Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,20 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
# [3.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream-dot@3.0.0) (2023-04-08)
|
|
13
|
+
|
|
14
|
+
#### 🛑 Breaking changes
|
|
15
|
+
|
|
16
|
+
- add serialize() ([f3bb5ab](https://github.com/thi-ng/umbrella/commit/f3bb5ab))
|
|
17
|
+
- BREAKING CHANGE: rename walk() => traverse()
|
|
18
|
+
- add serialize() function
|
|
19
|
+
- rename WalkState => TraversalState
|
|
20
|
+
- update default rank direction from TB => LR
|
|
21
|
+
|
|
22
|
+
#### 🩹 Bug fixes
|
|
23
|
+
|
|
24
|
+
- update descendants collection ([fdd1ad2](https://github.com/thi-ng/umbrella/commit/fdd1ad2))
|
|
25
|
+
|
|
12
26
|
## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream-dot@2.1.0) (2021-11-17)
|
|
13
27
|
|
|
14
28
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ For Node.js REPL:
|
|
|
54
54
|
const rstreamDot = await import("@thi.ng/rstream-dot");
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
Package sizes (brotli'd, pre-treeshake): ESM:
|
|
57
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 807 bytes
|
|
58
58
|
|
|
59
59
|
## Dependencies
|
|
60
60
|
|
|
@@ -70,54 +70,51 @@ directory are using this package.
|
|
|
70
70
|
|
|
71
71
|
A selection:
|
|
72
72
|
|
|
73
|
-
| Description
|
|
74
|
-
|
|
75
|
-
| Minimal rstream dataflow graph
|
|
73
|
+
| Screenshot | Description | Live demo | Source |
|
|
74
|
+
|:--------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------|:-------------------------------------------------------|:------------------------------------------------------------------------------------|
|
|
75
|
+
| | Minimal rstream dataflow graph | [Demo](https://demo.thi.ng/umbrella/rstream-dataflow/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rstream-dataflow) |
|
|
76
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/trace-bitmap.jpg" width="240"/> | Multi-layer vectorization & dithering of bitmap images | [Demo](https://demo.thi.ng/umbrella/trace-bitmap/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/trace-bitmap) |
|
|
76
77
|
|
|
77
78
|
## API
|
|
78
79
|
|
|
79
80
|
[Generated API docs](https://docs.thi.ng/umbrella/rstream-dot/)
|
|
80
81
|
|
|
81
|
-
```ts
|
|
82
|
-
import
|
|
83
|
-
|
|
84
|
-
import * as rs from "@thi.ng/rstream";
|
|
85
|
-
import * as tx from "@thi.ng/transducers";
|
|
82
|
+
```ts tangle:export/readme.ts
|
|
83
|
+
import { fromIterable, merge, trace } from "@thi.ng/rstream";
|
|
84
|
+
import { serialize } from "@thi.ng/rstream-dot";
|
|
86
85
|
|
|
87
86
|
// create dummy dataflow
|
|
88
|
-
a =
|
|
89
|
-
b =
|
|
90
|
-
a.
|
|
91
|
-
|
|
87
|
+
const a = fromIterable([1, 2, 3]);
|
|
88
|
+
const b = fromIterable([10, 20, 30]);
|
|
89
|
+
a.map((x) => x * 10, { id: "x10" });
|
|
90
|
+
merge({ src: [a, b] }).subscribe(trace());
|
|
92
91
|
|
|
93
92
|
// now capture the topology by walking the graph from its root(s)
|
|
94
93
|
// and convert the result to GraphViz DOT format
|
|
95
|
-
console.log(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
// s7 -> s8;
|
|
120
|
-
// }
|
|
94
|
+
console.log(serialize([a, b]));
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Resulting output:
|
|
98
|
+
|
|
99
|
+
```dot tangle:export/readme.dot
|
|
100
|
+
digraph g {
|
|
101
|
+
rankdir=LR;
|
|
102
|
+
node[fontname="sans-serif",fontsize=10,style=filled,fontcolor=white];
|
|
103
|
+
edge[fontname="sans-serif",fontsize=10];
|
|
104
|
+
s0[label="iterable-0\n(Stream)", color="blue"];
|
|
105
|
+
s1[label="x10", color="black"];
|
|
106
|
+
s2[label="in-iterable-0", color="black"];
|
|
107
|
+
s3[label="streammerge-2\n(StreamMerge)", color="red"];
|
|
108
|
+
s4[label="sub-3", color="black"];
|
|
109
|
+
s5[label="iterable-1\n(Stream)", color="blue"];
|
|
110
|
+
s6[label="in-iterable-1", color="black"];
|
|
111
|
+
s3 -> s4;
|
|
112
|
+
s2 -> s3;
|
|
113
|
+
s0 -> s1[label="xform"];
|
|
114
|
+
s0 -> s2;
|
|
115
|
+
s6 -> s3;
|
|
116
|
+
s5 -> s6;
|
|
117
|
+
}
|
|
121
118
|
```
|
|
122
119
|
|
|
123
120
|
Copy output to file `graph.dot` and then run:
|
package/api.d.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { ISubscribable } from "@thi.ng/rstream";
|
|
2
|
-
import type { DotOpts,
|
|
2
|
+
import type { DotOpts, TraversalState } from "./api.js";
|
|
3
3
|
export * from "./api.js";
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const toDot: (state:
|
|
4
|
+
export declare const traverse: (subs: ISubscribable<any>[], opts?: Partial<DotOpts>, state?: TraversalState) => TraversalState;
|
|
5
|
+
export declare const toDot: (state: TraversalState, opts?: Partial<DotOpts>) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Syntax sugar for the composition {@link traverse} and {@link toDot},
|
|
8
|
+
* serializing the traversable graph topology to Graphviz DOT format.
|
|
9
|
+
*
|
|
10
|
+
* @param subs
|
|
11
|
+
* @param opts
|
|
12
|
+
*/
|
|
13
|
+
export declare const serialize: (subs: ISubscribable<any>[], opts?: Partial<DotOpts>) => string;
|
|
6
14
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -11,6 +11,16 @@ const getNodeType = (sub) => sub instanceof Stream
|
|
|
11
11
|
: sub instanceof StreamMerge
|
|
12
12
|
? "StreamMerge"
|
|
13
13
|
: undefined;
|
|
14
|
+
const getChildren = (sub) => {
|
|
15
|
+
let children = [];
|
|
16
|
+
if (sub.subs)
|
|
17
|
+
children.push(...sub.subs);
|
|
18
|
+
if (sub.__owner)
|
|
19
|
+
children.push(sub.__owner);
|
|
20
|
+
if (sub.wrapped)
|
|
21
|
+
children.push(...getChildren(sub.wrapped));
|
|
22
|
+
return children;
|
|
23
|
+
};
|
|
14
24
|
const dotNode = (s, opts) => {
|
|
15
25
|
let res = `s${s.id}[label="`;
|
|
16
26
|
res += s.type ? `${s.label}\\n(${s.type})` : `${s.label}`;
|
|
@@ -28,7 +38,7 @@ const subValue = (sub) => {
|
|
|
28
38
|
const res = JSON.stringify(sub.deref ? sub.deref() : undefined);
|
|
29
39
|
return res ? truncate(64, "...")(res) : res;
|
|
30
40
|
};
|
|
31
|
-
export const
|
|
41
|
+
export const traverse = (subs, opts, state) => {
|
|
32
42
|
opts || (opts = {});
|
|
33
43
|
state || (state = { id: 0, subs: new Map(), rels: [] });
|
|
34
44
|
for (let sub of subs) {
|
|
@@ -44,10 +54,9 @@ export const walk = (subs, opts, state) => {
|
|
|
44
54
|
};
|
|
45
55
|
state.subs.set(sub, desc);
|
|
46
56
|
state.id++;
|
|
47
|
-
const children = sub
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
walk(children, opts, state);
|
|
57
|
+
const children = getChildren(sub);
|
|
58
|
+
if (children.length) {
|
|
59
|
+
traverse(children, opts, state);
|
|
51
60
|
for (let c of children) {
|
|
52
61
|
const childNode = state.subs.get(c);
|
|
53
62
|
childNode && state.rels.push([desc, childNode]);
|
|
@@ -58,7 +67,7 @@ export const walk = (subs, opts, state) => {
|
|
|
58
67
|
};
|
|
59
68
|
export const toDot = (state, opts) => {
|
|
60
69
|
opts = {
|
|
61
|
-
dir: "
|
|
70
|
+
dir: "LR",
|
|
62
71
|
font: "sans-serif",
|
|
63
72
|
fontsize: 10,
|
|
64
73
|
text: "white",
|
|
@@ -82,3 +91,11 @@ export const toDot = (state, opts) => {
|
|
|
82
91
|
"}",
|
|
83
92
|
].join("\n");
|
|
84
93
|
};
|
|
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
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Graphviz DOT conversion of @thi.ng/rstream dataflow graph topologies",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/rstream": "^
|
|
38
|
-
"@thi.ng/strings": "^3.4.
|
|
39
|
-
"@thi.ng/transducers": "^8.4.
|
|
37
|
+
"@thi.ng/rstream": "^8.0.1",
|
|
38
|
+
"@thi.ng/strings": "^3.4.5",
|
|
39
|
+
"@thi.ng/transducers": "^8.4.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@microsoft/api-extractor": "^7.34.4",
|
|
43
|
-
"@thi.ng/testament": "^0.3.
|
|
43
|
+
"@thi.ng/testament": "^0.3.15",
|
|
44
44
|
"rimraf": "^4.4.1",
|
|
45
45
|
"tools": "^0.0.1",
|
|
46
46
|
"typedoc": "^0.23.28",
|
|
47
|
-
"typescript": "^5.0.
|
|
47
|
+
"typescript": "^5.0.4"
|
|
48
48
|
},
|
|
49
49
|
"keywords": [
|
|
50
50
|
"conversion",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
],
|
|
86
86
|
"year": 2018
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "3a56bc490f1e68754762a503d06327b5b34ff7eb\n"
|
|
89
89
|
}
|