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.
Files changed (46) hide show
  1. package/dist/cli/actions.mjs +34 -31
  2. package/dist/cli/attributes-parser.mjs +914 -976
  3. package/dist/cli/execute-command-line.mjs +98 -48
  4. package/dist/cli/file-name-to-stream.mjs +8 -8
  5. package/dist/cli/normalize.mjs +89 -70
  6. package/dist/cli/validations.mjs +72 -52
  7. package/dist/index-node.mjs +12 -9
  8. package/dist/index.mjs +10 -7
  9. package/dist/options.mjs +53 -53
  10. package/dist/parse/index.mjs +17 -17
  11. package/dist/parse/parser-helpers.mjs +159 -139
  12. package/dist/parse/scxml/index.mjs +152 -129
  13. package/dist/parse/scxml/normalize-machine.mjs +36 -35
  14. package/dist/parse/scxml/utl.mjs +1 -1
  15. package/dist/parse/smcat/smcat-parser.mjs +2794 -2897
  16. package/dist/parse/smcat-ast.schema.mjs +185 -168
  17. package/dist/render/dot/attributebuilder.mjs +40 -37
  18. package/dist/render/dot/counter.mjs +14 -14
  19. package/dist/render/dot/dot.states.template.js +1 -26
  20. package/dist/render/dot/dot.template.js +1 -14
  21. package/dist/render/dot/index.mjs +129 -82
  22. package/dist/render/dot/render-dot-from-ast.mjs +33 -16
  23. package/dist/render/dot/state-transformers.mjs +96 -85
  24. package/dist/render/dot/transition-transformers.mjs +39 -41
  25. package/dist/render/dot/utl.mjs +21 -19
  26. package/dist/render/index-node.mjs +16 -16
  27. package/dist/render/index.mjs +9 -9
  28. package/dist/render/scjson/index.mjs +111 -94
  29. package/dist/render/scjson/make-valid-event-names.mjs +21 -18
  30. package/dist/render/scjson/make-valid-xml-name.mjs +17 -13
  31. package/dist/render/scxml/index.mjs +2 -1
  32. package/dist/render/scxml/render-from-scjson.mjs +5 -2
  33. package/dist/render/scxml/scxml.states.template.js +1 -14
  34. package/dist/render/scxml/scxml.template.js +1 -6
  35. package/dist/render/smcat/index.mjs +54 -39
  36. package/dist/render/smcat/smcat.template.js +1 -13
  37. package/dist/render/vector/dot-to-vector-native.mjs +30 -26
  38. package/dist/render/vector/vector-native-dot-with-fallback.mjs +27 -20
  39. package/dist/render/vector/vector-with-wasm.mjs +13 -6
  40. package/dist/state-machine-model.mjs +67 -52
  41. package/dist/transform/desugar.mjs +115 -66
  42. package/dist/transform/utl.mjs +12 -12
  43. package/dist/version.mjs +1 -1
  44. package/package.json +74 -74
  45. package/types/state-machine-cat.d.mts +209 -209
  46. package/types/state-machine-cat.d.ts +0 -296
