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,142 +1,142 @@
1
1
  export type StateType =
2
- | "regular"
3
- | "initial"
4
- | "final"
5
- | "parallel"
6
- | "choice"
7
- | "fork"
8
- | "forkjoin"
9
- | "history"
10
- | "deephistory"
11
- | "join"
12
- | "junction"
13
- | "terminate";
2
+ | "regular"
3
+ | "initial"
4
+ | "final"
5
+ | "parallel"
6
+ | "choice"
7
+ | "fork"
8
+ | "forkjoin"
9
+ | "history"
10
+ | "deephistory"
11
+ | "join"
12
+ | "junction"
13
+ | "terminate";
14
14
 
15
15
  export type TransitionType = "external" | "internal";
16
16
 
17
17
  export type ActionTypeType = "activity" | "entry" | "exit";
18
18
 
19
19
  export interface IActionType {
20
- body: string;
21
- type: ActionTypeType;
20
+ body: string;
21
+ type: ActionTypeType;
22
22
  }
23
23
 
24
24
  export interface IState {
25
- /**
26
- * The name and identifier of the state. Unique within the root state machine.
27
- */
28
- name: string;
29
- /**
30
- * What kind of state (or pseudo state) this state is. E.g. 'regular'
31
- * for normal states or 'initial', 'final', 'choice' etc for pseudo states
32
- */
33
- type: StateType;
34
- /**
35
- * The display label of the state. If it's not present, most renderers
36
- * will use the states' name in stead
37
- */
38
- label?: string;
39
- /**
40
- * A series of actions and their types. The type describe when the action
41
- * takes place (on entry, exit, or otherwise ('activity'))
42
- */
43
- actions?: IActionType[];
44
- /**
45
- * State machine nested within the state.
46
- */
47
- // eslint-disable-next-line no-use-before-define
48
- statemachine?: IStateMachine;
49
- /**
50
- * If true the state is considered to be active and rendered as such.
51
- */
52
- active?: boolean;
53
- /**
54
- * Color to use for rendering the state. Accepts all css color names
55
- * (\"blue\") and hex notation - with (\"#0000FF77\") or without
56
- * (\"#0000FF\") transparency.
57
- */
58
- color?: string;
59
- /**
60
- * Class name to give the state in dot and svg output.
61
- */
62
- class?: string;
63
- /**
64
- * Comments related to this state. Some renderers will use the note
65
- * attribute to render a note (i.e. as a post-it) attached to the
66
- * state.
67
- */
68
- note?: string[];
69
- /**
70
- * convenience, derived attribute - set to true if there's a state
71
- * machine inside the state; false in all other cases. For internal
72
- * use - @deprecated
73
- */
74
- isComposite?: boolean;
75
- /**
76
- * The default parser derives the `type` from the `name` with inband
77
- * signaling. The user can override that behavior by explicitly setting
78
- * the `type`. This attribute is there to express that (and make sure
79
- * that on next parses & processing it doesn't get accidentily
80
- * re-derived from the name again)
81
- */
82
- typeExplicitlySet?: boolean;
25
+ /**
26
+ * The name and identifier of the state. Unique within the root state machine.
27
+ */
28
+ name: string;
29
+ /**
30
+ * What kind of state (or pseudo state) this state is. E.g. 'regular'
31
+ * for normal states or 'initial', 'final', 'choice' etc for pseudo states
32
+ */
33
+ type: StateType;
34
+ /**
35
+ * The display label of the state. If it's not present, most renderers
36
+ * will use the states' name in stead
37
+ */
38
+ label?: string;
39
+ /**
40
+ * A series of actions and their types. The type describe when the action
41
+ * takes place (on entry, exit, or otherwise ('activity'))
42
+ */
43
+ actions?: IActionType[];
44
+ /**
45
+ * State machine nested within the state.
46
+ */
47
+ // eslint-disable-next-line no-use-before-define
48
+ statemachine?: IStateMachine;
49
+ /**
50
+ * If true the state is considered to be active and rendered as such.
51
+ */
52
+ active?: boolean;
53
+ /**
54
+ * Color to use for rendering the state. Accepts all css color names
55
+ * (\"blue\") and hex notation - with (\"#0000FF77\") or without
56
+ * (\"#0000FF\") transparency.
57
+ */
58
+ color?: string;
59
+ /**
60
+ * Class name to give the state in dot and svg output.
61
+ */
62
+ class?: string;
63
+ /**
64
+ * Comments related to this state. Some renderers will use the note
65
+ * attribute to render a note (i.e. as a post-it) attached to the
66
+ * state.
67
+ */
68
+ note?: string[];
69
+ /**
70
+ * convenience, derived attribute - set to true if there's a state
71
+ * machine inside the state; false in all other cases. For internal
72
+ * use - @deprecated
73
+ */
74
+ isComposite?: boolean;
75
+ /**
76
+ * The default parser derives the `type` from the `name` with inband
77
+ * signaling. The user can override that behavior by explicitly setting
78
+ * the `type`. This attribute is there to express that (and make sure
79
+ * that on next parses & processing it doesn't get accidentily
80
+ * re-derived from the name again)
81
+ */
82
+ typeExplicitlySet?: boolean;
83
83
  }
