@statewalker/fsm-charts 0.2.5 → 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 (74) 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 -2
  21. package/dist/index-dom.d.ts +2 -49
  22. package/dist/index-dom.js +2 -2
  23. package/dist/index-html.d.ts +3 -2
  24. package/dist/index-html.js +2 -3
  25. package/dist/index-layout.d.ts +3 -77
  26. package/dist/index-layout.js +2 -3
  27. package/dist/index-runtime.d.ts +3 -141
  28. package/dist/index-runtime.js +2 -2
  29. package/dist/index.d.ts +11 -10
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +6 -7
  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 +53 -25
  41. package/src/config/concatTransitionsToString.ts +2 -2
  42. package/src/config/splitTransitionString.ts +1 -3
  43. package/src/config/toFsmStateConfig.ts +2 -9
  44. package/src/dom/buildSections.ts +3 -11
  45. package/src/dom/description-panels.ts +2 -4
  46. package/src/dom/getStatesDescriptions.ts +3 -9
  47. package/src/full/toFsmStateCharts.ts +1 -1
  48. package/src/html/buildStatechartStyles.ts +4 -14
  49. package/src/html/buildStatechartSvg.ts +2 -14
  50. package/src/html/buildStatechartsPanel.ts +1 -3
  51. package/src/layout/buildCharts.ts +1 -2
  52. package/src/layout/buildFlatCharts.ts +6 -8
  53. package/src/layout/getGraphParamsProvider.ts +3 -12
  54. package/src/runtime/RuntimeStatechartApi.ts +10 -32
  55. package/src/runtime/StateChartIndex.ts +6 -23
  56. package/src/types/GraphParamsProvider.ts +1 -4
  57. package/src/utils/BasisCurve.ts +5 -14
  58. package/src/utils/domToText.ts +2 -6
  59. package/src/utils/getPadding.ts +1 -2
  60. package/src/utils/newId.ts +2 -1
  61. package/src/utils/newRegistry.ts +12 -12
  62. package/src/utils/serializeAttrs.ts +3 -11
  63. package/src/utils/serializeCss.ts +1 -5
  64. package/src/utils/serializeStyle.ts +1 -4
  65. package/src/utils/toKebabCase.ts +1 -4
  66. package/dist/StateChart-BYBjTmC2.d.ts +0 -82
  67. package/dist/chunk-2LFUT2C6.js +0 -2691
  68. package/dist/chunk-ARZYBFNA.js +0 -133
  69. package/dist/chunk-CR2M4445.js +0 -608
  70. package/dist/chunk-FIQDLBWD.js +0 -9
  71. package/dist/chunk-GW2Z65BN.js +0 -429
  72. package/dist/chunk-PKBMQBKP.js +0 -5
  73. package/dist/chunk-RZ4FP6JB.js +0 -233
  74. package/dist/index-html-BBQqYoST.d.ts +0 -75