@@ -1,170 +1,187 @@
1
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: "The name and identifier of the state. Unique within the root state machine.",
65
- type: "string",
66
- },
67
- type: {
68
- description: "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.",
69
- $ref: "#/definitions/StateType",
70
- },
71
- label: {
72
- description: "The display label of the state. If it's not present, most renderers will use the states' name in stead.",
73
- type: "string",
74
- },
75
- color: {
76
- description: 'Color to use for rendering the state. Accepts all css color names ("blue") and hex notation - with ("#0000FF77") or without ("#0000FF") transparency.',
77
- type: "string",
78
- },
79
- class: {
80
- description: "Class name to give the state in dot and svg output.",
81
- $ref: "#/definitions/ClassType",
82
- },
83
- active: {
84
- description: "If true the state is considered to be active and rendered as such.",
85
- type: "boolean",
86
- },
87
- typeExplicitlySet: {
88
- description: "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).",
89
- type: "boolean",
90
- },
91
- isComposite: {
92
- description: "convenience, derived attribute - set to true if there's a state machine inside the state; false in all other cases. For internal use - @deprecated",
93
- type: "boolean",
94
- },
95
- actions: {
96
- type: "array",
97
- description: "A series of actions and their types. The type describe when the action takes place (on entry, exit, or otherwise ('activity'))",
98
- items: { $ref: "#/definitions/ActionType" },
99
- },
100
- note: {
101
- description: "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.",
102
- $ref: "#/definitions/NoteType",
103
- },
104
- statemachine: {
105
- description: "state machine nested within the state.",
106
- $ref: "#/definitions/StateMachineType",
107
- },
108
- },
109
- },
110
- },
111
- transitions: {
112
- type: "array",
113
- items: {
114
- type: "object",
115
- required: ["from", "to"],
116
- additionalProperties: false,
117
- properties: {
118
- from: {
119
- description: "The name of the state this transition transitions from",
120
- type: "string",
121
- },
122
- to: {
123
- description: "The name of the state this transition transitions to",
124
- type: "string",
125
- },
126
- label: {
127
- description: "A display label to represent this transition. Parsers can parse this label into events conditions and actions.",
128
- type: "string",
129
- },
130
- event: {
131
- description: "Event triggering the transition",
132
- type: "string",
133
- },
134
- cond: {
135
- description: "Condition for the transition to occur.",
136
- type: "string",
137
- },
138
- action: {
139
- description: "Action to execute when the transition occurs.",
140
- type: "string",
141
- },
142
- note: {
143
- description: "Comments related to this transition",
144
- $ref: "#/definitions/NoteType",
145
- },
146
- color: {
147
- description: 'Color to use for rendering the transition. Accepts all css color names ("blue") and hex notation - with ("#0000FF77") or without ("#0000FF") transparency.',
148
- type: "string",
149
- },
150
- width: {
151
- description: "The line width to use for rendering the transition",
152
- type: "number",
153
- minimum: 0,
154
- maximum: 30,
155
- },
156
- class: {
157
- description: "Class name to give the state in dot and svg output.",
158
- $ref: "#/definitions/ClassType",
159
- },
160
- type: {
161
- description: "Whether the transition is external (default) or internal. See https://www.w3.org/TR/scxml/#transition for details.",
162
- $ref: "#/definitions/TransitionType",
163
- },
164
- },
165
- },
166
- },
167
- },
168
- },
169
- },
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: ["from", "to"],
126
+ additionalProperties: false,
127
+ properties: {
128
+ from: {
129
+ description:
130
+ "The name of the state this transition transitions from",
131
+ type: "string",
132
+ },
133
+ to: {
134
+ description:
135
+ "The name of the state this transition transitions to",
136
+ type: "string",
137
+ },
138
+ label: {
139
+ description:
140
+ "A display label to represent this transition. Parsers can parse this label into events conditions and actions.",
141
+ type: "string",
142
+ },
143
+ event: {
144
+ description: "Event triggering the transition",
145
+ type: "string",
146
+ },
147
+ cond: {
148
+ description: "Condition for the transition to occur.",
149
+ type: "string",
150
+ },
151
+ action: {
152
+ description: "Action to execute when the transition occurs.",
153
+ type: "string",
154
+ },
155
+ note: {
156
+ description: "Comments related to this transition",
157
+ $ref: "#/definitions/NoteType",
158
+ },
159
+ color: {
160
+ description:
161
+ 'Color to use for rendering the transition. Accepts all css color names ("blue") and hex notation - with ("#0000FF77") or without ("#0000FF") transparency.',
162
+ type: "string",
163
+ },
164
+ width: {
165
+ description:
166
+ "The line width to use for rendering the transition",
167
+ type: "number",
168
+ minimum: 0,
169
+ maximum: 30,
170
+ },
171
+ class: {
172
+ description:
173
+ "Class name to give the state in dot and svg output.",
174
+ $ref: "#/definitions/ClassType",
175
+ },
176
+ type: {
177
+ description:
178
+ "Whether the transition is external (default) or internal. See https://www.w3.org/TR/scxml/#transition for details.",
179
+ $ref: "#/definitions/TransitionType",
180
+ },
181
+ },
182
+ },
183
+ },
184
+ },
185
+ },
186
+ },
170
187
  };
@@ -1,51 +1,54 @@
1
1
  const GENERIC_GRAPH_ATTRIBUTES = [
2
- { name: "fontname", value: '"Helvetica"' },
3
- { name: "fontsize", value: "12" },
4
- { name: "penwidth", value: "2.0" },
2
+ { name: "fontname", value: '"Helvetica"' },
3
+ { name: "fontsize", value: "12" },
4
+ { name: "penwidth", value: "2.0" },
5
5
  ];
6
6
  const GRAPH_ATTRIBUTES = {
7
- dot: [
8
- { name: "splines", value: "true" },
9
- { name: "ordering", value: "out" },
10
- { name: "compound", value: "true" },
11
- { name: "overlap", value: "scale" },
12
- { name: "nodesep", value: "0.3" },
13
- { name: "ranksep", value: "0.1" },
14
- ],
15
- fdp: [{ name: "K", value: "0.9" }],
16
- osage: [{ name: "pack", value: "42" }],
17
- neato: [{ name: "epsilon", value: "0.9" }],
7
+ dot: [
8
+ { name: "splines", value: "true" },
9
+ { name: "ordering", value: "out" },
10
+ { name: "compound", value: "true" },
11
+ { name: "overlap", value: "scale" },
12
+ { name: "nodesep", value: "0.3" },
13
+ { name: "ranksep", value: "0.1" },
14
+ ],
15
+ fdp: [{ name: "K", value: "0.9" }],
16
+ osage: [{ name: "pack", value: "42" }],
17
+ neato: [{ name: "epsilon", value: "0.9" }],
18
18
  };
