@statewalker/fsm-charts 0.1.2 → 0.1.3

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.
@@ -28,10 +28,10 @@ var RuntimeStatechartApi = class {
28
28
  onTransitionClick(listener) {
29
29
  return this._addListener(this._transitionsClickListeners, listener);
30
30
  }
31
- openStatePenals() {
31
+ openStatePanels() {
32
32
  this._setStatePanelStatus(`details[data-state-id]`, true);
33
33
  }
34
- closeStatePenals() {
34
+ closeStatePanels() {
35
35
  this._setStatePanelStatus(`details[data-state-id]`, false);
36
36
  }
37
37
  isStatePanelOpen(stateId) {
@@ -44,7 +44,7 @@ var RuntimeStatechartApi = class {
44
44
  const lastId = stateIds[stateIds.length - 1];
45
45
  const selected = this.isStateSelected(lastId);
46
46
  this.deselectStates();
47
- this.closeStatePenals();
47
+ this.closeStatePanels();
48
48
  this.activateStates(...stateIds);
49
49
  if (selected) {
50
50
  this.deselectState(lastId);
@@ -242,9 +242,7 @@ var StateChartIndex = class {
242
242
  if (!node)
243
243
  break;
244
244
  result.push(node.id);
245
- list = node.children;
246
- if (!list?.length)
247
- list = node.nodes;
245
+ list = [...node.children || [], ...node.nodes || []];
248
246
  }
249
247
  return result.length === stack.length ? result : [];
250
248
  }
@@ -2474,8 +2474,9 @@ function buildFlatCharts({
2474
2474
  try {
2475
2475
  setLodash(lodash);
2476
2476
  const graph = new Graph({
2477
- directed: true
2478
- }).setGraph({ rankdir: vertical ? "tb" : "lr" }).setDefaultEdgeLabel(() => ({}));
2477
+ directed: true,
2478
+ multigraph: true
2479
+ }).setGraph({ rankdir: vertical ? "tb" : "lr", multigraph: true });
2479
2480
  const nodesIndex = {};
2480
2481
  const getStateNodeId = (key, state = key) => {
2481
2482
  let id = nodesIndex[key];
@@ -2492,12 +2493,18 @@ function buildFlatCharts({
2492
2493
  const toStateKey = toState || finalStateKey;
2493
2494
  const to = getStateNodeId(toStateKey, toState);
2494
2495
  const params = getTransitionParams(fromStateKey, event, toStateKey);
2495
- graph.setEdge(from, to, {
2496
- id: newId("t"),
2497
- ...params
2498
- });
2496
+ const edgeId = newId("t");
2497
+ graph.setEdge(
2498
+ from,
2499
+ to,
2500
+ {
2501
+ id: edgeId,
2502
+ ...params
2503
+ },
2504
+ edgeId
2505
+ );
2499
2506
  }
2500
- layout(graph, { rankdir: vertical ? "tb" : "lr" });
2507
+ layout(graph, { rankdir: "lr" });
2501
2508
  const [top, right, bottom, left] = getPadding(padding);
2502
2509
  const nodes = graph.nodes().map((id) => {
2503
2510
  const n = graph.node(id);
@@ -1,3 +1,3 @@
1
- export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-ZSGS37QH.js';
1
+ export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-OTGN3OYG.js';
2
2
  import './chunk-NXWOFQMO.js';
3
3
  import './chunk-XEO3YXBM.js';
@@ -16,8 +16,8 @@ declare class RuntimeStatechartApi {
16
16
  close(): void;
17
17
  onStateClick(listener: RuntimeListener): () => void;
18
18
  onTransitionClick(listener: RuntimeListener): () => void;
19
- openStatePenals(): void;
20
- closeStatePenals(): void;
19
+ openStatePanels(): void;
20
+ closeStatePanels(): void;
21
21
  isStatePanelOpen(stateId: string): boolean;
22
22
  toggleState(...stateIds: string[]): boolean;
23
23
  activateStates(...stateIds: string[]): void;
@@ -1,2 +1,2 @@
1
- export { RuntimeStatechartApi, StateChartIndex } from './chunk-UBYXED35.js';
1
+ export { RuntimeStatechartApi, StateChartIndex } from './chunk-4KTXTN7J.js';
2
2
  import './chunk-XEO3YXBM.js';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-ZSGS37QH.js';
1
+ export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-OTGN3OYG.js';
2
2
  export { buildStatechartCss, buildStatechartStyles, buildStatechartSvg, buildStatechartsPanel, serializeCss, toKebabCase } from './chunk-YYNW6Q2T.js';
3
3
  import './chunk-NXWOFQMO.js';
4
- export { RuntimeStatechartApi, StateChartIndex } from './chunk-UBYXED35.js';
4
+ export { RuntimeStatechartApi, StateChartIndex } from './chunk-4KTXTN7J.js';
5
5
  import './chunk-XEO3YXBM.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statewalker/fsm-charts",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "HFSM Implementation",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/statewalker/statewalker-fsm-charts",
@@ -49,9 +49,8 @@ export function buildFlatCharts({
49
49
  setLodash(lodash);
50
50
  const graph = new Graph({
51
51
  directed: true,
52
- })
53
- .setGraph({ rankdir: vertical ? "tb" : "lr" })
54
- .setDefaultEdgeLabel(() => ({}));
52
+ multigraph: true,
53
+ }).setGraph({ rankdir: vertical ? "tb" : "lr", multigraph: true });
55
54
 
56
55
  const nodesIndex: Record<string, string> = {};
57
56
 
@@ -71,12 +70,18 @@ export function buildFlatCharts({
71
70
  const toStateKey = toState || finalStateKey;
72
71
  const to = getStateNodeId(toStateKey, toState);
73
72
  const params = getTransitionParams(fromStateKey, event, toStateKey);
74
- graph.setEdge(from, to, {
75
- id: newId("t"),
76
- ...params,
77
- });
73
+ const edgeId = newId("t");
74
+ graph.setEdge(
75
+ from,
76
+ to,
77
+ {
78
+ id: edgeId,
79
+ ...params,
80
+ },
81
+ edgeId
82
+ );
78
83
  }
79
- layout(graph, { rankdir: vertical ? "tb" : "lr" });
84
+ layout(graph, { rankdir: "lr" });
80
85
 
81
86
  const [top, right, bottom, left] = getPadding(padding);
82
87
 
@@ -35,10 +35,10 @@ export class RuntimeStatechartApi {
35
35
  return this._addListener(this._transitionsClickListeners, listener);
36
36
  }
37
37
 
38
- openStatePenals() {
38
+ openStatePanels() {
39
39
  this._setStatePanelStatus(`details[data-state-id]`, true);
40
40
  }
41
- closeStatePenals() {
41
+ closeStatePanels() {
42
42
  this._setStatePanelStatus(`details[data-state-id]`, false);
43
43
  }
44
44
  isStatePanelOpen(stateId: string) {
@@ -52,7 +52,7 @@ export class RuntimeStatechartApi {
52
52
  const lastId = stateIds[stateIds.length - 1];
53
53
  const selected = this.isStateSelected(lastId);
54
54
  this.deselectStates();
55
- this.closeStatePenals();
55
+ this.closeStatePanels();
56
56
  this.activateStates(...stateIds);
57
57
  if (selected) {
58
58
  this.deselectState(lastId);
@@ -32,8 +32,7 @@ export class StateChartIndex {
32
32
  const node = list.find((node) => node.key === key);
33
33
  if (!node) break;
34
34
  result.push(node.id);
35
- list = node.children;
36
- if (!list?.length) list = node.nodes;
35
+ list = [...(node.children || []), ...(node.nodes || [])];
37
36
  }
38
37
  return result.length === stack.length ? result : [];
39
38
  }