state-machine-cat 12.0.19 → 12.0.21
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/LICENSE +1 -1
- package/dist/cli/actions.mjs +1 -1
- package/dist/counter.mjs +9 -0
- package/dist/parse/index.mjs +1 -1
- package/dist/parse/parser-helpers.mjs +0 -9
- package/dist/parse/scxml/index.mjs +10 -7
- package/dist/parse/smcat/parse.mjs +5 -0
- package/dist/parse/smcat/smcat-parser.mjs +1 -2
- package/dist/parse/smcat-ast.schema.mjs +1 -1
- package/dist/render/dot/index.mjs +52 -26
- package/dist/state-machine-model.mjs +17 -14
- package/dist/transform/desugar.mjs +14 -2
- package/dist/version.mjs +1 -1
- package/package.json +1 -1
- package/types/state-machine-cat.d.mts +4 -4
package/LICENSE
CHANGED
package/dist/cli/actions.mjs
CHANGED
|
@@ -5,7 +5,7 @@ const LICENSE = `
|
|
|
5
5
|
|
|
6
6
|
The MIT License (MIT)
|
|
7
7
|
|
|
8
|
-
Copyright (c) 2016-
|
|
8
|
+
Copyright (c) 2016-2025 Sander Verweij
|
|
9
9
|
|
|
10
10
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
11
11
|
a copy of this software and associated documentation files (the
|
package/dist/counter.mjs
ADDED
package/dist/parse/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Ajv from "ajv";
|
|
2
2
|
import options from "../options.mjs";
|
|
3
|
-
import { parse as parseSmCat } from "./smcat/
|
|
3
|
+
import { parse as parseSmCat } from "./smcat/parse.mjs";
|
|
4
4
|
import { parse as parseSCXML } from "./scxml/index.mjs";
|
|
5
5
|
import $schema from "./smcat-ast.schema.mjs";
|
|
6
6
|
const ajv = new Ajv();
|
|
@@ -2,7 +2,6 @@ import StateMachineModel from "../state-machine-model.mjs";
|
|
|
2
2
|
const TRIGGER_RE_AS_A_STRING =
|
|
3
3
|
"^(entry|activity|exit)\\s*/\\s*([^\\n$]*)(\\n|$)";
|
|
4
4
|
const TRIGGER_RE = new RegExp(TRIGGER_RE_AS_A_STRING);
|
|
5
|
-
let gTransitionIdHwm = 0;
|
|
6
5
|
function stateExists(pKnownStateNames, pName) {
|
|
7
6
|
return pKnownStateNames.includes(pName);
|
|
8
7
|
}
|
|
@@ -181,12 +180,6 @@ function extractActions(pString) {
|
|
|
181
180
|
.map((pActivityCandidate) => pActivityCandidate.trim())
|
|
182
181
|
.map(extractAction);
|
|
183
182
|
}
|
|
184
|
-
function nextTransitionId() {
|
|
185
|
-
return ++gTransitionIdHwm;
|
|
186
|
-
}
|
|
187
|
-
function resetTransitionId() {
|
|
188
|
-
gTransitionIdHwm = 0;
|
|
189
|
-
}
|
|
190
183
|
export default {
|
|
191
184
|
initState,
|
|
192
185
|
extractUndeclaredStates,
|
|
@@ -198,6 +191,4 @@ export default {
|
|
|
198
191
|
extractActions,
|
|
199
192
|
setIf,
|
|
200
193
|
setIfNotEmpty,
|
|
201
|
-
nextTransitionId,
|
|
202
|
-
resetTransitionId,
|
|
203
194
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import fastxml from "fast-xml-parser";
|
|
2
2
|
import he from "he";
|
|
3
3
|
import traverse from "neotraverse";
|
|
4
|
-
import
|
|
4
|
+
import { Counter } from "../../counter.mjs";
|
|
5
5
|
import parserHelpers from "../parser-helpers.mjs";
|
|
6
|
+
import utl from "../../transform/utl.mjs";
|
|
6
7
|
import { castArray } from "./utl.mjs";
|
|
7
8
|
import { normalizeMachine } from "./normalize-machine.mjs";
|
|
8
9
|
const formatLabel = utl.formatLabel;
|
|
@@ -97,12 +98,13 @@ function extractTransitionAttributes(pTransition) {
|
|
|
97
98
|
}
|
|
98
99
|
return lReturnValue;
|
|
99
100
|
}
|
|
100
|
-
function reduceTransition(pState) {
|
|
101
|
+
function reduceTransition(pState, pCounter) {
|
|
101
102
|
return (pAllTransitions, pTransition) => {
|
|
102
103
|
const lTargets = (pTransition?.target ?? pState.id).split(/\s+/);
|
|
103
104
|
const lTransitionAttributes = extractTransitionAttributes(pTransition);
|
|
104
105
|
return pAllTransitions.concat(
|
|
105
106
|
lTargets.map((pTarget) => ({
|
|
107
|
+
id: pCounter.next(),
|
|
106
108
|
from: pState.id,
|
|
107
109
|
to: pTarget,
|
|
108
110
|
...lTransitionAttributes,
|
|
@@ -110,13 +112,13 @@ function reduceTransition(pState) {
|
|
|
110
112
|
);
|
|
111
113
|
};
|
|
112
114
|
}
|
|
113
|
-
function extractTransitions(pStates) {
|
|
115
|
+
function extractTransitions(pStates, pCounter) {
|
|
114
116
|
return pStates
|
|
115
117
|
.filter((pState) => Object.hasOwn(pState, "transition"))
|
|
116
118
|
.reduce((pAllTransitions, pThisState) => {
|
|
117
119
|
const lTransitionAsArray = castArray(pThisState.transition);
|
|
118
120
|
return pAllTransitions.concat(
|
|
119
|
-
lTransitionAsArray.reduce(reduceTransition(pThisState), []),
|
|
121
|
+
lTransitionAsArray.reduce(reduceTransition(pThisState, pCounter), []),
|
|
120
122
|
);
|
|
121
123
|
}, []);
|
|
122
124
|
}
|
|
@@ -130,9 +132,10 @@ function mapMachine(pSCXMLStateMachine) {
|
|
|
130
132
|
.concat(lNormalizedMachine.history.map(mapState("history")))
|
|
131
133
|
.concat(lNormalizedMachine.final.map(mapState("final"))),
|
|
132
134
|
};
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
.concat(extractTransitions(lNormalizedMachine.
|
|
135
|
+
const lCounter = new Counter();
|
|
136
|
+
const lTransitions = extractTransitions(lNormalizedMachine.initial, lCounter)
|
|
137
|
+
.concat(extractTransitions(lNormalizedMachine.state, lCounter))
|
|
138
|
+
.concat(extractTransitions(lNormalizedMachine.parallel, lCounter));
|
|
136
139
|
if (lTransitions.length > 0) {
|
|
137
140
|
lReturnValue.transitions = lTransitions;
|
|
138
141
|
}
|
|
@@ -321,7 +321,6 @@ function peg$parse(input, options) {
|
|
|
321
321
|
var peg$e78 = peg$classExpectation(["\r", "\n"], true, false);
|
|
322
322
|
var peg$e79 = peg$otherExpectation("comment");
|
|
323
323
|
var peg$f0 = function (statemachine) {
|
|
324
|
-
parserHelpers.resetTransitionId();
|
|
325
324
|
statemachine.states = parserHelpers.extractUndeclaredStates(statemachine);
|
|
326
325
|
return parserHelpers.classifyForkJoins(statemachine);
|
|
327
326
|
};
|
|
@@ -431,7 +430,7 @@ function peg$parse(input, options) {
|
|
|
431
430
|
),
|
|
432
431
|
);
|
|
433
432
|
parserHelpers.setIfNotEmpty(trans, "note", notes);
|
|
434
|
-
trans.id =
|
|
433
|
+
trans.id = options.counter.next();
|
|
435
434
|
return trans;
|
|
436
435
|
};
|
|
437
436
|
var peg$f20 = function (from_, to) {
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
normalizeState,
|
|
17
17
|
stateNote,
|
|
18
18
|
} from "./utl.mjs";
|
|
19
|
-
let gRenderedTransitions = new Set();
|
|
20
19
|
function initial(pState, pIndent) {
|
|
21
20
|
const lActiveAttribute = pState.active ? " penwidth=3.0" : "";
|
|
22
21
|
return `${pIndent} "${pState.name}" [shape=circle style=filled class="${pState.class}" color="${pState.color}" fillcolor="${pState.color}" fixedsize=true height=0.15 label=""${lActiveAttribute}]${pState.noteText}`;
|
|
@@ -61,7 +60,13 @@ ${pIndent} </table>`;
|
|
|
61
60
|
return `${pIndent} "${pState.name}" [margin=0 class="${pState.class}" label= <${lLabelTag}
|
|
62
61
|
${pIndent} >${pState.colorAttribute}${pState.fontColorAttribute}${lActiveAttribute}]${pState.noteText}`;
|
|
63
62
|
}
|
|
64
|
-
function compositeRegular(
|
|
63
|
+
function compositeRegular(
|
|
64
|
+
pState,
|
|
65
|
+
pIndent,
|
|
66
|
+
pOptions,
|
|
67
|
+
pModel,
|
|
68
|
+
pRenderedTransitions,
|
|
69
|
+
) {
|
|
65
70
|
const lPenWidth = pState.isParallelArea
|
|
66
71
|
? "1.0"
|
|
67
72
|
: pState.active
|
|
@@ -85,12 +90,18 @@ ${pIndent} class="${pState.class}" label= <
|
|
|
85
90
|
${lLabelTag}
|
|
86
91
|
${pIndent} > style=${lStyle} penwidth=${lPenWidth}${pState.colorAttribute}${pState.fontColorAttribute}
|
|
87
92
|
${pIndent} "${pState.name}" [shape=point style=invis margin=0 width=0 height=0 fixedsize=true]
|
|
88
|
-
${states(pState?.statemachine?.states ?? [], `${pIndent} `, pOptions, pModel)}
|
|
93
|
+
${states(pState?.statemachine?.states ?? [], `${pIndent} `, pOptions, pModel, pRenderedTransitions)}
|
|
89
94
|
${pIndent} }${pState.noteText}`;
|
|
90
95
|
}
|
|
91
|
-
function regular(pState, pIndent, pOptions, pModel) {
|
|
96
|
+
function regular(pState, pIndent, pOptions, pModel, pRenderedTransitions) {
|
|
92
97
|
if (pState.statemachine) {
|
|
93
|
-
return compositeRegular(
|
|
98
|
+
return compositeRegular(
|
|
99
|
+
pState,
|
|
100
|
+
pIndent,
|
|
101
|
+
pOptions,
|
|
102
|
+
pModel,
|
|
103
|
+
pRenderedTransitions,
|
|
104
|
+
);
|
|
94
105
|
}
|
|
95
106
|
return atomicRegular(pState, pIndent);
|
|
96
107
|
}
|
|
@@ -163,14 +174,14 @@ const STATE_TYPE2FUNCTION = new Map([
|
|
|
163
174
|
["terminate", terminate],
|
|
164
175
|
["final", final],
|
|
165
176
|
]);
|
|
166
|
-
function state(pState, pIndent, pOptions, pModel) {
|
|
177
|
+
function state(pState, pIndent, pOptions, pModel, pRenderedTransitions) {
|
|
167
178
|
const lState = normalizeState(pState, pOptions, pIndent);
|
|
168
179
|
const lCandidateTransitions = pModel.findTransitionsToSiblings(
|
|
169
180
|
pState.name,
|
|
170
|
-
|
|
181
|
+
pRenderedTransitions,
|
|
171
182
|
);
|
|
172
183
|
lCandidateTransitions.forEach((pTransition) => {
|
|
173
|
-
|
|
184
|
+
pRenderedTransitions.add(pTransition.id);
|
|
174
185
|
});
|
|
175
186
|
const lTransitions = transitions(
|
|
176
187
|
lCandidateTransitions,
|
|
@@ -184,14 +195,17 @@ function state(pState, pIndent, pOptions, pModel) {
|
|
|
184
195
|
pIndent,
|
|
185
196
|
pOptions,
|
|
186
197
|
pModel,
|
|
198
|
+
pRenderedTransitions,
|
|
187
199
|
) +
|
|
188
200
|
lTransitions +
|
|
189
201
|
"\n"
|
|
190
202
|
);
|
|
191
203
|
}
|
|
192
|
-
function states(pStates, pIndent, pOptions, pModel) {
|
|
204
|
+
function states(pStates, pIndent, pOptions, pModel, pRenderedTransitions) {
|
|
193
205
|
return pStates
|
|
194
|
-
.map((pState) =>
|
|
206
|
+
.map((pState) =>
|
|
207
|
+
state(pState, pIndent, pOptions, pModel, pRenderedTransitions),
|
|
208
|
+
)
|
|
195
209
|
.join("");
|
|
196
210
|
}
|
|
197
211
|
function transition(pTransition, pIndent, pOptions, pModel) {
|
|
@@ -213,25 +227,32 @@ function transition(pTransition, pIndent, pOptions, pModel) {
|
|
|
213
227
|
? ` lhead="cluster_${pTransition.to}"`
|
|
214
228
|
: "";
|
|
215
229
|
const lTransitionName = `tr_${pTransition.from}_${pTransition.to}_${pTransition.id}`;
|
|
216
|
-
if (pTransition.note) {
|
|
217
|
-
const lNoteName = `note_${lTransitionName}`;
|
|
218
|
-
const lNoteNodeName = `i_${lNoteName}`;
|
|
219
|
-
const lNoteNode = `\n${pIndent} "${lNoteNodeName}" [shape=point style=invis margin=0 width=0 height=0 fixedsize=true]`;
|
|
220
|
-
const lTransitionFrom = `\n${pIndent} "${pTransition.from}" -> "${lNoteNodeName}" [arrowhead=none${lTail}${lColorAttribute}]`;
|
|
221
|
-
const lTransitionTo = `\n${pIndent} "${lNoteNodeName}" -> "${pTransition.to}" [label="${lLabel}"${lHead}${lColorAttribute}${lFontColorAttribute}]`;
|
|
222
|
-
const lLineToNote = `\n${pIndent} "${lNoteNodeName}" -> "${lNoteName}" [style=dashed arrowtail=none arrowhead=none weight=0]`;
|
|
223
|
-
const lNote = `\n${pIndent} "${lNoteName}" [label="${noteToLabel(pTransition.note)}" shape=note fontsize=10 color=black fontcolor=black fillcolor="#ffffcc" penwidth=1.0]`;
|
|
224
|
-
return lNoteNode + lTransitionFrom + lTransitionTo + lLineToNote + lNote;
|
|
225
|
-
}
|
|
226
230
|
if (isCompositeSelf(pModel, pTransition)) {
|
|
227
231
|
const { lTailPorts, lHeadPorts } = getTransitionPorts(
|
|
228
232
|
pOptions,
|
|
229
233
|
pModel,
|
|
230
234
|
pTransition,
|
|
231
235
|
);
|
|
232
|
-
|
|
236
|
+
let lNoteAndLine = "";
|
|
237
|
+
if (pTransition.note) {
|
|
238
|
+
const lNoteName = `note_${lTransitionName}`;
|
|
239
|
+
const lLineToNote = `\n${pIndent} "${lNoteName}" -> "self_tr_${pTransition.from}_${pTransition.to}_${pTransition.id}" [style=dashed arrowtail=none arrowhead=none weight=0]`;
|
|
240
|
+
const lNote = `\n${pIndent} "${lNoteName}" [label="${noteToLabel(pTransition.note)}" shape=note fontsize=10 color=black fontcolor=black fillcolor="#ffffcc" penwidth=1.0]`;
|
|
241
|
+
lNoteAndLine = lLineToNote + lNote;
|
|
242
|
+
}
|
|
243
|
+
const lTransitionFrom = `\n${pIndent} "${pTransition.from}" -> "self_tr_${pTransition.from}_${pTransition.to}_${pTransition.id}" [label="${lLabel}" arrowhead=none class="${lClass}"${lTailPorts}${lTail}${lColorAttribute}${lFontColorAttribute}${lPenWidth}]`;
|
|
233
244
|
const lTransitionTo = `\n${pIndent} "self_tr_${pTransition.from}_${pTransition.to}_${pTransition.id}" -> "${pTransition.to}" [class="${lClass}"${lHead}${lHeadPorts}${lColorAttribute}${lPenWidth}]`;
|
|
234
|
-
return lTransitionFrom + lTransitionTo;
|
|
245
|
+
return lTransitionFrom + lTransitionTo + lNoteAndLine;
|
|
246
|
+
}
|
|
247
|
+
if (pTransition.note) {
|
|
248
|
+
const lNoteName = `note_${lTransitionName}`;
|
|
249
|
+
const lNoteNodeName = `i_${lNoteName}`;
|
|
250
|
+
const lNoteNode = `\n${pIndent} "${lNoteNodeName}" [shape=point style=invis margin=0 width=0 height=0 fixedsize=true]`;
|
|
251
|
+
const lTransitionFrom = `\n${pIndent} "${pTransition.from}" -> "${lNoteNodeName}" [arrowhead=none${lTail}${lColorAttribute}${lPenWidth}]`;
|
|
252
|
+
const lTransitionTo = `\n${pIndent} "${lNoteNodeName}" -> "${pTransition.to}" [label="${lLabel}"${lHead}${lColorAttribute}${lFontColorAttribute}${lPenWidth}]`;
|
|
253
|
+
const lLineToNote = `\n${pIndent} "${lNoteNodeName}" -> "${lNoteName}" [style=dashed arrowtail=none arrowhead=none weight=0]`;
|
|
254
|
+
const lNote = `\n${pIndent} "${lNoteName}" [label="${noteToLabel(pTransition.note)}" shape=note fontsize=10 color=black fontcolor=black fillcolor="#ffffcc" penwidth=1.0]`;
|
|
255
|
+
return lNoteNode + lTransitionFrom + lTransitionTo + lLineToNote + lNote;
|
|
235
256
|
}
|
|
236
257
|
return `\n${pIndent} "${pTransition.from}" -> "${pTransition.to}" [label="${lLabel}" class="${lClass}"${lTail}${lHead}${lColorAttribute}${lFontColorAttribute}${lPenWidth}]`;
|
|
237
258
|
}
|
|
@@ -249,17 +270,22 @@ export default function renderDot(pStateMachine, pOptions = {}, pIndent = "") {
|
|
|
249
270
|
const lNodeAttributes = buildNodeAttributes(pOptions.dotNodeAttrs || []);
|
|
250
271
|
const lEdgeAttributes = buildEdgeAttributes(pOptions.dotEdgeAttrs || []);
|
|
251
272
|
const lModel = new StateMachineModel(pStateMachine);
|
|
252
|
-
|
|
253
|
-
const lStates = states(
|
|
273
|
+
const lRenderedTransitions = new Set();
|
|
274
|
+
const lStates = states(
|
|
275
|
+
pStateMachine.states,
|
|
276
|
+
pIndent,
|
|
277
|
+
pOptions,
|
|
278
|
+
lModel,
|
|
279
|
+
lRenderedTransitions,
|
|
280
|
+
);
|
|
254
281
|
const lRemainingTransitions = transitions(
|
|
255
282
|
lModel.flattenedTransitions.filter(
|
|
256
|
-
(pTransition) => !
|
|
283
|
+
(pTransition) => !lRenderedTransitions.has(pTransition.id),
|
|
257
284
|
),
|
|
258
285
|
pIndent,
|
|
259
286
|
pOptions,
|
|
260
287
|
lModel,
|
|
261
288
|
);
|
|
262
|
-
gRenderedTransitions = new Set();
|
|
263
289
|
return `digraph "state transitions" {
|
|
264
290
|
${lGraphAttributes}
|
|
265
291
|
node [${lNodeAttributes}]
|
|
@@ -32,26 +32,26 @@ function flattenTransitions(pStateMachine) {
|
|
|
32
32
|
return lTransitions;
|
|
33
33
|
}
|
|
34
34
|
export default class StateMachineModel {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
#flattenedTransitions;
|
|
36
|
+
#flattenedStates;
|
|
37
37
|
constructor(pStateMachine) {
|
|
38
|
-
this
|
|
39
|
-
flattenStatesToMap(pStateMachine.states ?? [], this
|
|
40
|
-
this
|
|
38
|
+
this.#flattenedStates = new Map();
|
|
39
|
+
flattenStatesToMap(pStateMachine.states ?? [], this.#flattenedStates);
|
|
40
|
+
this.#flattenedTransitions = flattenTransitions(pStateMachine);
|
|
41
41
|
}
|
|
42
42
|
get flattenedTransitions() {
|
|
43
|
-
return this
|
|
43
|
+
return this.#flattenedTransitions;
|
|
44
44
|
}
|
|
45
45
|
findStateByName(pName) {
|
|
46
|
-
return this.
|
|
46
|
+
return this.#flattenedStates.get(pName);
|
|
47
47
|
}
|
|
48
48
|
findStatesByTypes(pTypes) {
|
|
49
|
-
return Array.from(this.
|
|
49
|
+
return Array.from(this.#flattenedStates.values()).filter((pState) =>
|
|
50
50
|
pTypes.includes(pState.type),
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
findExternalSelfTransitions(pStateName) {
|
|
54
|
-
return this.
|
|
54
|
+
return this.#flattenedTransitions.filter(
|
|
55
55
|
(pTransition) =>
|
|
56
56
|
pTransition.from === pStateName &&
|
|
57
57
|
pTransition.to === pStateName &&
|
|
@@ -59,22 +59,25 @@ export default class StateMachineModel {
|
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
findTransitionsByFrom(pFromStateName) {
|
|
62
|
-
return this.
|
|
62
|
+
return this.#flattenedTransitions.filter(
|
|
63
63
|
(pTransition) => pTransition.from === pFromStateName,
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
findTransitionsByTo(pToStateName) {
|
|
67
|
-
return this.
|
|
67
|
+
return this.#flattenedTransitions.filter(
|
|
68
68
|
(pTransition) => pTransition.to === pToStateName,
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
|
+
getMaximumTransitionId() {
|
|
72
|
+
return Math.max(...this.#flattenedTransitions.map(({ id }) => id));
|
|
73
|
+
}
|
|
71
74
|
findTransitionsToSiblings(pStateName, pExcludeIds) {
|
|
72
|
-
return this.
|
|
75
|
+
return this.#flattenedTransitions.filter(
|
|
73
76
|
(pTransition) =>
|
|
74
77
|
!pExcludeIds.has(pTransition.id) &&
|
|
75
78
|
pTransition.from === pStateName &&
|
|
76
|
-
this.
|
|
77
|
-
this.
|
|
79
|
+
this.#flattenedStates.get(pTransition.to)?.parent ===
|
|
80
|
+
this.#flattenedStates.get(pStateName)?.parent,
|
|
78
81
|
);
|
|
79
82
|
}
|
|
80
83
|
}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import StateMachineModel from "../state-machine-model.mjs";
|
|
2
|
+
import { Counter } from "../counter.mjs";
|
|
2
3
|
import utl from "./utl.mjs";
|
|
3
4
|
function fuseTransitionAttribute(pIncomingThing, pOutgoingThing, pJoinChar) {
|
|
4
5
|
return pIncomingThing
|
|
5
6
|
? `${pIncomingThing}${pJoinChar}${pOutgoingThing}`
|
|
6
7
|
: pOutgoingThing;
|
|
7
8
|
}
|
|
8
|
-
function fuseIncomingToOutgoing(
|
|
9
|
+
function fuseIncomingToOutgoing(
|
|
10
|
+
pIncomingTransition,
|
|
11
|
+
pOutgoingTransition,
|
|
12
|
+
pCounter,
|
|
13
|
+
) {
|
|
9
14
|
const lReturnValue = {
|
|
10
15
|
...pIncomingTransition,
|
|
11
16
|
...pOutgoingTransition,
|
|
12
17
|
from: pIncomingTransition.from,
|
|
13
18
|
to: pOutgoingTransition.to,
|
|
19
|
+
id: pCounter.next(),
|
|
14
20
|
};
|
|
15
21
|
if (pOutgoingTransition.action) {
|
|
16
22
|
lReturnValue.action = fuseTransitionAttribute(
|
|
@@ -32,13 +38,14 @@ function fuseTransitions(
|
|
|
32
38
|
pTransitions,
|
|
33
39
|
pPseudoStateNames,
|
|
34
40
|
pOutgoingTransitionMap,
|
|
41
|
+
pCounter,
|
|
35
42
|
) {
|
|
36
43
|
return pTransitions.reduce((pAll, pTransition) => {
|
|
37
44
|
pPseudoStateNames.forEach((pStateName, pIndex) => {
|
|
38
45
|
if (pStateName === pTransition.to && pOutgoingTransitionMap[pStateName]) {
|
|
39
46
|
pAll = pAll.concat(
|
|
40
47
|
pOutgoingTransitionMap[pStateName].map((pOutgoingTransition) =>
|
|
41
|
-
fuseIncomingToOutgoing(pTransition, pOutgoingTransition),
|
|
48
|
+
fuseIncomingToOutgoing(pTransition, pOutgoingTransition, pCounter),
|
|
42
49
|
),
|
|
43
50
|
);
|
|
44
51
|
} else {
|
|
@@ -52,6 +59,7 @@ function deSugarPseudoStates(
|
|
|
52
59
|
pMachine,
|
|
53
60
|
pPseudoStateNames,
|
|
54
61
|
pOutgoingTransitionMap,
|
|
62
|
+
pCounter,
|
|
55
63
|
) {
|
|
56
64
|
const lMachine = structuredClone(pMachine);
|
|
57
65
|
if (lMachine.transitions && pPseudoStateNames.length > 0) {
|
|
@@ -59,6 +67,7 @@ function deSugarPseudoStates(
|
|
|
59
67
|
lMachine.transitions,
|
|
60
68
|
pPseudoStateNames,
|
|
61
69
|
pOutgoingTransitionMap,
|
|
70
|
+
pCounter,
|
|
62
71
|
);
|
|
63
72
|
}
|
|
64
73
|
lMachine.states = lMachine.states.map((pState) =>
|
|
@@ -69,6 +78,7 @@ function deSugarPseudoStates(
|
|
|
69
78
|
pState.statemachine,
|
|
70
79
|
pPseudoStateNames,
|
|
71
80
|
pOutgoingTransitionMap,
|
|
81
|
+
pCounter,
|
|
72
82
|
),
|
|
73
83
|
}
|
|
74
84
|
: pState,
|
|
@@ -117,10 +127,12 @@ export default (
|
|
|
117
127
|
},
|
|
118
128
|
{},
|
|
119
129
|
);
|
|
130
|
+
const lMaximumTransitionId = lModel.getMaximumTransitionId();
|
|
120
131
|
const lMachine = deSugarPseudoStates(
|
|
121
132
|
pMachine,
|
|
122
133
|
lPseudoStateNames,
|
|
123
134
|
lOutgoingTransitionMap,
|
|
135
|
+
new Counter(lMaximumTransitionId),
|
|
124
136
|
);
|
|
125
137
|
return removeStatesCascading(lMachine, lPseudoStateNames);
|
|
126
138
|
};
|
package/dist/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "12.0.
|
|
1
|
+
export const version = "12.0.21";
|
package/package.json
CHANGED
|
@@ -83,6 +83,10 @@ export interface IState {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
export interface ITransition {
|
|
86
|
+
/**
|
|
87
|
+
* The id of the transition. Unique within the root state machine.
|
|
88
|
+
*/
|
|
89
|
+
id: number;
|
|
86
90
|
/**
|
|
87
91
|
* The name of the IState the transition is from
|
|
88
92
|
*/
|
|
@@ -91,10 +95,6 @@ export interface ITransition {
|
|
|
91
95
|
* The name of the IState the transition is to
|
|
92
96
|
*/
|
|
93
97
|
to: string;
|
|
94
|
-
/**
|
|
95
|
-
* The id of the transition. Unique within the root state machine.
|
|
96
|
-
*/
|
|
97
|
-
id: number;
|
|
98
98
|
/**
|
|
99
99
|
* A display label to represent this transition. Parsers can parse this
|
|
100
100
|
* label into events conditions and actions.
|