state-machine-cat 11.0.0 → 11.0.4
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/LICENSE +1 -1
- package/README.md +23 -32
- package/bin/smcat.mjs +3 -2
- package/dist/esm/cli/actions.mjs +1 -1
- package/dist/esm/render/index-node.mjs +1 -1
- package/dist/esm/render/index.mjs +1 -1
- package/dist/esm/render/vector/vector-native-dot-with-fallback.mjs +10 -13
- package/dist/esm/render/vector/vector-with-wasm.mjs +17 -0
- package/dist/esm/version.mjs +1 -1
- package/package.json +20 -34
- package/types/state-machine-cat.d.ts +6 -1
- package/dist/esm/cli/make-description.mjs +0 -21
- package/dist/esm/render/vector/vector-with-viz-js.mjs +0 -13
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
_write beautiful state charts_
|
|
4
4
|
|
|
5
|
-
[](https://github.com/sverweij/state-machine-cat/actions/workflows/ci.yml)
|
|
6
|
+
[](https://gitlab.com/sverweij/state-machine-cat/builds)
|
|
7
7
|
[](https://snyk.io/test/github/sverweij/state-machine-cat?targetFile=package.json)
|
|
8
8
|
[](https://codeclimate.com/github/sverweij/state-machine-cat/maintainability)
|
|
9
9
|
[](https://npmjs.com/package/state-machine-cat)
|
|
@@ -14,7 +14,7 @@ _write beautiful state charts_
|
|
|
14
14
|
|
|
15
15
|
Makes this
|
|
16
16
|
|
|
17
|
-
<img width="853" alt="docs/pics/sample.png" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
17
|
+
<img width="853" alt="docs/pics/sample.png" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/sample.png">
|
|
18
18
|
|
|
19
19
|
from this
|
|
20
20
|
|
|
@@ -96,14 +96,6 @@ Options:
|
|
|
96
96
|
bin/smcat docs/sample.smcat
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
> <details>
|
|
100
|
-
> <summary>note for when GraphViz `dot` isn't installed</summary>
|
|
101
|
-
> You might see a warning message on stderr:
|
|
102
|
-
> <code>Invalid asm.js: Function definition doesn't match use</code>.
|
|
103
|
-
> It's generated by viz.js that serves as a fully functional fallback
|
|
104
|
-
> for GraphViz `dot` . See <a href="docs/faq.md#viz">the FAQ</a> for details.
|
|
105
|
-
> </details>
|
|
106
|
-
|
|
107
99
|
Or, if you'd rather pull dot output through GraphViz dot yourself:
|
|
108
100
|
|
|
109
101
|
```sh
|
|
@@ -177,7 +169,7 @@ tags like `<script type="text/x-smcat"></script>`. Documentation for that
|
|
|
177
169
|
on => off;
|
|
178
170
|
```
|
|
179
171
|
|
|
180
|
-
<img width="206" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
172
|
+
<img width="206" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/00simplest.png">
|
|
181
173
|
|
|
182
174
|
- _smcat_ automatically declares the states. You _can_ explicitly declare
|
|
183
175
|
them if you want them to have more than a name only - see _state
|
|
@@ -189,7 +181,7 @@ on => off;
|
|
|
189
181
|
on => off: switch;
|
|
190
182
|
```
|
|
191
183
|
|
|
192
|
-
<img width="251" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
184
|
+
<img width="251" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/01labels.png">
|
|
193
185
|
|
|
194
186
|
UML prescribes to place _conditions_ after _events_, to place
|
|
195
187
|
_conditions_ within squares and to place _actions_
|
|
@@ -206,7 +198,7 @@ off => on: switch flicked/
|
|
|
206
198
|
light on;
|
|
207
199
|
```
|
|
208
200
|
|
|
209
|
-
<img width="202" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
201
|
+
<img width="202" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/01labels_better.png">
|
|
210
202
|
|
|
211
203
|
> You note that smcat rendered the states in this chart _top down_ instead of
|
|
212
204
|
> _left to right_. It did that because we told it so. You can do that too
|
|
@@ -219,7 +211,7 @@ off => on: switch flicked/
|
|
|
219
211
|
on => off;
|
|
220
212
|
```
|
|
221
213
|
|
|
222
|
-
<img width="233" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
214
|
+
<img width="233" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/02notes.png">
|
|
223
215
|
|
|
224
216
|
#### state declarations
|
|
225
217
|
|
|
@@ -237,7 +229,7 @@ doing:
|
|
|
237
229
|
...;
|
|
238
230
|
```
|
|
239
231
|
|
|
240
|
-
<img width="478" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
232
|
+
<img width="478" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/04explicit_state_declarations.png">
|
|
241
233
|
|
|
242
234
|
_smcat_ recognizes the `entry/` and `exit/` keywords and treats
|
|
243
235
|
everything after it on the same line to be the 'body' of the
|
|
@@ -261,7 +253,7 @@ off => on: on pushed;
|
|
|
261
253
|
on => off: off pushed;
|
|
262
254
|
```
|
|
263
255
|
|
|
264
|
-
<img width="296" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
256
|
+
<img width="296" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/09labeled_states.png">
|
|
265
257
|
|
|
266
258
|
#### `initial` and `final`
|
|
267
259
|
|
|
@@ -275,7 +267,7 @@ doing => done;
|
|
|
275
267
|
done => final;
|
|
276
268
|
```
|
|
277
269
|
|
|
278
|
-
<img width="375" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
270
|
+
<img width="375" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/03initial_and_final.png">
|
|
279
271
|
|
|
280
272
|
#### `history`
|
|
281
273
|
|
|
@@ -298,7 +290,7 @@ running => "power off": power out;
|
|
|
298
290
|
"power off" => running.history: restore power;
|
|
299
291
|
```
|
|
300
292
|
|
|
301
|
-
<img width="735" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
293
|
+
<img width="735" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/07history.png">
|
|
302
294
|
|
|
303
295
|
History states are _shallow_ by default. If you want a history state to
|
|
304
296
|
be _deep_ just put that somewhere in the name (e.g. `"running deep history"`
|
|
@@ -324,7 +316,7 @@ ticketed -> final;
|
|
|
324
316
|
removed -> final;
|
|
325
317
|
```
|
|
326
318
|
|
|
327
|
-
<img width="710" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
319
|
+
<img width="710" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/03achoice.png">
|
|
328
320
|
|
|
329
321
|
#### Forks, joins and junctions - `]`
|
|
330
322
|
|
|
@@ -342,7 +334,7 @@ b => ]join;
|
|
|
342
334
|
]join => c;
|
|
343
335
|
```
|
|
344
336
|
|
|
345
|
-
<img width="224" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
337
|
+
<img width="224" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/03bforkjoin.png">
|
|
346
338
|
|
|
347
339
|
> State machine cat automatically derives which of the three types
|
|
348
340
|
> you meant by counting the number of incoming and the number of
|
|
@@ -362,7 +354,7 @@ b => ]junction;
|
|
|
362
354
|
]junction => d;
|
|
363
355
|
```
|
|
364
356
|
|
|
365
|
-
<img width="224" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
357
|
+
<img width="224" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/03cjunction.png">
|
|
366
358
|
|
|
367
359
|
#### Terminate
|
|
368
360
|
|
|
@@ -376,7 +368,7 @@ Aahnohd [type=terminate label="Terminated"];
|
|
|
376
368
|
a => Aahnohd: [hit by meteorite];
|
|
377
369
|
```
|
|
378
370
|
|
|
379
|
-
<img width="321" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
371
|
+
<img width="321" alt="rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/03dterminate.png">
|
|
380
372
|
|
|
381
373
|
> For proper exits you'd typically use the _final_ state.
|
|
382
374
|
|
|
@@ -431,7 +423,7 @@ initial => "tape player off";
|
|
|
431
423
|
"tape player on" => "tape player off" : power;
|
|
432
424
|
```
|
|
433
425
|
|
|
434
|
-
<img width="653" alt="tape player rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
426
|
+
<img width="653" alt="tape player rendition" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/05tape_player.png">
|
|
435
427
|
|
|
436
428
|
#### parallel states
|
|
437
429
|
|
|
@@ -459,7 +451,7 @@ second.thang -> ]merge;
|
|
|
459
451
|
]merge -> final;
|
|
460
452
|
```
|
|
461
453
|
|
|
462
|
-
<img width="482" alt="parallel" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
454
|
+
<img width="482" alt="parallel" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/08parallel.png">
|
|
463
455
|
|
|
464
456
|
#### `internal` and `external` transitions
|
|
465
457
|
|
|
@@ -498,7 +490,7 @@ act -> plan;
|
|
|
498
490
|
|
|
499
491
|
which will result in
|
|
500
492
|
|
|
501
|
-
<img width="424" alt="active states" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
493
|
+
<img width="424" alt="active states" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/11active_state.png">
|
|
502
494
|
|
|
503
495
|
#### colors and line width
|
|
504
496
|
|
|
@@ -523,7 +515,7 @@ eat -> sleep [color="blue" width=3.5] : belly full;
|
|
|
523
515
|
|
|
524
516
|
... would yield this diagram:
|
|
525
517
|
|
|
526
|
-
<img width="659" alt="colored states and transitions" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
518
|
+
<img width="659" alt="colored states and transitions" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/10colored_states_and_transitions.png">
|
|
527
519
|
|
|
528
520
|
What does 'experimental' mean?
|
|
529
521
|
|
|
@@ -623,7 +615,7 @@ running => stopped;
|
|
|
623
615
|
stopped => final;
|
|
624
616
|
```
|
|
625
617
|
|
|
626
|
-
<img width="520" alt="colored states and transitions" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
618
|
+
<img width="520" alt="colored states and transitions" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/12state_type_overrides.png">
|
|
627
619
|
|
|
628
620
|
The values you can use for the `type` of a state:
|
|
629
621
|
|
|
@@ -651,11 +643,10 @@ I made the parser with peggy - you can find it at
|
|
|
651
643
|
|
|
652
644
|
- Thoroughly tested and good enough for public use.
|
|
653
645
|
- Despite this you might bump into the occasional issue - don't hesitate to
|
|
654
|
-
report it
|
|
655
|
-
|
|
656
|
-
- Runs on latest versions of firefox, safari and chrome and node versions >= 14.13.1.
|
|
646
|
+
report it on [GitHub](https://github.com/sverweij/state-machine-cat/issues).
|
|
647
|
+
- Runs on latest versions of firefox, safari and chrome and node versions >= 16.14.0
|
|
657
648
|
Although it might run on other environments, it's not tested there. I will
|
|
658
649
|
reject issues on these other environments, unless they're accompanied with
|
|
659
650
|
sufficient enticement to make it worth my while.
|
|
660
651
|
|
|
661
|
-
<img width="640" alt="colored states and transitions" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/
|
|
652
|
+
<img width="640" alt="colored states and transitions" src="https://raw.githubusercontent.com/sverweij/state-machine-cat/main/docs/pics/state-machine-cat-social-sharing-picture.png">
|
package/bin/smcat.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import { readFileSync } from "node:fs";
|
|
|
4
4
|
import { program } from "commander";
|
|
5
5
|
import satisfies from "semver/functions/satisfies.js";
|
|
6
6
|
import actions from "../dist/esm/cli/actions.mjs";
|
|
7
|
-
import makeDescription from "../dist/esm/cli/make-description.mjs";
|
|
8
7
|
import normalize from "../dist/esm/cli/normalize.mjs";
|
|
9
8
|
import validations from "../dist/esm/cli/validations.mjs";
|
|
10
9
|
|
|
@@ -41,7 +40,9 @@ function presentError(pError) {
|
|
|
41
40
|
try {
|
|
42
41
|
program
|
|
43
42
|
.version($package.version)
|
|
44
|
-
.description(
|
|
43
|
+
.description(
|
|
44
|
+
"Write beautiful state charts - https://github.com/sverweij/state-machine-cat"
|
|
45
|
+
)
|
|
45
46
|
.option(
|
|
46
47
|
"-T --output-type <type>",
|
|
47
48
|
validations.validOutputTypeRE,
|
package/dist/esm/cli/actions.mjs
CHANGED
|
@@ -6,7 +6,7 @@ const LICENSE = `
|
|
|
6
6
|
|
|
7
7
|
The MIT License (MIT)
|
|
8
8
|
|
|
9
|
-
Copyright (c) 2016-
|
|
9
|
+
Copyright (c) 2016-2023 Sander Verweij
|
|
10
10
|
|
|
11
11
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
12
12
|
a copy of this software and associated documentation files (the
|
|
@@ -2,7 +2,7 @@ import has from "lodash/has.js";
|
|
|
2
2
|
import smcatRendererAsImported from "./smcat/index.mjs";
|
|
3
3
|
import renderDot from "./dot/index.mjs";
|
|
4
4
|
import vector from "./vector/vector-native-dot-with-fallback.mjs";
|
|
5
|
-
import oldVector from "./vector/vector-with-
|
|
5
|
+
import oldVector from "./vector/vector-with-wasm.mjs";
|
|
6
6
|
import scjson from "./scjson/index.mjs";
|
|
7
7
|
import scxml from "./scxml/index.mjs";
|
|
8
8
|
const smcat = smcatRendererAsImported;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import has from "lodash/has.js";
|
|
2
2
|
import smcatRendererAsImported from "./smcat/index.mjs";
|
|
3
3
|
import renderDot from "./dot/index.mjs";
|
|
4
|
-
import svg from "./vector/vector-with-
|
|
4
|
+
import svg from "./vector/vector-with-wasm.mjs";
|
|
5
5
|
import scjson from "./scjson/index.mjs";
|
|
6
6
|
import scxml from "./scxml/index.mjs";
|
|
7
7
|
const smcat = smcatRendererAsImported;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Graphviz } from "@hpcc-js/wasm/graphviz";
|
|
2
2
|
import indentString from "indent-string";
|
|
3
3
|
import wrapAnsi from "wrap-ansi";
|
|
4
4
|
import chalk from "chalk";
|
|
@@ -8,6 +8,7 @@ import dotToVectorNative from "./dot-to-vector-native.mjs";
|
|
|
8
8
|
const DEFAULT_INDENT = 2;
|
|
9
9
|
const DOGMATIC_CONSOLE_WIDTH = 78;
|
|
10
10
|
const VIZ_JS_UNSUPPORTED_OUTPUT_FORMATS = ["pdf", "png"];
|
|
11
|
+
const gGraphViz = await Graphviz.load();
|
|
11
12
|
const renderVector = (pStateMachine, pOptions) => {
|
|
12
13
|
const lDotProgram = ast2dot(pStateMachine, pOptions);
|
|
13
14
|
const lDotOptions = {
|
|
@@ -19,19 +20,15 @@ const renderVector = (pStateMachine, pOptions) => {
|
|
|
19
20
|
}
|
|
20
21
|
else {
|
|
21
22
|
if (VIZ_JS_UNSUPPORTED_OUTPUT_FORMATS.includes(lDotOptions.format)) {
|
|
22
|
-
throw new Error("GraphViz 'dot' executable not found. Falling back to
|
|
23
|
-
"
|
|
24
|
-
"select a format that it does
|
|
25
|
-
"(recommended), which has support for
|
|
23
|
+
throw new Error("GraphViz 'dot' executable not found. Falling back to wasm.\n\n" +
|
|
24
|
+
"The compiled-to-wasm version of GraphViz we use doesn't support the " +
|
|
25
|
+
"'pdf' and 'png' output formats. Either select a format that it does " +
|
|
26
|
+
"support or install GraphViz (recommended), which has support for " +
|
|
27
|
+
"both formats.\n");
|
|
26
28
|
}
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
"It's harmless and the svg will generate just fine. However, if " +
|
|
31
|
-
"you want to avoid the warning install GraphViz and make sure it's " +
|
|
32
|
-
"available in your path." +
|
|
33
|
-
"\n\n", DOGMATIC_CONSOLE_WIDTH), DEFAULT_INDENT));
|
|
34
|
-
return dotToSvgJs(lDotProgram, lDotOptions);
|
|
29
|
+
if (!pOptions?.noDotNativeWarning)
|
|
30
|
+
process.stderr.write(indentString(wrapAnsi(`\n${chalk.yellow("warning:")} GraphViz 'dot' executable not found. Falling back to wasm.\n\n`, DOGMATIC_CONSOLE_WIDTH), DEFAULT_INDENT));
|
|
31
|
+
return gGraphViz.layout(lDotProgram, lDotOptions.format, lDotOptions.engine);
|
|
35
32
|
}
|
|
36
33
|
};
|
|
37
34
|
export default renderVector;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Graphviz } from "@hpcc-js/wasm/graphviz";
|
|
2
|
+
import options from "../../options.mjs";
|
|
3
|
+
import ast2dot from "../dot/index.mjs";
|
|
4
|
+
const OUTPUT_TYPE2FORMAT = {
|
|
5
|
+
oldsvg: "svg",
|
|
6
|
+
oldps2: "ps2",
|
|
7
|
+
oldeps: "eps",
|
|
8
|
+
};
|
|
9
|
+
const gGraphViz = await Graphviz.load();
|
|
10
|
+
function getFormat(pOptions) {
|
|
11
|
+
return (OUTPUT_TYPE2FORMAT[options.getOptionValue(pOptions, "outputType")] || "svg");
|
|
12
|
+
}
|
|
13
|
+
function getEngine(pOptions) {
|
|
14
|
+
return options.getOptionValue(pOptions, "engine");
|
|
15
|
+
}
|
|
16
|
+
const renderVectorWithWasm = (pStateMachine, pOptions) => gGraphViz.layout(ast2dot(pStateMachine, pOptions), getFormat(pOptions), getEngine(pOptions));
|
|
17
|
+
export default renderVectorWithWasm;
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "11.0.
|
|
1
|
+
export const version = "11.0.4";
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "state-machine-cat",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.4",
|
|
4
4
|
"description": "write beautiful state charts",
|
|
5
|
-
"main": "./dist/
|
|
5
|
+
"main": "./dist/esm/index.mjs",
|
|
6
6
|
"module": "./dist/esm/index.mjs",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": [
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"depcruise:graph:doc:archi": "dependency-cruise bin src --config config/dependency-cruiser/graph.mjs --output-type archi | dot -T svg | tee docs/dependency-cruiser-archi-graph.svg | depcruise-wrap-stream-in-html > docs/dependency-cruiser-archi-graph.html",
|
|
27
27
|
"depcruise:graph:doc:deps": "dependency-cruise bin src --config config/dependency-cruiser/graph.mjs --output-type dot | dot -T svg | tee docs/dependency-cruiser-graph.svg | depcruise-wrap-stream-in-html > docs/dependency-cruiser-graph.html",
|
|
28
28
|
"depcruise:graph:doc:flat-deps": "dependency-cruise bin src --config config/dependency-cruiser/graph.mjs --output-type flat | dot -T svg | tee docs/dependency-cruiser-graph-flat-dot.svg | depcruise-wrap-stream-in-html > docs/dependency-cruiser-graph-flat-dot.html",
|
|
29
|
-
"depcruise:graph:dev": "dependency-cruise bin src --config config/dependency-cruiser/graph.mjs --output-type dot --prefix vscode://file/$(pwd)/ --highlight \"$(watskeburt
|
|
30
|
-
"depcruise:graph:dev:flat": "dependency-cruise bin src --config config/dependency-cruiser/graph.mjs --output-type flat --prefix vscode://file/$(pwd)/ --highlight \"$(watskeburt
|
|
29
|
+
"depcruise:graph:dev": "dependency-cruise bin src --config config/dependency-cruiser/graph.mjs --output-type dot --prefix vscode://file/$(pwd)/ --highlight \"$(watskeburt main)\"| dot -Tsvg | depcruise-wrap-stream-in-html | browser",
|
|
30
|
+
"depcruise:graph:dev:flat": "dependency-cruise bin src --config config/dependency-cruiser/graph.mjs --output-type flat --prefix vscode://file/$(pwd)/ --highlight \"$(watskeburt main)\"| twopi -Tsvg | depcruise-wrap-stream-in-html | browser",
|
|
31
31
|
"depcruise:view-report": "dependency-cruise bin src test types tools --config config/dependency-cruiser/base.mjs --output-type err-html --prefix vscode://file/$(pwd)/ | browser",
|
|
32
32
|
"depcruise:github-actions:markdown": "dependency-cruise bin src test types tools --config config/dependency-cruiser/base.mjs --output-type markdown",
|
|
33
33
|
"depcruise:github-actions:mermaid": "dependency-cruise bin src --config config/dependency-cruiser/graph.mjs --output-type mermaid",
|
|
@@ -71,20 +71,6 @@
|
|
|
71
71
|
"README.md",
|
|
72
72
|
"LICENSE"
|
|
73
73
|
],
|
|
74
|
-
"upem": {
|
|
75
|
-
"policies": [
|
|
76
|
-
{
|
|
77
|
-
"package": "viz.js",
|
|
78
|
-
"policy": "pin",
|
|
79
|
-
"because": "viz.js >=2 ditched its async interface, which we use. Will need some code reshuffling which is not worth it a.t.m."
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
"package": "dependency-cruiser",
|
|
83
|
-
"policy": "wanted",
|
|
84
|
-
"because": "we're beta testing dependency-cruiser v13 and the _latest_ policy would bump down to v12 again"
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
},
|
|
88
74
|
"keywords": [
|
|
89
75
|
"state",
|
|
90
76
|
"state chart",
|
|
@@ -104,36 +90,36 @@
|
|
|
104
90
|
"state-machine-cat": "bin/smcat.mjs"
|
|
105
91
|
},
|
|
106
92
|
"dependencies": {
|
|
93
|
+
"@hpcc-js/wasm": "2.13.0",
|
|
107
94
|
"ajv": "8.12.0",
|
|
108
95
|
"chalk": "5.2.0",
|
|
109
|
-
"commander": "10.0.
|
|
110
|
-
"fast-xml-parser": "4.2.
|
|
96
|
+
"commander": "10.0.1",
|
|
97
|
+
"fast-xml-parser": "4.2.2",
|
|
111
98
|
"get-stream": "6.0.1",
|
|
112
99
|
"handlebars": "4.7.7",
|
|
113
100
|
"he": "1.2.0",
|
|
114
101
|
"indent-string": "5.0.0",
|
|
115
102
|
"lodash": "4.17.21",
|
|
116
|
-
"semver": "^7.
|
|
103
|
+
"semver": "^7.5.1",
|
|
117
104
|
"traverse": "0.6.7",
|
|
118
|
-
"viz.js": "1.8.2",
|
|
119
105
|
"wrap-ansi": "8.1.0"
|
|
120
106
|
},
|
|
121
107
|
"devDependencies": {
|
|
122
|
-
"@types/chai": "4.3.
|
|
108
|
+
"@types/chai": "4.3.5",
|
|
123
109
|
"@types/chai-xml": "0.3.2",
|
|
124
110
|
"@types/he": "1.2.0",
|
|
125
|
-
"@types/lodash": "4.14.
|
|
111
|
+
"@types/lodash": "4.14.194",
|
|
126
112
|
"@types/mocha": "10.0.1",
|
|
127
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
128
|
-
"@typescript-eslint/parser": "5.
|
|
113
|
+
"@typescript-eslint/eslint-plugin": "5.59.6",
|
|
114
|
+
"@typescript-eslint/parser": "5.59.6",
|
|
129
115
|
"c8": "7.13.0",
|
|
130
116
|
"chai": "4.3.7",
|
|
131
117
|
"chai-as-promised": "7.1.1",
|
|
132
118
|
"chai-json-schema": "1.5.1",
|
|
133
|
-
"chai-xml": "0.4.
|
|
134
|
-
"dependency-cruiser": "
|
|
135
|
-
"esbuild": "0.17.
|
|
136
|
-
"eslint": "8.
|
|
119
|
+
"chai-xml": "0.4.1",
|
|
120
|
+
"dependency-cruiser": "13.0.0",
|
|
121
|
+
"esbuild": "0.17.19",
|
|
122
|
+
"eslint": "8.40.0",
|
|
137
123
|
"eslint-config-moving-meadow": "4.0.2",
|
|
138
124
|
"eslint-config-prettier": "8.8.0",
|
|
139
125
|
"eslint-plugin-budapestian": "5.0.1",
|
|
@@ -142,20 +128,20 @@
|
|
|
142
128
|
"eslint-plugin-mocha": "10.1.0",
|
|
143
129
|
"eslint-plugin-node": "11.1.0",
|
|
144
130
|
"eslint-plugin-security": "1.7.1",
|
|
145
|
-
"eslint-plugin-unicorn": "
|
|
131
|
+
"eslint-plugin-unicorn": "47.0.0",
|
|
146
132
|
"husky": "8.0.3",
|
|
147
133
|
"is-pdf": "1.0.0",
|
|
148
134
|
"is-png": "3.0.1",
|
|
149
|
-
"lint-staged": "13.2.
|
|
135
|
+
"lint-staged": "13.2.2",
|
|
150
136
|
"mocha": "10.2.0",
|
|
151
137
|
"npm-run-all": "4.1.5",
|
|
152
138
|
"peggy": "3.0.2",
|
|
153
|
-
"prettier": "2.8.
|
|
139
|
+
"prettier": "2.8.8",
|
|
154
140
|
"query-string": "8.1.0",
|
|
155
141
|
"ts-node": "10.9.1",
|
|
156
142
|
"typescript": "5.0.4",
|
|
157
143
|
"upem": "7.3.2",
|
|
158
|
-
"watskeburt": "0.
|
|
144
|
+
"watskeburt": "0.11.2",
|
|
159
145
|
"xml-name-validator": "4.0.0"
|
|
160
146
|
},
|
|
161
147
|
"overrides": {
|
|
@@ -236,7 +236,7 @@ export interface IBaseRenderOptions {
|
|
|
236
236
|
* (choice, forks and junctions) with their equivalent meaning
|
|
237
237
|
* (defaults to false).
|
|
238
238
|
*
|
|
239
|
-
* For details: https://github.com/sverweij/state-machine-cat/blob/
|
|
239
|
+
* For details: https://github.com/sverweij/state-machine-cat/blob/main/docs/desugar.md
|
|
240
240
|
*/
|
|
241
241
|
desugar?: boolean;
|
|
242
242
|
}
|
|
@@ -254,6 +254,11 @@ export interface IRenderOptions extends IBaseRenderOptions {
|
|
|
254
254
|
* For the 'dot' renderer: Edge attributes to the engine
|
|
255
255
|
*/
|
|
256
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;
|
|
257
262
|
}
|
|
258
263
|
|
|
259
264
|
export type StringRenderFunctionType = (
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import indentString from "indent-string";
|
|
3
|
-
import wrapAnsi from "wrap-ansi";
|
|
4
|
-
import dotToVectorNative from "../render/vector/dot-to-vector-native.mjs";
|
|
5
|
-
function wrapAndIndent(pString) {
|
|
6
|
-
const lDogmaticMaxConsoleWidth = 78;
|
|
7
|
-
const lDefaultIndent = 2;
|
|
8
|
-
const lMaxWidth = lDogmaticMaxConsoleWidth - lDefaultIndent;
|
|
9
|
-
return indentString(wrapAnsi(pString, lMaxWidth), lDefaultIndent);
|
|
10
|
-
}
|
|
11
|
-
export default (pDotIsAvailable = dotToVectorNative.isAvailable({})) => {
|
|
12
|
-
const lDescription = "Write beautiful state charts - https://github.com/sverweij/state-machine-cat";
|
|
13
|
-
const lNode12Warning = "When you want to output svg and the native GraphViz isn't installed, " +
|
|
14
|
-
"state-machine-cat will fall back to viz.js and you might see " +
|
|
15
|
-
`${chalk.italic("'Invalid asm.js: Function definition doesn't match use'")}. ` +
|
|
16
|
-
"It's harmless and your svg will come out ok. See " +
|
|
17
|
-
`https://github.com/sverweij/state-machine-cat/blob/develop/docs/faq.md#viz`;
|
|
18
|
-
return indentString(pDotIsAvailable
|
|
19
|
-
? lDescription
|
|
20
|
-
: `${lDescription}\n\n${wrapAndIndent(chalk.dim(lNode12Warning))}`);
|
|
21
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import viz from "viz.js";
|
|
2
|
-
import options from "../../options.mjs";
|
|
3
|
-
import ast2dot from "../dot/index.mjs";
|
|
4
|
-
const OUTPUT_TYPE2FORMAT = {
|
|
5
|
-
oldsvg: "svg",
|
|
6
|
-
oldps2: "ps2",
|
|
7
|
-
oldeps: "eps",
|
|
8
|
-
};
|
|
9
|
-
const renderVectorWithViz = (pStateMachine, pOptions) => viz(ast2dot(pStateMachine, pOptions), {
|
|
10
|
-
engine: options.getOptionValue(pOptions, "engine"),
|
|
11
|
-
format: OUTPUT_TYPE2FORMAT[options.getOptionValue(pOptions, "outputType")] || "svg",
|
|
12
|
-
});
|
|
13
|
-
export default renderVectorWithViz;
|