84
84
 
85
85
  export interface ITransition {
86
- /**
87
- * The name of the IState the transition is from
88
- */
89
- from: string;
90
- /**
91
- * The name of the IState the transition is to
92
- */
93
- to: string;
94
- /**
95
- * A display label to represent this transition. Parsers can parse this
96
- * label into events conditions and actions.
97
- */
98
- label?: string;
99
- /**
100
- * Event triggering the transition
101
- */
102
- event?: string;
103
- /**
104
- * Condition for the transition to occur.
105
- */
106
- cond?: string;
107
- /**
108
- * Action to execute when the transition occurs.
109
- */
110
- action?: string;
111
- /**
112
- * Comments related to this transition. Some renderers will use the note
113
- * attribute to render a note attached to the transition.
114
- */
115
- note?: string[];
116
- /**
117
- * Color to use for rendering the transition. Accepts all css color
118
- * names (\"blue\") and hex notation - with (\"#0000FF77\") or without
119
- * (\"#0000FF\") transparency.
120
- */
121
- color?: string;
122
- /**
123
- * The line width to use for rendering the transition
124
- */
125
- width?: number;
126
- /**
127
- * Class name to give the transition in dot and svg output.
128
- */
129
- class?: string;
130
- /**
131
- * Whether the transition is "external" (the default) or "internal".
132
- * See https://www.w3.org/TR/scxml/#transition for details.
133
- */
134
- type?: TransitionType;
86
+ /**
87
+ * The name of the IState the transition is from
88
+ */
89
+ from: string;
90
+ /**
91
+ * The name of the IState the transition is to
92
+ */
93
+ to: string;
94
+ /**
95
+ * A display label to represent this transition. Parsers can parse this
96
+ * label into events conditions and actions.
97
+ */
98
+ label?: string;
99
+ /**
100
+ * Event triggering the transition
101
+ */
102
+ event?: string;
103
+ /**
104
+ * Condition for the transition to occur.
105
+ */
106
+ cond?: string;
107
+ /**
108
+ * Action to execute when the transition occurs.
109
+ */
110
+ action?: string;
111
+ /**
112
+ * Comments related to this transition. Some renderers will use the note
113
+ * attribute to render a note attached to the transition.
114
+ */
115
+ note?: string[];
116
+ /**
117
+ * Color to use for rendering the transition. Accepts all css color
118
+ * names (\"blue\") and hex notation - with (\"#0000FF77\") or without
119
+ * (\"#0000FF\") transparency.
120
+ */
121
+ color?: string;
122
+ /**
123
+ * The line width to use for rendering the transition
124
+ */
125
+ width?: number;
126
+ /**
127
+ * Class name to give the transition in dot and svg output.
128
+ */
129
+ class?: string;
130
+ /**
131
+ * Whether the transition is "external" (the default) or "internal".
132
+ * See https://www.w3.org/TR/scxml/#transition for details.
133
+ */
134
+ type?: TransitionType;
135
135
  }
