state-machine-cat 13.0.3 → 14.0.1
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 +3 -3
- package/dist/cli/actions.mjs +3 -3
- package/dist/cli/cli.mjs +24 -21
- package/dist/cli/normalize.mjs +5 -5
- package/dist/cli/validations.mjs +61 -63
- package/dist/index-node.mjs +21 -17
- package/dist/index.mjs +22 -14
- package/dist/options.mjs +0 -4
- package/dist/parse/index.mjs +26 -23
- package/dist/parse/parser-helpers.mjs +10 -22
- package/dist/parse/scxml/index.mjs +3 -4
- package/dist/parse/smcat/smcat-parser.mjs +25 -33
- package/dist/parse/smcat-ast.validate.mjs +1 -0
- package/dist/render/dot/attributebuilder.mjs +0 -5
- package/dist/render/index-node.mjs +22 -25
- package/dist/render/index.mjs +41 -16
- package/dist/render/vector/dot-to-vector-native.mjs +2 -6
- package/dist/render/vector/vector-native-dot-with-fallback.mjs +6 -6
- package/dist/render/vector/vector-with-wasm.mjs +3 -5
- package/dist/transform/desugar.mjs +2 -2
- package/dist/transform/utl.mjs +1 -4
- package/dist/version.mjs +1 -1
- package/package.json +3 -4
- package/types/state-machine-cat.d.mts +2 -2
- package/dist/parse/smcat-ast.schema.mjs +0 -190
package/README.md
CHANGED
|
@@ -125,10 +125,10 @@ of thing you can read all about it in [State Machine Cat and SCXML](./docs/SCXML
|
|
|
125
125
|
After you `npm i` 'd `state-machine-cat`:
|
|
126
126
|
|
|
127
127
|
```javascript
|
|
128
|
-
import
|
|
128
|
+
import { render } from "state-machine-cat";
|
|
129
129
|
|
|
130
130
|
try {
|
|
131
|
-
const lSVGInAString =
|
|
131
|
+
const lSVGInAString = await render(
|
|
132
132
|
`
|
|
133
133
|
initial => backlog;
|
|
134
134
|
backlog => doing;
|
|
@@ -638,7 +638,7 @@ The values you can use for the `type` of a state:
|
|
|
638
638
|
#### grammar
|
|
639
639
|
|
|
640
640
|
I made the parser with peggy - you can find it at
|
|
641
|
-
[src/parse/
|
|
641
|
+
[src/parse/smcat-parser.peggy](src/parse/smcat/smcat-parser.peggy), and
|
|
642
642
|
railroad diagrams generated from these on [state-machine-cat.js.org/grammar.html](https://state-machine-cat.js.org/grammar.html)
|
|
643
643
|
|
|
644
644
|
## Status
|
package/dist/cli/actions.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { render } from "../index-node.mjs";
|
|
2
2
|
import { getOutStream, getInStream } from "./file-name-to-stream.mjs";
|
|
3
3
|
const LICENSE = `
|
|
4
4
|
state machine cat - write beautiful state charts
|
|
@@ -44,8 +44,8 @@ export function displayLicense(pOutStream) {
|
|
|
44
44
|
pOutStream.write(LICENSE, "utf8");
|
|
45
45
|
}
|
|
46
46
|
export function transform(pOptions) {
|
|
47
|
-
return getStream(getInStream(pOptions.inputFrom)).then((pInput) => {
|
|
48
|
-
const lOutput =
|
|
47
|
+
return getStream(getInStream(pOptions.inputFrom)).then(async (pInput) => {
|
|
48
|
+
const lOutput = await render(pInput, {
|
|
49
49
|
inputType: pOptions.inputType,
|
|
50
50
|
outputType: pOptions.outputType,
|
|
51
51
|
engine: pOptions.engine,
|
package/dist/cli/cli.mjs
CHANGED
|
@@ -2,7 +2,18 @@ import { parseArgs } from "node:util";
|
|
|
2
2
|
import { version } from "../version.mjs";
|
|
3
3
|
import { formatError, displayLicense, transform } from "./actions.mjs";
|
|
4
4
|
import normalize from "./normalize.mjs";
|
|
5
|
-
import
|
|
5
|
+
import {
|
|
6
|
+
validOutputType,
|
|
7
|
+
validInputType,
|
|
8
|
+
validEngine,
|
|
9
|
+
validDirection,
|
|
10
|
+
validDotAttrs,
|
|
11
|
+
validateArguments,
|
|
12
|
+
defaultOutputType,
|
|
13
|
+
defaultInputType,
|
|
14
|
+
defaultEngine,
|
|
15
|
+
defaultDirection,
|
|
16
|
+
} from "./validations.mjs";
|
|
6
17
|
const HELP_TEXT = `Usage: smcat [options] [infile]
|
|
7
18
|
|
|
8
19
|
Write beautiful state charts - https://github.com/sverweij/state-machine-cat
|
|
@@ -51,22 +62,22 @@ function parseArguments(pArguments) {
|
|
|
51
62
|
"output-type": {
|
|
52
63
|
type: "string",
|
|
53
64
|
short: "T",
|
|
54
|
-
default:
|
|
65
|
+
default: defaultOutputType,
|
|
55
66
|
},
|
|
56
67
|
"input-type": {
|
|
57
68
|
type: "string",
|
|
58
69
|
short: "I",
|
|
59
|
-
default:
|
|
70
|
+
default: defaultInputType,
|
|
60
71
|
},
|
|
61
72
|
engine: {
|
|
62
73
|
type: "string",
|
|
63
74
|
short: "E",
|
|
64
|
-
default:
|
|
75
|
+
default: defaultEngine,
|
|
65
76
|
},
|
|
66
77
|
direction: {
|
|
67
78
|
type: "string",
|
|
68
79
|
short: "d",
|
|
69
|
-
default:
|
|
80
|
+
default: defaultDirection,
|
|
70
81
|
},
|
|
71
82
|
"output-to": {
|
|
72
83
|
type: "string",
|
|
@@ -108,22 +119,16 @@ function parseArguments(pArguments) {
|
|
|
108
119
|
allowPositionals: true,
|
|
109
120
|
tokens: false,
|
|
110
121
|
});
|
|
111
|
-
values["output-type"] =
|
|
112
|
-
values["input-type"] =
|
|
113
|
-
values.engine =
|
|
114
|
-
values.direction =
|
|
122
|
+
values["output-type"] = validOutputType(values["output-type"]);
|
|
123
|
+
values["input-type"] = validInputType(values["input-type"]);
|
|
124
|
+
values.engine = validEngine(values.engine);
|
|
125
|
+
values.direction = validDirection(values.direction);
|
|
115
126
|
if (values["dot-graph-attrs"])
|
|
116
|
-
values["dot-graph-attrs"] =
|
|
117
|
-
values["dot-graph-attrs"],
|
|
118
|
-
);
|
|
127
|
+
values["dot-graph-attrs"] = validDotAttrs(values["dot-graph-attrs"]);
|
|
119
128
|
if (values["dot-node-attrs"])
|
|
120
|
-
values["dot-node-attrs"] =
|
|
121
|
-
values["dot-node-attrs"],
|
|
122
|
-
);
|
|
129
|
+
values["dot-node-attrs"] = validDotAttrs(values["dot-node-attrs"]);
|
|
123
130
|
if (values["dot-edge-attrs"])
|
|
124
|
-
values["dot-edge-attrs"] =
|
|
125
|
-
values["dot-edge-attrs"],
|
|
126
|
-
);
|
|
131
|
+
values["dot-edge-attrs"] = validDotAttrs(values["dot-edge-attrs"]);
|
|
127
132
|
return { values: camelizeObject(values), positionals };
|
|
128
133
|
}
|
|
129
134
|
export default async function cli(pArguments = process.argv, pOptions) {
|
|
@@ -146,9 +151,7 @@ export default async function cli(pArguments = process.argv, pOptions) {
|
|
|
146
151
|
displayLicense(lOptions.outStream);
|
|
147
152
|
return;
|
|
148
153
|
}
|
|
149
|
-
await transform(
|
|
150
|
-
validations.validateArguments(normalize(positionals[0], values)),
|
|
151
|
-
);
|
|
154
|
+
await transform(validateArguments(normalize(positionals[0], values)));
|
|
152
155
|
} catch (pError) {
|
|
153
156
|
presentError(pError, lOptions.errorStream);
|
|
154
157
|
}
|
package/dist/cli/normalize.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import
|
|
2
|
+
import { getAllowedValues } from "../options.mjs";
|
|
3
3
|
import { parse as parseAttributes } from "./attributes-parser.mjs";
|
|
4
4
|
const INPUT_EXTENSIONS = {
|
|
5
5
|
".smcat": "smcat",
|
|
@@ -58,7 +58,7 @@ function determineInputType(pInputFrom, pInputType) {
|
|
|
58
58
|
return classifyExtension(
|
|
59
59
|
pInputFrom,
|
|
60
60
|
INPUT_EXTENSIONS,
|
|
61
|
-
|
|
61
|
+
getAllowedValues().inputType.default,
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
64
|
function determineOutputType(pOutputTo, pOutputType) {
|
|
@@ -69,15 +69,15 @@ function determineOutputType(pOutputTo, pOutputType) {
|
|
|
69
69
|
return classifyExtension(
|
|
70
70
|
pOutputTo,
|
|
71
71
|
OUTPUT_EXTENSIONS,
|
|
72
|
-
|
|
72
|
+
getAllowedValues().outputType.default,
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
|
-
return
|
|
75
|
+
return getAllowedValues().outputType.default;
|
|
76
76
|
}
|
|
77
77
|
function determineParameter(pOptions, pParameter) {
|
|
78
78
|
return Object.hasOwn(pOptions, pParameter)
|
|
79
79
|
? pOptions[pParameter]
|
|
80
|
-
:
|
|
80
|
+
: getAllowedValues()[pParameter].default;
|
|
81
81
|
}
|
|
82
82
|
function determineDotAttributes(pOptions, pDotAttributes) {
|
|
83
83
|
return pOptions?.[pDotAttributes] &&
|
package/dist/cli/validations.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { accessSync, constants } from "node:fs";
|
|
2
|
+
import { getAllowedValues } from "../index-node.mjs";
|
|
3
3
|
import { parse as parseAttributes } from "./attributes-parser.mjs";
|
|
4
|
-
const allowedValues =
|
|
4
|
+
const allowedValues = getAllowedValues();
|
|
5
5
|
function getName(pValue) {
|
|
6
6
|
return pValue.name;
|
|
7
7
|
}
|
|
@@ -15,7 +15,7 @@ function isStdout(pFilename) {
|
|
|
15
15
|
function fileExists(pFilename) {
|
|
16
16
|
try {
|
|
17
17
|
if (!isStdout(pFilename)) {
|
|
18
|
-
|
|
18
|
+
accessSync(pFilename, constants.R_OK);
|
|
19
19
|
}
|
|
20
20
|
return true;
|
|
21
21
|
} catch (pError) {
|
|
@@ -28,63 +28,61 @@ function validOption(pOption, pValidValues, pError) {
|
|
|
28
28
|
}
|
|
29
29
|
throw new Error(pError);
|
|
30
30
|
}
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
`\n
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
`\n
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
`\n
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
`\n
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return pOptions;
|
|
81
|
-
},
|
|
82
|
-
validOutputTypeRE: VALID_OUTPUT_TYPES.join("|"),
|
|
83
|
-
defaultOutputType: allowedValues.outputType.default,
|
|
84
|
-
validInputTypeRE: VALID_INPUT_TYPES.join("|"),
|
|
85
|
-
defaultInputType: allowedValues.inputType.default,
|
|
86
|
-
validEngineRE: VALID_ENGINES.join("|"),
|
|
87
|
-
defaultEngine: allowedValues.engine.default,
|
|
88
|
-
validDirectionRE: VALID_DIRECTIONS.join("|"),
|
|
89
|
-
defaultDirection: allowedValues.direction.default,
|
|
31
|
+
export const validOutputType = (pType) =>
|
|
32
|
+
validOption(
|
|
33
|
+
pType,
|
|
34
|
+
VALID_OUTPUT_TYPES,
|
|
35
|
+
`\n error: '${pType}' is not a valid output type. smcat can emit:` +
|
|
36
|
+
`\n ${VALID_OUTPUT_TYPES.join(", ")}\n\n`,
|
|
37
|
+
);
|
|
38
|
+
export const validInputType = (pType) =>
|
|
39
|
+
validOption(
|
|
40
|
+
pType,
|
|
41
|
+
VALID_INPUT_TYPES,
|
|
42
|
+
`\n error: '${pType}' is not a valid input type.` +
|
|
43
|
+
`\n smcat can read ${VALID_INPUT_TYPES.join(", ")}\n\n`,
|
|
44
|
+
);
|
|
45
|
+
export const validEngine = (pEngine) =>
|
|
46
|
+
validOption(
|
|
47
|
+
pEngine,
|
|
48
|
+
VALID_ENGINES,
|
|
49
|
+
`\n error: '${pEngine}' is not a valid input type.` +
|
|
50
|
+
`\n you can choose from ${VALID_ENGINES.join(", ")}\n\n`,
|
|
51
|
+
);
|
|
52
|
+
export const validDirection = (pDirection) =>
|
|
53
|
+
validOption(
|
|
54
|
+
pDirection,
|
|
55
|
+
VALID_DIRECTIONS,
|
|
56
|
+
`\n error: '${pDirection}' is not a valid direction.` +
|
|
57
|
+
`\n you can choose from ${VALID_DIRECTIONS.join(", ")}\n\n`,
|
|
58
|
+
);
|
|
59
|
+
export const validDotAttrs = (pDotAttributes) => {
|
|
60
|
+
try {
|
|
61
|
+
parseAttributes(pDotAttributes);
|
|
62
|
+
return pDotAttributes;
|
|
63
|
+
} catch (pError) {
|
|
64
|
+
throw new Error(`Invalid dot attributes: ${pError.message}`);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
export const validateArguments = (pOptions) => {
|
|
68
|
+
if (!pOptions.inputFrom) {
|
|
69
|
+
throw new Error(`\n error: Please specify an input file.\n\n`);
|
|
70
|
+
}
|
|
71
|
+
if (!pOptions.outputTo) {
|
|
72
|
+
throw new Error(`\n error: Please specify an output file.\n\n`);
|
|
73
|
+
}
|
|
74
|
+
if (!fileExists(pOptions.inputFrom)) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
`\n error: Failed to open input file '${pOptions.inputFrom}'\n\n`,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
return pOptions;
|
|
90
80
|
};
|
|
81
|
+
export const validOutputTypeRE = VALID_OUTPUT_TYPES.join("|");
|
|
82
|
+
export const defaultOutputType = allowedValues.outputType.default;
|
|
83
|
+
export const validInputTypeRE = VALID_INPUT_TYPES.join("|");
|
|
84
|
+
export const defaultInputType = allowedValues.inputType.default;
|
|
85
|
+
export const validEngineRE = VALID_ENGINES.join("|");
|
|
86
|
+
export const defaultEngine = allowedValues.engine.default;
|
|
87
|
+
export const validDirectionRE = VALID_DIRECTIONS.join("|");
|
|
88
|
+
export const defaultDirection = allowedValues.direction.default;
|
package/dist/index-node.mjs
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
getAllowedValues as _getAllowedValues,
|
|
3
|
+
getOptionValue,
|
|
4
|
+
} from "./options.mjs";
|
|
5
|
+
import { getAST } from "./parse/index.mjs";
|
|
3
6
|
import desugar from "./transform/desugar.mjs";
|
|
4
7
|
import getRenderFunction from "./render/index-node.mjs";
|
|
5
|
-
import { version } from "./version.mjs";
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
import { version as _version } from "./version.mjs";
|
|
9
|
+
export async function render(pScript, pOptions) {
|
|
10
|
+
const lStateMachine = await getAST(pScript, pOptions);
|
|
11
|
+
const lDesugar = getOptionValue(pOptions, "desugar");
|
|
12
|
+
const lRenderFunction = await getRenderFunction(
|
|
13
|
+
getOptionValue(pOptions, "outputType"),
|
|
14
|
+
);
|
|
15
|
+
return lRenderFunction(
|
|
16
|
+
lDesugar ? desugar(lStateMachine) : lStateMachine,
|
|
17
|
+
pOptions,
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
export const version = _version;
|
|
21
|
+
export function getAllowedValues() {
|
|
22
|
+
return _getAllowedValues();
|
|
23
|
+
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
getAllowedValues as _getAllowedValues,
|
|
3
|
+
getOptionValue,
|
|
4
|
+
} from "./options.mjs";
|
|
5
|
+
import { getAST } from "./parse/index.mjs";
|
|
4
6
|
import getRenderFunction from "./render/index.mjs";
|
|
5
7
|
import { version as _version } from "./version.mjs";
|
|
6
|
-
|
|
8
|
+
let gDesugarModule = null;
|
|
9
|
+
async function desugar(pStateMachine) {
|
|
10
|
+
if (!gDesugarModule) {
|
|
11
|
+
gDesugarModule = await import("./transform/desugar.mjs");
|
|
12
|
+
}
|
|
13
|
+
const lDesugarFunction = gDesugarModule.default;
|
|
14
|
+
return lDesugarFunction(pStateMachine);
|
|
15
|
+
}
|
|
16
|
+
export async function render(pScript, pOptions) {
|
|
7
17
|
const lOptions = pOptions ?? {};
|
|
8
|
-
const lStateMachine =
|
|
9
|
-
const lDesugar =
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
const lStateMachine = await getAST(pScript, lOptions);
|
|
19
|
+
const lDesugar = getOptionValue(lOptions, "desugar");
|
|
20
|
+
const lRenderFunction = await getRenderFunction(
|
|
21
|
+
getOptionValue(lOptions, "outputType"),
|
|
22
|
+
);
|
|
23
|
+
return lRenderFunction(
|
|
24
|
+
lDesugar ? await desugar(lStateMachine) : lStateMachine,
|
|
12
25
|
lOptions,
|
|
13
26
|
);
|
|
14
27
|
}
|
|
15
28
|
export const version = _version;
|
|
16
29
|
export function getAllowedValues() {
|
|
17
|
-
return
|
|
30
|
+
return _getAllowedValues();
|
|
18
31
|
}
|
|
19
|
-
export default {
|
|
20
|
-
render,
|
|
21
|
-
version,
|
|
22
|
-
getAllowedValues,
|
|
23
|
-
};
|
package/dist/options.mjs
CHANGED
package/dist/parse/index.mjs
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import options from "../options.mjs";
|
|
1
|
+
import { getOptionValue } from "../options.mjs";
|
|
3
2
|
import { parse as parseSmCat } from "./smcat/parse.mjs";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
export default {
|
|
9
|
-
getAST(pScript, pOptions) {
|
|
10
|
-
let lReturnValue = pScript;
|
|
11
|
-
if (options.getOptionValue(pOptions, "inputType") === "smcat") {
|
|
12
|
-
lReturnValue = parseSmCat(pScript);
|
|
13
|
-
} else if (options.getOptionValue(pOptions, "inputType") === "scxml") {
|
|
14
|
-
lReturnValue = parseSCXML(pScript);
|
|
15
|
-
} else if (typeof pScript === "string") {
|
|
16
|
-
lReturnValue = JSON.parse(pScript);
|
|
17
|
-
}
|
|
18
|
-
if (!validate(lReturnValue)) {
|
|
19
|
-
throw new Error(
|
|
20
|
-
`The provided JSON is not a valid state-machine-cat AST: ${ajv.errorsText()}.\n`,
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
return lReturnValue;
|
|
24
|
-
},
|
|
3
|
+
import { validate } from "./smcat-ast.validate.mjs";
|
|
4
|
+
const parseSCXML = async (pScript) => {
|
|
5
|
+
const { parse } = await import("./scxml/index.mjs");
|
|
6
|
+
return parse(pScript);
|
|
25
7
|
};
|
|
8
|
+
export function validateErrorsToString(pErrors) {
|
|
9
|
+
return (pErrors || [])
|
|
10
|
+
.map((pError) => `data${pError.instancePath} ${pError.message}`)
|
|
11
|
+
.join(", ");
|
|
12
|
+
}
|
|
13
|
+
export async function getAST(pScript, pOptions) {
|
|
14
|
+
let lReturnValue = pScript;
|
|
15
|
+
if (getOptionValue(pOptions, "inputType") === "smcat") {
|
|
16
|
+
lReturnValue = parseSmCat(pScript);
|
|
17
|
+
} else if (getOptionValue(pOptions, "inputType") === "scxml") {
|
|
18
|
+
lReturnValue = await parseSCXML(pScript);
|
|
19
|
+
} else if (typeof pScript === "string") {
|
|
20
|
+
lReturnValue = JSON.parse(pScript);
|
|
21
|
+
}
|
|
22
|
+
if (!validate(lReturnValue)) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`The provided JSON is not a valid state-machine-cat AST: ${validateErrorsToString(validate.errors)}.\n`,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return lReturnValue;
|
|
28
|
+
}
|
|
@@ -38,11 +38,11 @@ const RE2STATE_TYPE = [
|
|
|
38
38
|
function matches(pName) {
|
|
39
39
|
return (pEntry) => pEntry.re.test(pName);
|
|
40
40
|
}
|
|
41
|
-
function getStateType(pName) {
|
|
41
|
+
export function getStateType(pName) {
|
|
42
42
|
return (RE2STATE_TYPE.find(matches(pName)) || { stateType: "regular" })
|
|
43
43
|
.stateType;
|
|
44
44
|
}
|
|
45
|
-
function initState(pName) {
|
|
45
|
+
export function initState(pName) {
|
|
46
46
|
return {
|
|
47
47
|
name: pName,
|
|
48
48
|
type: getStateType(pName),
|
|
@@ -59,7 +59,7 @@ function getAlreadyDeclaredStates(pStateMachine) {
|
|
|
59
59
|
lStates.map(({ name }) => name),
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
|
-
function extractUndeclaredStates(pStateMachine, pKnownStateNames) {
|
|
62
|
+
export function extractUndeclaredStates(pStateMachine, pKnownStateNames) {
|
|
63
63
|
pKnownStateNames =
|
|
64
64
|
pKnownStateNames ?? getAlreadyDeclaredStates(pStateMachine);
|
|
65
65
|
pStateMachine.states = pStateMachine?.states ?? [];
|
|
@@ -92,7 +92,7 @@ function classifyForkJoin(pInComingCount, pOutGoingCount) {
|
|
|
92
92
|
}
|
|
93
93
|
return lReturnValue;
|
|
94
94
|
}
|
|
95
|
-
function classifyForkJoins(
|
|
95
|
+
export function classifyForkJoins(
|
|
96
96
|
pStateMachine,
|
|
97
97
|
pFlattenedStateMachineModel = new StateMachineModel(pStateMachine),
|
|
98
98
|
) {
|
|
@@ -116,10 +116,10 @@ function classifyForkJoins(
|
|
|
116
116
|
});
|
|
117
117
|
return pStateMachine;
|
|
118
118
|
}
|
|
119
|
-
function stateEqual(pStateOne, pStateTwo) {
|
|
119
|
+
export function stateEqual(pStateOne, pStateTwo) {
|
|
120
120
|
return pStateOne.name === pStateTwo.name;
|
|
121
121
|
}
|
|
122
|
-
function uniq(pArray, pEqualFunction) {
|
|
122
|
+
export function uniq(pArray, pEqualFunction) {
|
|
123
123
|
return pArray.reduce((pBag, pMarble) => {
|
|
124
124
|
const lMarbleIndex = pBag.findIndex((pBagItem) =>
|
|
125
125
|
pEqualFunction(pBagItem, pMarble),
|
|
@@ -131,7 +131,7 @@ function uniq(pArray, pEqualFunction) {
|
|
|
131
131
|
return pBag.concat(pMarble);
|
|
132
132
|
}, []);
|
|
133
133
|
}
|
|
134
|
-
function parseTransitionExpression(pString) {
|
|
134
|
+
export function parseTransitionExpression(pString) {
|
|
135
135
|
const lTransitionExpressionRe = /([^[/]+)?(\[[^\]]+\])?[^/]*(\/.+)?/;
|
|
136
136
|
const lReturnValue = {};
|
|
137
137
|
const lMatchResult = lTransitionExpressionRe.exec(pString);
|
|
@@ -151,12 +151,12 @@ function parseTransitionExpression(pString) {
|
|
|
151
151
|
}
|
|
152
152
|
return lReturnValue;
|
|
153
153
|
}
|
|
154
|
-
function setIf(pObject, pProperty, pValue, pCondition = Boolean) {
|
|
154
|
+
export function setIf(pObject, pProperty, pValue, pCondition = Boolean) {
|
|
155
155
|
if (pCondition(pValue)) {
|
|
156
156
|
pObject[pProperty] = pValue;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
function setIfNotEmpty(pObject, pProperty, pValue) {
|
|
159
|
+
export function setIfNotEmpty(pObject, pProperty, pValue) {
|
|
160
160
|
setIf(pObject, pProperty, pValue, (pX) => pX && pX.length > 0);
|
|
161
161
|
}
|
|
162
162
|
function extractAction(pActivityCandidate) {
|
|
@@ -174,21 +174,9 @@ function extractAction(pActivityCandidate) {
|
|
|
174
174
|
body: pActivityCandidate,
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
-
function extractActions(pString) {
|
|
177
|
+
export function extractActions(pString) {
|
|
178
178
|
return pString
|
|
179
179
|
.split(/\n\s*/g)
|
|
180
180
|
.map((pActivityCandidate) => pActivityCandidate.trim())
|
|
181
181
|
.map(extractAction);
|
|
182
182
|
}
|
|
183
|
-
export default {
|
|
184
|
-
initState,
|
|
185
|
-
extractUndeclaredStates,
|
|
186
|
-
classifyForkJoins,
|
|
187
|
-
getStateType,
|
|
188
|
-
stateEqual,
|
|
189
|
-
uniq,
|
|
190
|
-
parseTransitionExpression,
|
|
191
|
-
extractActions,
|
|
192
|
-
setIf,
|
|
193
|
-
setIfNotEmpty,
|
|
194
|
-
};
|
|
@@ -2,11 +2,10 @@ import { XMLParser } from "fast-xml-parser";
|
|
|
2
2
|
import he from "he";
|
|
3
3
|
import traverse from "neotraverse";
|
|
4
4
|
import { Counter } from "../../counter.mjs";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import { getStateType } from "../parser-helpers.mjs";
|
|
6
|
+
import { formatLabel } from "../../transform/utl.mjs";
|
|
7
7
|
import { castArray } from "./utl.mjs";
|
|
8
8
|
import { normalizeMachine } from "./normalize-machine.mjs";
|
|
9
|
-
const formatLabel = utl.formatLabel;
|
|
10
9
|
function extractActions(pState, pActionType) {
|
|
11
10
|
return castArray(pState[pActionType]).map((pAction) => ({
|
|
12
11
|
type: pActionType === "onexit" ? "exit" : "entry",
|
|
@@ -46,7 +45,7 @@ function mapState(pType) {
|
|
|
46
45
|
name: pState.id,
|
|
47
46
|
type: deriveStateType(pType, pState),
|
|
48
47
|
};
|
|
49
|
-
if (
|
|
48
|
+
if (getStateType(pState.id) !== lReturnValue.type) {
|
|
50
49
|
lReturnValue.typeExplicitlySet = true;
|
|
51
50
|
}
|
|
52
51
|
if (pState.onentry || pState.onexit || pState.invoke) {
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
classifyForkJoins,
|
|
3
|
+
extractActions,
|
|
4
|
+
extractUndeclaredStates,
|
|
5
|
+
initState,
|
|
6
|
+
parseTransitionExpression,
|
|
7
|
+
setIf,
|
|
8
|
+
setIfNotEmpty,
|
|
9
|
+
stateEqual,
|
|
10
|
+
uniq,
|
|
11
|
+
} from "../parser-helpers.mjs";
|
|
2
12
|
class peg$SyntaxError extends SyntaxError {
|
|
3
13
|
constructor(message, expected, found, location) {
|
|
4
14
|
super(message);
|
|
@@ -313,13 +323,13 @@ function peg$parse(input, options) {
|
|
|
313
323
|
const peg$e75 = peg$classExpectation(["\r", "\n"], true, false, false);
|
|
314
324
|
const peg$e76 = peg$otherExpectation("comment");
|
|
315
325
|
function peg$f0(statemachine) {
|
|
316
|
-
statemachine.states =
|
|
317
|
-
return
|
|
326
|
+
statemachine.states = extractUndeclaredStates(statemachine);
|
|
327
|
+
return classifyForkJoins(statemachine);
|
|
318
328
|
}
|
|
319
329
|
function peg$f1(states, transitions) {
|
|
320
330
|
let lStateMachine = {};
|
|
321
|
-
|
|
322
|
-
|
|
331
|
+
setIf(lStateMachine, "states", states);
|
|
332
|
+
setIfNotEmpty(lStateMachine, "transitions", transitions);
|
|
323
333
|
return lStateMachine;
|
|
324
334
|
}
|
|
325
335
|
function peg$f2(state) {
|
|
@@ -329,10 +339,7 @@ function peg$parse(input, options) {
|
|
|
329
339
|
return state;
|
|
330
340
|
}
|
|
331
341
|
function peg$f4(states) {
|
|
332
|
-
return
|
|
333
|
-
states[0].concat(states[1]),
|
|
334
|
-
parserHelpers.stateEqual,
|
|
335
|
-
);
|
|
342
|
+
return uniq(states[0].concat(states[1]), stateEqual);
|
|
336
343
|
}
|
|
337
344
|
function peg$f5(notes, id, attrs) {
|
|
338
345
|
return attrs;
|
|
@@ -344,29 +351,21 @@ function peg$parse(input, options) {
|
|
|
344
351
|
return sm;
|
|
345
352
|
}
|
|
346
353
|
function peg$f8(notes, id, extended_state_attributes, actions, statemachine) {
|
|
347
|
-
let lState =
|
|
354
|
+
let lState = initState(id);
|
|
348
355
|
for (const lExtendedAttribute of extended_state_attributes || []) {
|
|
349
|
-
|
|
350
|
-
lState,
|
|
351
|
-
lExtendedAttribute.name,
|
|
352
|
-
lExtendedAttribute.value,
|
|
353
|
-
);
|
|
356
|
+
setIf(lState, lExtendedAttribute.name, lExtendedAttribute.value);
|
|
354
357
|
}
|
|
355
|
-
|
|
358
|
+
setIf(
|
|
356
359
|
lState,
|
|
357
360
|
"typeExplicitlySet",
|
|
358
361
|
(extended_state_attributes || []).some(
|
|
359
362
|
(pExtendedAttribute) => pExtendedAttribute.typeExplicitlySet,
|
|
360
363
|
),
|
|
361
364
|
);
|
|
362
|
-
|
|
363
|
-
|
|
365
|
+
setIf(lState, "statemachine", statemachine);
|
|
366
|
+
setIfNotEmpty(lState, "note", notes);
|
|
364
367
|
if (actions) {
|
|
365
|
-
|
|
366
|
-
lState,
|
|
367
|
-
"actions",
|
|
368
|
-
parserHelpers.extractActions(actions),
|
|
369
|
-
);
|
|
368
|
+
setIfNotEmpty(lState, "actions", extractActions(actions));
|
|
370
369
|
}
|
|
371
370
|
return lState;
|
|
372
371
|
}
|
|
@@ -403,19 +402,12 @@ function peg$parse(input, options) {
|
|
|
403
402
|
function peg$f19(notes, trans, extended_attributes, label) {
|
|
404
403
|
if (label) {
|
|
405
404
|
trans.label = label;
|
|
406
|
-
trans = Object.assign(
|
|
407
|
-
trans,
|
|
408
|
-
parserHelpers.parseTransitionExpression(label),
|
|
409
|
-
);
|
|
405
|
+
trans = Object.assign(trans, parseTransitionExpression(label));
|
|
410
406
|
}
|
|
411
407
|
for (const lExtendedAttribute of extended_attributes || []) {
|
|
412
|
-
|
|
413
|
-
trans,
|
|
414
|
-
lExtendedAttribute.name,
|
|
415
|
-
lExtendedAttribute.value,
|
|
416
|
-
);
|
|
408
|
+
setIf(trans, lExtendedAttribute.name, lExtendedAttribute.value);
|
|
417
409
|
}
|
|
418
|
-
|
|
410
|
+
setIfNotEmpty(trans, "note", notes);
|
|
419
411
|
trans.id = options.counter.next();
|
|
420
412
|
return trans;
|
|
421
413
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";export const validate=C;export default C;const z={type:"object",additionalProperties:!1,required:["states"],properties:{states:{type:"array",items:{type:"object",required:["name","type"],additionalProperties:!1,properties:{name:{type:"string"},type:{$ref:"#/definitions/StateType"},label:{type:"string"},color:{type:"string"},class:{$ref:"#/definitions/ClassType"},active:{type:"boolean"},typeExplicitlySet:{type:"boolean"},isComposite:{type:"boolean"},actions:{type:"array",items:{$ref:"#/definitions/ActionType"}},note:{$ref:"#/definitions/NoteType"},statemachine:{$ref:"#/definitions/StateMachineType"}}}},transitions:{type:"array",items:{type:"object",required:["id","from","to"],additionalProperties:!1,properties:{id:{type:"number"},from:{type:"string"},to:{type:"string"},label:{type:"string"},event:{type:"string"},cond:{type:"string"},action:{type:"string"},note:{$ref:"#/definitions/NoteType"},color:{type:"string"},width:{type:"number",minimum:0,maximum:30},class:{$ref:"#/definitions/ClassType"},type:{$ref:"#/definitions/TransitionType"}}}}}},R={type:"string",enum:["regular","initial","terminate","final","parallel","history","deephistory","choice","forkjoin","fork","join","junction"]};const B={type:"string",enum:["internal","external"]},Z=Object.prototype.hasOwnProperty,O=new RegExp("^[a-zA-Z0-9_\\- ]*$","u");const G={type:"string",enum:["entry","activity","exit"]};function c(y,{instancePath:r="",parentData:j,parentDataProperty:$,rootData:w=y}={}){let m=null,e=0;if(e===0)if(y&&typeof y=="object"&&!Array.isArray(y)){let n;if(y.type===void 0&&(n="type")||y.body===void 0&&(n="body"))return c.errors=[{instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:n},message:"must have required property '"+n+"'"}],!1;{const _=e;for(const f in y)if(!(f==="type"||f==="body")){return c.errors=[{instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"}],!1;break}if(_===e){if(y.type!==void 0){let f=y.type;const P=e;if(typeof f!="string")return c.errors=[{instancePath:r+"/type",schemaPath:"#/definitions/ActionTypeType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(f==="entry"||f==="activity"||f==="exit"))return c.errors=[{instancePath:r+"/type",schemaPath:"#/definitions/ActionTypeType/enum",keyword:"enum",params:{allowedValues:G.enum},message:"must be equal to one of the allowed values"}],!1;var g=P===e}else var g=!0;if(g)if(y.body!==void 0){const f=e;if(typeof y.body!="string")return c.errors=[{instancePath:r+"/body",schemaPath:"#/properties/body/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=f===e}else var g=!0}}}else return c.errors=[{instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return c.errors=m,e===0}const N={validate:i};function i(y,{instancePath:r="",parentData:j,parentDataProperty:$,rootData:w=y}={}){let m=null,e=0;if(e===0)if(y&&typeof y=="object"&&!Array.isArray(y)){let q;if(y.states===void 0&&(q="states"))return i.errors=[{instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:q},message:"must have required property '"+q+"'"}],!1;{const M=e;for(const u in y)if(!(u==="states"||u==="transitions")){return i.errors=[{instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"}],!1;break}if(M===e){if(y.states!==void 0){let u=y.states;const T=e;if(e===T)if(Array.isArray(u)){var g=!0;const V=u.length;for(let l=0;l<V;l++){let t=u[l];const p=e;if(e===p)if(t&&typeof t=="object"&&!Array.isArray(t)){let A;if(t.name===void 0&&(A="name")||t.type===void 0&&(A="type"))return i.errors=[{instancePath:r+"/states/"+l,schemaPath:"#/properties/states/items/required",keyword:"required",params:{missingProperty:A},message:"must have required property '"+A+"'"}],!1;{const v=e;for(const a in t)if(!Z.call(z.properties.states.items.properties,a)){return i.errors=[{instancePath:r+"/states/"+l,schemaPath:"#/properties/states/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"}],!1;break}if(v===e){if(t.name!==void 0){const a=e;if(typeof t.name!="string")return i.errors=[{instancePath:r+"/states/"+l+"/name",schemaPath:"#/properties/states/items/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var n=a===e}else var n=!0;if(n){if(t.type!==void 0){let a=t.type;const s=e;if(typeof a!="string")return i.errors=[{instancePath:r+"/states/"+l+"/type",schemaPath:"#/definitions/StateType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(a==="regular"||a==="initial"||a==="terminate"||a==="final"||a==="parallel"||a==="history"||a==="deephistory"||a==="choice"||a==="forkjoin"||a==="fork"||a==="join"||a==="junction"))return i.errors=[{instancePath:r+"/states/"+l+"/type",schemaPath:"#/definitions/StateType/enum",keyword:"enum",params:{allowedValues:R.enum},message:"must be equal to one of the allowed values"}],!1;var n=s===e}else var n=!0;if(n){if(t.label!==void 0){const a=e;if(typeof t.label!="string")return i.errors=[{instancePath:r+"/states/"+l+"/label",schemaPath:"#/properties/states/items/properties/label/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var n=a===e}else var n=!0;if(n){if(t.color!==void 0){const a=e;if(typeof t.color!="string")return i.errors=[{instancePath:r+"/states/"+l+"/color",schemaPath:"#/properties/states/items/properties/color/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var n=a===e}else var n=!0;if(n){if(t.class!==void 0){let a=t.class;const s=e;if(e===e)if(typeof a=="string"){if(!O.test(a))return i.errors=[{instancePath:r+"/states/"+l+"/class",schemaPath:"#/definitions/ClassType/pattern",keyword:"pattern",params:{pattern:"^[a-zA-Z0-9_\\- ]*$"},message:'must match pattern "^[a-zA-Z0-9_\\- ]*$"'}],!1}else return i.errors=[{instancePath:r+"/states/"+l+"/class",schemaPath:"#/definitions/ClassType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var n=s===e}else var n=!0;if(n){if(t.active!==void 0){const a=e;if(typeof t.active!="boolean")return i.errors=[{instancePath:r+"/states/"+l+"/active",schemaPath:"#/properties/states/items/properties/active/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var n=a===e}else var n=!0;if(n){if(t.typeExplicitlySet!==void 0){const a=e;if(typeof t.typeExplicitlySet!="boolean")return i.errors=[{instancePath:r+"/states/"+l+"/typeExplicitlySet",schemaPath:"#/properties/states/items/properties/typeExplicitlySet/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var n=a===e}else var n=!0;if(n){if(t.isComposite!==void 0){const a=e;if(typeof t.isComposite!="boolean")return i.errors=[{instancePath:r+"/states/"+l+"/isComposite",schemaPath:"#/properties/states/items/properties/isComposite/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var n=a===e}else var n=!0;if(n){if(t.actions!==void 0){let a=t.actions;const s=e;if(e===s)if(Array.isArray(a)){var _=!0;const x=a.length;for(let b=0;b<x;b++){const h=e;c(a[b],{instancePath:r+"/states/"+l+"/actions/"+b,parentData:a,parentDataProperty:b,rootData:w})||(m=m===null?c.errors:m.concat(c.errors),e=m.length);var _=h===e;if(!_)break}}else return i.errors=[{instancePath:r+"/states/"+l+"/actions",schemaPath:"#/properties/states/items/properties/actions/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var n=s===e}else var n=!0;if(n){if(t.note!==void 0){let a=t.note;const s=e;if(e===e)if(Array.isArray(a)){var f=!0;const b=a.length;for(let h=0;h<b;h++){const k=e;if(typeof a[h]!="string")return i.errors=[{instancePath:r+"/states/"+l+"/note/"+h,schemaPath:"#/definitions/NoteType/items/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var f=k===e;if(!f)break}}else return i.errors=[{instancePath:r+"/states/"+l+"/note",schemaPath:"#/definitions/NoteType/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var n=s===e}else var n=!0;if(n)if(t.statemachine!==void 0){const a=e;N.validate(t.statemachine,{instancePath:r+"/states/"+l+"/statemachine",parentData:t,parentDataProperty:"statemachine",rootData:w})||(m=m===null?N.validate.errors:m.concat(N.validate.errors),e=m.length);var n=a===e}else var n=!0}}}}}}}}}}}}else return i.errors=[{instancePath:r+"/states/"+l,schemaPath:"#/properties/states/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var g=p===e;if(!g)break}}else return i.errors=[{instancePath:r+"/states",schemaPath:"#/properties/states/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var P=T===e}else var P=!0;if(P)if(y.transitions!==void 0){let u=y.transitions;const T=e;if(e===T)if(Array.isArray(u)){var S=!0;const l=u.length;for(let t=0;t<l;t++){let p=u[t];const D=e;if(e===D)if(p&&typeof p=="object"&&!Array.isArray(p)){let v;if(p.id===void 0&&(v="id")||p.from===void 0&&(v="from")||p.to===void 0&&(v="to"))return i.errors=[{instancePath:r+"/transitions/"+t,schemaPath:"#/properties/transitions/items/required",keyword:"required",params:{missingProperty:v},message:"must have required property '"+v+"'"}],!1;{const a=e;for(const s in p)if(!Z.call(z.properties.transitions.items.properties,s)){return i.errors=[{instancePath:r+"/transitions/"+t,schemaPath:"#/properties/transitions/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:s},message:"must NOT have additional properties"}],!1;break}if(a===e){if(p.id!==void 0){let s=p.id;const d=e;if(!(typeof s=="number"&&isFinite(s)))return i.errors=[{instancePath:r+"/transitions/"+t+"/id",schemaPath:"#/properties/transitions/items/properties/id/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var o=d===e}else var o=!0;if(o){if(p.from!==void 0){const s=e;if(typeof p.from!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/from",schemaPath:"#/properties/transitions/items/properties/from/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.to!==void 0){const s=e;if(typeof p.to!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/to",schemaPath:"#/properties/transitions/items/properties/to/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.label!==void 0){const s=e;if(typeof p.label!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/label",schemaPath:"#/properties/transitions/items/properties/label/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.event!==void 0){const s=e;if(typeof p.event!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/event",schemaPath:"#/properties/transitions/items/properties/event/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.cond!==void 0){const s=e;if(typeof p.cond!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/cond",schemaPath:"#/properties/transitions/items/properties/cond/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.action!==void 0){const s=e;if(typeof p.action!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/action",schemaPath:"#/properties/transitions/items/properties/action/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.note!==void 0){let s=p.note;const d=e;if(e===e)if(Array.isArray(s)){var E=!0;const h=s.length;for(let k=0;k<h;k++){const F=e;if(typeof s[k]!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/note/"+k,schemaPath:"#/definitions/NoteType/items/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var E=F===e;if(!E)break}}else return i.errors=[{instancePath:r+"/transitions/"+t+"/note",schemaPath:"#/definitions/NoteType/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var o=d===e}else var o=!0;if(o){if(p.color!==void 0){const s=e;if(typeof p.color!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/color",schemaPath:"#/properties/transitions/items/properties/color/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.width!==void 0){let s=p.width;const d=e;if(e===d)if(typeof s=="number"&&isFinite(s)){if(s>30||isNaN(s))return i.errors=[{instancePath:r+"/transitions/"+t+"/width",schemaPath:"#/properties/transitions/items/properties/width/maximum",keyword:"maximum",params:{comparison:"<=",limit:30},message:"must be <= 30"}],!1;if(s<0||isNaN(s))return i.errors=[{instancePath:r+"/transitions/"+t+"/width",schemaPath:"#/properties/transitions/items/properties/width/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}else return i.errors=[{instancePath:r+"/transitions/"+t+"/width",schemaPath:"#/properties/transitions/items/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var o=d===e}else var o=!0;if(o){if(p.class!==void 0){let s=p.class;const d=e;if(e===e)if(typeof s=="string"){if(!O.test(s))return i.errors=[{instancePath:r+"/transitions/"+t+"/class",schemaPath:"#/definitions/ClassType/pattern",keyword:"pattern",params:{pattern:"^[a-zA-Z0-9_\\- ]*$"},message:'must match pattern "^[a-zA-Z0-9_\\- ]*$"'}],!1}else return i.errors=[{instancePath:r+"/transitions/"+t+"/class",schemaPath:"#/definitions/ClassType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=d===e}else var o=!0;if(o)if(p.type!==void 0){let s=p.type;const d=e;if(typeof s!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/type",schemaPath:"#/definitions/TransitionType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(s==="internal"||s==="external"))return i.errors=[{instancePath:r+"/transitions/"+t+"/type",schemaPath:"#/definitions/TransitionType/enum",keyword:"enum",params:{allowedValues:B.enum},message:"must be equal to one of the allowed values"}],!1;var o=d===e}else var o=!0}}}}}}}}}}}}}else return i.errors=[{instancePath:r+"/transitions/"+t,schemaPath:"#/properties/transitions/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var S=D===e;if(!S)break}}else return i.errors=[{instancePath:r+"/transitions",schemaPath:"#/properties/transitions/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var P=T===e}else var P=!0}}}else return i.errors=[{instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return i.errors=m,e===0}function C(y,{instancePath:r="",parentData:j,parentDataProperty:$,rootData:w=y}={}){let m=null,e=0;return i(y,{instancePath:r,parentData:j,parentDataProperty:$,rootData:w})||(m=m===null?i.errors:m.concat(i.errors),e=m.length),C.errors=m,e===0}
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
["scxml", scxml],
|
|
24
|
-
]);
|
|
25
|
-
return lOutputType2RenderFunctionMap.get(pOutputType) ?? ((pX) => pX);
|
|
1
|
+
const OUTPUT_TYPE2RENDER_MODULE = new Map([
|
|
2
|
+
["smcat", "./smcat.mjs"],
|
|
3
|
+
["dot", "./dot/index.mjs"],
|
|
4
|
+
["svg", "./vector/vector-native-dot-with-fallback.mjs"],
|
|
5
|
+
["eps", "./vector/vector-native-dot-with-fallback.mjs"],
|
|
6
|
+
["ps", "./vector/vector-native-dot-with-fallback.mjs"],
|
|
7
|
+
["ps2", "./vector/vector-native-dot-with-fallback.mjs"],
|
|
8
|
+
["oldsvg", "./vector/vector-with-wasm.mjs"],
|
|
9
|
+
["oldps2", "./vector/vector-with-wasm.mjs"],
|
|
10
|
+
["oldeps", "./vector/vector-with-wasm.mjs"],
|
|
11
|
+
["pdf", "./vector/vector-native-dot-with-fallback.mjs"],
|
|
12
|
+
["png", "./vector/vector-native-dot-with-fallback.mjs"],
|
|
13
|
+
["scjson", "./scjson/index.mjs"],
|
|
14
|
+
["scxml", "./scxml/index.mjs"],
|
|
15
|
+
]);
|
|
16
|
+
export default async function getRenderFunction(pOutputType) {
|
|
17
|
+
const lModulePath = OUTPUT_TYPE2RENDER_MODULE.get(pOutputType);
|
|
18
|
+
if (lModulePath) {
|
|
19
|
+
const lImportedModule = await import(lModulePath);
|
|
20
|
+
return lImportedModule.default;
|
|
21
|
+
}
|
|
22
|
+
return (pX) => pX;
|
|
26
23
|
}
|
package/dist/render/index.mjs
CHANGED
|
@@ -1,17 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
let gSmCatModule = null;
|
|
2
|
+
let gDotModule = null;
|
|
3
|
+
let gSVGModule = null;
|
|
4
|
+
let gSCJSONModule = null;
|
|
5
|
+
let gSCXMLModule = null;
|
|
6
|
+
export default async function getRenderFunction(pOutputType) {
|
|
7
|
+
switch (pOutputType) {
|
|
8
|
+
case "smcat": {
|
|
9
|
+
if (!gSmCatModule) {
|
|
10
|
+
gSmCatModule = await import("./smcat.mjs");
|
|
11
|
+
}
|
|
12
|
+
return gSmCatModule.default;
|
|
13
|
+
}
|
|
14
|
+
case "dot": {
|
|
15
|
+
if (!gDotModule) {
|
|
16
|
+
gDotModule = await import("./dot/index.mjs");
|
|
17
|
+
}
|
|
18
|
+
return gDotModule.default;
|
|
19
|
+
}
|
|
20
|
+
case "svg":
|
|
21
|
+
case "oldsvg": {
|
|
22
|
+
if (!gSVGModule) {
|
|
23
|
+
gSVGModule = await import("./vector/vector-with-wasm.mjs");
|
|
24
|
+
}
|
|
25
|
+
return gSVGModule.default;
|
|
26
|
+
}
|
|
27
|
+
case "scjson": {
|
|
28
|
+
if (!gSCJSONModule) {
|
|
29
|
+
gSCJSONModule = await import("./scjson/index.mjs");
|
|
30
|
+
}
|
|
31
|
+
return gSCJSONModule.default;
|
|
32
|
+
}
|
|
33
|
+
case "scxml": {
|
|
34
|
+
if (!gSCXMLModule) {
|
|
35
|
+
gSCXMLModule = await import("./scxml/index.mjs");
|
|
36
|
+
}
|
|
37
|
+
return gSCXMLModule.default;
|
|
38
|
+
}
|
|
39
|
+
default:
|
|
40
|
+
return (pX) => pX;
|
|
41
|
+
}
|
|
17
42
|
}
|
|
@@ -3,7 +3,7 @@ const DEFAULT_OPTIONS = {
|
|
|
3
3
|
exec: "dot",
|
|
4
4
|
format: "svg",
|
|
5
5
|
};
|
|
6
|
-
function convert(pDot, pOptions) {
|
|
6
|
+
export function convert(pDot, pOptions) {
|
|
7
7
|
const lOptions = {
|
|
8
8
|
...DEFAULT_OPTIONS,
|
|
9
9
|
...pOptions,
|
|
@@ -23,7 +23,7 @@ function convert(pDot, pOptions) {
|
|
|
23
23
|
throw new Error(`Unexpected error occurred. Exit code ${status}`);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
function isAvailable(pOptions) {
|
|
26
|
+
export function isAvailable(pOptions) {
|
|
27
27
|
const lOptions = {
|
|
28
28
|
...DEFAULT_OPTIONS,
|
|
29
29
|
...pOptions,
|
|
@@ -33,7 +33,3 @@ function isAvailable(pOptions) {
|
|
|
33
33
|
status === 0 && stderr.toString("utf8").startsWith("dot - graphviz version")
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
|
-
export default {
|
|
37
|
-
convert,
|
|
38
|
-
isAvailable,
|
|
39
|
-
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Graphviz } from "@hpcc-js/wasm-graphviz";
|
|
2
|
-
import
|
|
2
|
+
import { getOptionValue } from "../../options.mjs";
|
|
3
3
|
import ast2dot from "../dot/index.mjs";
|
|
4
|
-
import
|
|
4
|
+
import { isAvailable, convert } from "./dot-to-vector-native.mjs";
|
|
5
5
|
const VIZ_JS_UNSUPPORTED_OUTPUT_FORMATS = ["pdf", "png"];
|
|
6
6
|
const gGraphViz = await Graphviz.load();
|
|
7
7
|
const renderVector = (pStateMachine, pOptions) => {
|
|
8
8
|
const lDotProgram = ast2dot(pStateMachine, pOptions);
|
|
9
9
|
const lDotOptions = {
|
|
10
|
-
engine:
|
|
11
|
-
format:
|
|
10
|
+
engine: getOptionValue(pOptions, "engine"),
|
|
11
|
+
format: getOptionValue(pOptions, "outputType"),
|
|
12
12
|
};
|
|
13
|
-
if (
|
|
14
|
-
return
|
|
13
|
+
if (isAvailable(pOptions)) {
|
|
14
|
+
return convert(lDotProgram, lDotOptions);
|
|
15
15
|
} else {
|
|
16
16
|
if (VIZ_JS_UNSUPPORTED_OUTPUT_FORMATS.includes(lDotOptions.format)) {
|
|
17
17
|
throw new Error(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Graphviz } from "@hpcc-js/wasm-graphviz";
|
|
2
|
-
import
|
|
2
|
+
import { getOptionValue } from "../../options.mjs";
|
|
3
3
|
import ast2dot from "../dot/index.mjs";
|
|
4
4
|
const OUTPUT_TYPE2FORMAT = {
|
|
5
5
|
oldsvg: "svg",
|
|
@@ -8,12 +8,10 @@ const OUTPUT_TYPE2FORMAT = {
|
|
|
8
8
|
};
|
|
9
9
|
const gGraphViz = await Graphviz.load();
|
|
10
10
|
function getFormat(pOptions) {
|
|
11
|
-
return (
|
|
12
|
-
OUTPUT_TYPE2FORMAT[options.getOptionValue(pOptions, "outputType")] || "svg"
|
|
13
|
-
);
|
|
11
|
+
return OUTPUT_TYPE2FORMAT[getOptionValue(pOptions, "outputType")] || "svg";
|
|
14
12
|
}
|
|
15
13
|
function getEngine(pOptions) {
|
|
16
|
-
return
|
|
14
|
+
return getOptionValue(pOptions, "engine");
|
|
17
15
|
}
|
|
18
16
|
const renderVectorWithWasm = (pStateMachine, pOptions) =>
|
|
19
17
|
gGraphViz.layout(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import StateMachineModel from "../state-machine-model.mjs";
|
|
2
2
|
import { Counter } from "../counter.mjs";
|
|
3
|
-
import
|
|
3
|
+
import { formatLabel } from "./utl.mjs";
|
|
4
4
|
function fuseTransitionAttribute(pIncomingThing, pOutgoingThing, pJoinChar) {
|
|
5
5
|
return pIncomingThing
|
|
6
6
|
? `${pIncomingThing}${pJoinChar}${pOutgoingThing}`
|
|
@@ -26,7 +26,7 @@ function fuseIncomingToOutgoing(
|
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
28
|
if (lReturnValue.event || lReturnValue.cond || lReturnValue.action) {
|
|
29
|
-
lReturnValue.label =
|
|
29
|
+
lReturnValue.label = formatLabel(
|
|
30
30
|
lReturnValue.event,
|
|
31
31
|
lReturnValue.cond,
|
|
32
32
|
lReturnValue.action,
|
package/dist/transform/utl.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function formatLabel(pEvent, pCond, pActions) {
|
|
1
|
+
export function formatLabel(pEvent, pCond, pActions) {
|
|
2
2
|
let lReturnValue = "";
|
|
3
3
|
if (pEvent) {
|
|
4
4
|
lReturnValue += pEvent;
|
|
@@ -11,6 +11,3 @@ function formatLabel(pEvent, pCond, pActions) {
|
|
|
11
11
|
}
|
|
12
12
|
return lReturnValue.trim();
|
|
13
13
|
}
|
|
14
|
-
export default {
|
|
15
|
-
formatLabel,
|
|
16
|
-
};
|
package/dist/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "
|
|
1
|
+
export const version = "14.0.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "state-machine-cat",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.1",
|
|
4
4
|
"description": "write beautiful state charts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -41,9 +41,8 @@
|
|
|
41
41
|
"state-machine-cat": "dist/cli/main.mjs"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@hpcc-js/wasm-graphviz": "1.
|
|
45
|
-
"
|
|
46
|
-
"fast-xml-parser": "5.3.1",
|
|
44
|
+
"@hpcc-js/wasm-graphviz": "1.16.0",
|
|
45
|
+
"fast-xml-parser": "5.3.2",
|
|
47
46
|
"he": "1.2.0",
|
|
48
47
|
"neotraverse": "0.6.18"
|
|
49
48
|
},
|
|
@@ -286,7 +286,7 @@ export type RenderFunctionType =
|
|
|
286
286
|
* @param pScript The script to translate
|
|
287
287
|
* @param pOptions options influencing parsing & rendering.
|
|
288
288
|
* See below for the complete list.
|
|
289
|
-
* @return the string with the rendered content if
|
|
289
|
+
* @return a promise to the string with the rendered content if
|
|
290
290
|
* no error was found
|
|
291
291
|
* @throws {Error} If an error occurred and no callback
|
|
292
292
|
* function was passed: the error
|
|
@@ -297,4 +297,4 @@ export type RenderFunctionType =
|
|
|
297
297
|
export function render(
|
|
298
298
|
pScript: IStateMachine | string,
|
|
299
299
|
pOptions: IRenderOptions,
|
|
300
|
-
): string
|
|
300
|
+
): Promise<string>;
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
$schema: "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
title: "state-machine-cat abstract syntax tree schema",
|
|
4
|
-
$ref: "#/definitions/StateMachineType",
|
|
5
|
-
$id: "org.js.state-machine-cat/v7.4.0",
|
|
6
|
-
definitions: {
|
|
7
|
-
StateType: {
|
|
8
|
-
type: "string",
|
|
9
|
-
enum: [
|
|
10
|
-
"regular",
|
|
11
|
-
"initial",
|
|
12
|
-
"terminate",
|
|
13
|
-
"final",
|
|
14
|
-
"parallel",
|
|
15
|
-
"history",
|
|
16
|
-
"deephistory",
|
|
17
|
-
"choice",
|
|
18
|
-
"forkjoin",
|
|
19
|
-
"fork",
|
|
20
|
-
"join",
|
|
21
|
-
"junction",
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
TransitionType: {
|
|
25
|
-
type: "string",
|
|
26
|
-
enum: ["internal", "external"],
|
|
27
|
-
},
|
|
28
|
-
NoteType: {
|
|
29
|
-
type: "array",
|
|
30
|
-
items: {
|
|
31
|
-
type: "string",
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
ActionTypeType: {
|
|
35
|
-
type: "string",
|
|
36
|
-
enum: ["entry", "activity", "exit"],
|
|
37
|
-
},
|
|
38
|
-
ActionType: {
|
|
39
|
-
type: "object",
|
|
40
|
-
required: ["type", "body"],
|
|
41
|
-
additionalProperties: false,
|
|
42
|
-
properties: {
|
|
43
|
-
type: { $ref: "#/definitions/ActionTypeType" },
|
|
44
|
-
body: { type: "string" },
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
ClassType: {
|
|
48
|
-
type: "string",
|
|
49
|
-
pattern: "^[a-zA-Z0-9_\\- ]*$",
|
|
50
|
-
},
|
|
51
|
-
StateMachineType: {
|
|
52
|
-
type: "object",
|
|
53
|
-
additionalProperties: false,
|
|
54
|
-
required: ["states"],
|
|
55
|
-
properties: {
|
|
56
|
-
states: {
|
|
57
|
-
type: "array",
|
|
58
|
-
items: {
|
|
59
|
-
type: "object",
|
|
60
|
-
required: ["name", "type"],
|
|
61
|
-
additionalProperties: false,
|
|
62
|
-
properties: {
|
|
63
|
-
name: {
|
|
64
|
-
description:
|
|
65
|
-
"The name and identifier of the state. Unique within the root state machine.",
|
|
66
|
-
type: "string",
|
|
67
|
-
},
|
|
68
|
-
type: {
|
|
69
|
-
description:
|
|
70
|
-
"What kind of state (or pseudo state) this state is. E.g. 'regular' for normal states or 'initial', 'final', 'choice' etc for pseudo states. Most UML (pseudo-) states are supported.",
|
|
71
|
-
$ref: "#/definitions/StateType",
|
|
72
|
-
},
|
|
73
|
-
label: {
|
|
74
|
-
description:
|
|
75
|
-
"The display label of the state. If it's not present, most renderers will use the states' name in stead.",
|
|
76
|
-
type: "string",
|
|
77
|
-
},
|
|
78
|
-
color: {
|
|
79
|
-
description:
|
|
80
|
-
'Color to use for rendering the state. Accepts all css color names ("blue") and hex notation - with ("#0000FF77") or without ("#0000FF") transparency.',
|
|
81
|
-
type: "string",
|
|
82
|
-
},
|
|
83
|
-
class: {
|
|
84
|
-
description:
|
|
85
|
-
"Class name to give the state in dot and svg output.",
|
|
86
|
-
$ref: "#/definitions/ClassType",
|
|
87
|
-
},
|
|
88
|
-
active: {
|
|
89
|
-
description:
|
|
90
|
-
"If true the state is considered to be active and rendered as such.",
|
|
91
|
-
type: "boolean",
|
|
92
|
-
},
|
|
93
|
-
typeExplicitlySet: {
|
|
94
|
-
description:
|
|
95
|
-
"The default parser derives the `type` from the `name` with inband signaling. The user can override that behavior by explicitly setting the `type`. This attribute is there to express that (and make sure that on next parses & processing it doesn't get accidentily re-derived from the name again).",
|
|
96
|
-
type: "boolean",
|
|
97
|
-
},
|
|
98
|
-
isComposite: {
|
|
99
|
-
description:
|
|
100
|
-
"convenience, derived attribute - set to true if there's a state machine inside the state; false in all other cases. For internal use - @deprecated",
|
|
101
|
-
type: "boolean",
|
|
102
|
-
},
|
|
103
|
-
actions: {
|
|
104
|
-
type: "array",
|
|
105
|
-
description:
|
|
106
|
-
"A series of actions and their types. The type describe when the action takes place (on entry, exit, or otherwise ('activity'))",
|
|
107
|
-
items: { $ref: "#/definitions/ActionType" },
|
|
108
|
-
},
|
|
109
|
-
note: {
|
|
110
|
-
description:
|
|
111
|
-
"Comments related to this state. Some renderers will use the note attribute to render a note (i.e. as a post-it) attached to the state.",
|
|
112
|
-
$ref: "#/definitions/NoteType",
|
|
113
|
-
},
|
|
114
|
-
statemachine: {
|
|
115
|
-
description: "state machine nested within the state.",
|
|
116
|
-
$ref: "#/definitions/StateMachineType",
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
transitions: {
|
|
122
|
-
type: "array",
|
|
123
|
-
items: {
|
|
124
|
-
type: "object",
|
|
125
|
-
required: ["id", "from", "to"],
|
|
126
|
-
additionalProperties: false,
|
|
127
|
-
properties: {
|
|
128
|
-
id: {
|
|
129
|
-
type: "number",
|
|
130
|
-
},
|
|
131
|
-
from: {
|
|
132
|
-
description:
|
|
133
|
-
"The name of the state this transition transitions from",
|
|
134
|
-
type: "string",
|
|
135
|
-
},
|
|
136
|
-
to: {
|
|
137
|
-
description:
|
|
138
|
-
"The name of the state this transition transitions to",
|
|
139
|
-
type: "string",
|
|
140
|
-
},
|
|
141
|
-
label: {
|
|
142
|
-
description:
|
|
143
|
-
"A display label to represent this transition. Parsers can parse this label into events conditions and actions.",
|
|
144
|
-
type: "string",
|
|
145
|
-
},
|
|
146
|
-
event: {
|
|
147
|
-
description: "Event triggering the transition",
|
|
148
|
-
type: "string",
|
|
149
|
-
},
|
|
150
|
-
cond: {
|
|
151
|
-
description: "Condition for the transition to occur.",
|
|
152
|
-
type: "string",
|
|
153
|
-
},
|
|
154
|
-
action: {
|
|
155
|
-
description: "Action to execute when the transition occurs.",
|
|
156
|
-
type: "string",
|
|
157
|
-
},
|
|
158
|
-
note: {
|
|
159
|
-
description: "Comments related to this transition",
|
|
160
|
-
$ref: "#/definitions/NoteType",
|
|
161
|
-
},
|
|
162
|
-
color: {
|
|
163
|
-
description:
|
|
164
|
-
'Color to use for rendering the transition. Accepts all css color names ("blue") and hex notation - with ("#0000FF77") or without ("#0000FF") transparency.',
|
|
165
|
-
type: "string",
|
|
166
|
-
},
|
|
167
|
-
width: {
|
|
168
|
-
description:
|
|
169
|
-
"The line width to use for rendering the transition",
|
|
170
|
-
type: "number",
|
|
171
|
-
minimum: 0,
|
|
172
|
-
maximum: 30,
|
|
173
|
-
},
|
|
174
|
-
class: {
|
|
175
|
-
description:
|
|
176
|
-
"Class name to give the state in dot and svg output.",
|
|
177
|
-
$ref: "#/definitions/ClassType",
|
|
178
|
-
},
|
|
179
|
-
type: {
|
|
180
|
-
description:
|
|
181
|
-
"Whether the transition is external (default) or internal. See https://www.w3.org/TR/scxml/#transition for details.",
|
|
182
|
-
$ref: "#/definitions/TransitionType",
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
};
|