@statewalker/fsm-charts 0.0.3 → 0.0.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.
Files changed (43) hide show
  1. package/dist/StateChart-pFSQIvtE.d.ts +77 -0
  2. package/dist/chunk-3PNSXN5U.js +538 -0
  3. package/dist/{chunk-3GGM3ZWL.js → chunk-IT7GBMYV.js} +2 -2
  4. package/dist/chunk-X2UPWZLX.js +4 -0
  5. package/dist/index-layout.d.ts +3 -28
  6. package/dist/index-layout.js +1 -1
  7. package/dist/index-runtime.d.ts +5 -0
  8. package/dist/index-runtime.js +1 -0
  9. package/dist/index-svg-DCwEyX8X.d.ts +33 -0
  10. package/dist/index-svg.d.ts +2 -25
  11. package/dist/index-svg.js +1 -1
  12. package/dist/index.d.ts +8 -3
  13. package/dist/index.js +3 -2
  14. package/package.json +3 -3
  15. package/src/index-layout.ts +1 -0
  16. package/src/index-runtime.ts +2 -0
  17. package/src/index-svg.ts +1 -0
  18. package/src/index.ts +4 -2
  19. package/src/layout/buildCharts.ts +5 -13
  20. package/src/layout/buildFlatCharts.ts +9 -8
  21. package/src/layout/getGraphParamsProvider.ts +4 -3
  22. package/src/layout/getLabelDimensions.ts +2 -2
  23. package/src/layout/index.ts +0 -10
  24. package/src/runtime/index.ts +211 -0
  25. package/src/svg/buildStatechartStyles.ts +3 -0
  26. package/src/svg/buildStatechartSvg.ts +1 -1
  27. package/src/svg/buildStatechartsPanel.ts +12 -6
  28. package/src/types/FsmStateConfig.ts +7 -0
  29. package/src/{layout → types}/StateChart.ts +1 -2
  30. package/src/{layout → types}/StateGraphEdge.ts +2 -2
  31. package/src/{layout → types}/StateGraphNode.ts +2 -2
  32. package/src/types/TransitionsGraph.ts +13 -0
  33. package/src/types/index.ts +10 -0
  34. package/src/utils/getPadding.ts +1 -1
  35. package/dist/StateChart-DNGQd1XG.d.ts +0 -53
  36. package/dist/chunk-TPNWHU7Y.js +0 -437
  37. package/src/FsmStateConfig.ts +0 -5
  38. package/src/layout/TransitionsGraph.ts +0 -13
  39. /package/src/{layout → types}/Dimensions.ts +0 -0
  40. /package/src/{layout → types}/GraphParamsProvider.ts +0 -0
  41. /package/src/{layout → types}/Padding.ts +0 -0
  42. /package/src/{layout → types}/Position.ts +0 -0
  43. /package/src/{layout → types}/Transition.ts +0 -0
