state-machine-cat 12.0.5 → 12.0.7
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/cli/actions.mjs +34 -31
- package/dist/cli/attributes-parser.mjs +914 -976
- package/dist/cli/execute-command-line.mjs +98 -48
- package/dist/cli/file-name-to-stream.mjs +8 -8
- package/dist/cli/normalize.mjs +89 -70
- package/dist/cli/validations.mjs +72 -52
- package/dist/index-node.mjs +12 -9
- package/dist/index.mjs +10 -7
- package/dist/options.mjs +53 -53
- package/dist/parse/index.mjs +17 -17
- package/dist/parse/parser-helpers.mjs +159 -139
- package/dist/parse/scxml/index.mjs +152 -129
- package/dist/parse/scxml/normalize-machine.mjs +36 -35
- package/dist/parse/scxml/utl.mjs +1 -1
- package/dist/parse/smcat/smcat-parser.mjs +2794 -2897
- package/dist/parse/smcat-ast.schema.mjs +185 -168
- package/dist/render/dot/attributebuilder.mjs +40 -37
- package/dist/render/dot/counter.mjs +14 -14
- package/dist/render/dot/dot.states.template.js +1 -26
- package/dist/render/dot/dot.template.js +1 -14
- package/dist/render/dot/index.mjs +129 -82
- package/dist/render/dot/render-dot-from-ast.mjs +33 -16
- package/dist/render/dot/state-transformers.mjs +96 -85
- package/dist/render/dot/transition-transformers.mjs +39 -41
- package/dist/render/dot/utl.mjs +21 -19
- package/dist/render/index-node.mjs +16 -16
- package/dist/render/index.mjs +9 -9
- package/dist/render/scjson/index.mjs +111 -94
- package/dist/render/scjson/make-valid-event-names.mjs +21 -18
- package/dist/render/scjson/make-valid-xml-name.mjs +17 -13
- package/dist/render/scxml/index.mjs +2 -1
- package/dist/render/scxml/render-from-scjson.mjs +5 -2
- package/dist/render/scxml/scxml.states.template.js +1 -14
- package/dist/render/scxml/scxml.template.js +1 -6
- package/dist/render/smcat/index.mjs +54 -39
- package/dist/render/smcat/smcat.template.js +1 -13
- package/dist/render/vector/dot-to-vector-native.mjs +30 -26
- package/dist/render/vector/vector-native-dot-with-fallback.mjs +27 -20
- package/dist/render/vector/vector-with-wasm.mjs +13 -6
- package/dist/state-machine-model.mjs +67 -52
- package/dist/transform/desugar.mjs +115 -66
- package/dist/transform/utl.mjs +12 -12
- package/dist/version.mjs +1 -1
- package/package.json +74 -74
- package/types/state-machine-cat.d.mts +209 -209
- package/types/state-machine-cat.d.ts +0 -296
|
@@ -4,58 +4,108 @@ import satisfies from "semver/functions/satisfies.js";
|
|
|
4
4
|
import { formatError, displayLicense, transform } from "./actions.mjs";
|
|
5
5
|
import normalize from "./normalize.mjs";
|
|
6
6
|
import validations from "./validations.mjs";
|
|
7
|
-
const $package = JSON.parse(
|
|
7
|
+
const $package = JSON.parse(
|
|
8
|
+
readFileSync(new URL("../../package.json", import.meta.url), "utf8"),
|
|
9
|
+
);
|
|
8
10
|
function presentError(pError, pErrorStream) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
pErrorStream.write(formatError(pError));
|
|
12
|
+
process.exitCode = 1;
|
|
11
13
|
}
|
|
12
14
|
function parseArguments(pArguments) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
15
|
+
return new Command()
|
|
16
|
+
.description(
|
|
17
|
+
"Write beautiful state charts - https://github.com/sverweij/state-machine-cat",
|
|
18
|
+
)
|
|
19
|
+
.option(
|
|
20
|
+
"-T, --output-type <type>",
|
|
21
|
+
validations.validOutputTypeRE,
|
|
22
|
+
validations.validOutputType,
|
|
23
|
+
validations.defaultOutputType,
|
|
24
|
+
)
|
|
25
|
+
.option(
|
|
26
|
+
"-I, --input-type <type>",
|
|
27
|
+
validations.validInputTypeRE,
|
|
28
|
+
validations.validInputType,
|
|
29
|
+
validations.defaultInputType,
|
|
30
|
+
)
|
|
31
|
+
.option(
|
|
32
|
+
"-E, --engine <type>",
|
|
33
|
+
validations.validEngineRE,
|
|
34
|
+
validations.validEngine,
|
|
35
|
+
validations.defaultEngine,
|
|
36
|
+
)
|
|
37
|
+
.option(
|
|
38
|
+
"-d, --direction <dir>",
|
|
39
|
+
validations.validDirectionRE,
|
|
40
|
+
validations.validDirection,
|
|
41
|
+
validations.defaultDirection,
|
|
42
|
+
)
|
|
43
|
+
.option("-o --output-to <file>", "File to write to. use - for stdout.")
|
|
44
|
+
.addOption(
|
|
45
|
+
new Option(
|
|
46
|
+
"--dot-graph-attrs <string>",
|
|
47
|
+
"graph attributes to pass to the dot render engine",
|
|
48
|
+
)
|
|
49
|
+
.argParser(validations.validDotAttrs)
|
|
50
|
+
.hideHelp(true),
|
|
51
|
+
)
|
|
52
|
+
.addOption(
|
|
53
|
+
new Option(
|
|
54
|
+
"--dot-node-attrs <string>",
|
|
55
|
+
"node attributes to pass to the dot render engine",
|
|
56
|
+
)
|
|
57
|
+
.argParser(validations.validDotAttrs)
|
|
58
|
+
.hideHelp(true),
|
|
59
|
+
)
|
|
60
|
+
.addOption(
|
|
61
|
+
new Option(
|
|
62
|
+
"--dot-edge-attrs <string>",
|
|
63
|
+
"edge attributes to pass to the dot render engine",
|
|
64
|
+
)
|
|
65
|
+
.argParser(validations.validDotAttrs)
|
|
66
|
+
.hideHelp(true),
|
|
67
|
+
)
|
|
68
|
+
.option(
|
|
69
|
+
"--desugar",
|
|
70
|
+
"transform pseudo states into transitions (!experimental!)",
|
|
71
|
+
)
|
|
72
|
+
.version($package.version)
|
|
73
|
+
.option("-l, --license", "Display license and exit")
|
|
74
|
+
.arguments("[infile]")
|
|
75
|
+
.parse(pArguments);
|
|
34
76
|
}
|
|
35
77
|
function assertNodeVersion(pCurrentNodeVersion, pSupportedEngines) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
78
|
+
if (!satisfies(pCurrentNodeVersion, pSupportedEngines)) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
`\nERROR: your node version (${pCurrentNodeVersion}) is not recent enough.\n` +
|
|
81
|
+
` state-machine-cat is supported on node ${pSupportedEngines}\n\n`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
40
84
|
}
|
|
41
|
-
export default async function executeCommandLine(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
85
|
+
export default async function executeCommandLine(
|
|
86
|
+
pArguments = process.argv,
|
|
87
|
+
pOptions,
|
|
88
|
+
) {
|
|
89
|
+
const lOptions = {
|
|
90
|
+
currentNodeVersion: process.versions.node,
|
|
91
|
+
supportedEngines: $package.engines.node,
|
|
92
|
+
outStream: process.stdout,
|
|
93
|
+
errorStream: process.stderr,
|
|
94
|
+
...pOptions,
|
|
95
|
+
};
|
|
96
|
+
try {
|
|
97
|
+
assertNodeVersion(lOptions.currentNodeVersion, lOptions.supportedEngines);
|
|
98
|
+
const lProgram = parseArguments(pArguments);
|
|
99
|
+
if (lProgram.opts()?.license) {
|
|
100
|
+
displayLicense(lOptions.outStream);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
await transform(
|
|
104
|
+
validations.validateArguments(
|
|
105
|
+
normalize(lProgram.args[0], lProgram.opts()),
|
|
106
|
+
),
|
|
107
|
+
);
|
|
108
|
+
} catch (pError) {
|
|
109
|
+
presentError(pError, lOptions.errorStream);
|
|
110
|
+
}
|
|
61
111
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
export function getOutStream(pOutputTo) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
if ("-" === pOutputTo) {
|
|
4
|
+
return process.stdout;
|
|
5
|
+
}
|
|
6
|
+
return fs.createWriteStream(pOutputTo);
|
|
7
7
|
}
|
|
8
8
|
export function getInStream(pInputFrom) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
if ("-" === pInputFrom) {
|
|
10
|
+
return process.stdin;
|
|
11
|
+
}
|
|
12
|
+
return fs.createReadStream(pInputFrom);
|
|
13
13
|
}
|
package/dist/cli/normalize.mjs
CHANGED
|
@@ -2,94 +2,113 @@ import path from "node:path";
|
|
|
2
2
|
import options from "../options.mjs";
|
|
3
3
|
import { parse as parseAttributes } from "./attributes-parser.mjs";
|
|
4
4
|
const INPUT_EXTENSIONS = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
".smcat": "smcat",
|
|
6
|
+
".scxml": "scxml",
|
|
7
|
+
".xml": "scxml",
|
|
8
|
+
".json": "json",
|
|
9
|
+
".ast": "json",
|
|
10
10
|
};
|
|
11
11
|
const OUTPUT_EXTENSIONS = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
".ast": "json",
|
|
13
|
+
".dot": "dot",
|
|
14
|
+
".eps": "eps",
|
|
15
|
+
".json": "json",
|
|
16
|
+
".pdf": "pdf",
|
|
17
|
+
".png": "png",
|
|
18
|
+
".ps": "ps",
|
|
19
|
+
".ps2": "ps2",
|
|
20
|
+
".scjson": "scjson",
|
|
21
|
+
".scxml": "scxml",
|
|
22
|
+
".smcat": "smcat",
|
|
23
|
+
".svg": "svg",
|
|
24
24
|
};
|
|
25
25
|
function classifyExtension(pString, pExtensionMap, pDefault) {
|
|
26
|
-
|
|
26
|
+
return pExtensionMap[path.extname(pString)] || pDefault;
|
|
27
27
|
}
|
|
28
28
|
function outputType2Extension(pOutputType) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
const lExceptions = {
|
|
30
|
+
oldeps: "eps",
|
|
31
|
+
oldps: "ps",
|
|
32
|
+
oldps2: "ps",
|
|
33
|
+
oldsvg: "svg",
|
|
34
|
+
ps2: "ps",
|
|
35
|
+
};
|
|
36
|
+
return lExceptions[pOutputType] || pOutputType;
|
|
37
37
|
}
|
|
38
38
|
function deriveOutputFromInput(pInputFrom, pOutputType) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
const lExtension = outputType2Extension(pOutputType);
|
|
40
|
+
if (!pInputFrom || "-" === pInputFrom) {
|
|
41
|
+
return "-";
|
|
42
|
+
}
|
|
43
|
+
return path
|
|
44
|
+
.join(
|
|
45
|
+
path.dirname(pInputFrom),
|
|
46
|
+
path.basename(pInputFrom, path.extname(pInputFrom)),
|
|
47
|
+
)
|
|
48
|
+
.concat(".")
|
|
49
|
+
.concat(lExtension);
|
|
47
50
|
}
|
|
48
51
|
function determineOutputTo(pOutputTo, pInputFrom, pOutputType) {
|
|
49
|
-
|
|
52
|
+
return pOutputTo ? pOutputTo : deriveOutputFromInput(pInputFrom, pOutputType);
|
|
50
53
|
}
|
|
51
54
|
function determineInputType(pInputFrom, pInputType) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
if (pInputType) {
|
|
56
|
+
return pInputType;
|
|
57
|
+
}
|
|
58
|
+
return classifyExtension(
|
|
59
|
+
pInputFrom,
|
|
60
|
+
INPUT_EXTENSIONS,
|
|
61
|
+
options.getAllowedValues().inputType.default,
|
|
62
|
+
);
|
|
56
63
|
}
|
|
57
64
|
function determineOutputType(pOutputTo, pOutputType) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
if (pOutputType) {
|
|
66
|
+
return pOutputType;
|
|
67
|
+
}
|
|
68
|
+
if (pOutputTo) {
|
|
69
|
+
return classifyExtension(
|
|
70
|
+
pOutputTo,
|
|
71
|
+
OUTPUT_EXTENSIONS,
|
|
72
|
+
options.getAllowedValues().outputType.default,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return options.getAllowedValues().outputType.default;
|
|
65
76
|
}
|
|
66
77
|
function determineParameter(pOptions, pParameter) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
:
|
|
71
|
-
options.getAllowedValues()[pParameter].default;
|
|
78
|
+
return Object.prototype.hasOwnProperty.call(pOptions, pParameter)
|
|
79
|
+
? pOptions[pParameter]
|
|
80
|
+
: options.getAllowedValues()[pParameter].default;
|
|
72
81
|
}
|
|
73
82
|
function determineDotAttributes(pOptions, pDotAttributes) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
return Boolean(pOptions?.[pDotAttributes]) &&
|
|
84
|
+
typeof pOptions[pDotAttributes] === "string"
|
|
85
|
+
? parseAttributes(pOptions[pDotAttributes])
|
|
86
|
+
: [];
|
|
78
87
|
}
|
|
79
88
|
export default function normalize(pArgument = "-", pLooseOptions = {}) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
const lNormalizedInputFrom = pArgument || "-";
|
|
90
|
+
const lNormalizedInputType = determineInputType(
|
|
91
|
+
lNormalizedInputFrom,
|
|
92
|
+
pLooseOptions.inputType,
|
|
93
|
+
);
|
|
94
|
+
const lNormalizedOutputType = determineOutputType(
|
|
95
|
+
pLooseOptions.outputTo,
|
|
96
|
+
pLooseOptions.outputType,
|
|
97
|
+
);
|
|
98
|
+
return {
|
|
99
|
+
inputFrom: lNormalizedInputFrom,
|
|
100
|
+
inputType: lNormalizedInputType,
|
|
101
|
+
outputType: lNormalizedOutputType,
|
|
102
|
+
outputTo: determineOutputTo(
|
|
103
|
+
pLooseOptions.outputTo,
|
|
104
|
+
lNormalizedInputFrom,
|
|
105
|
+
lNormalizedOutputType,
|
|
106
|
+
),
|
|
107
|
+
engine: determineParameter(pLooseOptions, "engine"),
|
|
108
|
+
direction: determineParameter(pLooseOptions, "direction"),
|
|
109
|
+
dotGraphAttrs: determineDotAttributes(pLooseOptions, "dotGraphAttrs"),
|
|
110
|
+
dotNodeAttrs: determineDotAttributes(pLooseOptions, "dotNodeAttrs"),
|
|
111
|
+
dotEdgeAttrs: determineDotAttributes(pLooseOptions, "dotEdgeAttrs"),
|
|
112
|
+
desugar: pLooseOptions?.desugar ?? false,
|
|
113
|
+
};
|
|
95
114
|
}
|
package/dist/cli/validations.mjs
CHANGED
|
@@ -3,68 +3,88 @@ import smcat from "../index-node.mjs";
|
|
|
3
3
|
import { parse as parseAttributes } from "./attributes-parser.mjs";
|
|
4
4
|
const allowedValues = smcat.getAllowedValues();
|
|
5
5
|
function getName(pValue) {
|
|
6
|
-
|
|
6
|
+
return pValue.name;
|
|
7
7
|
}
|
|
8
8
|
const VALID_OUTPUT_TYPES = allowedValues.outputType.values.map(getName);
|
|
9
9
|
const VALID_INPUT_TYPES = allowedValues.inputType.values.map(getName);
|
|
10
10
|
const VALID_ENGINES = allowedValues.engine.values.map(getName);
|
|
11
11
|
const VALID_DIRECTIONS = allowedValues.direction.values.map(getName);
|
|
12
12
|
function isStdout(pFilename) {
|
|
13
|
-
|
|
13
|
+
return "-" === pFilename;
|
|
14
14
|
}
|
|
15
15
|
function fileExists(pFilename) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
16
|
+
try {
|
|
17
|
+
if (!isStdout(pFilename)) {
|
|
18
|
+
fs.accessSync(pFilename, fs.constants.R_OK);
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
} catch (pError) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
25
24
|
}
|
|
26
25
|
function validOption(pOption, pValidValues, pError) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
if (pValidValues.includes(pOption)) {
|
|
27
|
+
return pOption;
|
|
28
|
+
}
|
|
29
|
+
throw new Error(pError);
|
|
31
30
|
}
|
|
32
31
|
export default {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
32
|
+
validOutputType: (pType) =>
|
|
33
|
+
validOption(
|
|
34
|
+
pType,
|
|
35
|
+
VALID_OUTPUT_TYPES,
|
|
36
|
+
`\n error: '${pType}' is not a valid output type. smcat can emit:` +
|
|
37
|
+
`\n ${VALID_OUTPUT_TYPES.join(", ")}\n\n`,
|
|
38
|
+
),
|
|
39
|
+
validInputType: (pType) =>
|
|
40
|
+
validOption(
|
|
41
|
+
pType,
|
|
42
|
+
VALID_INPUT_TYPES,
|
|
43
|
+
`\n error: '${pType}' is not a valid input type.` +
|
|
44
|
+
`\n smcat can read ${VALID_INPUT_TYPES.join(", ")}\n\n`,
|
|
45
|
+
),
|
|
46
|
+
validEngine: (pEngine) =>
|
|
47
|
+
validOption(
|
|
48
|
+
pEngine,
|
|
49
|
+
VALID_ENGINES,
|
|
50
|
+
`\n error: '${pEngine}' is not a valid input type.` +
|
|
51
|
+
`\n you can choose from ${VALID_ENGINES.join(", ")}\n\n`,
|
|
52
|
+
),
|
|
53
|
+
validDirection: (pDirection) =>
|
|
54
|
+
validOption(
|
|
55
|
+
pDirection,
|
|
56
|
+
VALID_DIRECTIONS,
|
|
57
|
+
`\n error: '${pDirection}' is not a valid direction.` +
|
|
58
|
+
`\n you can choose from ${VALID_DIRECTIONS.join(", ")}\n\n`,
|
|
59
|
+
),
|
|
60
|
+
validDotAttrs: (pDotAttributes) => {
|
|
61
|
+
try {
|
|
62
|
+
parseAttributes(pDotAttributes);
|
|
63
|
+
return pDotAttributes;
|
|
64
|
+
} catch (pError) {
|
|
65
|
+
throw new Error(`Invalid dot attributes: ${pError.message}`);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
validateArguments(pOptions) {
|
|
69
|
+
if (!pOptions.inputFrom) {
|
|
70
|
+
throw new Error(`\n error: Please specify an input file.\n\n`);
|
|
71
|
+
}
|
|
72
|
+
if (!pOptions.outputTo) {
|
|
73
|
+
throw new Error(`\n error: Please specify an output file.\n\n`);
|
|
74
|
+
}
|
|
75
|
+
if (!fileExists(pOptions.inputFrom)) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`\n error: Failed to open input file '${pOptions.inputFrom}'\n\n`,
|
|
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,
|
|
70
90
|
};
|
package/dist/index-node.mjs
CHANGED
|
@@ -4,13 +4,16 @@ import desugar from "./transform/desugar.mjs";
|
|
|
4
4
|
import getRenderFunction from "./render/index-node.mjs";
|
|
5
5
|
import { version } from "./version.mjs";
|
|
6
6
|
export default {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
render(pScript, pOptions) {
|
|
8
|
+
const lStateMachine = parse.getAST(pScript, pOptions);
|
|
9
|
+
const lDesugar = options.getOptionValue(pOptions, "desugar");
|
|
10
|
+
return getRenderFunction(options.getOptionValue(pOptions, "outputType"))(
|
|
11
|
+
lDesugar ? desugar(lStateMachine) : lStateMachine,
|
|
12
|
+
pOptions,
|
|
13
|
+
);
|
|
14
|
+
},
|
|
15
|
+
version,
|
|
16
|
+
getAllowedValues() {
|
|
17
|
+
return options.getAllowedValues();
|
|
18
|
+
},
|
|
16
19
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -4,16 +4,19 @@ import desugar from "./transform/desugar.mjs";
|
|
|
4
4
|
import getRenderFunction from "./render/index.mjs";
|
|
5
5
|
import { version as _version } from "./version.mjs";
|
|
6
6
|
export function render(pScript, pOptions) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const lStateMachine = parse.getAST(pScript, pOptions);
|
|
8
|
+
const lDesugar = options.getOptionValue(pOptions, "desugar");
|
|
9
|
+
return getRenderFunction(options.getOptionValue(pOptions, "outputType"))(
|
|
10
|
+
lDesugar ? desugar(lStateMachine) : lStateMachine,
|
|
11
|
+
pOptions,
|
|
12
|
+
);
|
|
10
13
|
}
|
|
11
14
|
export const version = _version;
|
|
12
15
|
export function getAllowedValues() {
|
|
13
|
-
|
|
16
|
+
return options.getAllowedValues();
|
|
14
17
|
}
|
|
15
18
|
export default {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
render,
|
|
20
|
+
version,
|
|
21
|
+
getAllowedValues,
|
|
19
22
|
};
|