@statewalker/fsm-charts 0.2.3 → 0.2.5
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/dist/{chunk-AZBRQNTU.js → chunk-2LFUT2C6.js} +1062 -1110
- package/dist/{chunk-SVKVQY7B.js → chunk-ARZYBFNA.js} +4 -4
- package/dist/{chunk-36ZLXJVD.js → chunk-CR2M4445.js} +35 -33
- package/dist/{chunk-TZHCBZVP.js → chunk-GW2Z65BN.js} +22 -15
- package/dist/chunk-PKBMQBKP.js +5 -0
- package/dist/{chunk-VILLJJJD.js → chunk-RZ4FP6JB.js} +11 -9
- package/dist/index-config.js +2 -1
- package/dist/index-dom.js +2 -1
- package/dist/{index-html-DgSCNHkR.d.ts → index-html-BBQqYoST.d.ts} +10 -10
- package/dist/index-html.d.ts +1 -1
- package/dist/index-html.js +2 -1
- package/dist/index-layout.d.ts +15 -15
- package/dist/index-layout.js +2 -1
- package/dist/index-runtime.js +2 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -5
- package/package.json +16 -18
- package/src/config/concatTransitionsToString.ts +2 -2
- package/src/config/index.ts +4 -4
- package/src/config/serializeProcessConfig.ts +3 -3
- package/src/config/splitTransitionString.ts +2 -2
- package/src/config/toFsmStateConfig.ts +3 -3
- package/src/dagre/acyclic.js +9 -10
- package/src/dagre/add-border-segments.js +11 -7
- package/src/dagre/coordinate-system.js +12 -12
- package/src/dagre/data/list.js +2 -2
- package/src/dagre/debug.d.ts +1 -1
- package/src/dagre/debug.js +11 -11
- package/src/dagre/greedy-fas.js +17 -21
- package/src/dagre/index.d.ts +4 -4
- package/src/dagre/index.js +4 -4
- package/src/dagre/layout.js +107 -96
- package/src/dagre/nesting-graph.js +13 -19
- package/src/dagre/normalize.js +7 -7
- package/src/dagre/order/add-subgraph-constraints.js +2 -2
- package/src/dagre/order/barycenter.d.ts +1 -1
- package/src/dagre/order/barycenter.js +4 -4
- package/src/dagre/order/build-layer-graph.d.ts +1 -1
- package/src/dagre/order/build-layer-graph.js +7 -9
- package/src/dagre/order/cross-count.js +14 -17
- package/src/dagre/order/index.js +19 -17
- package/src/dagre/order/init-order.js +5 -15
- package/src/dagre/order/resolve-conflicts.js +10 -14
- package/src/dagre/order/sort-subgraph.d.ts +1 -1
- package/src/dagre/order/sort-subgraph.js +13 -14
- package/src/dagre/order/sort.d.ts +1 -1
- package/src/dagre/order/sort.js +6 -10
- package/src/dagre/parent-dummy-chains.js +10 -4
- package/src/dagre/position/bk.d.ts +3 -3
- package/src/dagre/position/bk.js +84 -65
- package/src/dagre/position/index.js +7 -11
- package/src/dagre/rank/feasible-tree.d.ts +1 -1
- package/src/dagre/rank/feasible-tree.js +6 -6
- package/src/dagre/rank/index.js +6 -6
- package/src/dagre/rank/network-simplex.d.ts +0 -1
- package/src/dagre/rank/network-simplex.js +20 -25
- package/src/dagre/rank/util.js +2 -6
- package/src/dagre/util.d.ts +12 -6
- package/src/dagre/util.js +31 -37
- package/src/dom/buildSections.ts +16 -12
- package/src/dom/description-panels.ts +3 -3
- package/src/dom/getStatesDescriptions.ts +1 -1
- package/src/full/index.ts +1 -1
- package/src/full/toFsmStateCharts.ts +11 -11
- package/src/graphlib/alg/components.js +2 -2
- package/src/graphlib/alg/dfs.js +5 -5
- package/src/graphlib/alg/dijkstra-all.js +4 -4
- package/src/graphlib/alg/dijkstra.js +9 -12
- package/src/graphlib/alg/find-cycles.js +7 -5
- package/src/graphlib/alg/floyd-warshall.js +8 -11
- package/src/graphlib/alg/index.d.ts +11 -11
- package/src/graphlib/alg/index.js +11 -11
- package/src/graphlib/alg/is-acyclic.js +1 -1
- package/src/graphlib/alg/postorder.js +2 -2
- package/src/graphlib/alg/preorder.js +2 -2
- package/src/graphlib/alg/prim.d.ts +1 -1
- package/src/graphlib/alg/prim.js +5 -5
- package/src/graphlib/alg/tarjan.js +3 -3
- package/src/graphlib/alg/topsort.js +1 -1
- package/src/graphlib/data/priority-queue.js +8 -10
- package/src/graphlib/graph.js +53 -52
- package/src/graphlib/index.d.ts +2 -2
- package/src/graphlib/index.js +2 -2
- package/src/graphlib/json.d.ts +1 -1
- package/src/graphlib/json.js +6 -6
- package/src/html/buildStatechartCss.ts +2 -2
- package/src/html/buildStatechartStyles.ts +1 -1
- package/src/html/buildStatechartSvg.ts +7 -7
- package/src/html/buildStatechartsPanel.ts +2 -2
- package/src/html/index.ts +4 -4
- package/src/index-config.ts +2 -2
- package/src/index-dom.ts +1 -1
- package/src/index-html.ts +2 -2
- package/src/index-layout.ts +2 -2
- package/src/index-runtime.ts +2 -2
- package/src/index.ts +8 -8
- package/src/layout/buildCharts.ts +5 -5
- package/src/layout/buildFlatCharts.ts +11 -13
- package/src/layout/getGraphParamsProvider.ts +5 -8
- package/src/layout/getLabelDimensions.ts +5 -5
- package/src/layout/index.ts +5 -4
- package/src/lodash-es/index.ts +2 -2
- package/src/lodash-es/types.ts +37 -35
- package/src/runtime/RuntimeStatechartApi.ts +12 -23
- package/src/runtime/StateChartIndex.ts +3 -3
- package/src/runtime/index.ts +2 -2
- package/src/types/FsmStateConfig.ts +1 -1
- package/src/types/GraphParamsProvider.ts +2 -2
- package/src/types/Position.ts +1 -1
- package/src/types/StateChart.ts +2 -2
- package/src/types/StateGraphEdge.ts +2 -2
- package/src/types/StateGraphNode.ts +2 -2
- package/src/types/TransitionsGraph.ts +4 -4
- package/src/types/index.ts +11 -11
- package/src/utils/BasisCurve.ts +3 -3
- package/src/utils/domToText.ts +1 -1
- package/src/utils/getPadding.ts +1 -1
- package/src/utils/newRegistry.ts +1 -1
- package/src/utils/serializeAttrs.ts +6 -6
- package/src/utils/serializeCss.ts +3 -3
- package/src/utils/serializeStyle.ts +2 -2
- package/src/utils/toKebabCase.ts +1 -1
- package/CHANGELOG.md +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ } from
|
|
1
|
+
import { _ } from "../../lodash-es/index.ts";
|
|
2
2
|
|
|
3
3
|
export { PriorityQueue };
|
|
4
4
|
|
|
@@ -24,9 +24,7 @@ class PriorityQueue {
|
|
|
24
24
|
* Returns the keys that are in the queue. Takes `O(n)` time.
|
|
25
25
|
*/
|
|
26
26
|
keys() {
|
|
27
|
-
return this._arr.map(
|
|
28
|
-
return x.key;
|
|
29
|
-
});
|
|
27
|
+
return this._arr.map((x) => x.key);
|
|
30
28
|
}
|
|
31
29
|
/**
|
|
32
30
|
* Returns `true` if **key** is in the queue and `false` if not.
|
|
@@ -52,7 +50,7 @@ class PriorityQueue {
|
|
|
52
50
|
*/
|
|
53
51
|
min() {
|
|
54
52
|
if (this.size() === 0) {
|
|
55
|
-
throw new Error(
|
|
53
|
+
throw new Error("Queue underflow");
|
|
56
54
|
}
|
|
57
55
|
return this._arr[0].key;
|
|
58
56
|
}
|
|
@@ -98,13 +96,13 @@ class PriorityQueue {
|
|
|
98
96
|
var index = this._keyIndices[key];
|
|
99
97
|
if (priority > this._arr[index].priority) {
|
|
100
98
|
throw new Error(
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
"New priority is greater than current priority. " +
|
|
100
|
+
"Key: " +
|
|
103
101
|
key +
|
|
104
|
-
|
|
102
|
+
" Old: " +
|
|
105
103
|
this._arr[index].priority +
|
|
106
|
-
|
|
107
|
-
priority
|
|
104
|
+
" New: " +
|
|
105
|
+
priority,
|
|
108
106
|
);
|
|
109
107
|
}
|
|
110
108
|
this._arr[index].priority = priority;
|
package/src/graphlib/graph.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { _ } from
|
|
1
|
+
import { _ } from "../lodash-es/index.ts";
|
|
2
2
|
|
|
3
|
-
var DEFAULT_EDGE_NAME =
|
|
4
|
-
var GRAPH_NODE =
|
|
5
|
-
var EDGE_KEY_DELIM =
|
|
3
|
+
var DEFAULT_EDGE_NAME = "\x00";
|
|
4
|
+
var GRAPH_NODE = "\x00";
|
|
5
|
+
var EDGE_KEY_DELIM = "\x01";
|
|
6
6
|
|
|
7
7
|
// Implementation notes:
|
|
8
8
|
//
|
|
@@ -25,9 +25,9 @@ var EDGE_KEY_DELIM = '\x01';
|
|
|
25
25
|
// we're going to get to a performant hashtable in JavaScript.
|
|
26
26
|
export class Graph {
|
|
27
27
|
constructor(opts = {}) {
|
|
28
|
-
this._isDirected = _.has(opts,
|
|
29
|
-
this._isMultigraph = _.has(opts,
|
|
30
|
-
this._isCompound = _.has(opts,
|
|
28
|
+
this._isDirected = _.has(opts, "directed") ? opts.directed : true;
|
|
29
|
+
this._isMultigraph = _.has(opts, "multigraph") ? opts.multigraph : false;
|
|
30
|
+
this._isCompound = _.has(opts, "compound") ? opts.compound : false;
|
|
31
31
|
|
|
32
32
|
// Label for the graph itself
|
|
33
33
|
this._label = undefined;
|
|
@@ -100,25 +100,18 @@ export class Graph {
|
|
|
100
100
|
return _.keys(this._nodes);
|
|
101
101
|
}
|
|
102
102
|
sources() {
|
|
103
|
-
|
|
104
|
-
return _.filter(this.nodes(), function (v) {
|
|
105
|
-
return _.isEmpty(self._in[v]);
|
|
106
|
-
});
|
|
103
|
+
return _.filter(this.nodes(), (v) => _.isEmpty(this._in[v]));
|
|
107
104
|
}
|
|
108
105
|
sinks() {
|
|
109
|
-
|
|
110
|
-
return _.filter(this.nodes(), function (v) {
|
|
111
|
-
return _.isEmpty(self._out[v]);
|
|
112
|
-
});
|
|
106
|
+
return _.filter(this.nodes(), (v) => _.isEmpty(this._out[v]));
|
|
113
107
|
}
|
|
114
108
|
setNodes(vs, value) {
|
|
115
109
|
var args = arguments;
|
|
116
|
-
|
|
117
|
-
_.each(vs, function (v) {
|
|
110
|
+
_.each(vs, (v) => {
|
|
118
111
|
if (args.length > 1) {
|
|
119
|
-
|
|
112
|
+
this.setNode(v, value);
|
|
120
113
|
} else {
|
|
121
|
-
|
|
114
|
+
this.setNode(v);
|
|
122
115
|
}
|
|
123
116
|
});
|
|
124
117
|
return this;
|
|
@@ -152,17 +145,16 @@ export class Graph {
|
|
|
152
145
|
return _.has(this._nodes, v);
|
|
153
146
|
}
|
|
154
147
|
removeNode(v) {
|
|
155
|
-
var self = this;
|
|
156
148
|
if (_.has(this._nodes, v)) {
|
|
157
|
-
var removeEdge =
|
|
158
|
-
|
|
149
|
+
var removeEdge = (e) => {
|
|
150
|
+
this.removeEdge(this._edgeObjs[e]);
|
|
159
151
|
};
|
|
160
152
|
delete this._nodes[v];
|
|
161
153
|
if (this._isCompound) {
|
|
162
154
|
this._removeFromParentsChildList(v);
|
|
163
155
|
delete this._parent[v];
|
|
164
|
-
_.each(this.children(v),
|
|
165
|
-
|
|
156
|
+
_.each(this.children(v), (child) => {
|
|
157
|
+
this.setParent(child);
|
|
166
158
|
});
|
|
167
159
|
delete this._children[v];
|
|
168
160
|
}
|
|
@@ -178,17 +170,23 @@ export class Graph {
|
|
|
178
170
|
}
|
|
179
171
|
setParent(v, parent) {
|
|
180
172
|
if (!this._isCompound) {
|
|
181
|
-
throw new Error(
|
|
173
|
+
throw new Error("Cannot set parent in a non-compound graph");
|
|
182
174
|
}
|
|
183
175
|
|
|
184
176
|
if (_.isUndefined(parent)) {
|
|
185
177
|
parent = GRAPH_NODE;
|
|
186
178
|
} else {
|
|
187
179
|
// Coerce parent to string
|
|
188
|
-
parent +=
|
|
189
|
-
for (
|
|
180
|
+
parent += "";
|
|
181
|
+
for (
|
|
182
|
+
var ancestor = parent;
|
|
183
|
+
!_.isUndefined(ancestor);
|
|
184
|
+
ancestor = this.parent(ancestor)
|
|
185
|
+
) {
|
|
190
186
|
if (ancestor === v) {
|
|
191
|
-
throw new Error(
|
|
187
|
+
throw new Error(
|
|
188
|
+
`Setting ${parent} as parent of ${v} would create a cycle`,
|
|
189
|
+
);
|
|
192
190
|
}
|
|
193
191
|
}
|
|
194
192
|
|
|
@@ -266,13 +264,13 @@ export class Graph {
|
|
|
266
264
|
copy.setGraph(this.graph());
|
|
267
265
|
|
|
268
266
|
var self = this;
|
|
269
|
-
_.each(this._nodes,
|
|
267
|
+
_.each(this._nodes, (value, v) => {
|
|
270
268
|
if (filter(v)) {
|
|
271
269
|
copy.setNode(v, value);
|
|
272
270
|
}
|
|
273
271
|
});
|
|
274
272
|
|
|
275
|
-
_.each(this._edgeObjs,
|
|
273
|
+
_.each(this._edgeObjs, (e) => {
|
|
276
274
|
// @ts-expect-error
|
|
277
275
|
if (copy.hasNode(e.v) && copy.hasNode(e.w)) {
|
|
278
276
|
copy.setEdge(e, self.edge(e));
|
|
@@ -293,7 +291,7 @@ export class Graph {
|
|
|
293
291
|
}
|
|
294
292
|
|
|
295
293
|
if (this._isCompound) {
|
|
296
|
-
_.each(copy.nodes(),
|
|
294
|
+
_.each(copy.nodes(), (v) => {
|
|
297
295
|
copy.setParent(v, findParent(v));
|
|
298
296
|
});
|
|
299
297
|
}
|
|
@@ -315,13 +313,12 @@ export class Graph {
|
|
|
315
313
|
return _.values(this._edgeObjs);
|
|
316
314
|
}
|
|
317
315
|
setPath(vs, value) {
|
|
318
|
-
var self = this;
|
|
319
316
|
var args = arguments;
|
|
320
|
-
_.reduce(vs,
|
|
317
|
+
_.reduce(vs, (v, w) => {
|
|
321
318
|
if (args.length > 1) {
|
|
322
|
-
|
|
319
|
+
this.setEdge(v, w, value);
|
|
323
320
|
} else {
|
|
324
|
-
|
|
321
|
+
this.setEdge(v, w);
|
|
325
322
|
}
|
|
326
323
|
return w;
|
|
327
324
|
});
|
|
@@ -336,7 +333,7 @@ export class Graph {
|
|
|
336
333
|
var valueSpecified = false;
|
|
337
334
|
var arg0 = arguments[0];
|
|
338
335
|
|
|
339
|
-
if (typeof arg0 ===
|
|
336
|
+
if (typeof arg0 === "object" && arg0 !== null && "v" in arg0) {
|
|
340
337
|
v = arg0.v;
|
|
341
338
|
w = arg0.w;
|
|
342
339
|
name = arg0.name;
|
|
@@ -354,10 +351,10 @@ export class Graph {
|
|
|
354
351
|
}
|
|
355
352
|
}
|
|
356
353
|
|
|
357
|
-
v =
|
|
358
|
-
w =
|
|
354
|
+
v = `${v}`;
|
|
355
|
+
w = `${w}`;
|
|
359
356
|
if (!_.isUndefined(name)) {
|
|
360
|
-
name =
|
|
357
|
+
name = `${name}`;
|
|
361
358
|
}
|
|
362
359
|
|
|
363
360
|
var e = edgeArgsToId(this._isDirected, v, w, name);
|
|
@@ -369,7 +366,7 @@ export class Graph {
|
|
|
369
366
|
}
|
|
370
367
|
|
|
371
368
|
if (!_.isUndefined(name) && !this._isMultigraph) {
|
|
372
|
-
throw new Error(
|
|
369
|
+
throw new Error("Cannot set a named edge when isMultigraph = false");
|
|
373
370
|
}
|
|
374
371
|
|
|
375
372
|
// It didn't exist, so we need to create it.
|
|
@@ -378,7 +375,9 @@ export class Graph {
|
|
|
378
375
|
this.setNode(w);
|
|
379
376
|
|
|
380
377
|
// @ts-expect-error
|
|
381
|
-
this._edgeLabels[e] = valueSpecified
|
|
378
|
+
this._edgeLabels[e] = valueSpecified
|
|
379
|
+
? value
|
|
380
|
+
: this._defaultEdgeLabelFn(v, w, name);
|
|
382
381
|
|
|
383
382
|
var edgeObj = edgeArgsToObj(this._isDirected, v, w, name);
|
|
384
383
|
// Ensure we add undirected edges in a consistent way.
|
|
@@ -434,9 +433,7 @@ export class Graph {
|
|
|
434
433
|
if (!u) {
|
|
435
434
|
return edges;
|
|
436
435
|
}
|
|
437
|
-
return _.filter(edges,
|
|
438
|
-
return edge.v === u;
|
|
439
|
-
});
|
|
436
|
+
return _.filter(edges, (edge) => edge.v === u);
|
|
440
437
|
}
|
|
441
438
|
}
|
|
442
439
|
outEdges(v, w) {
|
|
@@ -446,9 +443,7 @@ export class Graph {
|
|
|
446
443
|
if (!w) {
|
|
447
444
|
return edges;
|
|
448
445
|
}
|
|
449
|
-
return _.filter(edges,
|
|
450
|
-
return edge.w === w;
|
|
451
|
-
});
|
|
446
|
+
return _.filter(edges, (edge) => edge.w === w);
|
|
452
447
|
}
|
|
453
448
|
}
|
|
454
449
|
nodeEdges(v, w) {
|
|
@@ -480,19 +475,25 @@ function decrementOrRemoveEntry(map, k) {
|
|
|
480
475
|
}
|
|
481
476
|
|
|
482
477
|
function edgeArgsToId(isDirected, v_, w_, name) {
|
|
483
|
-
var v =
|
|
484
|
-
var w =
|
|
478
|
+
var v = `${v_}`;
|
|
479
|
+
var w = `${w_}`;
|
|
485
480
|
if (!isDirected && v > w) {
|
|
486
481
|
var tmp = v;
|
|
487
482
|
v = w;
|
|
488
483
|
w = tmp;
|
|
489
484
|
}
|
|
490
|
-
return
|
|
485
|
+
return (
|
|
486
|
+
v +
|
|
487
|
+
EDGE_KEY_DELIM +
|
|
488
|
+
w +
|
|
489
|
+
EDGE_KEY_DELIM +
|
|
490
|
+
(_.isUndefined(name) ? DEFAULT_EDGE_NAME : name)
|
|
491
|
+
);
|
|
491
492
|
}
|
|
492
493
|
|
|
493
494
|
function edgeArgsToObj(isDirected, v_, w_, name) {
|
|
494
|
-
var v =
|
|
495
|
-
var w =
|
|
495
|
+
var v = `${v_}`;
|
|
496
|
+
var w = `${w_}`;
|
|
496
497
|
if (!isDirected && v > w) {
|
|
497
498
|
var tmp = v;
|
|
498
499
|
v = w;
|
package/src/graphlib/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Graph } from
|
|
2
|
-
export const version:
|
|
1
|
+
import { Graph } from "./graph.js";
|
|
2
|
+
export const version: "2.1.9-pre";
|
|
3
3
|
export { Graph };
|
package/src/graphlib/index.js
CHANGED
package/src/graphlib/json.d.ts
CHANGED
package/src/graphlib/json.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ } from
|
|
2
|
-
import { Graph } from
|
|
1
|
+
import { _ } from "../lodash-es/index.ts";
|
|
2
|
+
import { Graph } from "./graph.js";
|
|
3
3
|
|
|
4
4
|
export { write, read };
|
|
5
5
|
|
|
@@ -20,7 +20,7 @@ function write(g) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
function writeNodes(g) {
|
|
23
|
-
return _.map(g.nodes(),
|
|
23
|
+
return _.map(g.nodes(), (v) => {
|
|
24
24
|
var nodeValue = g.node(v);
|
|
25
25
|
var parent = g.parent(v);
|
|
26
26
|
var node = { v: v };
|
|
@@ -35,7 +35,7 @@ function writeNodes(g) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function writeEdges(g) {
|
|
38
|
-
return _.map(g.edges(),
|
|
38
|
+
return _.map(g.edges(), (e) => {
|
|
39
39
|
var edgeValue = g.edge(e);
|
|
40
40
|
var edge = { v: e.v, w: e.w };
|
|
41
41
|
if (!_.isUndefined(e.name)) {
|
|
@@ -50,13 +50,13 @@ function writeEdges(g) {
|
|
|
50
50
|
|
|
51
51
|
function read(json) {
|
|
52
52
|
var g = new Graph(json.options).setGraph(json.value);
|
|
53
|
-
_.each(json.nodes,
|
|
53
|
+
_.each(json.nodes, (entry) => {
|
|
54
54
|
g.setNode(entry.v, entry.value);
|
|
55
55
|
if (entry.parent) {
|
|
56
56
|
g.setParent(entry.v, entry.parent);
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
|
-
_.each(json.edges,
|
|
59
|
+
_.each(json.edges, (entry) => {
|
|
60
60
|
g.setEdge({ v: entry.v, w: entry.w, name: entry.name }, entry.value);
|
|
61
61
|
});
|
|
62
62
|
return g;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { serializeCss } from "../utils/serializeCss.
|
|
1
|
+
import { serializeCss } from "../utils/serializeCss.js";
|
|
2
2
|
import {
|
|
3
3
|
activeStatesStyle,
|
|
4
4
|
activeTransitionsStyle,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
buildStateDetailsStyleWithModifier,
|
|
9
9
|
selectedStatesStyle,
|
|
10
10
|
selectedTransitionsStyle,
|
|
11
|
-
} from "./buildStatechartStyles.
|
|
11
|
+
} from "./buildStatechartStyles.js";
|
|
12
12
|
|
|
13
13
|
export function buildStatechartCss({ prefix = "" } = {}): string {
|
|
14
14
|
const root = prefix || ":root";
|
|
@@ -3,10 +3,10 @@ import type {
|
|
|
3
3
|
Padding,
|
|
4
4
|
Position,
|
|
5
5
|
TransitionsGraph,
|
|
6
|
-
} from "../types/index.
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
} from "../types/index.js";
|
|
7
|
+
import { BasisCurve } from "../utils/BasisCurve.js";
|
|
8
|
+
import { getPadding } from "../utils/getPadding.js";
|
|
9
|
+
import { serializeAttrs } from "../utils/serializeAttrs.js";
|
|
10
10
|
|
|
11
11
|
function getBoxParams({
|
|
12
12
|
x,
|
|
@@ -101,13 +101,13 @@ export function buildStatechartSvg({
|
|
|
101
101
|
x2: number,
|
|
102
102
|
y2: number,
|
|
103
103
|
) {
|
|
104
|
-
path.push(
|
|
104
|
+
path.push(`C${round(x0, y0, x1, y1, x2, y2).join(",")}`);
|
|
105
105
|
},
|
|
106
106
|
moveTo(x: number, y: number) {
|
|
107
|
-
path.push(
|
|
107
|
+
path.push(`M${round(x, y).join(",")}`);
|
|
108
108
|
},
|
|
109
109
|
lineTo(x: number, y: number) {
|
|
110
|
-
path.push(
|
|
110
|
+
path.push(`L${round(x, y).join(",")}`);
|
|
111
111
|
},
|
|
112
112
|
closePath() {
|
|
113
113
|
path.push("Z");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { StateChart } from "../types/StateChart.
|
|
2
|
-
import { buildStatechartSvg } from "./buildStatechartSvg.
|
|
1
|
+
import type { StateChart } from "../types/StateChart.js";
|
|
2
|
+
import { buildStatechartSvg } from "./buildStatechartSvg.js";
|
|
3
3
|
|
|
4
4
|
export function buildStatechartsPanel({
|
|
5
5
|
statechart,
|
package/src/html/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./buildStatechartCss.
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
1
|
+
export * from "./buildStatechartCss.js";
|
|
2
|
+
export * from "./buildStatechartStyles.js";
|
|
3
|
+
export * from "./buildStatechartSvg.js";
|
|
4
|
+
export * from "./buildStatechartsPanel.js";
|
package/src/index-config.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "./
|
|
1
|
+
export * from "./config/index.js";
|
|
2
|
+
export type * from "./types/index.js";
|
package/src/index-dom.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./dom/index.
|
|
1
|
+
export * from "./dom/index.js";
|
package/src/index-html.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "./
|
|
1
|
+
export * from "./html/index.js";
|
|
2
|
+
export type * from "./types/index.js";
|
package/src/index-layout.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "./
|
|
1
|
+
export * from "./layout/index.js";
|
|
2
|
+
export type * from "./types/index.js";
|
package/src/index-runtime.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "./
|
|
1
|
+
export * from "./runtime/index.js";
|
|
2
|
+
export type * from "./types/index.js";
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "./dom/index.
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./layout/index.
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./utils/
|
|
8
|
-
export * from "./utils/
|
|
1
|
+
export * from "./config/index.js";
|
|
2
|
+
export * from "./dom/index.js";
|
|
3
|
+
export * from "./html/index.js";
|
|
4
|
+
export * from "./layout/index.js";
|
|
5
|
+
export * from "./runtime/index.js";
|
|
6
|
+
export type * from "./types/index.js";
|
|
7
|
+
export * from "./utils/serializeCss.js";
|
|
8
|
+
export * from "./utils/toKebabCase.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type { StateChart } from "../types/StateChart.
|
|
1
|
+
import type { FsmStateConfig } from "../types/FsmStateConfig.js";
|
|
2
|
+
import type { GraphParamsProvider } from "../types/GraphParamsProvider.js";
|
|
3
|
+
import type { Padding } from "../types/Padding.js";
|
|
4
|
+
import type { StateChart } from "../types/StateChart.js";
|
|
5
5
|
|
|
6
|
-
import { buildFlatCharts } from "./buildFlatCharts.
|
|
6
|
+
import { buildFlatCharts } from "./buildFlatCharts.js";
|
|
7
7
|
/**
|
|
8
8
|
* Build graphs corresponding to the specified transitions.
|
|
9
9
|
* @param config - State configuration with transitions and sub-states.
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { layout } from "../dagre/layout.js";
|
|
2
2
|
import { Graph } from "../graphlib/graph.js";
|
|
3
|
-
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type { StateGraphEdge } from "../types/StateGraphEdge.
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
|
|
13
|
-
import { getPadding } from "../utils/getPadding.ts";
|
|
14
|
-
import { getLodash, setLodash } from "../lodash-es/index.ts";
|
|
3
|
+
import { getLodash, setLodash } from "../lodash-es/index.js";
|
|
4
|
+
import type { Dimensions } from "../types/Dimensions.js";
|
|
5
|
+
import type { GraphParamsProvider } from "../types/GraphParamsProvider.js";
|
|
6
|
+
import type { Padding } from "../types/Padding.js";
|
|
7
|
+
import type { Position } from "../types/Position.js";
|
|
8
|
+
import type { StateGraphEdge } from "../types/StateGraphEdge.js";
|
|
9
|
+
import type { StateGraphNode } from "../types/StateGraphNode.js";
|
|
10
|
+
import type { Transition } from "../types/Transition.js";
|
|
11
|
+
import type { TransitionsGraph } from "../types/TransitionsGraph.js";
|
|
12
|
+
import { getPadding } from "../utils/getPadding.js";
|
|
15
13
|
|
|
16
14
|
/**
|
|
17
15
|
* Build graphs corresponding to the specified transitions.
|
|
@@ -46,7 +44,7 @@ export function buildFlatCharts({
|
|
|
46
44
|
padding?: Padding;
|
|
47
45
|
direction?: "tb" | "bt" | "lr" | "rl";
|
|
48
46
|
} & GraphParamsProvider): TransitionsGraph {
|
|
49
|
-
|
|
47
|
+
const prevLodash = getLodash();
|
|
50
48
|
try {
|
|
51
49
|
setLodash(lodash);
|
|
52
50
|
const rankdir = direction || (vertical ? "tb" : "lr");
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { getLabelDimensions } from "./getLabelDimensions.ts";
|
|
6
|
-
import { getPadding } from "../utils/getPadding.ts";
|
|
7
|
-
import { Label } from "../types/Label.ts";
|
|
1
|
+
import type { GraphParamsProvider } from "../types/GraphParamsProvider.js";
|
|
2
|
+
import type { Padding } from "../types/Padding.js";
|
|
3
|
+
import { getPadding } from "../utils/getPadding.js";
|
|
4
|
+
import { getLabelDimensions } from "./getLabelDimensions.js";
|
|
8
5
|
|
|
9
6
|
/**
|
|
10
7
|
* Provides default functions measuring dimensions for state nodes and transition edges in the graph.
|
|
@@ -21,7 +18,7 @@ export function getGraphParamsProvider({
|
|
|
21
18
|
transitionsFontSize = fontSize,
|
|
22
19
|
transitionsTextPadding = 0,
|
|
23
20
|
getStateLabel = (state: string) => state,
|
|
24
|
-
getTransitionLabel = (
|
|
21
|
+
getTransitionLabel = (_fromState: string, event: string, _toState: string) =>
|
|
25
22
|
event,
|
|
26
23
|
}: {
|
|
27
24
|
fontSize?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Dimensions } from "../types/Dimensions.
|
|
2
|
-
import type { Padding } from "../types/Padding.
|
|
3
|
-
import { getPadding } from "../utils/getPadding.
|
|
1
|
+
import type { Dimensions } from "../types/Dimensions.js";
|
|
2
|
+
import type { Padding } from "../types/Padding.js";
|
|
3
|
+
import { getPadding } from "../utils/getPadding.js";
|
|
4
4
|
|
|
5
5
|
export function getLabelDimensions(
|
|
6
6
|
label: string,
|
|
@@ -14,7 +14,7 @@ export function getLabelDimensions(
|
|
|
14
14
|
fontSize?: number;
|
|
15
15
|
getCharWidth?: (char: string) => number;
|
|
16
16
|
lineGap?: number;
|
|
17
|
-
} = {}
|
|
17
|
+
} = {},
|
|
18
18
|
) {
|
|
19
19
|
const lines = [label]; // label.split("\n");
|
|
20
20
|
let dimensions: Dimensions = { width: 0, height: 0 };
|
|
@@ -27,7 +27,7 @@ export function getLabelDimensions(
|
|
|
27
27
|
line,
|
|
28
28
|
fontSize,
|
|
29
29
|
getCharWidth,
|
|
30
|
-
})
|
|
30
|
+
}),
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
const [top, right, bottom, left] = getPadding(padding);
|
package/src/layout/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Methods
|
|
2
|
-
|
|
3
|
-
export * from "./buildCharts.
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
2
|
+
|
|
3
|
+
export * from "./buildCharts.js";
|
|
4
|
+
export * from "./buildFlatCharts.js";
|
|
5
|
+
export * from "./getGraphParamsProvider.js";
|
|
6
|
+
export * from "./getLabelDimensions.js";
|