@@ -0,0 +1,33 @@
1
+ import { S as StateChart, d as TransitionsGraph } from './StateChart-pFSQIvtE.js';
2
+
3
+ declare function buildStatechartCss({ prefix }?: {
4
+ prefix?: string | undefined;
5
+ }): string;
6
+
7
+ declare function buildStatechartsPanel({ statechart, newId, println, initialStateKey, finalStateKey, }: {
8
+ statechart: StateChart;
9
+ newId: (prefix: string) => string;
10
+ println: (str: string) => void;
11
+ initialStateKey?: string;
12
+ finalStateKey?: string;
13
+ }): void;
14
+
15
+ interface CssTree extends Record<string, string | number | CssTree> {
16
+ }
17
+ declare function serializeCss(obj: CssTree): string;
18
+
19
+ declare function buildStatechartStyles({ root, }?: {
20
+ root?: string;
21
+ }): CssTree;
22
+
23
+ declare function buildStatechartSvg({ graph: { width, height, nodes, edges }, newId, stateFontSize, transitionFontSize, println, initialStateKey, finalStateKey, }: {
24
+ graph: TransitionsGraph;
25
+ newId: (prefix: string) => string;
26
+ println: (str: string) => void;
27
+ stateFontSize?: number;
28
+ transitionFontSize?: number;
29
+ initialStateKey?: string;
30
+ finalStateKey?: string;
31
+ }): void;
32
+
33
+ export { type CssTree as C, buildStatechartsPanel as a, buildStatechartCss as b, buildStatechartStyles as c, buildStatechartSvg as d, serializeCss as s };
@@ -1,25 +1,2 @@
1
- import { b as StateChart, T as TransitionsGraph } from './StateChart-DNGQd1XG.js';
2
-
3
- declare function buildStatechartCss({ prefix }?: {
4
- prefix?: string | undefined;
5
- }): string;
6
-
7
- declare function buildStatechartsPanel({ statechart, newId, println, initialStateKey, finalStateKey, }: {
8
- statechart: StateChart;
9
- newId: (prefix: string) => string;
10
- println: (str: string) => void;
11
- initialStateKey?: string;
12
- finalStateKey?: string;
13
- }): void;
14
-
15
- declare function buildStatechartSvg({ graph: { width, height, nodes, edges }, newId, stateFontSize, transitionFontSize, println, initialStateKey, finalStateKey, }: {
16
- graph: TransitionsGraph;
17
- newId: (prefix: string) => string;
18
- println: (str: string) => void;
19
- stateFontSize?: number;
20
- transitionFontSize?: number;
21
- initialStateKey?: string;
22
- finalStateKey?: string;
23
- }): void;
24
-
25
- export { buildStatechartCss, buildStatechartSvg, buildStatechartsPanel };
1
+ export { D as Dimensions, F as FsmStateConfig, G as GraphParamsProvider, P as Padding, a as Position, S as StateChart, b as StateGraphEdge, c as StateGraphNode, T as Transition, d as TransitionsGraph } from './StateChart-pFSQIvtE.js';
2
+ export { b as buildStatechartCss, c as buildStatechartStyles, d as buildStatechartSvg, a as buildStatechartsPanel } from './index-svg-DCwEyX8X.js';
package/dist/index-svg.js CHANGED
@@ -1,2 +1,2 @@
1
- export { buildStatechartCss, buildStatechartSvg, buildStatechartsPanel } from './chunk-TPNWHU7Y.js';
1
+ export { buildStatechartCss, buildStatechartStyles, buildStatechartSvg, buildStatechartsPanel } from './chunk-3PNSXN5U.js';
2
2
  import './chunk-NXWOFQMO.js';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,8 @@
1
- export { GraphParamsProvider, Padding, Transition, buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './index-layout.js';
2
- export { D as Dimensions, P as Position, S as StateGraphEdge, a as StateGraphNode, T as TransitionsGraph } from './StateChart-DNGQd1XG.js';
3
- export { buildStatechartCss, buildStatechartSvg, buildStatechartsPanel } from './index-svg.js';
1
+ export { D as Dimensions, F as FsmStateConfig, G as GraphParamsProvider, P as Padding, a as Position, S as StateChart, b as StateGraphEdge, c as StateGraphNode, T as Transition, d as TransitionsGraph } from './StateChart-pFSQIvtE.js';
2
+ export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './index-layout.js';
3
+ export { C as CssTree, b as buildStatechartCss, c as buildStatechartStyles, d as buildStatechartSvg, a as buildStatechartsPanel, s as serializeCss } from './index-svg-DCwEyX8X.js';
4
+ export { a } from './index-runtime.js';
5
+
6
+ declare function toKebabCase(str: string): string;
7
+
8
+ export { toKebabCase };
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
- export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-3GGM3ZWL.js';
2
- export { buildStatechartCss, buildStatechartSvg, buildStatechartsPanel } from './chunk-TPNWHU7Y.js';
1
+ export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-IT7GBMYV.js';
2
+ export { buildStatechartCss, buildStatechartStyles, buildStatechartSvg, buildStatechartsPanel, serializeCss, toKebabCase } from './chunk-3PNSXN5U.js';
3
3
  import './chunk-NXWOFQMO.js';
4
+ export { a } from './chunk-X2UPWZLX.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statewalker/fsm-charts",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "HFSM Implementation",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/statewalker/statewalker-fsm-charts",
@@ -44,8 +44,8 @@
44
44
  "url": "git@github.com:statewalker/statewalker-fsm-charts.git"
45
45
  },
