@statewalker/fsm-charts 0.2.4 → 0.2.6

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.
Files changed (155) hide show
  1. package/README.md +206 -1
  2. package/dist/StateChart-cXyVRcs-.d.ts +94 -0
  3. package/dist/StateChart-cXyVRcs-.d.ts.map +1 -0
  4. package/dist/StateChartIndex-BK2315qj.d.ts +142 -0
  5. package/dist/StateChartIndex-BK2315qj.d.ts.map +1 -0
  6. package/dist/StateChartIndex-BOIrc_nq.js +355 -0
  7. package/dist/StateChartIndex-BOIrc_nq.js.map +1 -0
  8. package/dist/buildStatechartsPanel-CxQlIwTh.js +494 -0
  9. package/dist/buildStatechartsPanel-CxQlIwTh.js.map +1 -0
  10. package/dist/buildStatechartsPanel-hCtZbdiF.d.ts +79 -0
  11. package/dist/buildStatechartsPanel-hCtZbdiF.d.ts.map +1 -0
  12. package/dist/defineProperty-C0rC37pP.js +39 -0
  13. package/dist/description-panels-DI2MNlbK.js +184 -0
  14. package/dist/description-panels-DI2MNlbK.js.map +1 -0
  15. package/dist/getLabelDimensions-BY0q7j3D.d.ts +79 -0
  16. package/dist/getLabelDimensions-BY0q7j3D.d.ts.map +1 -0
  17. package/dist/getPadding-Cw0e7G2v.js +25 -0
  18. package/dist/getPadding-Cw0e7G2v.js.map +1 -0
  19. package/dist/index-config.d.ts +3 -12
  20. package/dist/index-config.js +2 -1
  21. package/dist/index-dom.d.ts +2 -49
  22. package/dist/index-dom.js +2 -1
  23. package/dist/index-html.d.ts +3 -2
  24. package/dist/index-html.js +2 -2
  25. package/dist/index-layout.d.ts +3 -77
  26. package/dist/index-layout.js +2 -2
  27. package/dist/index-runtime.d.ts +3 -141
  28. package/dist/index-runtime.js +2 -1
  29. package/dist/index.d.ts +11 -10
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +6 -6
  32. package/dist/layout-Dp671N6q.js +2465 -0
  33. package/dist/layout-Dp671N6q.js.map +1 -0
  34. package/dist/newTreeBuilder-CvtLDjGj.d.ts +54 -0
  35. package/dist/newTreeBuilder-CvtLDjGj.d.ts.map +1 -0
  36. package/dist/toFsmStateConfig-DlJkyZni.js +135 -0
  37. package/dist/toFsmStateConfig-DlJkyZni.js.map +1 -0
  38. package/dist/toFsmStateConfig-DmOlTRjv.d.ts +15 -0
  39. package/dist/toFsmStateConfig-DmOlTRjv.d.ts.map +1 -0
  40. package/package.json +54 -28
  41. package/src/config/concatTransitionsToString.ts +4 -4
  42. package/src/config/index.ts +4 -4
  43. package/src/config/serializeProcessConfig.ts +3 -3
  44. package/src/config/splitTransitionString.ts +2 -4
  45. package/src/config/toFsmStateConfig.ts +5 -12
  46. package/src/dagre/acyclic.js +9 -10
  47. package/src/dagre/add-border-segments.js +11 -7
  48. package/src/dagre/coordinate-system.js +12 -12
  49. package/src/dagre/data/list.js +2 -2
  50. package/src/dagre/debug.d.ts +1 -1
  51. package/src/dagre/debug.js +11 -11
  52. package/src/dagre/greedy-fas.js +17 -21
  53. package/src/dagre/index.d.ts +4 -4
  54. package/src/dagre/index.js +4 -4
  55. package/src/dagre/layout.js +107 -96
  56. package/src/dagre/nesting-graph.js +13 -19
  57. package/src/dagre/normalize.js +7 -7
  58. package/src/dagre/order/add-subgraph-constraints.js +2 -2
  59. package/src/dagre/order/barycenter.d.ts +1 -1
  60. package/src/dagre/order/barycenter.js +4 -4
  61. package/src/dagre/order/build-layer-graph.d.ts +1 -1
  62. package/src/dagre/order/build-layer-graph.js +7 -9
  63. package/src/dagre/order/cross-count.js +14 -17
  64. package/src/dagre/order/index.js +19 -17
  65. package/src/dagre/order/init-order.js +5 -15
  66. package/src/dagre/order/resolve-conflicts.js +10 -14
  67. package/src/dagre/order/sort-subgraph.d.ts +1 -1
  68. package/src/dagre/order/sort-subgraph.js +13 -14
  69. package/src/dagre/order/sort.d.ts +1 -1
  70. package/src/dagre/order/sort.js +6 -10
  71. package/src/dagre/parent-dummy-chains.js +10 -4
  72. package/src/dagre/position/bk.d.ts +3 -3
  73. package/src/dagre/position/bk.js +84 -65
  74. package/src/dagre/position/index.js +7 -11
  75. package/src/dagre/rank/feasible-tree.d.ts +1 -1
  76. package/src/dagre/rank/feasible-tree.js +6 -6
  77. package/src/dagre/rank/index.js +6 -6
  78. package/src/dagre/rank/network-simplex.d.ts +0 -1
  79. package/src/dagre/rank/network-simplex.js +20 -25
  80. package/src/dagre/rank/util.js +2 -6
  81. package/src/dagre/util.d.ts +12 -6
  82. package/src/dagre/util.js +31 -37
  83. package/src/dom/buildSections.ts +15 -19
  84. package/src/dom/description-panels.ts +5 -7
  85. package/src/dom/getStatesDescriptions.ts +4 -10
  86. package/src/full/index.ts +1 -1
  87. package/src/full/toFsmStateCharts.ts +11 -11
  88. package/src/graphlib/alg/components.js +2 -2
  89. package/src/graphlib/alg/dfs.js +5 -5
  90. package/src/graphlib/alg/dijkstra-all.js +4 -4
  91. package/src/graphlib/alg/dijkstra.js +9 -12
  92. package/src/graphlib/alg/find-cycles.js +7 -5
  93. package/src/graphlib/alg/floyd-warshall.js +8 -11
  94. package/src/graphlib/alg/index.d.ts +11 -11
  95. package/src/graphlib/alg/index.js +11 -11
  96. package/src/graphlib/alg/is-acyclic.js +1 -1
  97. package/src/graphlib/alg/postorder.js +2 -2
  98. package/src/graphlib/alg/preorder.js +2 -2
  99. package/src/graphlib/alg/prim.d.ts +1 -1
  100. package/src/graphlib/alg/prim.js +5 -5
  101. package/src/graphlib/alg/tarjan.js +3 -3
  102. package/src/graphlib/alg/topsort.js +1 -1
  103. package/src/graphlib/data/priority-queue.js +8 -10
  104. package/src/graphlib/graph.js +53 -52
  105. package/src/graphlib/index.d.ts +2 -2
  106. package/src/graphlib/index.js +2 -2
  107. package/src/graphlib/json.d.ts +1 -1
  108. package/src/graphlib/json.js +6 -6
  109. package/src/html/buildStatechartCss.ts +2 -2
  110. package/src/html/buildStatechartStyles.ts +5 -15
  111. package/src/html/buildStatechartSvg.ts +8 -20
  112. package/src/html/buildStatechartsPanel.ts +3 -5
  113. package/src/html/index.ts +4 -4
  114. package/src/index-config.ts +2 -2
  115. package/src/index-dom.ts +1 -1
  116. package/src/index-html.ts +2 -2
  117. package/src/index-layout.ts +2 -2
  118. package/src/index-runtime.ts +2 -2
  119. package/src/index.ts +8 -8
  120. package/src/layout/buildCharts.ts +6 -7
  121. package/src/layout/buildFlatCharts.ts +17 -21
  122. package/src/layout/getGraphParamsProvider.ts +7 -19
  123. package/src/layout/getLabelDimensions.ts +5 -5
  124. package/src/layout/index.ts +5 -4
  125. package/src/lodash-es/index.ts +2 -2
  126. package/src/lodash-es/types.ts +37 -35
  127. package/src/runtime/RuntimeStatechartApi.ts +13 -46
  128. package/src/runtime/StateChartIndex.ts +7 -24
  129. package/src/runtime/index.ts +2 -2
  130. package/src/types/FsmStateConfig.ts +1 -1
  131. package/src/types/GraphParamsProvider.ts +3 -6
  132. package/src/types/Position.ts +1 -1
  133. package/src/types/StateChart.ts +2 -2
  134. package/src/types/StateGraphEdge.ts +2 -2
  135. package/src/types/StateGraphNode.ts +2 -2
  136. package/src/types/TransitionsGraph.ts +4 -4
  137. package/src/types/index.ts +11 -11
  138. package/src/utils/BasisCurve.ts +6 -15
  139. package/src/utils/domToText.ts +3 -7
  140. package/src/utils/getPadding.ts +2 -3
  141. package/src/utils/newId.ts +2 -1
  142. package/src/utils/newRegistry.ts +13 -13
  143. package/src/utils/serializeAttrs.ts +6 -14
  144. package/src/utils/serializeCss.ts +3 -7
  145. package/src/utils/serializeStyle.ts +2 -5
  146. package/src/utils/toKebabCase.ts +1 -4
  147. package/CHANGELOG.md +0 -1
  148. package/dist/StateChart-BYBjTmC2.d.ts +0 -82
  149. package/dist/chunk-36ZLXJVD.js +0 -606
  150. package/dist/chunk-AZBRQNTU.js +0 -2739
  151. package/dist/chunk-FIQDLBWD.js +0 -9
  152. package/dist/chunk-SVKVQY7B.js +0 -133
  153. package/dist/chunk-TZHCBZVP.js +0 -422
  154. package/dist/chunk-VILLJJJD.js +0 -231
  155. package/dist/index-html-DgSCNHkR.d.ts +0 -75
