state-machine-cat 11.1.3 → 11.1.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/parse/scxml/index.mjs +5 -2
- package/dist/parse/scxml/normalize-machine.mjs +1 -1
- package/dist/parse/scxml/utl.mjs +3 -0
- package/dist/parse/smcat/smcat-parser.mjs +10 -31
- package/dist/render/dot/index.mjs +1 -1
- package/dist/render/dot/state-transformers.mjs +1 -1
- package/dist/render/index-node.mjs +16 -19
- package/dist/render/index.mjs +9 -12
- package/dist/render/smcat/index.mjs +1 -1
- package/dist/render/vector/vector-native-dot-with-fallback.mjs +1 -6
- package/dist/transform/desugar.mjs +5 -4
- package/dist/utl.mjs +3 -0
- package/dist/version.mjs +1 -1
- package/package.json +18 -35
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import fastxml from "fast-xml-parser";
|
|
2
2
|
import he from "he";
|
|
3
|
-
import castArray from "lodash/castArray.js";
|
|
4
3
|
import traverse from "traverse";
|
|
5
4
|
import utl from "../../transform/utl.mjs";
|
|
6
5
|
import parserHelpers from "../parser-helpers.mjs";
|
|
6
|
+
import { castArray } from "./utl.mjs";
|
|
7
7
|
import { normalizeMachine } from "./normalize-machine.mjs";
|
|
8
8
|
const formatLabel = utl.formatLabel;
|
|
9
9
|
function extractActions(pState, pActionType) {
|
|
@@ -99,7 +99,10 @@ function reduceTransition(pState) {
|
|
|
99
99
|
function extractTransitions(pStates) {
|
|
100
100
|
return pStates
|
|
101
101
|
.filter((pState) => Object.prototype.hasOwnProperty.call(pState, "transition"))
|
|
102
|
-
.reduce((pAllTransitions, pThisState) =>
|
|
102
|
+
.reduce((pAllTransitions, pThisState) => {
|
|
103
|
+
const lTransitionAsArray = castArray(pThisState.transition);
|
|
104
|
+
return pAllTransitions.concat(lTransitionAsArray.reduce(reduceTransition(pThisState), []));
|
|
105
|
+
}, []);
|
|
103
106
|
}
|
|
104
107
|
function mapMachine(pSCXMLStateMachine) {
|
|
105
108
|
const lNormalizedMachine = normalizeMachine(pSCXMLStateMachine);
|
|
@@ -389,15 +389,6 @@ function peg$parse(input, options) {
|
|
|
389
389
|
var peg$f38 = function (c) { return c; };
|
|
390
390
|
var peg$f39 = function (c) { return c; };
|
|
391
391
|
var peg$f40 = function (chars) { return chars.join(""); };
|
|
392
|
-
var peg$f41 = function (c) { return c; };
|
|
393
|
-
var peg$f42 = function (c) { return c; };
|
|
394
|
-
var peg$f43 = function (c) { return c; };
|
|
395
|
-
var peg$f44 = function (start, com, end) {
|
|
396
|
-
return start + com.join("") + end;
|
|
397
|
-
};
|
|
398
|
-
var peg$f45 = function (start, com) {
|
|
399
|
-
return start + com.join("");
|
|
400
|
-
};
|
|
401
392
|
var peg$currPos = 0;
|
|
402
393
|
var peg$savedPos = 0;
|
|
403
394
|
var peg$posDetailsCache = [{ line: 1, column: 1 }];
|
|
@@ -2673,22 +2664,16 @@ function peg$parse(input, options) {
|
|
|
2673
2664
|
function peg$parsewhitespace() {
|
|
2674
2665
|
var s0, s1;
|
|
2675
2666
|
peg$silentFails++;
|
|
2676
|
-
s0 = peg$currPos;
|
|
2677
2667
|
if (peg$r3.test(input.charAt(peg$currPos))) {
|
|
2678
|
-
|
|
2668
|
+
s0 = input.charAt(peg$currPos);
|
|
2679
2669
|
peg$currPos++;
|
|
2680
2670
|
}
|
|
2681
2671
|
else {
|
|
2682
|
-
|
|
2672
|
+
s0 = peg$FAILED;
|
|
2683
2673
|
if (peg$silentFails === 0) {
|
|
2684
2674
|
peg$fail(peg$e70);
|
|
2685
2675
|
}
|
|
2686
2676
|
}
|
|
2687
|
-
if (s1 !== peg$FAILED) {
|
|
2688
|
-
peg$savedPos = s0;
|
|
2689
|
-
s1 = peg$f41(s1);
|
|
2690
|
-
}
|
|
2691
|
-
s0 = s1;
|
|
2692
2677
|
peg$silentFails--;
|
|
2693
2678
|
if (s0 === peg$FAILED) {
|
|
2694
2679
|
s1 = peg$FAILED;
|
|
@@ -2701,22 +2686,16 @@ function peg$parse(input, options) {
|
|
|
2701
2686
|
function peg$parselineend() {
|
|
2702
2687
|
var s0, s1;
|
|
2703
2688
|
peg$silentFails++;
|
|
2704
|
-
s0 = peg$currPos;
|
|
2705
2689
|
if (peg$r4.test(input.charAt(peg$currPos))) {
|
|
2706
|
-
|
|
2690
|
+
s0 = input.charAt(peg$currPos);
|
|
2707
2691
|
peg$currPos++;
|
|
2708
2692
|
}
|
|
2709
2693
|
else {
|
|
2710
|
-
|
|
2694
|
+
s0 = peg$FAILED;
|
|
2711
2695
|
if (peg$silentFails === 0) {
|
|
2712
2696
|
peg$fail(peg$e72);
|
|
2713
2697
|
}
|
|
2714
2698
|
}
|
|
2715
|
-
if (s1 !== peg$FAILED) {
|
|
2716
|
-
peg$savedPos = s0;
|
|
2717
|
-
s1 = peg$f42(s1);
|
|
2718
|
-
}
|
|
2719
|
-
s0 = s1;
|
|
2720
2699
|
peg$silentFails--;
|
|
2721
2700
|
if (s0 === peg$FAILED) {
|
|
2722
2701
|
s1 = peg$FAILED;
|
|
@@ -2789,8 +2768,8 @@ function peg$parse(input, options) {
|
|
|
2789
2768
|
}
|
|
2790
2769
|
}
|
|
2791
2770
|
if (s2 !== peg$FAILED) {
|
|
2792
|
-
|
|
2793
|
-
s0 =
|
|
2771
|
+
s1 = [s1, s2];
|
|
2772
|
+
s0 = s1;
|
|
2794
2773
|
}
|
|
2795
2774
|
else {
|
|
2796
2775
|
peg$currPos = s0;
|
|
@@ -2816,8 +2795,8 @@ function peg$parse(input, options) {
|
|
|
2816
2795
|
}
|
|
2817
2796
|
s3 = peg$parsemlcomend();
|
|
2818
2797
|
if (s3 !== peg$FAILED) {
|
|
2819
|
-
|
|
2820
|
-
s0 =
|
|
2798
|
+
s1 = [s1, s2, s3];
|
|
2799
|
+
s0 = s1;
|
|
2821
2800
|
}
|
|
2822
2801
|
else {
|
|
2823
2802
|
peg$currPos = s0;
|
|
@@ -2869,8 +2848,8 @@ function peg$parse(input, options) {
|
|
|
2869
2848
|
s2.push(s3);
|
|
2870
2849
|
s3 = peg$parseslcomtok();
|
|
2871
2850
|
}
|
|
2872
|
-
|
|
2873
|
-
s0 =
|
|
2851
|
+
s1 = [s1, s2];
|
|
2852
|
+
s0 = s1;
|
|
2874
2853
|
}
|
|
2875
2854
|
else {
|
|
2876
2855
|
peg$currPos = s0;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import has from "lodash/has.js";
|
|
2
1
|
import smcatRendererAsImported from "./smcat/index.mjs";
|
|
3
2
|
import renderDot from "./dot/index.mjs";
|
|
4
3
|
import vector from "./vector/vector-native-dot-with-fallback.mjs";
|
|
@@ -7,22 +6,20 @@ import scjson from "./scjson/index.mjs";
|
|
|
7
6
|
import scxml from "./scxml/index.mjs";
|
|
8
7
|
const smcat = smcatRendererAsImported;
|
|
9
8
|
export default function getRenderFunction(pOutputType) {
|
|
10
|
-
const
|
|
11
|
-
smcat,
|
|
12
|
-
dot
|
|
13
|
-
svg
|
|
14
|
-
eps
|
|
15
|
-
ps
|
|
16
|
-
ps2
|
|
17
|
-
oldsvg
|
|
18
|
-
oldps2
|
|
19
|
-
oldeps
|
|
20
|
-
pdf
|
|
21
|
-
png
|
|
22
|
-
scjson,
|
|
23
|
-
scxml,
|
|
24
|
-
|
|
25
|
-
return
|
|
26
|
-
? lOutputType2RenderFunction[pOutputType]
|
|
27
|
-
: (pX) => pX;
|
|
9
|
+
const lOutputType2RenderFunctionMap = new Map([
|
|
10
|
+
["smcat", smcat],
|
|
11
|
+
["dot", renderDot],
|
|
12
|
+
["svg", vector],
|
|
13
|
+
["eps", vector],
|
|
14
|
+
["ps", vector],
|
|
15
|
+
["ps2", vector],
|
|
16
|
+
["oldsvg", oldVector],
|
|
17
|
+
["oldps2", oldVector],
|
|
18
|
+
["oldeps", oldVector],
|
|
19
|
+
["pdf", vector],
|
|
20
|
+
["png", vector],
|
|
21
|
+
["scjson", scjson],
|
|
22
|
+
["scxml", scxml],
|
|
23
|
+
]);
|
|
24
|
+
return lOutputType2RenderFunctionMap.get(pOutputType) ?? ((pX) => pX);
|
|
28
25
|
}
|
package/dist/render/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import has from "lodash/has.js";
|
|
2
1
|
import smcatRendererAsImported from "./smcat/index.mjs";
|
|
3
2
|
import renderDot from "./dot/index.mjs";
|
|
4
3
|
import svg from "./vector/vector-with-wasm.mjs";
|
|
@@ -6,15 +5,13 @@ import scjson from "./scjson/index.mjs";
|
|
|
6
5
|
import scxml from "./scxml/index.mjs";
|
|
7
6
|
const smcat = smcatRendererAsImported;
|
|
8
7
|
export default function getRenderFunction(pOutputType) {
|
|
9
|
-
const
|
|
10
|
-
smcat,
|
|
11
|
-
dot
|
|
12
|
-
svg,
|
|
13
|
-
oldsvg
|
|
14
|
-
scjson,
|
|
15
|
-
scxml,
|
|
16
|
-
|
|
17
|
-
return
|
|
18
|
-
? lOutputType2RenderFunction[pOutputType]
|
|
19
|
-
: (pX) => pX;
|
|
8
|
+
const lOutputType2RenderFunctionMap = new Map([
|
|
9
|
+
["smcat", smcat],
|
|
10
|
+
["dot", renderDot],
|
|
11
|
+
["svg", svg],
|
|
12
|
+
["oldsvg", svg],
|
|
13
|
+
["scjson", scjson],
|
|
14
|
+
["scxml", scxml],
|
|
15
|
+
]);
|
|
16
|
+
return lOutputType2RenderFunctionMap.get(pOutputType) ?? ((pX) => pX);
|
|
20
17
|
}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { Graphviz } from "@hpcc-js/wasm/graphviz";
|
|
2
|
-
import indentString from "indent-string";
|
|
3
|
-
import wrapAnsi from "wrap-ansi";
|
|
4
|
-
import chalk from "chalk";
|
|
5
2
|
import options from "../../options.mjs";
|
|
6
3
|
import ast2dot from "../dot/index.mjs";
|
|
7
4
|
import dotToVectorNative from "./dot-to-vector-native.mjs";
|
|
8
|
-
const DEFAULT_INDENT = 2;
|
|
9
|
-
const DOGMATIC_CONSOLE_WIDTH = 78;
|
|
10
5
|
const VIZ_JS_UNSUPPORTED_OUTPUT_FORMATS = ["pdf", "png"];
|
|
11
6
|
const gGraphViz = await Graphviz.load();
|
|
12
7
|
const renderVector = (pStateMachine, pOptions) => {
|
|
@@ -27,7 +22,7 @@ const renderVector = (pStateMachine, pOptions) => {
|
|
|
27
22
|
"both formats.\n");
|
|
28
23
|
}
|
|
29
24
|
if (!pOptions?.noDotNativeWarning)
|
|
30
|
-
process.stderr.write(
|
|
25
|
+
process.stderr.write(` warning: GraphViz 'dot' executable not found. Falling back to wasm.\n\n`);
|
|
31
26
|
return gGraphViz.layout(lDotProgram, lDotOptions.format, lDotOptions.engine);
|
|
32
27
|
}
|
|
33
28
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import cloneDeep from "
|
|
2
|
-
import reject from "lodash/reject.js";
|
|
1
|
+
import { cloneDeep } from "../utl.mjs";
|
|
3
2
|
import StateMachineModel from "../state-machine-model.mjs";
|
|
4
3
|
import utl from "./utl.mjs";
|
|
5
4
|
function fuseTransitionAttribute(pIncomingThing, pOutgoingThing, pJoinChar) {
|
|
@@ -52,10 +51,12 @@ function deSugarPseudoStates(pMachine, pPseudoStateNames, pOutgoingTransitionMap
|
|
|
52
51
|
function removeStatesCascading(pMachine, pStateNames) {
|
|
53
52
|
const lMachine = cloneDeep(pMachine);
|
|
54
53
|
if (lMachine.transitions) {
|
|
55
|
-
lMachine.transitions =
|
|
54
|
+
lMachine.transitions = lMachine.transitions.filter((pTransition) => !pStateNames.some((pJunctionStateName) => pJunctionStateName === pTransition.from ||
|
|
56
55
|
pJunctionStateName === pTransition.to));
|
|
57
56
|
}
|
|
58
|
-
lMachine.states =
|
|
57
|
+
lMachine.states = lMachine.states
|
|
58
|
+
.filter((pState) => !pStateNames.includes(pState.name))
|
|
59
|
+
.map((pState) => pState.statemachine
|
|
59
60
|
? {
|
|
60
61
|
...pState,
|
|
61
62
|
statemachine: removeStatesCascading(pState.statemachine, pStateNames),
|
package/dist/utl.mjs
ADDED
package/dist/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "11.1.
|
|
1
|
+
export const version = "11.1.5";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "state-machine-cat",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.5",
|
|
4
4
|
"description": "write beautiful state charts",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -90,65 +90,48 @@
|
|
|
90
90
|
"state-machine-cat": "bin/smcat.mjs"
|
|
91
91
|
},
|
|
92
92
|
"dependencies": {
|
|
93
|
-
"@hpcc-js/wasm": "2.13.
|
|
93
|
+
"@hpcc-js/wasm": "2.13.1",
|
|
94
94
|
"ajv": "8.12.0",
|
|
95
|
-
"chalk": "5.3.0",
|
|
96
95
|
"commander": "11.0.0",
|
|
97
|
-
"fast-xml-parser": "4.2.
|
|
98
|
-
"handlebars": "4.7.
|
|
96
|
+
"fast-xml-parser": "4.2.7",
|
|
97
|
+
"handlebars": "4.7.8",
|
|
99
98
|
"he": "1.2.0",
|
|
100
|
-
"indent-string": "5.0.0",
|
|
101
|
-
"lodash": "4.17.21",
|
|
102
99
|
"semver": "^7.5.4",
|
|
103
|
-
"traverse": "0.6.7"
|
|
104
|
-
"wrap-ansi": "8.1.0"
|
|
100
|
+
"traverse": "0.6.7"
|
|
105
101
|
},
|
|
106
102
|
"devDependencies": {
|
|
107
|
-
"@types/chai": "4.3.5",
|
|
108
|
-
"@types/chai-xml": "0.3.2",
|
|
109
103
|
"@types/he": "1.2.0",
|
|
110
|
-
"@types/lodash": "4.14.195",
|
|
111
104
|
"@types/mocha": "10.0.1",
|
|
112
|
-
"@typescript-eslint/eslint-plugin": "6.1
|
|
113
|
-
"@typescript-eslint/parser": "6.1
|
|
114
|
-
"c8": "8.0.
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"chai-xml": "0.4.1",
|
|
119
|
-
"dependency-cruiser": "13.1.1",
|
|
120
|
-
"esbuild": "0.18.16",
|
|
121
|
-
"eslint": "8.45.0",
|
|
105
|
+
"@typescript-eslint/eslint-plugin": "6.4.1",
|
|
106
|
+
"@typescript-eslint/parser": "6.4.1",
|
|
107
|
+
"c8": "8.0.1",
|
|
108
|
+
"dependency-cruiser": "13.1.4",
|
|
109
|
+
"esbuild": "0.19.2",
|
|
110
|
+
"eslint": "8.48.0",
|
|
122
111
|
"eslint-config-moving-meadow": "4.0.2",
|
|
123
|
-
"eslint-config-prettier": "
|
|
112
|
+
"eslint-config-prettier": "9.0.0",
|
|
124
113
|
"eslint-plugin-budapestian": "5.0.1",
|
|
125
114
|
"eslint-plugin-eslint-comments": "3.2.0",
|
|
126
|
-
"eslint-plugin-import": "2.
|
|
115
|
+
"eslint-plugin-import": "2.28.1",
|
|
127
116
|
"eslint-plugin-mocha": "10.1.0",
|
|
128
117
|
"eslint-plugin-node": "11.1.0",
|
|
129
118
|
"eslint-plugin-security": "1.7.1",
|
|
130
|
-
"eslint-plugin-unicorn": "48.0.
|
|
119
|
+
"eslint-plugin-unicorn": "48.0.1",
|
|
131
120
|
"husky": "8.0.3",
|
|
132
121
|
"is-pdf": "1.0.0",
|
|
133
122
|
"is-png": "3.0.1",
|
|
134
|
-
"lint-staged": "
|
|
123
|
+
"lint-staged": "14.0.1",
|
|
135
124
|
"mocha": "10.2.0",
|
|
136
125
|
"npm-run-all": "4.1.5",
|
|
137
126
|
"peggy": "3.0.2",
|
|
138
|
-
"prettier": "3.0.
|
|
127
|
+
"prettier": "3.0.2",
|
|
139
128
|
"query-string": "8.1.0",
|
|
140
129
|
"ts-node": "10.9.1",
|
|
141
|
-
"typescript": "5.
|
|
130
|
+
"typescript": "5.2.2",
|
|
142
131
|
"upem": "8.0.0",
|
|
143
|
-
"watskeburt": "0.
|
|
132
|
+
"watskeburt": "1.0.1",
|
|
144
133
|
"xml-name-validator": "4.0.0"
|
|
145
134
|
},
|
|
146
|
-
"overrides": {
|
|
147
|
-
"xml2js": "^0.5.0"
|
|
148
|
-
},
|
|
149
|
-
"resolutions": {
|
|
150
|
-
"xml2js": "^0.5.0"
|
|
151
|
-
},
|
|
152
135
|
"engines": {
|
|
153
136
|
"node": "^16.14||>=18"
|
|
154
137
|
},
|