136
136
 
137
137
  export interface IStateMachine {
138
- states: IState[];
139
- transitions?: ITransition[];
138
+ states: IState[];
139
+ transitions?: ITransition[];
140
140
  }
141
141
 
142
142
  /**
@@ -149,24 +149,24 @@ export interface IStateMachine {
149
149
  export const version: string;
150
150
 
151
151
  export interface IAllowedValue {
152
- default: string;
153
- values: {
154
- name: string;
155
- }[];
152
+ default: string;
153
+ values: {
154
+ name: string;
155
+ }[];
156
156
  }
157
157
 
158
158
  export interface IAllowedBooleanValue {
159
- default: boolean;
160
- values: {
161
- name: boolean;
162
- }[];
159
+ default: boolean;
160
+ values: {
161
+ name: boolean;
162
+ }[];
163
163
  }
164
164
  export interface IAllowedValues {
165
- inputType: IAllowedValue;
166
- outputType: IAllowedValue;
167
- engine: IAllowedValue;
168
- direction: IAllowedValue;
169
- desugar: IAllowedBooleanValue;
165
+ inputType: IAllowedValue;
166
+ outputType: IAllowedValue;
167
+ engine: IAllowedValue;
168
+ direction: IAllowedValue;
169
+ desugar: IAllowedBooleanValue;
170
170
  }
171
171
 
172
172
  /**
@@ -183,98 +183,98 @@ export function getAllowedValues(): IAllowedValues;
183
183
  export type InputType = "smcat" | "json" | "scxml";
184
184
 
185
185
  export type OutputType =
186
- | "ast"
187
- | "dot"
188
- | "eps"
189
- | "json"
190
- | "oldeps"
191
- | "oldps"
192
- | "oldps2"
193
- | "oldsvg"
194
- | "pdf"
195
- | "png"
196
- | "ps"
197
- | "ps2"
198
- | "scjson"
199
- | "scxml"
200
- | "smcat"
201
- | "svg";
186
+ | "ast"
187
+ | "dot"
188
+ | "eps"
189
+ | "json"
190
+ | "oldeps"
191
+ | "oldps"
192
+ | "oldps2"
193
+ | "oldsvg"
194
+ | "pdf"
195
+ | "png"
196
+ | "ps"
197
+ | "ps2"
198
+ | "scjson"
199
+ | "scxml"
200
+ | "smcat"
201
+ | "svg";
202
202
 
203
203
  export type EngineType = "dot" | "circo" | "fdp" | "neato" | "osage" | "twopi";
204
204
 
205
205
  export type DirectionType =
206
- | "top-down"
207
- | "bottom-top"
208
- | "left-right"
209
- | "right-left";
206
+ | "top-down"
207
+ | "bottom-top"
208
+ | "left-right"
209
+ | "right-left";
210
210
 
211
211
  export type dotAttributesType = {
212
- name: string;
213
- value: string;
212
+ name: string;
213
+ value: string;
214
214
  }[];
215
215
 
216
216
  export interface IBaseRenderOptions {
217
- /**
218
- * How to interpret the input (defaults to 'smcat')
219
- */
220
- inputType?: InputType;
221
- /**
222
- * What renderer to use (defaults to 'svg')
223
- */
224
- outputType?: OutputType;
225
- /**
226
- * For the 'dot' renderer: what engine to use (defaults to 'dot')
227
- */
228
- engine?: EngineType;
229
- /**
230
- * For the 'dot' renderer: in what direction to plot the states
231
- * (defaults to 'top-down')
232
- */
233
- direction?: DirectionType;
234
- /**
235
- * If true state machine cat will replace 'sugar' pseudo states
236
- * (choice, forks and junctions) with their equivalent meaning
237
- * (defaults to false).
238
- *
239
- * For details: https://github.com/sverweij/state-machine-cat/blob/main/docs/desugar.md
240
- */
241
- desugar?: boolean;
217
+ /**
218
+ * How to interpret the input (defaults to 'smcat')
219
+ */
220
+ inputType?: InputType;
221
+ /**
222
+ * What renderer to use (defaults to 'svg')
223
+ */
224
+ outputType?: OutputType;
225
+ /**
226
+ * For the 'dot' renderer: what engine to use (defaults to 'dot')
227
+ */
228
+ engine?: EngineType;
229
+ /**
230
+ * For the 'dot' renderer: in what direction to plot the states
231
+ * (defaults to 'top-down')
232
+ */
233
+ direction?: DirectionType;
234
+ /**
235
+ * If true state machine cat will replace 'sugar' pseudo states
236
+ * (choice, forks and junctions) with their equivalent meaning
237
+ * (defaults to false).
238
+ *
239
+ * For details: https://github.com/sverweij/state-machine-cat/blob/main/docs/desugar.md
240
+ */
241
+ desugar?: boolean;
242
242
  }
