state-machine-cat 15.0.6 → 15.0.8

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.
@@ -29,6 +29,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
29
  `;
30
30
  const MAX_INPUT_BYTES = 4_194_304;
31
31
  const ONE_MEGA_BYTE = 1_048_576;
32
+ const BINARY_OUTPUT_TYPES = new Set(["png", "pdf"]);
32
33
  function getStream(pStream) {
33
34
  return new Promise((pResolve, pReject) => {
34
35
  let lInputString = "";
@@ -71,7 +72,7 @@ export function transform(pOptions) {
71
72
  typeof lOutput === "string"
72
73
  ? lOutput
73
74
  : JSON.stringify(lOutput, null, " "),
74
- "binary",
75
+ BINARY_OUTPUT_TYPES.has(pOptions.outputType) ? "binary" : "utf8",
75
76
  );
76
77
  });
77
78
  }
@@ -64,7 +64,7 @@ function mapState(pType) {
64
64
  function extractTransitionAttributesFromObject(pTransition) {
65
65
  const lReturnValue = {};
66
66
  if (pTransition.event) {
67
- lReturnValue.event = pTransition.event.split(/\s+/).join("\n");
67
+ lReturnValue.event = pTransition.event.replaceAll(/\s+/g, "\n");
68
68
  }
69
69
  if (pTransition.cond) {
70
70
  lReturnValue.cond = pTransition.cond;
@@ -2,7 +2,9 @@ import { spawnSync } from "node:child_process";
2
2
  const DEFAULT_OPTIONS = {
3
3
  exec: "dot",
4
4
  format: "svg",
5
+ engine: "dot",
5
6
  };
7
+ const BINARY_FORMATS = new Set(["png", "pdf"]);
6
8
  export function convert(pDot, pOptions) {
7
9
  const lOptions = {
8
10
  ...DEFAULT_OPTIONS,
@@ -10,13 +12,15 @@ export function convert(pDot, pOptions) {
10
12
  };
11
13
  const { stdout, status, error } = spawnSync(
12
14
  lOptions.exec,
13
- [`-T${lOptions.format}`],
15
+ [`-K${lOptions.engine}`, `-T${lOptions.format}`],
14
16
  {
15
17
  input: pDot,
16
18
  },
17
19
  );
18
20
  if (status === 0) {
19
- return stdout.toString("binary");
21
+ return stdout.toString(
22
+ BINARY_FORMATS.has(lOptions.format) ? "binary" : "utf8",
23
+ );
20
24
  } else if (error) {
21
25
  throw new Error(error);
22
26
  } else {
package/dist/version.mjs CHANGED
@@ -1 +1 @@
1
- export const version = "15.0.6";
1
+ export const version = "15.0.8";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "state-machine-cat",
3
- "version": "15.0.6",
3
+ "version": "15.0.8",
4
4
  "description": "write beautiful state charts",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -41,8 +41,8 @@
41
41
  "state-machine-cat": "dist/cli/main.mjs"
42
42
  },
43
43
  "dependencies": {
44
- "@hpcc-js/wasm-graphviz": "1.24.1",
45
- "fast-xml-parser": "5.9.3",
44
+ "@hpcc-js/wasm-graphviz": "1.28.0",
45
+ "fast-xml-parser": "5.10.1",
46
46
  "he": "1.2.0",
47
47
  "neotraverse": "^0.6.18"
48
48
  },