19
19
  const DIRECTION_ATTRIBUTES = {
20
- "bottom-top": [{ name: "rankdir", value: "BT" }],
21
- "left-right": [{ name: "rankdir", value: "LR" }],
22
- "right-left": [{ name: "rankdir", value: "RL" }],
20
+ "bottom-top": [{ name: "rankdir", value: "BT" }],
21
+ "left-right": [{ name: "rankdir", value: "LR" }],
22
+ "right-left": [{ name: "rankdir", value: "RL" }],
23
23
  };
24
24
  const NODE_ATTRIBUTES = [
25
- { name: "shape", value: "plaintext" },
26
- { name: "style", value: "filled" },
27
- { name: "fillcolor", value: '"#FFFFFF01"' },
28
- { name: "fontname", value: "Helvetica" },
29
- { name: "fontsize", value: 12 },
30
- { name: "penwidth", value: "2.0" },
25
+ { name: "shape", value: "plaintext" },
26
+ { name: "style", value: "filled" },
27
+ { name: "fillcolor", value: '"#FFFFFF01"' },
28
+ { name: "fontname", value: "Helvetica" },
29
+ { name: "fontsize", value: 12 },
30
+ { name: "penwidth", value: "2.0" },
31
31
  ];
32
32
  const EDGE_ATTRIBUTES = [
33
- { name: "fontname", value: "Helvetica" },
34
- { name: "fontsize", value: 10 },
33
+ { name: "fontname", value: "Helvetica" },
34
+ { name: "fontsize", value: 10 },
35
35
  ];
36
36
  function toNameValueString(pAttribute) {
37
- return `${pAttribute.name}=${pAttribute.value}`;
37
+ return `${pAttribute.name}=${pAttribute.value}`;
38
38
  }
39
39
  export default {
40
- buildGraphAttributes: (pEngine, pDirection, pDotGraphAttributes) => GENERIC_GRAPH_ATTRIBUTES.concat(GRAPH_ATTRIBUTES[pEngine] || [])
41
- .concat(DIRECTION_ATTRIBUTES[pDirection] || [])
42
- .concat(pDotGraphAttributes || [])
43
- .map(toNameValueString)
44
- .join(" "),
45
- buildNodeAttributes: (pDotNodeAttributes) => NODE_ATTRIBUTES.concat(pDotNodeAttributes || [])
46
- .map(toNameValueString)
47
- .join(" "),
48
- buildEdgeAttributes: (pDotEdgeAttributes) => EDGE_ATTRIBUTES.concat(pDotEdgeAttributes || [])
49
- .map(toNameValueString)
50
- .join(" "),
40
+ buildGraphAttributes: (pEngine, pDirection, pDotGraphAttributes) =>
41
+ GENERIC_GRAPH_ATTRIBUTES.concat(GRAPH_ATTRIBUTES[pEngine] || [])
42
+ .concat(DIRECTION_ATTRIBUTES[pDirection] || [])
43
+ .concat(pDotGraphAttributes || [])
44
+ .map(toNameValueString)
45
+ .join(" "),
46
+ buildNodeAttributes: (pDotNodeAttributes) =>
47
+ NODE_ATTRIBUTES.concat(pDotNodeAttributes || [])
48
+ .map(toNameValueString)
49
+ .join(" "),
50
+ buildEdgeAttributes: (pDotEdgeAttributes) =>
51
+ EDGE_ATTRIBUTES.concat(pDotEdgeAttributes || [])
52
+ .map(toNameValueString)
53
+ .join(" "),
51
54
  };
@@ -1,16 +1,16 @@
1
1
  export default class Counter {
2
- COUNTER = 0;
3
- constructor() {
4
- this.reset();
5
- }
6
- reset() {
7
- this.COUNTER = 0;
8
- }
9
- next() {
10
- return ++this.COUNTER;
11
- }
12
- nextAsString() {
13
- const lBase = 10;
14
- return this.next().toString(lBase);
15
- }
2
+ COUNTER = 0;
3
+ constructor() {
4
+ this.reset();
5
+ }
6
+ reset() {
7
+ this.COUNTER = 0;
8
+ }
9
+ next() {
10
+ return ++this.COUNTER;
11
+ }
12
+ nextAsString() {
13
+ const lBase = 10;
14
+ return this.next().toString(lBase);
15
+ }
16
16
  }