243
243
 
244
244
  export interface IRenderOptions extends IBaseRenderOptions {
245
- /**
246
- * For the 'dot' renderer: Graph attributes to the engine
247
- */
248
- dotGraphAttrs?: dotAttributesType;
249
- /**
250
- * For the 'dot' renderer: Node attributes to the engine
251
- */
252
- dotNodeAttrs?: dotAttributesType;
253
- /**
254
- * For the 'dot' renderer: Edge attributes to the engine
255
- */
256
- dotEdgeAttrs?: dotAttributesType;
257
- /**
258
- * On nodejs don't display the warning that GraphViz 'dot'
259
- * can't be found and we're falling back to wasm
260
- */
261
- noDotNativeWarning?: boolean;
245
+ /**
246
+ * For the 'dot' renderer: Graph attributes to the engine
247
+ */
248
+ dotGraphAttrs?: dotAttributesType;
249
+ /**
250
+ * For the 'dot' renderer: Node attributes to the engine
251
+ */
252
+ dotNodeAttrs?: dotAttributesType;
253
+ /**
254
+ * For the 'dot' renderer: Edge attributes to the engine
255
+ */
256
+ dotEdgeAttrs?: dotAttributesType;
257
+ /**
258
+ * On nodejs don't display the warning that GraphViz 'dot'
259
+ * can't be found and we're falling back to wasm
260
+ */
261
+ noDotNativeWarning?: boolean;
262
262
  }
263
263
 
264
264
  export type StringRenderFunctionType = (
265
- pStateMachine: IStateMachine,
266
- pOptions?: IRenderOptions,
265
+ pStateMachine: IStateMachine,
266
+ pOptions?: IRenderOptions,
267
267
  ) => string;
268
268
 
269
269
  export type WhateverRenderFunctionType = (
270
- pStateMachine: IStateMachine,
271
- pOptions?: IRenderOptions,
272
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
270
+ pStateMachine: IStateMachine,
271
+ pOptions?: IRenderOptions,
272
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
273
273
  ) => any;
274
274
 
275
275
  export type RenderFunctionType =
276
- | StringRenderFunctionType
277
- | WhateverRenderFunctionType;
276
+ | StringRenderFunctionType
277
+ | WhateverRenderFunctionType;
278
278
 
279
279
  /**
280
280
  * Translates the input script to an output script.
@@ -291,6 +291,6 @@ export type RenderFunctionType =
291
291
  *
292
292
  */
293
293
  export function render(
294
- pScript: IStateMachine | string,
295
- pOptions: IRenderOptions,
294
+ pScript: IStateMachine | string,
295
+ pOptions: IRenderOptions,
296
296
  ): string;