@statewalker/fsm-charts 0.1.12 → 0.1.13

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.
@@ -2579,62 +2579,37 @@ function buildCharts({
2579
2579
  direction
2580
2580
  }) {
2581
2581
  return buildChart(config);
2582
- function buildChart(config2, id = newId("s"), stack = []) {
2583
- stack.push(config2);
2584
- try {
2585
- const getStateLabel = (state, key = state) => {
2586
- if (key === "<initial>" || key === "<final>") {
2587
- return "";
2588
- }
2589
- let result;
2590
- for (let i = stack.length - 1; result === void 0 && i >= 0; i--) {
2591
- const conf = stack[i];
2592
- console.log("WT", state, key, "=>", conf);
2593
- if (conf.key !== state) continue;
2594
- result = conf.label;
2595
- }
2596
- return result === void 0 ? state : result;
2597
- };
2598
- const graph = buildFlatCharts({
2599
- lodash,
2600
- transitions: config2.transitions || [],
2601
- newId,
2602
- getStateParams: (state, key) => {
2603
- const params = getStateParams(state, key);
2604
- params.text = getStateLabel(state, key);
2605
- return params;
2606
- },
2607
- getTransitionParams,
2608
- padding,
2609
- initialStateKey,
2610
- finalStateKey,
2611
- vertical,
2612
- direction
2613
- });
2614
- const index = graph.nodes.reduce(
2615
- (index2, node) => {
2616
- index2[node.key] = node.id;
2617
- return index2;
2618
- },
2619
- {}
2620
- );
2621
- const children = [];
2622
- if (config2.states) {
2623
- for (const child of config2.states) {
2624
- const childId = index[child.key];
2625
- children.push(buildChart(child, childId));
2626
- }
2582
+ function buildChart(config2, id = newId("s")) {
2583
+ const graph = buildFlatCharts({
2584
+ lodash,
2585
+ transitions: config2.transitions || [],
2586
+ newId,
2587
+ getStateParams,
2588
+ getTransitionParams,
2589
+ padding,
2590
+ initialStateKey,
2591
+ finalStateKey,
2592
+ vertical,
2593
+ direction
2594
+ });
2595
+ const index = graph.nodes.reduce((index2, node) => {
2596
+ index2[node.key] = node.id;
2597
+ return index2;
2598
+ }, {});
2599
+ const children = [];
2600
+ if (config2.states) {
2601
+ for (const child of config2.states) {
2602
+ const childId = index[child.key];
2603
+ children.push(buildChart(child, childId));
2627
2604
  }
2628
- return {
2629
- id,
2630
- key: config2.key,
2631
- state: config2.key,
2632
- ...graph,
2633
- children
2634
- };
2635
- } finally {
2636
- stack.pop();
2637
2605
  }
2606
+ return {
2607
+ id,
2608
+ key: config2.key,
2609
+ state: config2.key,
2610
+ ...graph,
2611
+ children
2612
+ };
2638
2613
  }
2639
2614
  }
2640
2615
 
@@ -1,2 +1,2 @@
1
- export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-GNTY7KMJ.js';
1
+ export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-NWCC4WSF.js';
2
2
  import './chunk-FIQDLBWD.js';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { concatTransitionsToString, serializeProcessConfig, splitTransitionString, toFsmStateConfig } from './chunk-SVKVQY7B.js';
2
2
  export { buildSections, findSection, getStateDescriptionRenderer, renderSections, visitDom, visitSectionNodes, vistSections } from './chunk-AVTSJE25.js';
3
3
  export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle, serializeCss, toKebabCase } from './chunk-GCVBCAOL.js';
4
- export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-GNTY7KMJ.js';
4
+ export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-NWCC4WSF.js';
5
5
  import './chunk-FIQDLBWD.js';
6
6
  export { RuntimeStatechartApi, StateChartIndex } from './chunk-N77KKO5K.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statewalker/fsm-charts",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "HFSM Implementation",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/statewalker/statewalker-fsm-charts",
@@ -39,66 +39,38 @@ export function buildCharts({
39
39
 
40
40
  function buildChart(
41
41
  config: FsmStateConfig,
42
- id: string = newId("s"),
43
- stack: Array<FsmStateConfig> = [],
42
+ id: string = newId("s")
44
43
  ): StateChart {
45
- stack.push(config);
46
- try {
47
- const getStateLabel = (state: string, key: string = state) => {
48
- if (key === "<initial>" || key === "<final>") {
49
- return "";
50
- }
51
- // TODO: search labels in sub-states of the current state.
52
- let result: string | undefined;
53
- for (let i = stack.length - 1; result === undefined && i >= 0; i--) {
54
- const conf = stack[i];
55
- console.log('WT', state, key, '=>', conf)
56
- if (conf.key !== state) continue;
57
- result = conf.label;
58
- }
44
+ const graph = buildFlatCharts({
45
+ lodash,
46
+ transitions: config.transitions || [],
47
+ newId,
48
+ getStateParams,
49
+ getTransitionParams,
50
+ padding,
51
+ initialStateKey,
52
+ finalStateKey,
53
+ vertical,
54
+ direction
55
+ });
56
+ const index = graph.nodes.reduce((index, node) => {
57
+ index[node.key as string] = node.id as string;
58
+ return index;
59
+ }, {} as Record<string, string>);
59
60
 
60
- return result === undefined ? state : result;
61
- };
62
- const graph = buildFlatCharts({
63
- lodash,
64
- transitions: config.transitions || [],
65
- newId,
66
- getStateParams: (state: string, key?: string) => {
67
- const params = getStateParams(state, key);
68
- params.text = getStateLabel(state, key);
69
- return params;
70
- },
71
- getTransitionParams,
72
- padding,
73
- initialStateKey,
74
- finalStateKey,
75
- vertical,
76
- direction,
77
- });
78
- const index = graph.nodes.reduce(
79
- (index, node) => {
80
- index[node.key as string] = node.id as string;
81
- return index;
82
- },
83
- {} as Record<string, string>,
84
- );
85
-
86
- const children: StateChart[] = [];
87
- if (config.states) {
88
- for (const child of config.states) {
89
- const childId = index[child.key];
90
- children.push(buildChart(child, childId));
91
- }
61
+ const children: StateChart[] = [];
62
+ if (config.states) {
63
+ for (const child of config.states) {
64
+ const childId = index[child.key];
65
+ children.push(buildChart(child, childId));
92
66
  }
93
- return {
94
- id,
95
- key: config.key,
96
- state: config.key,
97
- ...graph,
98
- children,
99
- };
100
- } finally {
101
- stack.pop();
102
67
  }
68
+ return {
69
+ id,
70
+ key: config.key,
71
+ state: config.key,
72
+ ...graph,
73
+ children,
74
+ };
103
75
  }
104
76
  }