package/README.md CHANGED
@@ -1 +1,206 @@
1
- # @statewalker/fsm-charts: Visualization of Hierarchical Finite State Machines
1
+ # @statewalker/fsm-charts
2
+
3
+ ## What it is: statechart layout and rendering for HFSM configurations
4
+
5
+ Turns a hierarchical state machine (HFSM) configuration (`{ key, transitions, states }`,
6
+ the format `@statewalker/fsm` runs) into a statechart. It lays the chart out with a
7
+ vendored copy of dagre, writes SVG/HTML and CSS as strings, and provides a runtime API
8
+ that highlights states and transitions on the rendered chart. `@statewalker/fsm-viewer`
9
+ builds a ready-made browser viewer on top of it.
10
+
11
+ ## Why it exists: a nested state machine is hard to read as JSON
12
+
13
+ A configuration with several levels of nested states and wildcard transitions is hard to
14
+ follow as text. This package draws each composite state as its own chart, nested the same
15
+ way the states are, so the structure and the transitions out of every state are visible.
16
+ It works from the configuration alone and does not import `@statewalker/fsm`, so drawing
17
+ a machine does not require running it.
18
+
19
+ ## How to use: lay out, render to strings, then bind to the DOM
20
+
21
+ ```sh
22
+ pnpm add @statewalker/fsm-charts lodash-es
23
+ ```
24
+
25
+ The package has no runtime dependencies, but the layout functions need a lodash object
26
+ passed in as the `lodash` option. Either `lodash` or `lodash-es` works.
27
+
28
+ ```
29
+ FsmStateConfig --buildCharts--> StateChart --buildStatechartsPanel--> HTML + SVG strings
30
+ | --buildStatechartCss-----> CSS string
31
+ |
32
+ +--> StateChartIndex (key <-> id lookups)
33
+ +--> RuntimeStatechartApi (highlight, panels, clicks on the DOM)
34
+ ```
35
+
36
+ The only entry point is the package root, `@statewalker/fsm-charts` (`dist/index.js` with
37
+ `.d.ts` types; sources are published in `src/`). It is ESM only.
38
+
39
+ The `config`, `layout` and `html` functions produce plain strings and objects and run
40
+ anywhere, including Node.js. The `dom` helpers and `RuntimeStatechartApi` work on DOM
41
+ elements and need a browser or a DOM implementation such as jsdom.
42
+
43
+ ### What each export is for
44
+
45
+ **Config**
46
+
47
+ - `serializeProcessConfig(config)` - format a configuration as JSON text with one
48
+ transition per line.
49
+ - `splitTransitionString(str)` - parse a chain such as `"Idle -play-> Active -stop-> Idle"`
50
+ into `[from, event, to]` tuples; `concatTransitionsToString(transitions)` does the
51
+ reverse.
52
+ - `toFsmStateConfig(json)` - normalize a loosely written configuration (transitions as
53
+ strings or arrays, duplicates removed) into an `FsmStateConfig`.
54
+
55
+ **Layout**
56
+
57
+ - `buildCharts({ lodash, config, newId, ...graphParams })` - lay out the whole state
58
+ tree. Returns a `StateChart` (nested charts with nodes, edges, sizes). Options:
59
+ `direction`, `vertical`, `padding`, `getStateLabel`, `initialStateKey`
60
+ (default `"<initial>"`), `finalStateKey` (default `"<final>"`).
61
+ - `buildFlatCharts(...)` - lay out one flat transition graph (a `TransitionsGraph`).
62
+ - `getGraphParamsProvider({ fontSize, stateFontSize, stateTextPadding, transitionsFontSize, transitionsTextPadding, ... })`
63
+ - default `getStateParams` / `getTransitionParams` functions that size nodes and
64
+ edges from their labels.
65
+ - `getLabelDimensions(label, options)` - estimate label size from font size and
66
+ character width.
67
+
68
+ **HTML and CSS**
69
+
70
+ - `buildStatechartsPanel({ statechart, newId, println })` - write nested `<details>`
71
+ panels, one per composite state, each with its SVG chart.
72
+ - `buildStatechartSvg({ graph, newId, println, ... })` - write the SVG of one chart.
73
+ - `buildStatechartCss({ prefix })` - the stylesheet for the charts, scoped to `prefix`
74
+ (default `:root`). `buildStatechartStyles`, `buildStatechartStylesWithModifier`,
75
+ `buildStateDetailsStyle`, `buildStateDetailsStyleWithModifier` and the
76
+ `activeStatesStyle` / `activeTransitionsStyle` / `selectedStatesStyle` /
77
+ `selectedTransitionsStyle` objects are its building blocks.
78
+ - `serializeCss(tree)` and `toKebabCase(str)` - CSS helpers.
79
+
80
+ **DOM** (browser)
81
+
82
+ - `buildSections`, `visitSectionNodes`, `vistSections`, `findSection`, `visitDom`,
83
+ `toDomNodesIterator`, `isDomElement` - split a document into sections by headings.
84
+ - `getStatesDescriptions({ element, rootStateKey })`, `visitStateDescriptions` - read
85
+ per-state descriptions from a document section whose heading matches the root state.
86
+ - `getStateDescriptionRenderer`, `renderSections`, `newTreeBuilder` - helpers to render
87
+ those descriptions.
88
+
89
+ **Runtime**
90
+
91
+ - `StateChartIndex({ statechart })` - lookups over a built chart: `getStatesIds(...keys)`,
92
+ `getStackByStateId(id)`, `getTransitions(stateId)`, `getEdgeById(id)`,
93
+ `getStateNodes()` and more.
94
+ - `RuntimeStatechartApi({ element, statechart })` - acts on the rendered chart:
95
+ `selectState` / `deselectState(s)`, `selectTransition` / `deselectTransition(s)`
96
+ with a modifier (`"selected"` by default, `"active"` for the running state),
97
+ `openStatePanel` / `closeStatePanel(s)`, `setStateDescription`, `onStateClick`,
98
+ `onTransitionClick`, `close()`.
99
+
100
+ Types such as `StateChart`, `StateGraphNode`, `StateGraphEdge`, `FsmStateConfig` and
101
+ `GraphParamsProvider` are exported as well.
102
+
103
+ ## Examples
104
+
105
+ ### Draw a configuration and highlight a state
106
+
107
+ ```js
108
+ import * as lodash from "lodash-es";
109
+ import {
110
+ buildCharts,
111
+ buildStatechartCss,
112
+ buildStatechartsPanel,
113
+ getGraphParamsProvider,
114
+ RuntimeStatechartApi,
115
+ StateChartIndex,
116
+ } from "@statewalker/fsm-charts";
117
+
118
+ let counter = 0;
119
+ const newId = (prefix) => `${prefix}-${++counter}`;
120
+
121
+ const config = {
122
+ key: "Player",
123
+ transitions: [
124
+ ["", "*", "Idle"],
125
+ ["Idle", "play", "Active"],
126
+ ["*", "stop", "Idle"],
127
+ ],
128
+ states: [
129
+ { key: "Idle" },
130
+ {
131
+ key: "Active",
132
+ transitions: [
133
+ ["", "*", "Playing"],
134
+ ["Playing", "pause", "Paused"],
135
+ ["Paused", "play", "Playing"],
136
+ ],
137
+ },
138
+ ],
139
+ };
140
+
141
+ // 1. Layout: nested charts with node and edge geometry.
142
+ const statechart = buildCharts({
143
+ lodash,
144
+ config,
145
+ newId,
146
+ direction: "lr", // "tb" | "bt" | "lr" | "rl"
147
+ ...getGraphParamsProvider({ fontSize: 12 }),
148
+ });
149
+
150
+ // 2. Render: HTML (nested <details> panels with SVG charts) and CSS.
151
+ const lines = [];
152
+ buildStatechartsPanel({ statechart, newId, println: (line) => lines.push(line) });
153
+ const element = document.createElement("div");
154
+ element.id = "chart";
155
+ element.innerHTML = lines.join("\n");
156
+ const style = document.createElement("style");
157
+ style.textContent = buildStatechartCss({ prefix: "#chart" });
158
+ element.append(style);
159
+ document.body.append(element);
160
+
161
+ // 3. Runtime: map state keys to chart ids and highlight them.
162
+ const index = new StateChartIndex({ statechart });
163
+ const api = new RuntimeStatechartApi({ element, statechart });
164
+ for (const id of index.getStatesIds("Player", "Active", "Playing")) {
165
+ api.selectState(id, "active");
166
+ api.openStatePanel(id);
167
+ }
168
+ api.onStateClick((stateId) => console.log(index.getStackByStateId(stateId)));
169
+ ```
170
+
171
+ ### Print a configuration compactly
172
+
173
+ ```js
174
+ import { serializeProcessConfig, splitTransitionString } from "@statewalker/fsm-charts";
175
+
176
+ console.log(serializeProcessConfig(config)); // JSON text, one transition per line
177
+ console.log(splitTransitionString("Idle -play-> Active -stop-> Idle"));
178
+ // [["Idle", "play", "Active"], ["Active", "stop", "Idle"]]
179
+ ```
180
+
181
+ ## Internals: vendored layout, injected lodash
182
+
183
+ - **Layout.** `buildCharts` walks the state tree and lays out each composite state as a
184
+ separate flat graph with `buildFlatCharts`, which uses the vendored dagre and graphlib
185
+ sources in `src/dagre` and `src/graphlib`. Pseudo-states are drawn as `"<initial>"` and
186
+ `"<final>"` nodes; both keys can be changed with `initialStateKey` / `finalStateKey`.
187
+ - **Rendering is string output.** `buildStatechartsPanel` and `buildStatechartSvg` write
188
+ lines through a `println` callback instead of creating DOM nodes, so the same code
189
+ renders in a browser, in Node.js, or into a file.
190
+ - **Styling is by CSS variables and modifiers.** `buildStatechartCss` emits rules for the
191
+ `selected` and `active` modifiers that `RuntimeStatechartApi` toggles, scoped to a
192
+ `prefix` selector so several charts can share a page.
193
+ - **lodash is injected.** The vendored dagre code calls lodash through a module-level
194
+ holder that `buildFlatCharts` sets from the `lodash` option, so the host decides which
195
+ lodash build ends up in its bundle. Without it, layout fails with
196
+ `TypeError: Cannot read properties of undefined (reading 'has')`.
197
+ - **Entry points by area.** Besides the package root (everything), each area is its own
198
+ entry: `@statewalker/fsm-charts/config`, `/layout`, `/html`, `/dom` and `/runtime`. Layout
199
+ and HTML generation import no DOM code, so a Node.js or worker build can take
200
+ `/layout` and `/html` alone.
201
+ - **Dependencies.** Zero runtime dependencies. dagre and graphlib are vendored; lodash
202
+ comes from the caller.
203
+
204
+ ## License
205
+
206
+ MIT.
@@ -0,0 +1,94 @@
1
+ //#region src/types/Dimensions.d.ts
2
+ /**
3
+ * Visual element dimensions.
4
+ * @typedef {Object} Dimensions
5
+ */
6
+ type Dimensions = {
7
+ width: number;
8
+ height: number;
9
+ };
10
+ //#endregion
11
+ //#region src/types/Transition.d.ts
12
+ /**
13
+ * A transition from one state to another.
14
+ * Contains the state before the transition, the event that triggers the transition, and the state after the transition.
15
+ */
16
+ type Transition = [string, string, string];
17
+ //#endregion
18
+ //#region src/types/FsmStateConfig.d.ts
19
+ type FsmStateConfig = {
20
+ key: string;
21
+ transitions?: Transition[];
22
+ states?: FsmStateConfig[];
23
+ } & Record<string, any>;
24
+ //#endregion
25
+ //#region src/types/Label.d.ts
26
+ /**
27
+ * Human-readable label
28
+ */
29
+ type Label = {
30
+ text: string;
31
+ };
32
+ //#endregion
33
+ //#region src/types/GraphParamsProvider.d.ts
34
+ /**
35
+ * Provides default functions measuring dimensions for state nodes and transition edges in the graph.
36
+ */
37
+ type GraphParamsProvider = {
38
+ getStateParams: (stateKey: string, state?: string) => Dimensions & Label & Record<string, any>;
39
+ getTransitionParams: (fromStateKey: string, event: string, toStateKey: string) => Dimensions & Label & Record<string, any>;
40
+ };
41
+ //#endregion
42
+ //#region src/types/Padding.d.ts
43
+ /**
44
+ * Padding type.
45
+ */
46
+ type Padding = [number, number, number, number] | [number, number] | number;
47
+ //#endregion
48
+ //#region src/types/Position.d.ts
49
+ /**
50
+ * X/Y position of a node in the graph.
51
+ */
52
+ type Position = {
53
+ x: number;
54
+ y: number;
55
+ };
56
+ //#endregion
57
+ //#region src/types/StateGraphNode.d.ts
58
+ /**
59
+ * Information about a state node in the graph.
60
+ */
61
+ type StateGraphNode = Dimensions & Position & {
62
+ id: string;
63
+ key: string;
64
+ text: string;
65
+ } & Record<string, any>;
66
+ //#endregion
67
+ //#region src/types/StateGraphEdge.d.ts
68
+ /**
69
+ * Information about a state graph edge.
70
+ */
71
+ type StateGraphEdge = Dimensions & Position & {
72
+ id: string;
73
+ from: string;
74
+ event: string;
75
+ to: string;
76
+ points: Position[];
77
+ } & Record<string, any>;
78
+ //#endregion
79
+ //#region src/types/TransitionsGraph.d.ts
80
+ /**
81
+ * Coordinates for state nodes and endges corresponding to state transitions.
82
+ */
83
+ type TransitionsGraph = Position & Dimensions & {
84
+ nodes: StateGraphNode[];
85
+ edges: StateGraphEdge[];
86
+ };
87
+ //#endregion
88
+ //#region src/types/StateChart.d.ts
89
+ type StateChart = TransitionsGraph & StateGraphNode & {
90
+ children?: StateChart[];
91
+ } & Record<string, any>;
92
+ //#endregion
93
+ export { Position as a, Label as c, Dimensions as d, StateGraphNode as i, FsmStateConfig as l, TransitionsGraph as n, Padding as o, StateGraphEdge as r, GraphParamsProvider as s, StateChart as t, Transition as u };
94
+ //# sourceMappingURL=StateChart-cXyVRcs-.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StateChart-cXyVRcs-.d.ts","names":[],"sources":["../src/types/Dimensions.ts","../src/types/Transition.ts","../src/types/FsmStateConfig.ts","../src/types/Label.ts","../src/types/GraphParamsProvider.ts","../src/types/Padding.ts","../src/types/Position.ts","../src/types/StateGraphNode.ts","../src/types/StateGraphEdge.ts","../src/types/TransitionsGraph.ts","../src/types/StateChart.ts"],"mappings":";;;;;KAIY;EACV;EACA;;;;;;;;KCFU;;;KCOA;EACV;EACA,cAAc;EACd,SAAS;IACP;;;;;;KCZQ;EAEV;;;;;;;KCCU;EACV,iBAAiB,kBAAkB,mBAAmB,aAAa,QAAQ;EAC3E,sBACE,sBACA,eACA,uBACG,aAAa,QAAQ;;;;;;;KCThB;;;;;;KCAA;EAAa;EAAW;;;;;;;KCGxB,iBAAiB,aAC3B;EACE;EACA;EACA;IAEE;;;;;;KCNM,iBAAiB,aAC3B;EACE;EACA;EACA;EACA;EACA,QAAQ;IACN;;;;;;KCLM,mBAAmB,WAC7B;EACE,OAAO;EACP,OAAO;;;;KCRC,aAAa,mBACvB;EACE,WAAW;IACT"}
@@ -0,0 +1,142 @@
1
+ import { i as StateGraphNode, r as StateGraphEdge, t as StateChart } from "./StateChart-cXyVRcs-.js";
2
+ //#region src/runtime/RuntimeStatechartApi.d.ts
3
+ type RuntimeListener = (id: string) => void;
4
+ declare class RuntimeStatechartApi {
5
+ element: HTMLElement;
6
+ statechart: StateChart;
7
+ _listenersCounter: number;
8
+ _transitionsClickListeners: Record<number, RuntimeListener>;
9
+ _statesClickListeners: Record<number, RuntimeListener>;
10
+ _registry: Record<number, () => void>;
11
+ constructor({ element, statechart }: {
12
+ element: HTMLElement;
13
+ statechart: StateChart;
14
+ });
15
+ close(): void;
16
+ onStateClick(listener: RuntimeListener): () => void;
17
+ onTransitionClick(listener: RuntimeListener): () => void;
18
+ openStatePanels(): void;
19
+ closeStatePanels(): void;
20
+ isStatePanelOpen(stateId: string): boolean;
21
+ toggleState(...stateIds: string[]): boolean;
22
+ activateStates(...stateIds: string[]): void;
23
+ focusStates(...stateIds: string[]): void;
24
+ setStateDescription(stateId: string, description: Node | string | undefined): void;
25
+ closeStatePanel(stateId: string): void;
26
+ openStatePanel(stateId: string): void;
27
+ deselectTransitions(modifier?: string): void;
28
+ deselectTransition(id: string, modifier?: string): void;
29
+ selectTransition(id: string, modifier?: string): void;
30
+ toggleTransition(id: string, modifier?: string): void;
31
+ isTransitionSelected(id: string, modifier?: string): boolean;
32
+ deselectStates(modifier?: string): void;
33
+ isStateSelected(id: string, modifier?: string): boolean;
34
+ deselectState(id: string, modifier?: string): void;
35
+ selectState(id: string, modifier?: string): void;
36
+ _addListener<T = Function>(index: Record<string, T>, listener: T): () => void;
37
+ _bindListeners(): void;
38
+ _setStatePanelStatus(selector: string, open: boolean): void;
39
+ _addStateModifier(cssSelector: string, modifier?: string): void;
40
+ _removeStateModifier(cssSelector: string, modifier?: string): void;
41
+ _applyStateModifier(cssSelector: string, modifier: string | undefined, apply: (elm: Element | null, className: string) => void): void;
42
+ _addTransitionsModifier(cssSelector: string, modifier?: string): void;
43
+ _removeTransitionsModifier(cssSelector: string, modifier?: string): void;
44
+ _applyTransitionsModifier(cssSelector: string, modifier: string | undefined, apply: (elm: Element | null, className: string) => void): void;
45
+ }
46
+ //#endregion
47
+ //#region src/runtime/StateChartIndex.d.ts
48
+ declare class StateChartIndex {
49
+ statechart: StateChart;
50
+ _chartsIndex: Record<string, StateChart>;
51
+ _nodesIndex: Record<string, StateGraphNode>;
52
+ _nodesParentsIndex: Record<string, string>;
53
+ _edgeIndex: Record<string, StateGraphEdge>;
54
+ _edgesParentsIndex: Record<string, string>;
55
+ initialStateKey: string;
56
+ finalStateKey: string;
57
+ constructor({ statechart, initialStateKey, finalStateKey }: {
58
+ statechart: StateChart;
59
+ initialStateKey?: string;
60
+ finalStateKey?: string;
61
+ });
62
+ /**
63
+ * Returns a state node or a chart by the specified identifier.
64
+ * @param id the id of a state node or a chart
65
+ * @returns a state node or a chart
66
+ */
67
+ getNodeById(id: string): StateGraphNode | undefined;
68
+ /**
69
+ * Returns a chart by the specified identifier.
70
+ * @param id the id of a state node or a chart
71
+ * @returns a state node or a chart
72
+ */
73
+ getChartById(id: string): StateChart | undefined;
74
+ /**
75
+ * Returns an edge by the specified identifier.
76
+ * @param id the id of a graph edge
77
+ * @returns a graph edge
78
+ */
79
+ getEdgeById(id: string): StateGraphEdge | undefined;
80
+ /**
81
+ * Returns a list of all nodes in this chart.
82
+ * @return a list of all nodes
83
+ */
84
+ getAllNodes(): StateGraphNode[];
85
+ /**
86
+ * Returns a list of all non-empty state nodes in this chart.
87
+ * The result excludes nodes for initial and fina states.
88
+ * @return a list of all non-empty state nodes
89
+ */
90
+ getStateNodes(): StateGraphNode[];
91
+ /**
92
+ * Transforms a stack of state keys to the corresponding identifiers.
93
+ * If a key in the stack was not found then this method returns
94
+ * an empty stack.
95
+ * @param stack a stack of state keys
96
+ * @returns a stack of state identifiers for the given states
97
+ */
98
+ getStatesIds(...stack: string[]): string[];
99
+ /**
100
+ * Returns graph nodes for the specified identifier.
101
+ * @param id the id of a node
102
+ * @returns a stack of nodes
103
+ */
104
+ getStackByStateId(id?: string): StateGraphNode[];
105
+ /**
106
+ * Returns an edge object corresponding to the transition from the state
107
+ * @param stateId identifier of the source state
108
+ * @param event an event triggering the transition
109
+ * @returns graph edge
110
+ */
111
+ getTransition(stateId?: string, event?: string): StateGraphEdge | undefined;
112
+ /**
113
+ * Returns a list of edge objects corresponding to all transitions from the state
114
+ * @param stateId identifier of the source state
115
+ * @returns a list of graph edges
116
+ */
117
+ getTransitions(stateId?: string): StateGraphEdge[];
118
+ /**
119
+ * Returns a graph node corresponding to the specified state id.
120
+ * @param stateId identifier of the state
121
+ * @returns graph node
122
+ * @see getStateChart
123
+ */
124
+ getStateNode(stateId?: string): StateGraphNode | undefined;
125
+ /**
126
+ * Returns a chart corresponding to the specified state id.
127
+ * @param stateId identifier of the state
128
+ * @returns graph node
129
+ * @see getStateNode
130
+ */
131
+ getStateChart(stateId?: string): StateChart | undefined;
132
+ /**
133
+ * Returns ids of the previous and next state for the specified transition
134
+ * @param transition a graph edge instance defining transition
135
+ * @returns an array with two identifiers - [sourceStateId, targetStateId] - the source state id and target state id
136
+ */
137
+ getTransitionStateIds(transition?: StateGraphEdge): [string | undefined, string | undefined];
138
+ _buildIndexes(): void;
139
+ }
140
+ //#endregion
141
+ export { RuntimeListener as n, RuntimeStatechartApi as r, StateChartIndex as t };
142
+ //# sourceMappingURL=StateChartIndex-BK2315qj.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StateChartIndex-BK2315qj.d.ts","names":[],"sources":["../src/runtime/RuntimeStatechartApi.ts","../src/runtime/StateChartIndex.ts"],"mappings":";;KAEY,mBAAmB;cAClB;EACX,SAAS;EACT,YAAY;EACZ;EACA,4BAA4B,eAAe;EAC3C,uBAAuB,eAAe;EACtC,WAAW;EAEX,cACE,SACA;IAEA,SAAS;IACT,YAAY;;EAOd;EAOA,aAAa,UAAU;EAGvB,kBAAkB,UAAU;EAI5B;EAGA;EAGA,iBAAiB;EAOjB,eAAe;EAaf,kBAAkB;EAQlB,eAAe;EAUf,oBAAoB,iBAAiB,aAAa;EAUlD,gBAAgB;EAGhB,eAAe;EAIf,oBAAoB;EAGpB,mBAAmB,YAAY;EAG/B,iBAAiB,YAAY;EAG7B,iBAAiB,YAAY;EAS7B,qBAAqB,YAAY;EAMjC,eAAe;EAGf,gBAAgB,YAAY;EAK5B,cAAc,YAAY;EAG1B,YAAY,YAAY;EAMxB,aAAa,IAAI,UAAU,OAAO,eAAe,IAAI,UAAU;EAQ/D;EA+BA,qBAAqB,kBAAkB;EAOvC,kBAAkB,qBAAqB;EAGvC,qBAAqB,qBAAqB;EAG1C,oBACE,qBACA,8BACA,QAAQ,KAAK,gBAAgB;EAgB/B,wBAAwB,qBAAqB;EAG7C,2BAA2B,qBAAqB;EAGhD,0BACE,qBACA,8BACA,QAAQ,KAAK,gBAAgB;;;;cCzNpB;EACX,YAAY;EACZ,cAAc,eAAe;EAC7B,aAAa,eAAe;EAC5B,oBAAoB;EACpB,YAAY,eAAe;EAC3B,oBAAoB;EACpB;EACA;EAEA,cACE,YACA,iBACA;IAEA,YAAY;IACZ;IACA;;;;;;;EAcF,YAAY,aAAa;;;;;;EASzB,aAAa,aAAa;;;;;;EAS1B,YAAY,aAAa;;;;;EAQzB,eAAe;;;;;;EASf,iBAAiB;;;;;;;;EAajB,gBAAgB;;;;;;EAkBhB,kBAAkB,cAAc;;;;;;;EAqBhC,cAAc,kBAAkB,iBAAiB;;;;;;EAcjD,eAAe,mBAAmB;;;;;;;EAclC,aAAa,mBAAmB;;;;;;;EAUhC,cAAc,mBAAmB;;;;;;EASjC,sBAAsB,aAAa;EAoBnC"}