state-machine-cat 10.1.1 → 10.1.3

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 (36) hide show
  1. package/README.md +1 -1
  2. package/bin/smcat.mjs +5 -0
  3. package/dist/commonjs/bundle.js +64 -64
  4. package/package.json +33 -32
  5. package/src/cli/actions.mjs +9 -0
  6. package/src/cli/file-name-to-stream.mjs +5 -6
  7. package/src/cli/make-description.mjs +9 -0
  8. package/src/cli/normalize.mjs +79 -41
  9. package/src/cli/validations.mjs +27 -1
  10. package/src/index-node.mjs +15 -47
  11. package/src/index.mjs +9 -9
  12. package/src/options.mjs +19 -13
  13. package/src/parse/index.mjs +13 -0
  14. package/src/parse/parser-helpers.mjs +70 -6
  15. package/src/parse/scxml/index.mjs +40 -1
  16. package/src/parse/scxml/normalize-machine.mjs +1 -1
  17. package/src/render/dot/attributebuilder.mjs +7 -0
  18. package/src/render/dot/counter.mjs +13 -0
  19. package/src/render/dot/index.mjs +66 -28
  20. package/src/render/dot/render-dot-from-ast.js +37 -15
  21. package/src/render/dot/state-transformers.mjs +4 -2
  22. package/src/render/dot/utl.mjs +20 -0
  23. package/src/render/index-node.mjs +9 -3
  24. package/src/render/index.mjs +3 -3
  25. package/src/render/scjson/index.mjs +6 -0
  26. package/src/render/scjson/make-valid-xml-name.mjs +7 -1
  27. package/src/render/scxml/index.mjs +3 -1
  28. package/src/render/smcat/index.js +48 -14
  29. package/src/render/vector/dot-to-vector-native.mjs +1 -1
  30. package/src/render/vector/vector-native-dot-with-fallback.mjs +3 -2
  31. package/src/render/vector/vector-with-viz-js.mjs +3 -2
  32. package/src/state-machine-model.mjs +46 -4
  33. package/src/transform/desugar.mjs +67 -18
  34. package/src/transform/utl.mjs +8 -0
  35. package/src/version.mjs +2 -1
  36. package/types/state-machine-cat.d.ts +41 -14
@@ -183,13 +183,22 @@ export function getAllowedValues(): IAllowedValues;
183
183
  export type InputType = "smcat" | "json" | "scxml";
184
184
 
185
185
  export type OutputType =
186
- | "smcat"
186
+ | "ast"
187
187
  | "dot"
188
+ | "eps"
188
189
  | "json"
189
- | "ast"
190
- | "svg"
190
+ | "oldeps"
191
+ | "oldps"
192
+ | "oldps2"
193
+ | "oldsvg"
194
+ | "pdf"
195
+ | "png"
196
+ | "ps"
197
+ | "ps2"
191
198
  | "scjson"
192
- | "scxml";
199
+ | "scxml"
200
+ | "smcat"
201
+ | "svg";
193
202
 
194
203
  export type EngineType = "dot" | "circo" | "fdp" | "neato" | "osage" | "twopi";
195
204
 
@@ -204,7 +213,7 @@ export type dotAttributesType = {
204
213
  value: string;
205
214
  }[];
206
215
 
207
- export interface IRenderOptions {
216
+ export interface IBaseRenderOptions {
208
217
  /**
209
218
  * How to interpret the input (defaults to 'smcat')
210
219
  */
@@ -222,6 +231,17 @@ export interface IRenderOptions {
222
231
  * (defaults to 'top-down')
223
232
  */
224
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/master/docs/desugar.md
240
+ */
241
+ desugar?: boolean;
242
+ }
243
+
244
+ export interface IRenderOptions extends IBaseRenderOptions {
225
245
  /**
226
246
  * For the 'dot' renderer: Graph attributes to the engine
227
247
  */
@@ -234,18 +254,25 @@ export interface IRenderOptions {
234
254
  * For the 'dot' renderer: Edge attributes to the engine
235
255
  */
236
256
  dotEdgeAttrs?: dotAttributesType;
237
- /**
238
- * If true state machine cat will replace 'sugar' pseudo states
239
- * (choice, forks and junctions) with their equivalent meaning
240
- * (defaults to false).
241
- *
242
- * For details: https://github.com/sverweij/state-machine-cat/blob/master/docs/desugar.md
243
- */
244
- desugar?: boolean;
245
257
  }
246
258
 
259
+ export type StringRenderFunctionType = (
260
+ pScript: IStateMachine,
261
+ pOptions: IRenderOptions
262
+ ) => string;
263
+
264
+ export type WhateverRenderFunctionType = (
265
+ pScript: IStateMachine,
266
+ pOptions: IRenderOptions
267
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
268
+ ) => any;
269
+
270
+ export type RenderFunctionType =
271
+ | StringRenderFunctionType
272
+ | WhateverRenderFunctionType;
273
+
247
274
  /**
248
- * Translates the input script to an outputscript.
275
+ * Translates the input script to an output script.
249
276
  *
250
277
  * @param pScript The script to translate
251
278
  * @param pOptions options influencing parsing & rendering.