46
46
  "scripts": {
47
- "build_": "yarn test && tsup",
48
- "build": "tsup",
47
+ "build": "rm -fr ./dist && yarn test && tsup",
48
+ "prepare": "yarn build",
49
49
  "watch": "tsup --watch",
50
50
  "clean": "rm -rf dist",
51
51
  "lint": "eslint",
@@ -1 +1,2 @@
1
+ export * from "./types/index.ts";
1
2
  export * from "./layout/index.ts";
@@ -0,0 +1,2 @@
1
+ export * from "./types/index.ts";
2
+ export * from "./runtime/index.ts";
package/src/index-svg.ts CHANGED
@@ -1 +1,2 @@
1
+ export * from "./types/index.ts";
1
2
  export * from "./svg/index.ts";
package/src/index.ts CHANGED
@@ -1,4 +1,6 @@
1
- export * from "./index-layout.ts";
2
- export * from "./index-svg.ts";
1
+ export * from "./types/index.ts";
2
+ export * from "./layout/index.ts";
3
+ export * from "./svg/index.ts";
4
+ export * from "./runtime/index.ts";
3
5
  export * from "./utils/toKebabCase.ts";
4
6
  export * from "./utils/serializeCss.ts";
@@ -1,16 +1,8 @@
1
- import type { GraphParamsProvider } from "./GraphParamsProvider.ts";
2
- import type { StateGraphNode } from "./StateGraphNode.ts";
3
- import type { StateGraphEdge } from "./StateGraphEdge.ts";
4
- import type { Padding } from "./Padding.ts";
5
- import type { Position } from "./Position.ts";
6
- import type { Dimensions } from "./Dimensions.ts";
7
- import type { FsmStateConfig } from "../FsmStateConfig.ts";
8
- import type { StateChart } from "./StateChart.ts";
1
+ import type { GraphParamsProvider } from "../types/GraphParamsProvider.ts";
2
+ import type { Padding } from "../types/Padding.ts";
3
+ import type { FsmStateConfig } from "../types/FsmStateConfig.ts";
4
+ import type { StateChart } from "../types/StateChart.ts";
9
5
 
10
- import { layout } from "../dagre/layout.js";
11
- import { Graph } from "../graphlib/graph.js";
12
- import { getPadding } from "../utils/getPadding.ts";
13
- import { getLodash, setLodash } from "../lodash-es/index.ts";
14
6
  import { buildFlatCharts } from "./buildFlatCharts.ts";
15
7
  /**
16
8
  * Build graphs corresponding to the specified transitions.
@@ -67,7 +59,7 @@ export function buildCharts({
67
59
  return {
68
60
  id,
69
61
  key: config.key,
70
- graph,
62
+ ...graph,
71
63
  children,
72
64
  };
73
65
  }
@@ -1,15 +1,16 @@
1
1
  import { layout } from "../dagre/layout.js";
2
2
  import { Graph } from "../graphlib/graph.js";
3
3
 
4
- import type { GraphParamsProvider } from "./GraphParamsProvider.ts";
5
- import type { Transition } from "./Transition.ts";
6
- import type { TransitionsGraph } from "./TransitionsGraph.ts";
7
- import type { StateGraphNode } from "./StateGraphNode.ts";
8
- import type { StateGraphEdge } from "./StateGraphEdge.ts";
9
- import { Padding } from "./Padding.ts";
4
+ import type { GraphParamsProvider } from "../types/GraphParamsProvider.ts";
5
+ import type { Transition } from "../types/Transition.ts";
6
+ import type { TransitionsGraph } from "../types/TransitionsGraph.ts";
7
+ import type { StateGraphNode } from "../types/StateGraphNode.ts";
8
+ import type { StateGraphEdge } from "../types/StateGraphEdge.ts";
9
+ import type { Padding } from "../types/Padding.ts";
10
+ import type { Position } from "../types/Position.ts";
11
+ import type { Dimensions } from "../types/Dimensions.ts";
12
+
10
13
  import { getPadding } from "../utils/getPadding.ts";
11
- import { Position } from "./Position.ts";
12
- import { Dimensions } from "./Dimensions.ts";
13
14
  import { getLodash, setLodash } from "../lodash-es/index.ts";
14
15
 
15
16
  /**
@@ -1,8 +1,9 @@
1
- import type { Dimensions } from "./Dimensions.ts";
1
+ import type { Dimensions } from "../types/Dimensions.ts";
2
+ import type { GraphParamsProvider } from "../types/GraphParamsProvider.ts";
3
+ import type { Padding } from "../types/Padding.ts";
4
+
2
5
  import { getLabelDimensions } from "./getLabelDimensions.ts";
3
6
  import { getPadding } from "../utils/getPadding.ts";
4
- import type { GraphParamsProvider } from "./GraphParamsProvider.ts";
5
- import type { Padding } from "./Padding.ts";
6
7
 
7
8
  /**
8
9
  * Provides default functions measuring dimensions for state nodes and transition edges in the graph.
@@ -1,5 +1,5 @@
1
- import type { Dimensions } from "./Dimensions.ts";
2
- import type { Padding } from "./Padding.ts";
1
+ import type { Dimensions } from "../types/Dimensions.ts";
2
+ import type { Padding } from "../types/Padding.ts";
3
3
  import { getPadding } from "../utils/getPadding.ts";
4
4
 
5
5
  export function getLabelDimensions(
@@ -3,13 +3,3 @@ export * from "./buildFlatCharts.ts";
3
3
  export * from "./buildCharts.ts";
4
4
  export * from "./getGraphParamsProvider.ts";
5
5
  export * from "./getLabelDimensions.ts";
6
-
7
- // Types
8
- export * from "./Dimensions.ts";
9
- export * from "./GraphParamsProvider.ts";
10
- export * from "./Padding.ts";
11
- export * from "./Position.ts";
12
- export * from "./StateGraphEdge.ts";
13
- export * from "./StateGraphNode.ts";
14
- export * from "./Transition.ts";
15
- export * from "./TransitionsGraph.ts";
@@ -0,0 +1,211 @@
1
+ export const a = "a";
2
+
3
+ // class RuntimeStatechartsApi {
4
+ // constructor({ element, statechart }) {
5
+ // this.element = element;
6
+ // this.statechart = statechart;
7
+ // // this._statesIndex = {};
8
+ // // this._transitionsIndex = {};
9
+ // // this._buildIndexes(this.statechart);
10
+ // }
11
+
12
+ // _applyStateModifier(cssSelector, modifier = "selected", apply) {
13
+ // const detailsModifier = `state-details--${modifier}`;
14
+ // const stateLabelsModifier = `state-details__label--${modifier}`;
15
+ // const stateModifier = `state--${modifier}`;
16
+ // [...this.element.querySelectorAll(cssSelector)].forEach((elm) => {
17
+ // if (elm.tagName.toLowerCase() === "details") {
18
+ // apply(elm, detailsModifier);
19
+ // const labelElm = elm.querySelector(".state-details__label");
20
+ // if (labelElm) apply(labelElm, stateLabelsModifier);
21
+ // } else {
22
+ // apply(elm, stateModifier);
23
+ // }
24
+ // });
25
+ // }
26
+
27
+ // _applyTransitionsModifier(cssSelector, modifier = "selected", action) {}
28
+
29
+ // deselectAllTransitions() {
30
+ // const removeClass = (elm, cls) => elm.classList.remove(cls);
31
+ // this._applyTransitionsModifier(
32
+ // "[data-transition-id]",
33
+ // "selected",
34
+ // removeClass
35
+ // );
36
+ // }
37
+ // deselectTransitions(...ids) {
38
+ // const removeClass = (elm, cls) => elm.classList.remove(cls);
39
+ // for (const id of ids) {
40
+ // this._applyTransitionsModifier(
41
+ // `[data-transition-id="${id}"]`,
42
+ // "selected",
43
+ // removeClass
44
+ // );
45
+ // }
46
+ // }
47
+ // selectTransitions(...ids) {
48
+ // const addClass = (elm, cls) => elm.classList.add(cls);
49
+ // for (const id of ids) {
50
+ // this._applyTransitionsModifier(
51
+ // `[data-transition-id="${id}"]`,
52
+ // "selected",
53
+ // addClass
54
+ // );
55
+ // }
56
+ // }
57
+
58
+ // deselectAllStates() {
59
+ // const removeClass = (elm, cls) => elm.classList.remove(cls);
60
+ // this._applyStateModifier("[data-state-id]", "selected", removeClass);
61
+ // }
62
+ // deselectStates(...ids) {
63
+ // const removeClass = (elm, cls) => elm.classList.remove(cls);
64
+ // for (const id of ids) {
65
+ // this._applyStateModifier(
66
+ // `[data-state-id="${id}"]`,
67
+ // "selected",
68
+ // removeClass
69
+ // );
70
+ // }
71
+ // }
72
+ // selectStates(...ids) {
73
+ // const addClass = (elm, cls) => elm.classList.add(cls);
74
+ // for (const id of ids) {
75
+ // this._applyStateModifier(`[data-state-id="${id}"]`, "selected", addClass);
76
+ // }
77
+ // }
78
+
79
+ // // -----------------------------------------------
80
+ // // Access to charts data
81
+ // // - get state ids by stack of state keys
82
+ // // - get stack of states by state id
83
+ // // - get transitionId by stateId + event
84
+ // // - get targetId, sourceId, event by transitionId
85
+ // getStatesIds(...stack) {
86
+ // let statechart = this.statechart;
87
+ // let result = [];
88
+ // if (statechart.key === stack[0]) {
89
+ // result.push(statechart.id);
90
+ // for (let i = 1; i < stack.length; i++) {
91
+ // const key = stack[i];
92
+ // let id = statechart.graph.nodes.find((node) => node.key === key)?.id;
93
+ // if (!id) break;
94
+ // result.push(id);
95
+ // statechart = (statechart.children || []).find(
96
+ // (child) => child.key === key
97
+ // );
98
+ // }
99
+ // }
100
+ // return result.length === stack.length ? result : [];
101
+ // }
102
+
103
+ // getStackByStateId(id) {
104
+ // return this._getStack(id, ({ id, key }) => key);
105
+ // }
106
+
107
+ // getTransition(stateId, event) {
108
+ // const stack = this._getStack(stateId);
109
+ // const state = stack.pop();
110
+ // if (!state || !stack.length) return;
111
+ // const parent = stack[stack.length - 1];
112
+ // const t = parent.graph.edges.find(
113
+ // (t) => t.from === state.key && t.event === event
114
+ // );
115
+ // if (!t) return;
116
+ // const to = parent.graph.nodes.find((n) => n.key === t.to);
117
+ // return to && { id: t.id, fromId: state.id, event: t.event, toId: to.id };
118
+ // }
119
+
120
+ // _getStack(id, get = (d) => d) {
121
+ // return findById(this.statechart, id, get);
122
+
123
+ // function findById(statechart, id, get, stack = []) {
124
+ // try {
125
+ // stack.push(get(statechart));
126
+ // if (statechart.id === id) {
127
+ // return [...stack];
128
+ // } else {
129
+ // let node = statechart.graph.nodes.find((node) => node.id === id);
130
+ // if (node) {
131
+ // return [...stack, get(node)];
132
+ // } else {
133
+ // let result;
134
+ // if (statechart.children) {
135
+ // for (const child of statechart.children) {
136
+ // result = findById(child, id, get, stack);
137
+ // if (result) break;
138
+ // }
139
+ // }
140
+ // return result;
141
+ // }
142
+ // }
143
+ // } finally {
144
+ // stack.pop();
145
+ // }
146
+ // }
147
+ // }
148
+
149
+ // // getTransitionId(stateId, event) {
150
+ // // }
151
+
152
+ // // const stateInfo = this._statesIndex[stateId];
153
+ // // if (!stateInfo) return;
154
+ // // if (stateInfo.parent) return ;
155
+ // // const targetState = stateInfo.parent.
156
+ // // const fromId = stateIds.pop();
157
+ // // const parentId = stateIds.pop();
158
+ // // const parent = parentId ? this._statesIndex[parentId] : null;
159
+ // // return parent
160
+ // // ? parent.graph?.edges.find(
161
+ // // (edge) => edge.from === fromId && edge.event === event
162
+ // // )
163
+ // // : undefined;
164
+ // // }
165
+
166
+ // // _getInfo(index, id, create) {
167
+ // // let info = index[id];
168
+ // // if (!info && create) {
169
+ // // info = index[id] = { id };
170
+ // // }
171
+ // // return info;
172
+ // // }
173
+ // // _getStateInfo(id, create) {
174
+ // // return this._getInfo(this._statesIndex, id, create);
175
+ // // }
176
+ // // _getTransitionInfo(id, create) {
177
+ // // return this._getInfo(this._transitionsIndex, id, create);
178
+ // // }
179
+ // // _buildIndexes(statechart) {
180
+ // // const { id, key } = statechart;
181
+ // // const stateInfo = this._getStateInfo(id, true);
182
+ // // stateInfo.key = key;
183
+ // // stateInfo.detailsElement = this.element.querySelector(
184
+ // // `details[data-state-id="${id}"]`
185
+ // // );
186
+ // // for (const node of statechart.graph?.nodes || []) {
187
+ // // const info = this._getStateInfo(node.id, true);
188
+ // // info.parent = stateInfo;
189
+ // // // info.parentId = id;
190
+ // // info.node = node;
191
+ // // info.key = node.key;
192
+ // // info.svgGroupElement = this.element.querySelector(
193
+ // // `g[data-state-id="${info.id}"]`
194
+ // // );
195
+ // // }
196
+ // // for (const edge of statechart.graph?.edges || []) {
197
+ // // const info = this._getTransitionInfo(edge.id, true);
198
+ // // info.transition = edge;
199
+ // // info.from = edge.from;
200
+ // // info.event = edge.event;
201
+ // // info.to = edge.to;
202
+ // // info.svgGroupElement = this.element.querySelector(
203
+ // // `g[data-transition-id="${info.id}"]`
204
+ // // );
205
+ // // }
206
+
207
+ // // for (const child of statechart.children) {
208
+ // // this._buildIndexes(child);
209
+ // // }
210
+ // // }
211
+ // }
@@ -102,11 +102,13 @@ export function buildStatechartStyles({
102
102
  stroke: "var(--transition-border-color, none)",
103
103
  strokeWidth: "var(--transition-border-width, 1px)",
104
104
  borderRadius: "0.5em",
105
+ cursor: "pointer",
105
106
  },
106
107
  ".transition__label": {
107
108
  fill: "var(--transition-label-color, currentColor)",
108
109
  fontSize: "var(--transition-label-font-size, 12px)",
109
110
  fontFamily: "var(--transition-label-font-family, sans-serif)",
111
+ cursor: "pointer",
110
112
  },
111
113
 
112
114
  // ----------------------------------------------
@@ -147,6 +149,7 @@ export function buildStatechartStyles({
147
149
  stroke: "var(--state-border-color, currentColor)",
148
150
  strokeWidth: "var(--state-border-width, 1px)",
149
151
  borderRadius: "0.5em",
152
+ cursor: "pointer",
150
153
  },
151
154
  ".state__label": {
152
155
  color: "var(--state-label-color, currentColor)",
@@ -3,7 +3,7 @@ import type {
3
3
  Padding,
4
4
  Position,
5
5
  TransitionsGraph,
6
- } from "../layout/index.ts";
6
+ } from "../types/index.ts";
7
7
  import { getPadding } from "../utils/getPadding.ts";
8
8
  import { serializeAttrs } from "../utils/serializeAttrs.ts";
9
9
  import { BasisCurve } from "../utils/BasisCurve.ts";
@@ -1,5 +1,5 @@
1
1
  import { buildStatechartSvg } from "./buildStatechartSvg.ts";
2
- import type { StateChart } from "../layout/StateChart.ts";
2
+ import type { StateChart } from "../types/StateChart.ts";
3
3
 
4
4
  export function buildStatechartsPanel({
5
5
  statechart,
@@ -13,16 +13,22 @@ export function buildStatechartsPanel({
13
13
  println: (str: string) => void;
14
14
  initialStateKey?: string;
15
15
  finalStateKey?: string;
16
- }) : void {
16
+ }): void {
17
17
  render(statechart, println);
18
18
 
19
19
  function render(statechart: StateChart, println: (str: string) => void) {
20
- println(` <details class="state-details" data-state-id="${statechart.id}">`);
21
- println(` <summary class="state-details__label">${statechart.key}</summary>`);
22
- println(` <div class="state-details__description"><div class="state-details__chart">`);
20
+ println(
21
+ ` <details class="state-details" data-state-id="${statechart.id}">`
22
+ );
23
+ println(
24
+ ` <summary class="state-details__label">${statechart.key}</summary>`
25
+ );
26
+ println(
27
+ ` <div class="state-details__description"><div class="state-details__chart">`
28
+ );
23
29
  const printChildren = (str: string) => println(` ${str}`);
24
30
  buildStatechartSvg({
25
- graph: statechart.graph,
31
+ graph: statechart,
26
32
  newId,
27
33
  println: printChildren,
28
34
  initialStateKey,
@@ -0,0 +1,7 @@
1
+ import type { Transition } from "./Transition.ts";
2
+
3
+ export type FsmStateConfig = {
4
+ key: string;
5
+ transitions: Transition[];
6
+ states?: FsmStateConfig[];
7
+ };
@@ -1,8 +1,7 @@
1
1
  import type { TransitionsGraph } from "./TransitionsGraph.ts";
2
2
 
3
- export type StateChart = {
3
+ export type StateChart = TransitionsGraph & {
4
4
  id: string;
5
5
  key: string;
6
6
  children?: StateChart[];
7
- graph: TransitionsGraph;
8
7
  } & Record<string, any>;
@@ -1,5 +1,5 @@
1
- import { Dimensions } from "./Dimensions.ts";
2
- import { Position } from "./Position.ts";
1
+ import type { Dimensions } from "./Dimensions.ts";
2
+ import type { Position } from "./Position.ts";
3
3
 
4
4
  /**
5
5
  * Information about a state graph edge.
@@ -1,5 +1,5 @@
1
- import { Dimensions } from "./Dimensions";
2
- import { Position } from "./Position";
1
+ import type { Dimensions } from "./Dimensions.ts";
2
+ import type { Position } from "./Position.ts";
3
3
 
4
4
  /**
5
5
  * Information about a state node in the graph.
@@ -0,0 +1,13 @@
1
+ import type { Dimensions } from "./Dimensions.ts";
2
+ import type { Position } from "./Position.ts";
3
+ import type { StateGraphEdge } from "./StateGraphEdge.ts";
4
+ import type { StateGraphNode } from "./StateGraphNode.ts";
5
+
6
+ /**
7
+ * Coordinates for state nodes and endges corresponding to state transitions.
8
+ */
9
+ export type TransitionsGraph = Position &
10
+ Dimensions & {
11
+ nodes: StateGraphNode[];
12
+ edges: StateGraphEdge[];
13
+ };
@@ -0,0 +1,10 @@
1
+ export * from "./Dimensions.ts";
2
+ export * from "./FsmStateConfig.ts";
3
+ export * from "./GraphParamsProvider.ts";
4
+ export * from "./Padding.ts";
5
+ export * from "./Position.ts";
6
+ export * from "./StateChart.ts";
7
+ export * from "./StateGraphEdge.ts";
8
+ export * from "./StateGraphNode.ts";
9
+ export * from "./Transition.ts";
10
+ export * from "./TransitionsGraph.ts";
@@ -1,4 +1,4 @@
1
- import { Padding } from "../layout/Padding.ts";
1
+ import type { Padding } from "../types/Padding.ts";
2
2
 
3
3
  /**
4
4
  * Expands a padding value to a 4-element array: [top, right, bottom, left].
@@ -1,53 +0,0 @@
1
- /**
2
- * Visual element dimensions.
3
- * @typedef {Object} Dimensions
4
- */
5
- type Dimensions = {
6
- width: number;
7
- height: number;
8
- };
9
-
10
- /**
11
- * X/Y position of a node in the graph.
12
- */
13
- type Position = {
14
- x: number;
15
- y: number;
16
- };
17
-
18
- /**
19
- * Information about a state graph edge.
20
- */
21
- type StateGraphEdge = Dimensions & Position & {
22
- id: string;
23
- from: string;
24
- event: string;
25
- to: string;
26
- points: Position[];
27
- } & Record<string, any>;
28
-
29
- /**
30
- * Information about a state node in the graph.
31
- */
32
- type StateGraphNode = Dimensions & Position & {
33
- id: string;
34
- key: string;
35
- state: string;
36
- } & Record<string, any>;
37
-
38
- /**
39
- * Coordinates for state nodes and endges corresponding to state transitions.
40
- */
41
- type TransitionsGraph = Position & Dimensions & {
42
- nodes: StateGraphNode[];
43
- edges: StateGraphEdge[];
44
- };
45
-
46
- type StateChart = {
47
- id: string;
48
- key: string;
49
- children?: StateChart[];
50
- graph: TransitionsGraph;
51
- } & Record<string, any>;
52
-
53
- export type { Dimensions as D, Position as P, StateGraphEdge as S, TransitionsGraph as T, StateGraphNode as a, StateChart as b };