@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
@@ -1,231 +0,0 @@
1
- // src/dom/newTreeBuilder.ts
2
- function newTreeBuilder(context) {
3
- let level = -1;
4
- return (newLevel, ...params) => {
5
- while (level >= 0 && level >= newLevel) {
6
- context.exit(level--, ...params);
7
- }
8
- while (level < newLevel) {
9
- context.enter(++level, ...params);
10
- }
11
- };
12
- }
13
-
14
- // src/dom/buildSections.ts
15
- function buildSections(root) {
16
- const nodes = toDomNodesIterator(root);
17
- let top = null;
18
- let peek = null;
19
- const stack = [];
20
- const aligner = newTreeBuilder({
21
- enter(level, header) {
22
- const section = {
23
- header,
24
- content: [],
25
- children: []
26
- };
27
- top = top || section;
28
- peek && peek.children.push(section);
29
- peek = section;
30
- stack.push(section);
31
- },
32
- exit() {
33
- stack.pop();
34
- peek = stack[stack.length - 1];
35
- }
36
- });
37
- aligner(0);
38
- let currentHeaderLevel = 0;
39
- let currentLevel = 0;
40
- for (const node of nodes) {
41
- if (isDomElement(node)) {
42
- if (/^H[1-6]$/i.test(node.tagName)) {
43
- const headerLevel = +node.tagName.replace(/^H/, "");
44
- currentLevel = headerLevel > currentHeaderLevel ? currentLevel + 1 : headerLevel < currentHeaderLevel ? currentLevel - 1 : currentLevel;
45
- currentHeaderLevel = headerLevel;
46
- aligner(currentLevel, node);
47
- } else {
48
- peek.content.push(node);
49
- }
50
- } else {
51
- peek.content.push(node);
52
- }
53
- }
54
- return top.content.length === 0 && top.children.length === 1 && !top.header ? top.children[0] : top;
55
- }
56
- function* visitSectionNodes(section) {
57
- if (section.header) yield section.header;
58
- yield* section.content;
59
- for (const s of vistSections(section, true)) {
60
- yield* visitSectionNodes(s);
61
- }
62
- }
63
- function* vistSections(root, ignoreRoot = false) {
64
- !ignoreRoot && (yield root);
65
- for (const child of root.children) {
66
- yield* vistSections(child, false);
67
- }
68
- }
69
- function findSection(section, accept) {
70
- for (const s of vistSections(section)) {
71
- if (accept(s) === true) return s;
72
- }
73
- }
74
- function isDomElement(node) {
75
- return node.nodeType === Node.ELEMENT_NODE;
76
- }
77
- function* toDomNodesIterator(root) {
78
- yield* root instanceof Node ? visitDom(root) : root;
79
- }
80
- function* visitDom(elm) {
81
- if (isDomElement(elm) && elm.tagName === "TEMPLATE") {
82
- elm = elm.content;
83
- }
84
- for (let node = elm.firstChild; node; node = node.nextSibling) {
85
- if (isDomElement(node)) {
86
- if (node.tagName === "DIV" || node.tagName === "TEMPLATE") {
87
- yield* visitDom(node);
88
- } else {
89
- yield node;
90
- }
91
- } else {
92
- yield node;
93
- }
94
- }
95
- }
96
-
97
- // src/dom/getStatesDescriptions.ts
98
- function* visitStateDescriptions({
99
- element,
100
- rootStateKey,
101
- removeFromDom = true,
102
- splitHeader = (header) => {
103
- if (!header) return [void 0, ""];
104
- const text = header.innerText.trim();
105
- let key;
106
- let label = text;
107
- text.replace(/^\s*\[(.*)\]\s*(.*)$/, (_, k, l) => {
108
- key = k.trim();
109
- label = l.trim() || key;
110
- return "";
111
- });
112
- return [key, label];
113
- }
114
- }) {
115
- const docSections = buildSections(element);
116
- const rootDescription = findSection(docSections, (section) => {
117
- if (!section.header) return false;
118
- const [key] = splitHeader(section.header);
119
- return key === rootStateKey;
120
- });
121
- if (!rootDescription) return;
122
- if (removeFromDom) {
123
- for (const node of visitSectionNodes(rootDescription)) {
124
- if (node.nodeName[0] === "#") continue;
125
- node.parentElement?.removeChild(node);
126
- }
127
- }
128
- for (const section of vistSections(rootDescription, false)) {
129
- if (!section.header) continue;
130
- const [state, title] = splitHeader(section.header);
131
- if (state)
132
- yield {
133
- state,
134
- title,
135
- ...section
136
- };
137
- }
138
- }
139
- function getStatesDescriptions(options) {
140
- const index = {};
141
- for (const description of visitStateDescriptions(options)) {
142
- index[description.state] = description;
143
- }
144
- return index;
145
- }
146
-
147
- // src/dom/description-panels.ts
148
- function getStateDescriptionRenderer(options) {
149
- const descriptionsIndex = getStatesDescriptions(options);
150
- return (statesStack) => {
151
- const stateKey = [...statesStack].pop();
152
- if (!stateKey) return;
153
- const section = descriptionsIndex[stateKey];
154
- if (!section) return;
155
- const elm = renderSections({
156
- section,
157
- deep: (section2) => false,
158
- // section.state !== options.rootStateKey, // ???
159
- header: (section2) => {
160
- if (section2.state === stateKey) {
161
- return section2.title || section2.state;
162
- }
163
- return;
164
- }
165
- });
166
- const details = elm?.querySelector("details");
167
- details && (details.open = true);
168
- return elm;
169
- };
170
- }
171
- function renderSections({
172
- section,
173
- deep = (s) => true,
174
- header = (section2) => section2.header?.cloneNode(true)
175
- }) {
176
- const container = document.createElement("div");
177
- const id = `id-${String(Math.random()).split(".")[1]}-${Date.now()}`;
178
- container.setAttribute("id", id);
179
- if (!section) return container;
180
- const sectionView = renderSection(section);
181
- container.append(sectionView);
182
- const style = renderSectionStyles(id);
183
- container.append(style);
184
- return container;
185
- function renderSectionStyles(id2) {
186
- const prefix = id2 ? `#${id2}` : "";
187
- const style2 = document.createElement("style");
188
- container.appendChild(style2);
189
- style2.innerHTML = `
190
- ${prefix} details {
191
- border: 1px solid #aaa;
192
- border-radius: 4px;
193
- padding: 0.5em 0.5em 0;
194
- margin-bottom: 0.5em;
195
- }
196
-
197
- ${prefix} details > summary {
198
- font-weight: bold;
199
- margin: -0.5em -0.5em 0;
200
- padding: 0.5em;
201
- cursor: pointer;
202
- }
203
-
204
- ${prefix} details[open] {
205
- padding: 0.5em;
206
- }
207
- `;
208
- return style2;
209
- }
210
- function renderSection(section2) {
211
- const details = document.createElement("details");
212
- const summary = document.createElement("summary");
213
- details.appendChild(summary);
214
- const content = document.createElement("div");
215
- details.appendChild(content);
216
- const headerElm = header(section2);
217
- headerElm && summary.append(headerElm);
218
- for (const node of section2.content) {
219
- if (node.nodeName[0] === "#") continue;
220
- content.append(node.cloneNode(true));
221
- }
222
- if (deep(section2)) {
223
- for (const child of section2.children) {
224
- content.append(renderSection(child));
225
- }
226
- }
227
- return details;
228
- }
229
- }
230
-
231
- export { buildSections, findSection, getStateDescriptionRenderer, getStatesDescriptions, isDomElement, newTreeBuilder, renderSections, toDomNodesIterator, visitDom, visitSectionNodes, visitStateDescriptions, vistSections };
@@ -1,75 +0,0 @@
1
- import { S as StateChart, d as TransitionsGraph } from './StateChart-BYBjTmC2.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 const activeStatesStyle: {
20
- backgroundColor: string;
21
- borderColor: string;
22
- borderWidth: string;
23
- labelColor: string;
24
- };
25
- declare const activeTransitionsStyle: {
26
- backgroundColor: string;
27
- borderColor: string;
28
- borderWidth: string;
29
- lineColor: string;
30
- lineWidth: string;
31
- labelColor: string;
32
- };
33
- declare const selectedStatesStyle: {
34
- backgroundColor: string;
35
- borderColor: string;
36
- borderWidth: string;
37
- labelColor: string;
38
- };
39
- declare const selectedTransitionsStyle: {
40
- backgroundColor: string;
41
- borderColor: string;
42
- borderWidth: string;
43
- lineColor: string;
44
- lineWidth: string;
45
- labelColor: string;
46
- };
47
- declare function buildStateDetailsStyle({ root, }: {
48
- root?: string;
49
- }): CssTree;
50
- declare function buildStateDetailsStyleWithModifier({ root, modifier, states, }: {
51
- root?: string;
52
- modifier: string;
53
- states: Record<string, string>;
54
- }): CssTree;
55
- declare function buildStatechartStylesWithModifier({ root, modifier, states, transitions, }: {
56
- root?: string;
57
- modifier: string;
58
- states: Record<string, string>;
59
- transitions: Record<string, string>;
60
- }): CssTree;
61
- declare function buildStatechartStyles({ root, }: {
62
- root?: string;
63
- }): CssTree;
64
-
65
- declare function buildStatechartSvg({ graph: { width, height, nodes, edges }, newId, stateFontSize, transitionFontSize, println, initialStateKey, finalStateKey, }: {
66
- graph: TransitionsGraph;
67
- newId: (prefix: string) => string;
68
- println: (str: string) => void;
69
- stateFontSize?: number;
70
- transitionFontSize?: number;
71
- initialStateKey?: string;
72
- finalStateKey?: string;
73
- }): void;
74
-
75
- export { type CssTree as C, buildStatechartsPanel as a, buildStatechartCss as b, activeStatesStyle as c, activeTransitionsStyle as d, selectedTransitionsStyle as e, buildStateDetailsStyle as f, buildStateDetailsStyleWithModifier as g, buildStatechartStylesWithModifier as h, buildStatechartStyles as i, buildStatechartSvg as j, serializeCss as k, selectedStatesStyle as s };