package/src/dagre/util.js CHANGED
@@ -1,5 +1,5 @@
1
- import { _ } from '../lodash-es/index.ts';
2
- import { Graph } from '../graphlib/index.js';
1
+ import { Graph } from "../graphlib/index.js";
2
+ import { _ } from "../lodash-es/index.ts";
3
3
 
4
4
  export {
5
5
  addDummyNode,
@@ -38,10 +38,10 @@ function addDummyNode(g, type, attrs, name) {
38
38
  */
39
39
  function simplify(g) {
40
40
  var simplified = new Graph().setGraph(g.graph());
41
- _.forEach(g.nodes(), function (v) {
41
+ _.forEach(g.nodes(), (v) => {
42
42
  simplified.setNode(v, g.node(v));
43
43
  });
44
- _.forEach(g.edges(), function (e) {
44
+ _.forEach(g.edges(), (e) => {
45
45
  var simpleLabel = simplified.edge(e.v, e.w) || { weight: 0, minlen: 1 };
46
46
  var label = g.edge(e);
47
47
  simplified.setEdge(e.v, e.w, {
@@ -53,22 +53,24 @@ function simplify(g) {
53
53
  }
54
54
 
55
55
  function asNonCompoundGraph(g) {
56
- var simplified = new Graph({ multigraph: g.isMultigraph() }).setGraph(g.graph());
57
- _.forEach(g.nodes(), function (v) {
56
+ var simplified = new Graph({ multigraph: g.isMultigraph() }).setGraph(
57
+ g.graph(),
58
+ );
59
+ _.forEach(g.nodes(), (v) => {
58
60
  if (!g.children(v).length) {
59
61
  simplified.setNode(v, g.node(v));
60
62
  }
61
63
  });
62
- _.forEach(g.edges(), function (e) {
64
+ _.forEach(g.edges(), (e) => {
63
65
  simplified.setEdge(e, g.edge(e));
64
66
  });
65
67
  return simplified;
66
68
  }
67
69
 
68
70
  function successorWeights(g) {
69
- var weightMap = _.map(g.nodes(), function (v) {
71
+ var weightMap = _.map(g.nodes(), (v) => {
70
72
  var sucs = {};
71
- _.forEach(g.outEdges(v), function (e) {
73
+ _.forEach(g.outEdges(v), (e) => {
72
74
  sucs[e.w] = (sucs[e.w] || 0) + g.edge(e).weight;
73
75
  });
74
76
  return sucs;
@@ -77,9 +79,9 @@ function successorWeights(g) {
77
79
  }
78
80
 
79
81
  function predecessorWeights(g) {
80
- var weightMap = _.map(g.nodes(), function (v) {
82
+ var weightMap = _.map(g.nodes(), (v) => {
81
83
  var preds = {};
82
- _.forEach(g.inEdges(v), function (e) {
84
+ _.forEach(g.inEdges(v), (e) => {
83
85
  preds[e.v] = (preds[e.v] || 0) + g.edge(e).weight;
84
86
  });
85
87
  return preds;
@@ -103,7 +105,9 @@ function intersectRect(rect, point) {
103
105
  var h = rect.height / 2;
104
106
 
105
107
  if (!dx && !dy) {
106
- throw new Error('Not possible to find intersection inside of the rectangle');
108
+ throw new Error(
109
+ "Not possible to find intersection inside of the rectangle",
110
+ );
107
111
  }
108
112
 
109
113
  var sx, sy;
@@ -131,10 +135,8 @@ function intersectRect(rect, point) {
131
135
  * function will produce a matrix with the ids of each node.
132
136
  */
133
137
  function buildLayerMatrix(g) {
134
- var layering = _.map(_.range(maxRank(g) + 1), function () {
135
- return [];
136
- });
137
- _.forEach(g.nodes(), function (v) {
138
+ var layering = _.map(_.range(maxRank(g) + 1), () => []);
139
+ _.forEach(g.nodes(), (v) => {
138
140
  var node = g.node(v);
139
141
  var rank = node.rank;
140
142
  if (!_.isUndefined(rank)) {
@@ -149,14 +151,10 @@ function buildLayerMatrix(g) {
149
151
  * rank(v) >= 0 and at least one node w has rank(w) = 0.
150
152
  */
151
153
  function normalizeRanks(g) {
152
- var min = _.min(
153
- _.map(g.nodes(), function (v) {
154
- return g.node(v).rank;
155
- })
156
- );
157
- _.forEach(g.nodes(), function (v) {
154
+ var min = _.min(_.map(g.nodes(), (v) => g.node(v).rank));
155
+ _.forEach(g.nodes(), (v) => {
158
156
  var node = g.node(v);
159
- if (_.has(node, 'rank')) {
157
+ if (_.has(node, "rank")) {
160
158
  node.rank -= min;
161
159
  }
162
160
  });
@@ -164,14 +162,10 @@ function normalizeRanks(g) {
164
162
 
165
163
  function removeEmptyRanks(g) {
166
164
  // Ranks may not start at 0, so we need to offset them
167
- var offset = _.min(
168
- _.map(g.nodes(), function (v) {
169
- return g.node(v).rank;
170
- })
171
- );
165
+ var offset = _.min(_.map(g.nodes(), (v) => g.node(v).rank));
172
166
 
173
167
  var layers = [];
174
- _.forEach(g.nodes(), function (v) {
168
+ _.forEach(g.nodes(), (v) => {
175
169
  var rank = g.node(v).rank - offset;
176
170
  if (!layers[rank]) {
177
171
  layers[rank] = [];
@@ -181,11 +175,11 @@ function removeEmptyRanks(g) {
181
175
 
182
176
  var delta = 0;
183
177
  var nodeRankFactor = g.graph().nodeRankFactor;
184
- _.forEach(layers, function (vs, i) {
178
+ _.forEach(layers, (vs, i) => {
185
179
  if (_.isUndefined(vs) && i % nodeRankFactor !== 0) {
186
180
  --delta;
187
181
  } else if (delta) {
188
- _.forEach(vs, function (v) {
182
+ _.forEach(vs, (v) => {
189
183
  g.node(v).rank += delta;
190
184
  });
191
185
  }
@@ -201,17 +195,17 @@ function addBorderNode(g, prefix, rank, order) {
201
195
  node.rank = rank;
202
196
  node.order = order;
203
197
  }
204
- return addDummyNode(g, 'border', node, prefix);
198
+ return addDummyNode(g, "border", node, prefix);
205
199
  }
206
200
 
207
201
  function maxRank(g) {
208
202
  return _.max(
209
- _.map(g.nodes(), function (v) {
203
+ _.map(g.nodes(), (v) => {
210
204
  var rank = g.node(v).rank;
211
205
  if (!_.isUndefined(rank)) {
212
206
  return rank;
213
207
  }
214
- })
208
+ }),
215
209
  );
216
210
  }
217
211
 
@@ -222,7 +216,7 @@ function maxRank(g) {
222
216
  */
223
217
  function partition(collection, fn) {
224
218
  var result = { lhs: [], rhs: [] };
225
- _.forEach(collection, function (value) {
219
+ _.forEach(collection, (value) => {
226
220
  if (fn(value)) {
227
221
  result.lhs.push(value);
228
222
  } else {
@@ -241,10 +235,10 @@ function time(name, fn) {
241
235
  try {
242
236
  return fn();
243
237
  } finally {
244
- console.log(name + ' time: ' + (_.now() - start) + 'ms');
238
+ console.log(`${name} time: ${_.now() - start}ms`);
245
239
  }
246
240
  }
247
241
 
248
- function notime(name, fn) {
242
+ function notime(_name, fn) {
249
243
  return fn();
250
244
  }
@@ -12,14 +12,14 @@ export function buildSections(root: HTMLElement | Iterable<Node>): DomSection {
12
12
  let peek: DomSection = null!;
13
13
  const stack: DomSection[] = [];
14
14
  const aligner = newTreeBuilder<[HTMLElement?]>({
15
- enter(level, header) {
15
+ enter(_level, header) {
16
16
  const section: DomSection = {
17
17
  header,
18
18
  content: [],
19
19
  children: [],
20
20
  };
21
21
  top = top || section;
22
- peek && peek.children.push(section);
22
+ peek?.children.push(section);
23
23
  peek = section;
24
24
  stack.push(section);
25
25
  },
@@ -29,20 +29,20 @@ export function buildSections(root: HTMLElement | Iterable<Node>): DomSection {
29
29
  },
30
30
  });
31
31
  aligner(0);
32
- let currentHeaderLevel = 0;
33
- let currentLevel = 0;
32
+ // Track the actual header magnitudes of the open ancestor sections. A header of
33
+ // level L closes every open header at its level or deeper, then opens at the
34
+ // resulting depth. Deriving depth from the real magnitudes (not a ±1 delta) keeps
35
+ // nesting correct for any header sequence and never goes negative.
36
+ const headerLevels: number[] = [];
34
37
  for (const node of nodes) {
35
38
  if (isDomElement(node)) {
36
39
  if (/^H[1-6]$/i.test(node.tagName)) {
37
40
  const headerLevel = +node.tagName.replace(/^H/, "");
38
- currentLevel =
39
- headerLevel > currentHeaderLevel
40
- ? currentLevel + 1
41
- : headerLevel < currentHeaderLevel
42
- ? currentLevel - 1
43
- : currentLevel;
44
- currentHeaderLevel = headerLevel;
45
- aligner(currentLevel, node);
41
+ while (headerLevels.length > 0 && headerLevels[headerLevels.length - 1] >= headerLevel) {
42
+ headerLevels.pop();
43
+ }
44
+ headerLevels.push(headerLevel);
45
+ aligner(headerLevels.length, node);
46
46
  } else {
47
47
  peek.content.push(node);
48
48
  }
@@ -73,13 +73,11 @@ export function* vistSections(
73
73
  }
74
74
  }
75
75
 
76
- export function findSection(
77
- section: DomSection,
78
- accept: (section: DomSection) => boolean,
79
- ) {
76
+ export function findSection(section: DomSection, accept: (section: DomSection) => boolean) {
80
77
  for (const s of vistSections(section)) {
81
78
  if (accept(s) === true) return s;
82
79
  }
80
+ return undefined;
83
81
  }
84
82
 
85
83
  // --------------------------------------------
@@ -89,9 +87,7 @@ export function isDomElement(node: Node): node is HTMLElement {
89
87
  return node.nodeType === Node.ELEMENT_NODE;
90
88
  }
91
89
 
92
- export function* toDomNodesIterator(
93
- root: Node | Iterable<Node>,
94
- ): Iterable<Node> {
90
+ export function* toDomNodesIterator(root: Node | Iterable<Node>): Iterable<Node> {
95
91
  yield* root instanceof Node ? visitDom(root) : root;
96
92
  }
97
93
 
@@ -1,12 +1,10 @@
1
- import { type DomSection } from "./buildSections.js";
1
+ import type { DomSection } from "./buildSections.js";
2
2
  import { getStatesDescriptions } from "./getStatesDescriptions.js";
3
3
 
4
4
  export function getStateDescriptionRenderer(options: {
5
5
  element: HTMLElement;
6
6
  rootStateKey: string;
7
- splitHeader?: (
8
- header?: HTMLElement,
9
- ) => [stateKey: undefined | string, label: string];
7
+ splitHeader?: (header?: HTMLElement) => [stateKey: undefined | string, label: string];
10
8
  }) {
11
9
  const descriptionsIndex = getStatesDescriptions(options);
12
10
 
@@ -19,7 +17,7 @@ export function getStateDescriptionRenderer(options: {
19
17
 
20
18
  const elm = renderSections({
21
19
  section,
22
- deep: (section) => false, // section.state !== options.rootStateKey, // ???
20
+ deep: (_section) => false, // section.state !== options.rootStateKey, // ???
23
21
  header: (section) => {
24
22
  if (section.state === stateKey) {
25
23
  return section.title || section.state;
@@ -28,14 +26,14 @@ export function getStateDescriptionRenderer(options: {
28
26
  },
29
27
  });
30
28
  const details = elm?.querySelector("details");
31
- details && (details.open = true);
29
+ if (details) details.open = true;
32
30
  return elm;
33
31
  };
34
32
  }
35
33
 
36
34
  export function renderSections<T extends DomSection>({
37
35
  section,
38
- deep = (s) => true,
36
+ deep = (_s) => true,
39
37
  header = (section) => section.header?.cloneNode(true) as Node,
40
38
  }: {
41
39
  section: T;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  buildSections,
3
+ type DomSection,
3
4
  findSection,
4
5
  visitSectionNodes,
5
6
  vistSections,
6
- type DomSection,
7
7
  } from "./buildSections.js";
8
8
 
9
9
  export type StateDescriptionSection = DomSection & {
@@ -14,9 +14,7 @@ export function* visitStateDescriptions({
14
14
  element,
15
15
  rootStateKey,
16
16
  removeFromDom = true,
17
- splitHeader = (
18
- header?: HTMLElement,
19
- ): [stateKey: undefined | string, label: string] => {
17
+ splitHeader = (header?: HTMLElement): [stateKey: undefined | string, label: string] => {
20
18
  if (!header) return [undefined, ""];
21
19
  const text = header.innerText.trim();
22
20
  let key: string | undefined;
@@ -32,9 +30,7 @@ export function* visitStateDescriptions({
32
30
  element: HTMLElement;
33
31
  rootStateKey: string;
34
32
  removeFromDom?: boolean; // If true - removes state description nodes from the DOM
35
- splitHeader?: (
36
- header?: HTMLElement,
37
- ) => [stateKey: undefined | string, label: string];
33
+ splitHeader?: (header?: HTMLElement) => [stateKey: undefined | string, label: string];
38
34
  }): Generator<StateDescriptionSection> {
39
35
  const docSections = buildSections(element);
40
36
  const rootDescription = findSection(docSections, (section: DomSection) => {
@@ -68,9 +64,7 @@ export function getStatesDescriptions(options: {
68
64
  element: HTMLElement;
69
65
  rootStateKey: string;
70
66
  removeFromDom?: boolean; // If true - removes state description nodes from the DOM
71
- splitHeader?: (
72
- header?: HTMLElement,
73
- ) => [stateKey: undefined | string, label: string];
67
+ splitHeader?: (header?: HTMLElement) => [stateKey: undefined | string, label: string];
74
68
  }): { [state: string]: StateDescriptionSection } {
75
69
  const index: { [state: string]: StateDescriptionSection } = {};
76
70
  for (const description of visitStateDescriptions(options)) {
package/src/full/index.ts CHANGED
@@ -1 +1 @@
1
- export * from "./toFsmStateCharts.ts";
1
+ export * from "./toFsmStateCharts.js";
@@ -1,14 +1,14 @@
1
- import { newId } from "../utils/newId.ts";
2
- import { newRegistry } from "../utils/newRegistry.ts";
3
- import { RuntimeStatechartApi, StateChartIndex } from "../runtime/index.ts";
4
1
  import {
5
2
  buildStatechartCss,
6
3
  buildStatechartsPanel,
7
- FsmStateConfig,
8
- StateChart,
9
- StateGraphEdge,
10
- } from "../index-html.ts";
11
- import { buildCharts, getGraphParamsProvider } from "../index-layout.ts";
4
+ type FsmStateConfig,
5
+ type StateChart,
6
+ type StateGraphEdge,
7
+ } from "../index-html.js";
8
+ import { buildCharts, getGraphParamsProvider } from "../index-layout.js";
9
+ import { RuntimeStatechartApi, StateChartIndex } from "../runtime/index.js";
10
+ import { newId } from "../utils/newId.js";
11
+ import { newRegistry } from "../utils/newRegistry.js";
12
12
 
13
13
  export type FsmStateCharts = {
14
14
  api: RuntimeStatechartApi;
@@ -92,11 +92,11 @@ ${css}
92
92
  const stateId = node.id;
93
93
  if (i < nodes.length - 1 || selected) {
94
94
  const transitions = index.getTransitions(stateId);
95
- transitions.forEach((t) => api.selectTransition(t.id));
95
+ for (const t of transitions) api.selectTransition(t.id);
96
96
  }
97
97
  }
98
98
  // api.focusStates(...nodeIds);
99
- })
99
+ }),
100
100
  );
101
101
 
102
102
  if (onTransitionClick) {
@@ -104,7 +104,7 @@ ${css}
104
104
  api.onTransitionClick((transitionId) => {
105
105
  const transition = index.getEdgeById(transitionId);
106
106
  transition && onTransitionClick(transition);
107
- })
107
+ }),
108
108
  );
109
109
  }
110
110
  return {
@@ -1,4 +1,4 @@
1
- import { _ } from '../../lodash-es/index.ts';
1
+ import { _ } from "../../lodash-es/index.ts";
2
2
 
3
3
  export { components };
4
4
 
@@ -15,7 +15,7 @@ function components(g) {
15
15
  _.each(g.predecessors(v), dfs);
16
16
  }
17
17
 
18
- _.each(g.nodes(), function (v) {
18
+ _.each(g.nodes(), (v) => {
19
19
  cmpt = [];
20
20
  dfs(v);
21
21
  if (cmpt.length) {
@@ -1,4 +1,4 @@
1
- import { _ } from '../../lodash-es/index.ts';
1
+ import { _ } from "../../lodash-es/index.ts";
2
2
 
3
3
  export { dfs };
4
4
 
@@ -19,12 +19,12 @@ function dfs(g, vs, order) {
19
19
 
20
20
  var acc = [];
21
21
  var visited = {};
22
- _.each(vs, function (v) {
22
+ _.each(vs, (v) => {
23
23
  if (!g.hasNode(v)) {
24
- throw new Error('Graph does not have node: ' + v);
24
+ throw new Error(`Graph does not have node: ${v}`);
25
25
  }
26
26
 
27
- doDfs(g, v, order === 'post', visited, navigation, acc);
27
+ doDfs(g, v, order === "post", visited, navigation, acc);
28
28
  });
29
29
  return acc;
30
30
  }
@@ -36,7 +36,7 @@ function doDfs(g, v, postorder, visited, navigation, acc) {
36
36
  if (!postorder) {
37
37
  acc.push(v);
38
38
  }
39
- _.each(navigation(v), function (w) {
39
+ _.each(navigation(v), (w) => {
40
40
  doDfs(g, w, postorder, visited, navigation, acc);
41
41
  });
42
42
  if (postorder) {
@@ -1,14 +1,14 @@
1
- import { _ } from '../../lodash-es/index.ts';
2
- import { dijkstra } from './dijkstra.js';
1
+ import { _ } from "../../lodash-es/index.ts";
2
+ import { dijkstra } from "./dijkstra.js";
3
3
 
4
4
  export { dijkstraAll };
5
5
 
6
6
  function dijkstraAll(g, weightFunc, edgeFunc) {
7
7
  return _.transform(
8
8
  g.nodes(),
9
- function (acc, v) {
9
+ (acc, v) => {
10
10
  acc[v] = dijkstra(g, v, weightFunc, edgeFunc);
11
11
  },
12
- {}
12
+ {},
13
13
  );
14
14
  }
@@ -1,5 +1,5 @@
1
- import { _ } from '../../lodash-es/index.ts';
2
- import { PriorityQueue } from '../data/priority-queue.js';
1
+ import { _ } from "../../lodash-es/index.ts";
2
+ import { PriorityQueue } from "../data/priority-queue.js";
3
3
 
4
4
  export { dijkstra };
5
5
 
@@ -10,10 +10,7 @@ function dijkstra(g, source, weightFn, edgeFn) {
10
10
  g,
11
11
  String(source),
12
12
  weightFn || DEFAULT_WEIGHT_FUNC,
13
- edgeFn ||
14
- function (v) {
15
- return g.outEdges(v);
16
- }
13
+ edgeFn || ((v) => g.outEdges(v)),
17
14
  );
18
15
  }
19
16
 
@@ -22,7 +19,7 @@ function runDijkstra(g, source, weightFn, edgeFn) {
22
19
  var pq = new PriorityQueue();
23
20
  var v, vEntry;
24
21
 
25
- var updateNeighbors = function (edge) {
22
+ var updateNeighbors = (edge) => {
26
23
  var w = edge.v !== v ? edge.v : edge.w;
27
24
  var wEntry = results[w];
28
25
  var weight = weightFn(edge);
@@ -30,11 +27,11 @@ function runDijkstra(g, source, weightFn, edgeFn) {
30
27
 
31
28
  if (weight < 0) {
32
29
  throw new Error(
33
- 'dijkstra does not allow negative edge weights. ' +
34
- 'Bad edge: ' +
30
+ "dijkstra does not allow negative edge weights. " +
31
+ "Bad edge: " +
35
32
  edge +
36
- ' Weight: ' +
37
- weight
33
+ " Weight: " +
34
+ weight,
38
35
  );
39
36
  }
40
37
 
@@ -45,7 +42,7 @@ function runDijkstra(g, source, weightFn, edgeFn) {
45
42
  }
46
43
  };
47
44
 
48
- g.nodes().forEach(function (v) {
45
+ g.nodes().forEach((v) => {
49
46
  var distance = v === source ? 0 : Number.POSITIVE_INFINITY;
50
47
  results[v] = { distance: distance };
51
48
  pq.add(v, distance);
@@ -1,10 +1,12 @@
1
- import { _ } from '../../lodash-es/index.ts';
2
- import { tarjan } from './tarjan.js';
1
+ import { _ } from "../../lodash-es/index.ts";
2
+ import { tarjan } from "./tarjan.js";
3
3
 
4
4
  export { findCycles };
5
5
 
6
6
  function findCycles(g) {
7
- return _.filter(tarjan(g), function (cmpt) {
8
- return cmpt.length > 1 || (cmpt.length === 1 && g.hasEdge(cmpt[0], cmpt[0]));
9
- });
7
+ return _.filter(
8
+ tarjan(g),
9
+ (cmpt) =>
10
+ cmpt.length > 1 || (cmpt.length === 1 && g.hasEdge(cmpt[0], cmpt[0])),
11
+ );
10
12
  }
@@ -1,4 +1,4 @@
1
- import { _ } from '../../lodash-es/index.ts';
1
+ import { _ } from "../../lodash-es/index.ts";
2
2
 
3
3
  export { floydWarshall };
4
4
 
@@ -8,10 +8,7 @@ function floydWarshall(g, weightFn, edgeFn) {
8
8
  return runFloydWarshall(
9
9
  g,
10
10
  weightFn || DEFAULT_WEIGHT_FUNC,
11
- edgeFn ||
12
- function (v) {
13
- return g.outEdges(v);
14
- }
11
+ edgeFn || ((v) => g.outEdges(v)),
15
12
  );
16
13
  }
17
14
 
@@ -19,26 +16,26 @@ function runFloydWarshall(g, weightFn, edgeFn) {
19
16
  var results = {};
20
17
  var nodes = g.nodes();
21
18
 
22
- nodes.forEach(function (v) {
19
+ nodes.forEach((v) => {
23
20
  results[v] = {};
24
21
  results[v][v] = { distance: 0 };
25
- nodes.forEach(function (w) {
22
+ nodes.forEach((w) => {
26
23
  if (v !== w) {
27
24
  results[v][w] = { distance: Number.POSITIVE_INFINITY };
28
25
  }
29
26
  });
30
- edgeFn(v).forEach(function (edge) {
27
+ edgeFn(v).forEach((edge) => {
31
28
  var w = edge.v === v ? edge.w : edge.v;
32
29
  var d = weightFn(edge);
33
30
  results[v][w] = { distance: d, predecessor: v };
34
31
  });
35
32
  });
36
33
 
37
- nodes.forEach(function (k) {
34
+ nodes.forEach((k) => {
38
35
  var rowK = results[k];
39
- nodes.forEach(function (i) {
36
+ nodes.forEach((i) => {
40
37
  var rowI = results[i];
41
- nodes.forEach(function (j) {
38
+ nodes.forEach((j) => {
42
39
  var ik = rowI[k];
43
40
  var kj = rowK[j];
44
41
  var ij = rowI[j];
@@ -1,14 +1,14 @@
1
- import { components } from './components.js';
2
- import { dijkstra } from './dijkstra.js';
3
- import { dijkstraAll } from './dijkstra-all.js';
4
- import { findCycles } from './find-cycles.js';
5
- import { floydWarshall } from './floyd-warshall.js';
6
- import { isAcyclic } from './is-acyclic.js';
7
- import { postorder } from './postorder.js';
8
- import { preorder } from './preorder.js';
9
- import { prim } from './prim.js';
10
- import { tarjan } from './tarjan.js';
11
- import { topsort } from './topsort.js';
1
+ import { components } from "./components.js";
2
+ import { dijkstra } from "./dijkstra.js";
3
+ import { dijkstraAll } from "./dijkstra-all.js";
4
+ import { findCycles } from "./find-cycles.js";
5
+ import { floydWarshall } from "./floyd-warshall.js";
6
+ import { isAcyclic } from "./is-acyclic.js";
7
+ import { postorder } from "./postorder.js";
8
+ import { preorder } from "./preorder.js";
9
+ import { prim } from "./prim.js";
10
+ import { tarjan } from "./tarjan.js";
11
+ import { topsort } from "./topsort.js";
12
12
  export {
13
13
  components,
14
14
  dijkstra,
@@ -1,14 +1,14 @@
1
- import { components } from './components.js';
2
- import { dijkstra } from './dijkstra.js';
3
- import { dijkstraAll } from './dijkstra-all.js';
4
- import { findCycles } from './find-cycles.js';
5
- import { floydWarshall } from './floyd-warshall.js';
6
- import { isAcyclic } from './is-acyclic.js';
7
- import { postorder } from './postorder.js';
8
- import { preorder } from './preorder.js';
9
- import { prim } from './prim.js';
10
- import { tarjan } from './tarjan.js';
11
- import { topsort } from './topsort.js';
1
+ import { components } from "./components.js";
2
+ import { dijkstra } from "./dijkstra.js";
3
+ import { dijkstraAll } from "./dijkstra-all.js";
4
+ import { findCycles } from "./find-cycles.js";
5
+ import { floydWarshall } from "./floyd-warshall.js";
6
+ import { isAcyclic } from "./is-acyclic.js";
7
+ import { postorder } from "./postorder.js";
8
+ import { preorder } from "./preorder.js";
9
+ import { prim } from "./prim.js";
10
+ import { tarjan } from "./tarjan.js";
11
+ import { topsort } from "./topsort.js";
12
12
 
13
13
  export {
14
14
  components,
@@ -1,4 +1,4 @@
1
- import { topsort, CycleException } from './topsort.js';
1
+ import { CycleException, topsort } from "./topsort.js";
2
2
 
3
3
  export { isAcyclic };
4
4
 
@@ -1,7 +1,7 @@
1
- import { dfs } from './dfs.js';
1
+ import { dfs } from "./dfs.js";
2
2
 
3
3
  export { postorder };
4
4
 
5
5
  function postorder(g, vs) {
6
- return dfs(g, vs, 'post');
6
+ return dfs(g, vs, "post");
7
7
  }
@@ -1,7 +1,7 @@
1
- import { dfs } from './dfs.js';
1
+ import { dfs } from "./dfs.js";
2
2
 
3
3
  export { preorder };
4
4
 
5
5
  function preorder(g, vs) {
6
- return dfs(g, vs, 'pre');
6
+ return dfs(g, vs, "pre");
7
7
  }
@@ -1,2 +1,2 @@
1
1
  export function prim(g: any, weightFunc: any): Graph;
2
- import { Graph } from '../graph.js';
2
+ import { Graph } from "../graph.js";