state-machine-cat 11.1.2 → 11.1.4
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/README.md +1 -1
- 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/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 +21 -31
- package/types/state-machine-cat.d.ts +3 -3
package/README.md
CHANGED
|
@@ -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);
|
|
@@ -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.4";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "state-machine-cat",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.4",
|
|
4
4
|
"description": "write beautiful state charts",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"depcruise:github-actions:markdown": "dependency-cruise bin src test types tools --config config/dependency-cruiser/base.mjs --output-type markdown",
|
|
33
33
|
"depcruise:github-actions:mermaid": "dependency-cruise bin src --config config/dependency-cruiser/graph.mjs --output-type mermaid",
|
|
34
34
|
"depcruise:github-actions:mermaid:affected": "dependency-cruise bin src test types tools --no-cache --config config/dependency-cruiser/base.mjs --output-type mermaid --reaches \"$(watskeburt $SHA -T regex)\"",
|
|
35
|
-
"format": "prettier --cache --
|
|
35
|
+
"format": "prettier --cache --log-level warn --write \"bin/*.mjs\" \"{src,test}/**/*.{js,mjs}\" \"{config,test}/**/*.{js,json}\" \"tools/*.{js,mjs,json}\" \"{src,types}/**/*.{ts,mts}\" \"*.{json,yml,md}\" \"docs/{smcat-online-interpreter.js,*.md}\"",
|
|
36
36
|
"format:check": "prettier --cache --check \"bin/*.mjs\" \"{src,test}/**/*.{js,mjs}\" \"{config,test}/**/*.{js,json}\" \"tools/*.{js,mjs,json}\" \"{src,types}/**/*.{ts,mts}\" \"*.{json,yml,md}\" \"docs/{smcat-online-interpreter.js,*.md}\"",
|
|
37
37
|
"lint": "run-p lint:eslint format:check lint:types",
|
|
38
38
|
"lint:eslint": "eslint --cache --cache-location node_modules/.cache/eslint/cache.json --color src test config",
|
|
@@ -90,44 +90,36 @@
|
|
|
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
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"semver": "^7.5.3",
|
|
103
|
-
"traverse": "0.6.7",
|
|
104
|
-
"wrap-ansi": "8.1.0"
|
|
99
|
+
"semver": "^7.5.4",
|
|
100
|
+
"traverse": "0.6.7"
|
|
105
101
|
},
|
|
106
102
|
"devDependencies": {
|
|
107
103
|
"@types/chai": "4.3.5",
|
|
108
|
-
"@types/chai-xml": "0.3.2",
|
|
109
104
|
"@types/he": "1.2.0",
|
|
110
|
-
"@types/lodash": "4.14.
|
|
105
|
+
"@types/lodash": "4.14.196",
|
|
111
106
|
"@types/mocha": "10.0.1",
|
|
112
|
-
"@typescript-eslint/eslint-plugin": "
|
|
113
|
-
"@typescript-eslint/parser": "
|
|
114
|
-
"c8": "8.0.
|
|
107
|
+
"@typescript-eslint/eslint-plugin": "6.2.1",
|
|
108
|
+
"@typescript-eslint/parser": "6.2.1",
|
|
109
|
+
"c8": "8.0.1",
|
|
115
110
|
"chai": "4.3.7",
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"
|
|
119
|
-
"dependency-cruiser": "13.0.4",
|
|
120
|
-
"esbuild": "0.18.11",
|
|
121
|
-
"eslint": "8.44.0",
|
|
111
|
+
"dependency-cruiser": "13.1.1",
|
|
112
|
+
"esbuild": "0.18.17",
|
|
113
|
+
"eslint": "8.46.0",
|
|
122
114
|
"eslint-config-moving-meadow": "4.0.2",
|
|
123
|
-
"eslint-config-prettier": "8.
|
|
115
|
+
"eslint-config-prettier": "8.10.0",
|
|
124
116
|
"eslint-plugin-budapestian": "5.0.1",
|
|
125
117
|
"eslint-plugin-eslint-comments": "3.2.0",
|
|
126
|
-
"eslint-plugin-import": "2.
|
|
118
|
+
"eslint-plugin-import": "2.28.0",
|
|
127
119
|
"eslint-plugin-mocha": "10.1.0",
|
|
128
120
|
"eslint-plugin-node": "11.1.0",
|
|
129
121
|
"eslint-plugin-security": "1.7.1",
|
|
130
|
-
"eslint-plugin-unicorn": "
|
|
122
|
+
"eslint-plugin-unicorn": "48.0.1",
|
|
131
123
|
"husky": "8.0.3",
|
|
132
124
|
"is-pdf": "1.0.0",
|
|
133
125
|
"is-png": "3.0.1",
|
|
@@ -135,21 +127,19 @@
|
|
|
135
127
|
"mocha": "10.2.0",
|
|
136
128
|
"npm-run-all": "4.1.5",
|
|
137
129
|
"peggy": "3.0.2",
|
|
138
|
-
"prettier": "
|
|
130
|
+
"prettier": "3.0.1",
|
|
139
131
|
"query-string": "8.1.0",
|
|
140
132
|
"ts-node": "10.9.1",
|
|
141
133
|
"typescript": "5.1.6",
|
|
142
134
|
"upem": "8.0.0",
|
|
143
|
-
"watskeburt": "0.
|
|
135
|
+
"watskeburt": "0.12.1",
|
|
144
136
|
"xml-name-validator": "4.0.0"
|
|
145
137
|
},
|
|
146
138
|
"overrides": {
|
|
147
|
-
"xml2js": "^0.5.0"
|
|
148
|
-
"semver": "^7.5.3"
|
|
139
|
+
"xml2js": "^0.5.0"
|
|
149
140
|
},
|
|
150
141
|
"resolutions": {
|
|
151
|
-
"xml2js": "^0.5.0"
|
|
152
|
-
"semver": "^7.5.3"
|
|
142
|
+
"xml2js": "^0.5.0"
|
|
153
143
|
},
|
|
154
144
|
"engines": {
|
|
155
145
|
"node": "^16.14||>=18"
|
|
@@ -263,12 +263,12 @@ export interface IRenderOptions extends IBaseRenderOptions {
|
|
|
263
263
|
|
|
264
264
|
export type StringRenderFunctionType = (
|
|
265
265
|
pStateMachine: IStateMachine,
|
|
266
|
-
pOptions?: IRenderOptions
|
|
266
|
+
pOptions?: IRenderOptions,
|
|
267
267
|
) => string;
|
|
268
268
|
|
|
269
269
|
export type WhateverRenderFunctionType = (
|
|
270
270
|
pStateMachine: IStateMachine,
|
|
271
|
-
pOptions?: IRenderOptions
|
|
271
|
+
pOptions?: IRenderOptions,
|
|
272
272
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
273
273
|
) => any;
|
|
274
274
|
|
|
@@ -292,5 +292,5 @@ export type RenderFunctionType =
|
|
|
292
292
|
*/
|
|
293
293
|
export function render(
|
|
294
294
|
pScript: IStateMachine | string,
|
|
295
|
-
pOptions: IRenderOptions
|
|
295
|
+
pOptions: IRenderOptions,
|
|
296
296
|
): string;
|