state-machine-cat 11.0.0 → 11.0.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016-2022 Sander Verweij
3
+ Copyright (c) 2016-2023 Sander Verweij
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  _write beautiful state charts_
4
4
 
5
- [![install, lint, test](https://github.com/sverweij/state-machine-cat/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/sverweij/state-machine-cat/actions/workflows/ci.yml)
6
- [![coverage report](https://gitlab.com/sverweij/state-machine-cat/badges/master/coverage.svg)](https://gitlab.com/sverweij/state-machine-cat/builds)
5
+ [![install, lint, test](https://github.com/sverweij/state-machine-cat/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/sverweij/state-machine-cat/actions/workflows/ci.yml)
6
+ [![coverage report](https://gitlab.com/sverweij/state-machine-cat/badges/main/coverage.svg)](https://gitlab.com/sverweij/state-machine-cat/builds)
7
7
  [![Known Vulnerabilities](https://snyk.io/test/github/sverweij/state-machine-cat/badge.svg?targetFile=package.json)](https://snyk.io/test/github/sverweij/state-machine-cat?targetFile=package.json)
8
8
  [![Maintainability](https://api.codeclimate.com/v1/badges/e052b461624c043f32c7/maintainability)](https://codeclimate.com/github/sverweij/state-machine-cat/maintainability)
9
9
  [![npm stable version](https://img.shields.io/npm/v/state-machine-cat.svg?logo=npm)](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/master/docs/pics/sample.png">
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/master/docs/pics/00simplest.png">
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/master/docs/pics/01labels.png">
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/master/docs/pics/01labels_better.png">
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/master/docs/pics/02notes.png">
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/master/docs/pics/04explicit_state_declarations.png">
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/master/docs/pics/09labeled_states.png">
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/master/docs/pics/03initial_and_final.png">
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/master/docs/pics/07history.png">
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/master/docs/pics/03achoice.png">
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/master/docs/pics/03bforkjoin.png">
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/master/docs/pics/03cjunction.png">
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/master/docs/pics/03dterminate.png">
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/master/docs/pics/05tape_player.png">
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/master/docs/pics/08parallel.png">
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/master/docs/pics/11active_state.png">
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/master/docs/pics/10colored_states_and_transitions.png">
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/master/docs/pics/12state_type_overrides.png">
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, either on [GitLab](https://gitlab.com/sverweij/state-machine-cat/issues)
655
- or on [GitHub](https://github.com/sverweij/state-machine-cat/issues).
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/master/docs/pics/state-machine-cat-social-sharing-picture.png">
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(makeDescription())
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,
@@ -1,4 +1,3 @@
1
- import getStream from "get-stream";
2
1
  import smcat from "../index-node.mjs";
3
2
  import { getOutStream, getInStream } from "./file-name-to-stream.mjs";
4
3
  const LICENSE = `
@@ -6,7 +5,7 @@ const LICENSE = `
6
5
 
7
6
  The MIT License (MIT)
8
7
 
9
- Copyright (c) 2016-2022 Sander Verweij
8
+ Copyright (c) 2016-2023 Sander Verweij
10
9
 
11
10
  Permission is hereby granted, free of charge, to any person obtaining
12
11
  a copy of this software and associated documentation files (the
@@ -28,6 +27,19 @@ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28
27
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
28
 
30
29
  `;
30
+ function getStream(pStream) {
31
+ return new Promise((pResolve, pReject) => {
32
+ let lInputAsString = "";
33
+ pStream
34
+ .on("data", (pChunk) => {
35
+ lInputAsString += pChunk;
36
+ })
37
+ .on("error", pReject)
38
+ .on("end", () => {
39
+ pResolve(lInputAsString);
40
+ });
41
+ });
42
+ }
31
43
  export default {
32
44
  LICENSE,
33
45
  transform(pOptions) {
@@ -122,12 +122,12 @@ function mapMachine(pSCXMLStateMachine) {
122
122
  function deDuplicateAttributesAndTags(pObject, pAttributeNamePrefix) {
123
123
  return traverse(pObject).map(function deDuplicate() {
124
124
  if (this.key?.startsWith(pAttributeNamePrefix)) {
125
- const pUnprefixedAttributeName = this.key.slice(pAttributeNamePrefix.length);
126
- if (this.parent.keys.includes(pUnprefixedAttributeName)) {
125
+ const pUnPrefixedAttributeName = this.key.slice(pAttributeNamePrefix.length);
126
+ if (this.parent.keys.includes(pUnPrefixedAttributeName)) {
127
127
  this.remove();
128
128
  }
129
129
  else {
130
- this.parent.node[pUnprefixedAttributeName] = this.node;
130
+ this.parent.node[pUnPrefixedAttributeName] = this.node;
131
131
  this.remove();
132
132
  }
133
133
  }
@@ -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-viz-js.mjs";
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-viz-js.mjs";
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 dotToSvgJs from "viz.js";
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 viz.js.\n\n" +
23
- "'viz.js' doesn't support the 'pdf' and 'png' output formats. Either " +
24
- "select a format that it does support or install GraphViz " +
25
- "(recommended), which has support for both formats.\n");
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
- process.stderr.write(indentString(wrapAnsi(`\n${chalk.yellow("warning:")} GraphViz 'dot' executable not found. Falling back to viz.js.\n\n` +
28
- "On node >=12 this fallback will trigger a warning from the " +
29
- `node runtime:\n${chalk.italic("Invalid asm.js: Function definition doesn't match use")}.\n` +
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;
@@ -1 +1 @@
1
- export const version = "11.0.0";
1
+ export const version = "11.0.5";
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "state-machine-cat",
3
- "version": "11.0.0",
3
+ "version": "11.0.5",
4
4
  "description": "write beautiful state charts",
5
- "main": "./dist/exm/index.js",
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 develop)\"| 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 develop)\"| twopi -Tsvg | depcruise-wrap-stream-in-html | browser",
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,35 @@
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.0",
110
- "fast-xml-parser": "4.2.0",
111
- "get-stream": "6.0.1",
96
+ "commander": "10.0.1",
97
+ "fast-xml-parser": "4.2.2",
112
98
  "handlebars": "4.7.7",
113
99
  "he": "1.2.0",
114
100
  "indent-string": "5.0.0",
115
101
  "lodash": "4.17.21",
116
- "semver": "^7.3.8",
102
+ "semver": "^7.5.1",
117
103
  "traverse": "0.6.7",
118
- "viz.js": "1.8.2",
119
104
  "wrap-ansi": "8.1.0"
120
105
  },
121
106
  "devDependencies": {
122
- "@types/chai": "4.3.4",
107
+ "@types/chai": "4.3.5",
123
108
  "@types/chai-xml": "0.3.2",
124
109
  "@types/he": "1.2.0",
125
- "@types/lodash": "4.14.192",
110
+ "@types/lodash": "4.14.195",
126
111
  "@types/mocha": "10.0.1",
127
- "@typescript-eslint/eslint-plugin": "5.57.1",
128
- "@typescript-eslint/parser": "5.57.1",
129
- "c8": "7.13.0",
112
+ "@typescript-eslint/eslint-plugin": "5.59.8",
113
+ "@typescript-eslint/parser": "5.59.8",
114
+ "c8": "7.14.0",
130
115
  "chai": "4.3.7",
131
116
  "chai-as-promised": "7.1.1",
132
117
  "chai-json-schema": "1.5.1",
133
- "chai-xml": "0.4.0",
134
- "dependency-cruiser": "^13.0.0-beta-1",
135
- "esbuild": "0.17.16",
136
- "eslint": "8.38.0",
118
+ "chai-xml": "0.4.1",
119
+ "dependency-cruiser": "13.0.3",
120
+ "esbuild": "0.17.19",
121
+ "eslint": "8.42.0",
137
122
  "eslint-config-moving-meadow": "4.0.2",
138
123
  "eslint-config-prettier": "8.8.0",
139
124
  "eslint-plugin-budapestian": "5.0.1",
@@ -142,20 +127,20 @@
142
127
  "eslint-plugin-mocha": "10.1.0",
143
128
  "eslint-plugin-node": "11.1.0",
144
129
  "eslint-plugin-security": "1.7.1",
145
- "eslint-plugin-unicorn": "46.0.0",
130
+ "eslint-plugin-unicorn": "47.0.0",
146
131
  "husky": "8.0.3",
147
132
  "is-pdf": "1.0.0",
148
133
  "is-png": "3.0.1",
149
- "lint-staged": "13.2.1",
134
+ "lint-staged": "13.2.2",
150
135
  "mocha": "10.2.0",
151
136
  "npm-run-all": "4.1.5",
152
137
  "peggy": "3.0.2",
153
- "prettier": "2.8.7",
138
+ "prettier": "2.8.8",
154
139
  "query-string": "8.1.0",
155
140
  "ts-node": "10.9.1",
156
- "typescript": "5.0.4",
141
+ "typescript": "5.1.3",
157
142
  "upem": "7.3.2",
158
- "watskeburt": "0.10.1",
143
+ "watskeburt": "0.11.3",
159
144
  "xml-name-validator": "4.0.0"
160
145
  },
161
146
  "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/master/docs/desugar.md
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;