@statewalker/fsm-charts 0.2.4 → 0.2.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.
- package/dist/{chunk-AZBRQNTU.js → chunk-2LFUT2C6.js} +1062 -1110
- package/dist/{chunk-SVKVQY7B.js → chunk-ARZYBFNA.js} +4 -4
- package/dist/{chunk-36ZLXJVD.js → chunk-CR2M4445.js} +35 -33
- package/dist/{chunk-TZHCBZVP.js → chunk-GW2Z65BN.js} +22 -15
- package/dist/chunk-PKBMQBKP.js +5 -0
- package/dist/{chunk-VILLJJJD.js → chunk-RZ4FP6JB.js} +11 -9
- package/dist/index-config.js +2 -1
- package/dist/index-dom.js +2 -1
- package/dist/{index-html-DgSCNHkR.d.ts → index-html-BBQqYoST.d.ts} +10 -10
- package/dist/index-html.d.ts +1 -1
- package/dist/index-html.js +2 -1
- package/dist/index-layout.d.ts +15 -15
- package/dist/index-layout.js +2 -1
- package/dist/index-runtime.js +2 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -5
- package/package.json +16 -18
- package/src/config/concatTransitionsToString.ts +2 -2
- package/src/config/index.ts +4 -4
- package/src/config/serializeProcessConfig.ts +3 -3
- package/src/config/splitTransitionString.ts +2 -2
- package/src/config/toFsmStateConfig.ts +3 -3
- package/src/dagre/acyclic.js +9 -10
- package/src/dagre/add-border-segments.js +11 -7
- package/src/dagre/coordinate-system.js +12 -12
- package/src/dagre/data/list.js +2 -2
- package/src/dagre/debug.d.ts +1 -1
- package/src/dagre/debug.js +11 -11
- package/src/dagre/greedy-fas.js +17 -21
- package/src/dagre/index.d.ts +4 -4
- package/src/dagre/index.js +4 -4
- package/src/dagre/layout.js +107 -96
- package/src/dagre/nesting-graph.js +13 -19
- package/src/dagre/normalize.js +7 -7
- package/src/dagre/order/add-subgraph-constraints.js +2 -2
- package/src/dagre/order/barycenter.d.ts +1 -1
- package/src/dagre/order/barycenter.js +4 -4
- package/src/dagre/order/build-layer-graph.d.ts +1 -1
- package/src/dagre/order/build-layer-graph.js +7 -9
- package/src/dagre/order/cross-count.js +14 -17
- package/src/dagre/order/index.js +19 -17
- package/src/dagre/order/init-order.js +5 -15
- package/src/dagre/order/resolve-conflicts.js +10 -14
- package/src/dagre/order/sort-subgraph.d.ts +1 -1
- package/src/dagre/order/sort-subgraph.js +13 -14
- package/src/dagre/order/sort.d.ts +1 -1
- package/src/dagre/order/sort.js +6 -10
- package/src/dagre/parent-dummy-chains.js +10 -4
- package/src/dagre/position/bk.d.ts +3 -3
- package/src/dagre/position/bk.js +84 -65
- package/src/dagre/position/index.js +7 -11
- package/src/dagre/rank/feasible-tree.d.ts +1 -1
- package/src/dagre/rank/feasible-tree.js +6 -6
- package/src/dagre/rank/index.js +6 -6
- package/src/dagre/rank/network-simplex.d.ts +0 -1
- package/src/dagre/rank/network-simplex.js +20 -25
- package/src/dagre/rank/util.js +2 -6
- package/src/dagre/util.d.ts +12 -6
- package/src/dagre/util.js +31 -37
- package/src/dom/buildSections.ts +16 -12
- package/src/dom/description-panels.ts +3 -3
- package/src/dom/getStatesDescriptions.ts +1 -1
- package/src/full/index.ts +1 -1
- package/src/full/toFsmStateCharts.ts +10 -10
- package/src/graphlib/alg/components.js +2 -2
- package/src/graphlib/alg/dfs.js +5 -5
- package/src/graphlib/alg/dijkstra-all.js +4 -4
- package/src/graphlib/alg/dijkstra.js +9 -12
- package/src/graphlib/alg/find-cycles.js +7 -5
- package/src/graphlib/alg/floyd-warshall.js +8 -11
- package/src/graphlib/alg/index.d.ts +11 -11
- package/src/graphlib/alg/index.js +11 -11
- package/src/graphlib/alg/is-acyclic.js +1 -1
- package/src/graphlib/alg/postorder.js +2 -2
- package/src/graphlib/alg/preorder.js +2 -2
- package/src/graphlib/alg/prim.d.ts +1 -1
- package/src/graphlib/alg/prim.js +5 -5
- package/src/graphlib/alg/tarjan.js +3 -3
- package/src/graphlib/alg/topsort.js +1 -1
- package/src/graphlib/data/priority-queue.js +8 -10
- package/src/graphlib/graph.js +53 -52
- package/src/graphlib/index.d.ts +2 -2
- package/src/graphlib/index.js +2 -2
- package/src/graphlib/json.d.ts +1 -1
- package/src/graphlib/json.js +6 -6
- package/src/html/buildStatechartCss.ts +2 -2
- package/src/html/buildStatechartStyles.ts +1 -1
- package/src/html/buildStatechartSvg.ts +7 -7
- package/src/html/buildStatechartsPanel.ts +2 -2
- package/src/html/index.ts +4 -4
- package/src/index-config.ts +2 -2
- package/src/index-dom.ts +1 -1
- package/src/index-html.ts +2 -2
- package/src/index-layout.ts +2 -2
- package/src/index-runtime.ts +2 -2
- package/src/index.ts +8 -8
- package/src/layout/buildCharts.ts +5 -5
- package/src/layout/buildFlatCharts.ts +11 -13
- package/src/layout/getGraphParamsProvider.ts +5 -8
- package/src/layout/getLabelDimensions.ts +5 -5
- package/src/layout/index.ts +5 -4
- package/src/lodash-es/index.ts +2 -2
- package/src/lodash-es/types.ts +37 -35
- package/src/runtime/RuntimeStatechartApi.ts +12 -23
- package/src/runtime/StateChartIndex.ts +3 -3
- package/src/runtime/index.ts +2 -2
- package/src/types/FsmStateConfig.ts +1 -1
- package/src/types/GraphParamsProvider.ts +2 -2
- package/src/types/Position.ts +1 -1
- package/src/types/StateChart.ts +2 -2
- package/src/types/StateGraphEdge.ts +2 -2
- package/src/types/StateGraphNode.ts +2 -2
- package/src/types/TransitionsGraph.ts +4 -4
- package/src/types/index.ts +11 -11
- package/src/utils/BasisCurve.ts +3 -3
- package/src/utils/domToText.ts +1 -1
- package/src/utils/getPadding.ts +1 -1
- package/src/utils/newRegistry.ts +1 -1
- package/src/utils/serializeAttrs.ts +6 -6
- package/src/utils/serializeCss.ts +3 -3
- package/src/utils/serializeStyle.ts +2 -2
- package/src/utils/toKebabCase.ts +1 -1
- package/CHANGELOG.md +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/config/concatTransitionsToString.ts
|
|
2
2
|
function concatTransitionsToString(transitions) {
|
|
3
|
-
|
|
3
|
+
const list = [];
|
|
4
4
|
let str = "";
|
|
5
5
|
let prev;
|
|
6
6
|
for (const [from, event, to] of transitions) {
|
|
@@ -21,7 +21,7 @@ function concatTransitionsToString(transitions) {
|
|
|
21
21
|
// src/config/serializeProcessConfig.ts
|
|
22
22
|
function serializeProcessConfig(config) {
|
|
23
23
|
if (!config) return "";
|
|
24
|
-
|
|
24
|
+
const lines = [];
|
|
25
25
|
visit(config, lines);
|
|
26
26
|
return lines.join("\n");
|
|
27
27
|
function visit(config2, lines2, shift = "") {
|
|
@@ -46,7 +46,7 @@ function serializeProcessConfig(config) {
|
|
|
46
46
|
if (i > 0) {
|
|
47
47
|
lines2[lines2.length - 1] += ",";
|
|
48
48
|
}
|
|
49
|
-
visit(states[i], lines2, shift
|
|
49
|
+
visit(states[i], lines2, `${shift} `);
|
|
50
50
|
}
|
|
51
51
|
lines2.push(`${shift} ]`);
|
|
52
52
|
}
|
|
@@ -103,7 +103,7 @@ function toFsmStateConfig(json) {
|
|
|
103
103
|
const transitions2 = [];
|
|
104
104
|
const index = {};
|
|
105
105
|
const array = toArray(json2);
|
|
106
|
-
for (
|
|
106
|
+
for (const line of array) {
|
|
107
107
|
const lineTransitions = typeof line === "string" ? splitTransitionString(line) : [toArray(line)];
|
|
108
108
|
for (const transition of lineTransitions.map(validateTransition)) {
|
|
109
109
|
if (!transition) continue;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { getPadding } from './chunk-FIQDLBWD.js';
|
|
2
|
+
import { __publicField } from './chunk-PKBMQBKP.js';
|
|
2
3
|
|
|
3
4
|
// src/utils/toKebabCase.ts
|
|
4
5
|
function toKebabCase(str) {
|
|
5
6
|
str = (str || "").trim().replace(/\s+/gim, "-");
|
|
6
7
|
str = str.replace(
|
|
7
8
|
/([^A-Z]?)([A-Z])/g,
|
|
8
|
-
(_, a, b) => a.toLowerCase()
|
|
9
|
+
(_, a, b) => `${a.toLowerCase()}-${b.toLowerCase()}`
|
|
9
10
|
);
|
|
10
11
|
return str;
|
|
11
12
|
}
|
|
@@ -20,7 +21,7 @@ function serializeCss(obj) {
|
|
|
20
21
|
for (const prefix of prefixes) {
|
|
21
22
|
const selector = sel.replace(
|
|
22
23
|
/^(.)/,
|
|
23
|
-
(_, ch) => ch === "&" ? prefix : prefix.length > 0 ? prefix
|
|
24
|
+
(_, ch) => ch === "&" ? prefix : prefix.length > 0 ? `${prefix} ${ch}` : ch
|
|
24
25
|
);
|
|
25
26
|
selectors.push(selector);
|
|
26
27
|
}
|
|
@@ -281,37 +282,16 @@ function buildStatechartCss({ prefix = "" } = {}) {
|
|
|
281
282
|
].map(serializeCss).join("\n");
|
|
282
283
|
}
|
|
283
284
|
|
|
284
|
-
// src/utils/serializeAttrs.ts
|
|
285
|
-
function serializeAttrs(attrs = {}, {
|
|
286
|
-
prefix = "",
|
|
287
|
-
transform = false
|
|
288
|
-
} = {}) {
|
|
289
|
-
const result = [];
|
|
290
|
-
for (const [key, value] of Object.entries(attrs || {}).sort(
|
|
291
|
-
([a], [b]) => a > b ? 1 : -1
|
|
292
|
-
)) {
|
|
293
|
-
if (value === void 0 || value === null || value === "") continue;
|
|
294
|
-
result.push(
|
|
295
|
-
`${prefix}${escapeValue(key)}${"=" + JSON.stringify(
|
|
296
|
-
escapeValue(transform ? toKebabCase(String(value)) : value)
|
|
297
|
-
)}`
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
return result.join(" ");
|
|
301
|
-
function escapeValue(value) {
|
|
302
|
-
return String(value).replaceAll(/</gim, "<").replaceAll(/>/gim, ">").replaceAll(/"/gim, "&qout;");
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
285
|
// src/utils/BasisCurve.ts
|
|
307
286
|
var BasisCurve = class {
|
|
308
287
|
constructor(context) {
|
|
309
|
-
this
|
|
310
|
-
this
|
|
311
|
-
this
|
|
312
|
-
this
|
|
313
|
-
this
|
|
314
|
-
this
|
|
288
|
+
__publicField(this, "_context");
|
|
289
|
+
__publicField(this, "_x0", 0);
|
|
290
|
+
__publicField(this, "_y0", 0);
|
|
291
|
+
__publicField(this, "_x1", 0);
|
|
292
|
+
__publicField(this, "_y1", 0);
|
|
293
|
+
__publicField(this, "_point", 0);
|
|
294
|
+
__publicField(this, "_line", 0);
|
|
315
295
|
this._context = context;
|
|
316
296
|
}
|
|
317
297
|
$point(x, y) {
|
|
@@ -373,6 +353,28 @@ var BasisCurve = class {
|
|
|
373
353
|
}
|
|
374
354
|
};
|
|
375
355
|
|
|
356
|
+
// src/utils/serializeAttrs.ts
|
|
357
|
+
function serializeAttrs(attrs = {}, {
|
|
358
|
+
prefix = "",
|
|
359
|
+
transform = false
|
|
360
|
+
} = {}) {
|
|
361
|
+
const result = [];
|
|
362
|
+
for (const [key, value] of Object.entries(attrs || {}).sort(
|
|
363
|
+
([a], [b]) => a > b ? 1 : -1
|
|
364
|
+
)) {
|
|
365
|
+
if (value === void 0 || value === null || value === "") continue;
|
|
366
|
+
result.push(
|
|
367
|
+
`${prefix}${escapeValue(key)}${"=" + JSON.stringify(
|
|
368
|
+
escapeValue(transform ? toKebabCase(String(value)) : value)
|
|
369
|
+
)}`
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
return result.join(" ");
|
|
373
|
+
function escapeValue(value) {
|
|
374
|
+
return String(value).replaceAll(/</gim, "<").replaceAll(/>/gim, ">").replaceAll(/"/gim, """);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
376
378
|
// src/html/buildStatechartSvg.ts
|
|
377
379
|
function getBoxParams({
|
|
378
380
|
x,
|
|
@@ -435,13 +437,13 @@ function buildStatechartSvg({
|
|
|
435
437
|
const round = (...n) => n.map(Math.round);
|
|
436
438
|
const base = new BasisCurve({
|
|
437
439
|
bezierCurveTo(x0, y0, x1, y1, x2, y2) {
|
|
438
|
-
path.push(
|
|
440
|
+
path.push(`C${round(x0, y0, x1, y1, x2, y2).join(",")}`);
|
|
439
441
|
},
|
|
440
442
|
moveTo(x, y) {
|
|
441
|
-
path.push(
|
|
443
|
+
path.push(`M${round(x, y).join(",")}`);
|
|
442
444
|
},
|
|
443
445
|
lineTo(x, y) {
|
|
444
|
-
path.push(
|
|
446
|
+
path.push(`L${round(x, y).join(",")}`);
|
|
445
447
|
},
|
|
446
448
|
closePath() {
|
|
447
449
|
path.push("Z");
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
+
import { __publicField } from './chunk-PKBMQBKP.js';
|
|
2
|
+
|
|
1
3
|
// src/runtime/RuntimeStatechartApi.ts
|
|
2
4
|
var RuntimeStatechartApi = class {
|
|
3
5
|
constructor({
|
|
4
6
|
element,
|
|
5
7
|
statechart
|
|
6
8
|
}) {
|
|
7
|
-
this
|
|
8
|
-
this
|
|
9
|
-
this
|
|
10
|
-
this
|
|
9
|
+
__publicField(this, "element");
|
|
10
|
+
__publicField(this, "statechart");
|
|
11
|
+
__publicField(this, "_listenersCounter", 0);
|
|
12
|
+
__publicField(this, "_transitionsClickListeners", {});
|
|
13
|
+
__publicField(this, "_statesClickListeners", {});
|
|
14
|
+
__publicField(this, "_registry", {});
|
|
11
15
|
this.element = element;
|
|
12
16
|
this.statechart = statechart;
|
|
13
17
|
this._bindListeners();
|
|
14
18
|
}
|
|
15
19
|
close() {
|
|
16
|
-
Object.values(this._registry).forEach((r) => r
|
|
20
|
+
Object.values(this._registry).forEach((r) => r?.());
|
|
17
21
|
this._registry = {};
|
|
18
22
|
this._transitionsClickListeners = {};
|
|
19
23
|
this._statesClickListeners = {};
|
|
@@ -167,14 +171,14 @@ var RuntimeStatechartApi = class {
|
|
|
167
171
|
this._applyStateModifier(
|
|
168
172
|
cssSelector,
|
|
169
173
|
modifier,
|
|
170
|
-
(elm, cls) => elm
|
|
174
|
+
(elm, cls) => elm?.classList.add(cls)
|
|
171
175
|
);
|
|
172
176
|
}
|
|
173
177
|
_removeStateModifier(cssSelector, modifier = "selected") {
|
|
174
178
|
this._applyStateModifier(
|
|
175
179
|
cssSelector,
|
|
176
180
|
modifier,
|
|
177
|
-
(elm, cls) => elm
|
|
181
|
+
(elm, cls) => elm?.classList.remove(cls)
|
|
178
182
|
);
|
|
179
183
|
}
|
|
180
184
|
_applyStateModifier(cssSelector, modifier = "selected", apply) {
|
|
@@ -195,14 +199,14 @@ var RuntimeStatechartApi = class {
|
|
|
195
199
|
this._applyTransitionsModifier(
|
|
196
200
|
cssSelector,
|
|
197
201
|
modifier,
|
|
198
|
-
(elm, cls) => elm
|
|
202
|
+
(elm, cls) => elm?.classList.add(cls)
|
|
199
203
|
);
|
|
200
204
|
}
|
|
201
205
|
_removeTransitionsModifier(cssSelector, modifier = "selected") {
|
|
202
206
|
this._applyTransitionsModifier(
|
|
203
207
|
cssSelector,
|
|
204
208
|
modifier,
|
|
205
|
-
(elm, cls) => elm
|
|
209
|
+
(elm, cls) => elm?.classList.remove(cls)
|
|
206
210
|
);
|
|
207
211
|
}
|
|
208
212
|
_applyTransitionsModifier(cssSelector, modifier = "selected", apply) {
|
|
@@ -226,11 +230,14 @@ var StateChartIndex = class {
|
|
|
226
230
|
initialStateKey = "<initial>",
|
|
227
231
|
finalStateKey = "<final>"
|
|
228
232
|
}) {
|
|
229
|
-
this
|
|
230
|
-
this
|
|
231
|
-
this
|
|
232
|
-
this
|
|
233
|
-
this
|
|
233
|
+
__publicField(this, "statechart");
|
|
234
|
+
__publicField(this, "_chartsIndex", {});
|
|
235
|
+
__publicField(this, "_nodesIndex", {});
|
|
236
|
+
__publicField(this, "_nodesParentsIndex", {});
|
|
237
|
+
__publicField(this, "_edgeIndex", {});
|
|
238
|
+
__publicField(this, "_edgesParentsIndex", {});
|
|
239
|
+
__publicField(this, "initialStateKey");
|
|
240
|
+
__publicField(this, "finalStateKey");
|
|
234
241
|
this.statechart = statechart;
|
|
235
242
|
this.initialStateKey = initialStateKey;
|
|
236
243
|
this.finalStateKey = finalStateKey;
|
|
@@ -290,7 +297,7 @@ var StateChartIndex = class {
|
|
|
290
297
|
* @returns a stack of state identifiers for the given states
|
|
291
298
|
*/
|
|
292
299
|
getStatesIds(...stack) {
|
|
293
|
-
|
|
300
|
+
const result = [];
|
|
294
301
|
let list = [this.statechart];
|
|
295
302
|
for (let i = 0; list?.length > 0 && i < stack.length; i++) {
|
|
296
303
|
const key = stack[i];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
|
|
5
|
+
export { __publicField };
|
|
@@ -18,14 +18,14 @@ function buildSections(root) {
|
|
|
18
18
|
let peek = null;
|
|
19
19
|
const stack = [];
|
|
20
20
|
const aligner = newTreeBuilder({
|
|
21
|
-
enter(
|
|
21
|
+
enter(_level, header) {
|
|
22
22
|
const section = {
|
|
23
23
|
header,
|
|
24
24
|
content: [],
|
|
25
25
|
children: []
|
|
26
26
|
};
|
|
27
27
|
top = top || section;
|
|
28
|
-
peek
|
|
28
|
+
peek?.children.push(section);
|
|
29
29
|
peek = section;
|
|
30
30
|
stack.push(section);
|
|
31
31
|
},
|
|
@@ -35,15 +35,16 @@ function buildSections(root) {
|
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
aligner(0);
|
|
38
|
-
|
|
39
|
-
let currentLevel = 0;
|
|
38
|
+
const headerLevels = [];
|
|
40
39
|
for (const node of nodes) {
|
|
41
40
|
if (isDomElement(node)) {
|
|
42
41
|
if (/^H[1-6]$/i.test(node.tagName)) {
|
|
43
42
|
const headerLevel = +node.tagName.replace(/^H/, "");
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
while (headerLevels.length > 0 && headerLevels[headerLevels.length - 1] >= headerLevel) {
|
|
44
|
+
headerLevels.pop();
|
|
45
|
+
}
|
|
46
|
+
headerLevels.push(headerLevel);
|
|
47
|
+
aligner(headerLevels.length, node);
|
|
47
48
|
} else {
|
|
48
49
|
peek.content.push(node);
|
|
49
50
|
}
|
|
@@ -70,6 +71,7 @@ function findSection(section, accept) {
|
|
|
70
71
|
for (const s of vistSections(section)) {
|
|
71
72
|
if (accept(s) === true) return s;
|
|
72
73
|
}
|
|
74
|
+
return void 0;
|
|
73
75
|
}
|
|
74
76
|
function isDomElement(node) {
|
|
75
77
|
return node.nodeType === Node.ELEMENT_NODE;
|
|
@@ -154,7 +156,7 @@ function getStateDescriptionRenderer(options) {
|
|
|
154
156
|
if (!section) return;
|
|
155
157
|
const elm = renderSections({
|
|
156
158
|
section,
|
|
157
|
-
deep: (
|
|
159
|
+
deep: (_section) => false,
|
|
158
160
|
// section.state !== options.rootStateKey, // ???
|
|
159
161
|
header: (section2) => {
|
|
160
162
|
if (section2.state === stateKey) {
|
|
@@ -170,7 +172,7 @@ function getStateDescriptionRenderer(options) {
|
|
|
170
172
|
}
|
|
171
173
|
function renderSections({
|
|
172
174
|
section,
|
|
173
|
-
deep = (
|
|
175
|
+
deep = (_s) => true,
|
|
174
176
|
header = (section2) => section2.header?.cloneNode(true)
|
|
175
177
|
}) {
|
|
176
178
|
const container = document.createElement("div");
|
package/dist/index-config.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { concatTransitionsToString, serializeProcessConfig, splitTransitionString, toFsmStateConfig } from './chunk-
|
|
1
|
+
export { concatTransitionsToString, serializeProcessConfig, splitTransitionString, toFsmStateConfig } from './chunk-ARZYBFNA.js';
|
|
2
|
+
import './chunk-PKBMQBKP.js';
|
package/dist/index-dom.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { buildSections, findSection, getStateDescriptionRenderer, getStatesDescriptions, isDomElement, newTreeBuilder, renderSections, toDomNodesIterator, visitDom, visitSectionNodes, visitStateDescriptions, vistSections } from './chunk-
|
|
1
|
+
export { buildSections, findSection, getStateDescriptionRenderer, getStatesDescriptions, isDomElement, newTreeBuilder, renderSections, toDomNodesIterator, visitDom, visitSectionNodes, visitStateDescriptions, vistSections } from './chunk-RZ4FP6JB.js';
|
|
2
|
+
import './chunk-PKBMQBKP.js';
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as TransitionsGraph, S as StateChart } from './StateChart-BYBjTmC2.js';
|
|
2
2
|
|
|
3
3
|
declare function buildStatechartCss({ prefix }?: {
|
|
4
4
|
prefix?: string | undefined;
|
|
5
5
|
}): string;
|
|
6
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
7
|
interface CssTree extends Record<string, string | number | CssTree> {
|
|
16
8
|
}
|
|
17
9
|
declare function serializeCss(obj: CssTree): string;
|
|
@@ -72,4 +64,12 @@ declare function buildStatechartSvg({ graph: { width, height, nodes, edges }, ne
|
|
|
72
64
|
finalStateKey?: string;
|
|
73
65
|
}): void;
|
|
74
66
|
|
|
75
|
-
|
|
67
|
+
declare function buildStatechartsPanel({ statechart, newId, println, initialStateKey, finalStateKey, }: {
|
|
68
|
+
statechart: StateChart;
|
|
69
|
+
newId: (prefix: string) => string;
|
|
70
|
+
println: (str: string) => void;
|
|
71
|
+
initialStateKey?: string;
|
|
72
|
+
finalStateKey?: string;
|
|
73
|
+
}): void;
|
|
74
|
+
|
|
75
|
+
export { type CssTree as C, activeStatesStyle as a, activeTransitionsStyle as b, buildStateDetailsStyle as c, buildStateDetailsStyleWithModifier as d, buildStatechartCss as e, buildStatechartStyles as f, buildStatechartStylesWithModifier as g, buildStatechartSvg as h, buildStatechartsPanel as i, selectedTransitionsStyle as j, serializeCss as k, selectedStatesStyle as s };
|
package/dist/index-html.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
+
export { a as activeStatesStyle, b as activeTransitionsStyle, c as buildStateDetailsStyle, d as buildStateDetailsStyleWithModifier, e as buildStatechartCss, f as buildStatechartStyles, g as buildStatechartStylesWithModifier, h as buildStatechartSvg, i as buildStatechartsPanel, s as selectedStatesStyle, j as selectedTransitionsStyle } from './index-html-BBQqYoST.js';
|
|
1
2
|
export { D as Dimensions, F as FsmStateConfig, G as GraphParamsProvider, L as Label, P as Padding, a as Position, S as StateChart, b as StateGraphEdge, c as StateGraphNode, T as Transition, d as TransitionsGraph } from './StateChart-BYBjTmC2.js';
|
|
2
|
-
export { c as activeStatesStyle, d as activeTransitionsStyle, f as buildStateDetailsStyle, g as buildStateDetailsStyleWithModifier, b as buildStatechartCss, i as buildStatechartStyles, h as buildStatechartStylesWithModifier, j as buildStatechartSvg, a as buildStatechartsPanel, s as selectedStatesStyle, e as selectedTransitionsStyle } from './index-html-DgSCNHkR.js';
|
package/dist/index-html.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle } from './chunk-
|
|
1
|
+
export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle } from './chunk-CR2M4445.js';
|
|
2
2
|
import './chunk-FIQDLBWD.js';
|
|
3
|
+
import './chunk-PKBMQBKP.js';
|
package/dist/index-layout.d.ts
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as FsmStateConfig, P as Padding, G as GraphParamsProvider, S as StateChart, T as Transition, d as TransitionsGraph } from './StateChart-BYBjTmC2.js';
|
|
2
2
|
export { D as Dimensions, L as Label, a as Position, b as StateGraphEdge, c as StateGraphNode } from './StateChart-BYBjTmC2.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Build graphs corresponding to the specified transitions.
|
|
6
|
-
* @param
|
|
6
|
+
* @param config - State configuration with transitions and sub-states.
|
|
7
7
|
* @param newId - A function that generates unique ids for nodes and edges.
|
|
8
8
|
* @param getStateParams - A function that returns the dimensions of a state node.
|
|
9
9
|
* @param getTransitionParams - A function that returns the dimensions of a transition edge.
|
|
10
10
|
* @param initialStateKey - The key for the initial state.
|
|
11
11
|
* @param finalStateKey - The key for the final state.
|
|
12
|
-
* @
|
|
13
|
-
* @returns {TransitionsGraph} - The graph with nodes and edges.
|
|
12
|
+
* @returns {StateChart} - The graph with nodes and edges.
|
|
14
13
|
*/
|
|
15
|
-
declare function
|
|
16
|
-
|
|
14
|
+
declare function buildCharts({ lodash, config, newId, getStateParams, getStateLabel, getTransitionParams, padding, vertical, initialStateKey, finalStateKey, direction, }: {
|
|
15
|
+
config: FsmStateConfig;
|
|
17
16
|
lodash: any;
|
|
18
17
|
newId: (prefix: string) => string;
|
|
19
18
|
initialStateKey?: string;
|
|
20
19
|
finalStateKey?: string;
|
|
21
|
-
vertical?: boolean;
|
|
22
20
|
padding?: Padding;
|
|
21
|
+
vertical?: boolean;
|
|
23
22
|
direction?: "tb" | "bt" | "lr" | "rl";
|
|
24
|
-
|
|
23
|
+
getStateLabel?: (stateKey: string) => string | undefined;
|
|
24
|
+
} & GraphParamsProvider): StateChart;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Build graphs corresponding to the specified transitions.
|
|
28
|
-
* @param
|
|
28
|
+
* @param transitions - The transitions between states.
|
|
29
29
|
* @param newId - A function that generates unique ids for nodes and edges.
|
|
30
30
|
* @param getStateParams - A function that returns the dimensions of a state node.
|
|
31
31
|
* @param getTransitionParams - A function that returns the dimensions of a transition edge.
|
|
32
32
|
* @param initialStateKey - The key for the initial state.
|
|
33
33
|
* @param finalStateKey - The key for the final state.
|
|
34
|
-
* @
|
|
34
|
+
* @param vertical - Whether the graph should be vertical.
|
|
35
|
+
* @returns {TransitionsGraph} - The graph with nodes and edges.
|
|
35
36
|
*/
|
|
36
|
-
declare function
|
|
37
|
-
|
|
37
|
+
declare function buildFlatCharts({ lodash, transitions, newId, getStateParams, getTransitionParams, padding, initialStateKey, finalStateKey, vertical, direction, }: {
|
|
38
|
+
transitions?: Transition[];
|
|
38
39
|
lodash: any;
|
|
39
40
|
newId: (prefix: string) => string;
|
|
40
41
|
initialStateKey?: string;
|
|
41
42
|
finalStateKey?: string;
|
|
42
|
-
padding?: Padding;
|
|
43
43
|
vertical?: boolean;
|
|
44
|
+
padding?: Padding;
|
|
44
45
|
direction?: "tb" | "bt" | "lr" | "rl";
|
|
45
|
-
|
|
46
|
-
} & GraphParamsProvider): StateChart;
|
|
46
|
+
} & GraphParamsProvider): TransitionsGraph;
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Provides default functions measuring dimensions for state nodes and transition edges in the graph.
|
package/dist/index-layout.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-
|
|
1
|
+
export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-2LFUT2C6.js';
|
|
2
2
|
import './chunk-FIQDLBWD.js';
|
|
3
|
+
import './chunk-PKBMQBKP.js';
|
package/dist/index-runtime.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { RuntimeStatechartApi, StateChartIndex } from './chunk-
|
|
1
|
+
export { RuntimeStatechartApi, StateChartIndex } from './chunk-GW2Z65BN.js';
|
|
2
|
+
import './chunk-PKBMQBKP.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { D as Dimensions, F as FsmStateConfig, G as GraphParamsProvider, L as Label, P as Padding, a as Position, S as StateChart, b as StateGraphEdge, c as StateGraphNode, T as Transition, d as TransitionsGraph } from './StateChart-BYBjTmC2.js';
|
|
2
|
-
export { DomSection, StateDescriptionSection, buildSections, findSection, getStateDescriptionRenderer, getStatesDescriptions, isDomElement, newTreeBuilder, renderSections, toDomNodesIterator, visitDom, visitSectionNodes, visitStateDescriptions, vistSections } from './index-dom.js';
|
|
3
1
|
export { concatTransitionsToString, serializeProcessConfig, splitTransitionString, toFsmStateConfig } from './index-config.js';
|
|
2
|
+
export { DomSection, StateDescriptionSection, buildSections, findSection, getStateDescriptionRenderer, getStatesDescriptions, isDomElement, newTreeBuilder, renderSections, toDomNodesIterator, visitDom, visitSectionNodes, visitStateDescriptions, vistSections } from './index-dom.js';
|
|
3
|
+
export { C as CssTree, a as activeStatesStyle, b as activeTransitionsStyle, c as buildStateDetailsStyle, d as buildStateDetailsStyleWithModifier, e as buildStatechartCss, f as buildStatechartStyles, g as buildStatechartStylesWithModifier, h as buildStatechartSvg, i as buildStatechartsPanel, s as selectedStatesStyle, j as selectedTransitionsStyle, k as serializeCss } from './index-html-BBQqYoST.js';
|
|
4
4
|
export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './index-layout.js';
|
|
5
|
-
export { C as CssTree, c as activeStatesStyle, d as activeTransitionsStyle, f as buildStateDetailsStyle, g as buildStateDetailsStyleWithModifier, b as buildStatechartCss, i as buildStatechartStyles, h as buildStatechartStylesWithModifier, j as buildStatechartSvg, a as buildStatechartsPanel, s as selectedStatesStyle, e as selectedTransitionsStyle, k as serializeCss } from './index-html-DgSCNHkR.js';
|
|
6
5
|
export { RuntimeListener, RuntimeStatechartApi, StateChartIndex } from './index-runtime.js';
|
|
6
|
+
export { D as Dimensions, F as FsmStateConfig, G as GraphParamsProvider, L as Label, P as Padding, a as Position, S as StateChart, b as StateGraphEdge, c as StateGraphNode, T as Transition, d as TransitionsGraph } from './StateChart-BYBjTmC2.js';
|
|
7
7
|
|
|
8
8
|
declare function toKebabCase(str?: string): string;
|
|
9
9
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { concatTransitionsToString, serializeProcessConfig, splitTransitionString, toFsmStateConfig } from './chunk-
|
|
2
|
-
export { buildSections, findSection, getStateDescriptionRenderer, getStatesDescriptions, isDomElement, newTreeBuilder, renderSections, toDomNodesIterator, visitDom, visitSectionNodes, visitStateDescriptions, vistSections } from './chunk-
|
|
3
|
-
export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle, serializeCss, toKebabCase } from './chunk-
|
|
4
|
-
export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-
|
|
1
|
+
export { concatTransitionsToString, serializeProcessConfig, splitTransitionString, toFsmStateConfig } from './chunk-ARZYBFNA.js';
|
|
2
|
+
export { buildSections, findSection, getStateDescriptionRenderer, getStatesDescriptions, isDomElement, newTreeBuilder, renderSections, toDomNodesIterator, visitDom, visitSectionNodes, visitStateDescriptions, vistSections } from './chunk-RZ4FP6JB.js';
|
|
3
|
+
export { activeStatesStyle, activeTransitionsStyle, buildStateDetailsStyle, buildStateDetailsStyleWithModifier, buildStatechartCss, buildStatechartStyles, buildStatechartStylesWithModifier, buildStatechartSvg, buildStatechartsPanel, selectedStatesStyle, selectedTransitionsStyle, serializeCss, toKebabCase } from './chunk-CR2M4445.js';
|
|
4
|
+
export { buildCharts, buildFlatCharts, getGraphParamsProvider, getLabelDimensions } from './chunk-2LFUT2C6.js';
|
|
5
5
|
import './chunk-FIQDLBWD.js';
|
|
6
|
-
export { RuntimeStatechartApi, StateChartIndex } from './chunk-
|
|
6
|
+
export { RuntimeStatechartApi, StateChartIndex } from './chunk-GW2Z65BN.js';
|
|
7
|
+
import './chunk-PKBMQBKP.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statewalker/fsm-charts",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "HFSM Implementation",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/statewalker/statewalker-fsm-charts",
|
|
@@ -29,37 +29,35 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@
|
|
33
|
-
"@types/
|
|
34
|
-
"@
|
|
35
|
-
"
|
|
36
|
-
"eslint": "
|
|
37
|
-
"eslint-
|
|
38
|
-
"eslint-plugin-import": "^2.25.2",
|
|
32
|
+
"@types/jsdom": "catalog:",
|
|
33
|
+
"@types/lodash-es": "catalog:",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "catalog:",
|
|
35
|
+
"eslint": "catalog:",
|
|
36
|
+
"eslint-config-standard-with-typescript": "catalog:",
|
|
37
|
+
"eslint-plugin-import": "catalog:",
|
|
39
38
|
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
|
|
40
|
-
"eslint-plugin-promise": "
|
|
41
|
-
"jsdom": "
|
|
42
|
-
"lodash": "
|
|
43
|
-
"lodash-es": "
|
|
44
|
-
"tsup": "
|
|
39
|
+
"eslint-plugin-promise": "catalog:",
|
|
40
|
+
"jsdom": "catalog:",
|
|
41
|
+
"lodash": "catalog:",
|
|
42
|
+
"lodash-es": "catalog:",
|
|
43
|
+
"tsup": "catalog:",
|
|
45
44
|
"typescript": "*",
|
|
46
|
-
"vitest": "
|
|
45
|
+
"vitest": "catalog:"
|
|
47
46
|
},
|
|
48
47
|
"repository": {
|
|
49
48
|
"type": "git",
|
|
50
49
|
"url": "git@github.com:statewalker/statewalker-fsm-charts.git"
|
|
51
50
|
},
|
|
52
51
|
"scripts": {
|
|
53
|
-
"build": "rm -fr ./dist &&
|
|
54
|
-
"prepare": "yarn build",
|
|
52
|
+
"build": "rm -fr ./dist && pnpm test && tsup",
|
|
55
53
|
"watch": "tsup --watch",
|
|
56
54
|
"watch-for-viewer": "tsup --watch --outDir=../statewalker-fsm-viewer/src/.observablehq/cache/_node/@statewalker/fsm-charts@0.2.1",
|
|
57
55
|
"clean": "rm -rf dist",
|
|
58
56
|
"lint": "eslint",
|
|
59
|
-
"lint:fix": "
|
|
57
|
+
"lint:fix": "pnpm lint --fix",
|
|
60
58
|
"test": "vitest --run",
|
|
61
59
|
"test:watch": "vitest",
|
|
62
|
-
"prepublish": "
|
|
60
|
+
"prepublish": "pnpm build"
|
|
63
61
|
},
|
|
64
62
|
"publishConfig": {
|
|
65
63
|
"access": "public"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Transition } from "../types/index.js";
|
|
2
2
|
|
|
3
3
|
export function concatTransitionsToString(transitions: Transition[]) {
|
|
4
|
-
|
|
4
|
+
const list: string[] = [];
|
|
5
5
|
let str: string = "";
|
|
6
6
|
let prev: undefined | string;
|
|
7
7
|
for (const [from, event, to] of transitions) {
|
package/src/config/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./concatTransitionsToString.
|
|
2
|
-
export * from "./serializeProcessConfig.
|
|
3
|
-
export * from "./splitTransitionString.
|
|
4
|
-
export * from "./toFsmStateConfig.
|
|
1
|
+
export * from "./concatTransitionsToString.js";
|
|
2
|
+
export * from "./serializeProcessConfig.js";
|
|
3
|
+
export * from "./splitTransitionString.js";
|
|
4
|
+
export * from "./toFsmStateConfig.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { FsmStateConfig } from "../types/index.
|
|
1
|
+
import type { FsmStateConfig } from "../types/index.js";
|
|
2
2
|
|
|
3
3
|
export function serializeProcessConfig(config: FsmStateConfig | undefined) {
|
|
4
4
|
if (!config) return "";
|
|
5
|
-
|
|
5
|
+
const lines: string[] = [];
|
|
6
6
|
visit(config, lines);
|
|
7
7
|
return lines.join("\n");
|
|
8
8
|
|
|
@@ -29,7 +29,7 @@ export function serializeProcessConfig(config: FsmStateConfig | undefined) {
|
|
|
29
29
|
if (i > 0) {
|
|
30
30
|
lines[lines.length - 1] += ",";
|
|
31
31
|
}
|
|
32
|
-
visit(states[i], lines, shift
|
|
32
|
+
visit(states[i], lines, `${shift} `);
|
|
33
33
|
}
|
|
34
34
|
lines.push(`${shift} ]`);
|
|
35
35
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Transition } from "../types/index.js";
|
|
2
2
|
|
|
3
3
|
export function splitTransitionString(str: string): Transition[] {
|
|
4
4
|
let list: string[] = [];
|
|
5
5
|
let pos = 0;
|
|
6
6
|
const matches = Array.from(
|
|
7
|
-
str.matchAll(/-\s*("[^"]*?"|'[^']*?'|[^-]*?)\s*->/g)
|
|
7
|
+
str.matchAll(/-\s*("[^"]*?"|'[^']*?'|[^-]*?)\s*->/g),
|
|
8
8
|
);
|
|
9
9
|
for (const match of matches) {
|
|
10
10
|
list.push(str.substring(pos, match.index));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { FsmStateConfig, Transition } from "../types/index.js";
|
|
2
|
+
import { splitTransitionString } from "./splitTransitionString.js";
|
|
3
3
|
|
|
4
4
|
export function toFsmStateConfig(json: any): FsmStateConfig | undefined {
|
|
5
5
|
if (!json || typeof json !== "object") return;
|
|
@@ -20,7 +20,7 @@ export function toFsmStateConfig(json: any): FsmStateConfig | undefined {
|
|
|
20
20
|
const transitions: Transition[] = [];
|
|
21
21
|
const index: Record<string, boolean> = {};
|
|
22
22
|
const array = toArray(json);
|
|
23
|
-
for (
|
|
23
|
+
for (const line of array) {
|
|
24
24
|
const lineTransitions =
|
|
25
25
|
typeof line === "string"
|
|
26
26
|
? splitTransitionString(line)
|