state-machine-cat 11.1.3 → 11.1.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.
@@ -1,9 +1,9 @@
1
1
  import fastxml from "fast-xml-parser";
2
2
  import he from "he";
3
- import castArray from "lodash/castArray.js";
4
3
  import traverse from "traverse";
5
4
  import utl from "../../transform/utl.mjs";
6
5
  import parserHelpers from "../parser-helpers.mjs";
6
+ import { castArray } from "./utl.mjs";
7
7
  import { normalizeMachine } from "./normalize-machine.mjs";
8
8
  const formatLabel = utl.formatLabel;
9
9
  function extractActions(pState, pActionType) {
@@ -99,7 +99,10 @@ function reduceTransition(pState) {
99
99
  function extractTransitions(pStates) {
100
100
  return pStates
101
101
  .filter((pState) => Object.prototype.hasOwnProperty.call(pState, "transition"))
102
- .reduce((pAllTransitions, pThisState) => pAllTransitions.concat(castArray(pThisState.transition).reduce(reduceTransition(pThisState), [])), []);
102
+ .reduce((pAllTransitions, pThisState) => {
103
+ const lTransitionAsArray = castArray(pThisState.transition);
104
+ return pAllTransitions.concat(lTransitionAsArray.reduce(reduceTransition(pThisState), []));
105
+ }, []);
103
106
  }
104
107
  function mapMachine(pSCXMLStateMachine) {
105
108
  const lNormalizedMachine = normalizeMachine(pSCXMLStateMachine);
@@ -1,4 +1,4 @@
1
- import castArray from "lodash/castArray.js";
1
+ import { castArray } from "./utl.mjs";
2
2
  function normalizeInitialFromObject(pInitialObject, pId) {
3
3
  const lReturnValue = {
4
4
  id: pId ? `${pId}.initial` : "initial",
@@ -0,0 +1,3 @@
1
+ export function castArray(pAThing) {
2
+ return Array.isArray(pAThing) ? pAThing : [pAThing];
3
+ }
@@ -1,4 +1,4 @@
1
- import cloneDeep from "lodash/cloneDeep.js";
1
+ import { cloneDeep } from "../../utl.mjs";
2
2
  import options from "../../options.mjs";
3
3
  import StateMachineModel from "../../state-machine-model.mjs";
4
4
  import attributebuilder from "./attributebuilder.mjs";
@@ -1,4 +1,4 @@
1
- import cloneDeep from "lodash/cloneDeep.js";
1
+ import { cloneDeep } from "../../utl.mjs";
2
2
  import utl from "./utl.mjs";
3
3
  function isType(pString) {
4
4
  return (pState) => pState.type === pString;
@@ -1,4 +1,3 @@
1
- import has from "lodash/has.js";
2
1
  import smcatRendererAsImported from "./smcat/index.mjs";
3
2
  import renderDot from "./dot/index.mjs";
4
3
  import vector from "./vector/vector-native-dot-with-fallback.mjs";
@@ -7,22 +6,20 @@ import scjson from "./scjson/index.mjs";
7
6
  import scxml from "./scxml/index.mjs";
8
7
  const smcat = smcatRendererAsImported;
9
8
  export default function getRenderFunction(pOutputType) {
10
- const lOutputType2RenderFunction = {
11
- smcat,
12
- dot: renderDot,
13
- svg: vector,
14
- eps: vector,
15
- ps: vector,
16
- ps2: vector,
17
- oldsvg: oldVector,
18
- oldps2: oldVector,
19
- oldeps: oldVector,
20
- pdf: vector,
21
- png: vector,
22
- scjson,
23
- scxml,
24
- };
25
- return has(lOutputType2RenderFunction, pOutputType)
26
- ? lOutputType2RenderFunction[pOutputType]
27
- : (pX) => pX;
9
+ const lOutputType2RenderFunctionMap = new Map([
10
+ ["smcat", smcat],
11
+ ["dot", renderDot],
12
+ ["svg", vector],
13
+ ["eps", vector],
14
+ ["ps", vector],
15
+ ["ps2", vector],
16
+ ["oldsvg", oldVector],
17
+ ["oldps2", oldVector],
18
+ ["oldeps", oldVector],
19
+ ["pdf", vector],
20
+ ["png", vector],
21
+ ["scjson", scjson],
22
+ ["scxml", scxml],
23
+ ]);
24
+ return lOutputType2RenderFunctionMap.get(pOutputType) ?? ((pX) => pX);
28
25
  }
@@ -1,4 +1,3 @@
1
- import has from "lodash/has.js";
2
1
  import smcatRendererAsImported from "./smcat/index.mjs";
3
2
  import renderDot from "./dot/index.mjs";
4
3
  import svg from "./vector/vector-with-wasm.mjs";
@@ -6,15 +5,13 @@ import scjson from "./scjson/index.mjs";
6
5
  import scxml from "./scxml/index.mjs";
7
6
  const smcat = smcatRendererAsImported;
8
7
  export default function getRenderFunction(pOutputType) {
9
- const lOutputType2RenderFunction = {
10
- smcat,
11
- dot: renderDot,
12
- svg,
13
- oldsvg: svg,
14
- scjson,
15
- scxml,
16
- };
17
- return has(lOutputType2RenderFunction, pOutputType)
18
- ? lOutputType2RenderFunction[pOutputType]
19
- : (pX) => pX;
8
+ const lOutputType2RenderFunctionMap = new Map([
9
+ ["smcat", smcat],
10
+ ["dot", renderDot],
11
+ ["svg", svg],
12
+ ["oldsvg", svg],
13
+ ["scjson", scjson],
14
+ ["scxml", scxml],
15
+ ]);
16
+ return lOutputType2RenderFunctionMap.get(pOutputType) ?? ((pX) => pX);
20
17
  }
@@ -1,5 +1,5 @@
1
1
  import Handlebars from "handlebars/dist/handlebars.runtime.js";
2
- import cloneDeep from "lodash/cloneDeep.js";
2
+ import { cloneDeep } from "../../utl.mjs";
3
3
  await import("./smcat.template.js");
4
4
  const NAME_QUOTABLE = /;|,|{| |\[/;
5
5
  const ACTIONS_QUOTABLE = /;|,|{/;
@@ -1,12 +1,7 @@
1
1
  import { Graphviz } from "@hpcc-js/wasm/graphviz";
2
- import indentString from "indent-string";
3
- import wrapAnsi from "wrap-ansi";
4
- import chalk from "chalk";
5
2
  import options from "../../options.mjs";
6
3
  import ast2dot from "../dot/index.mjs";
7
4
  import dotToVectorNative from "./dot-to-vector-native.mjs";
8
- const DEFAULT_INDENT = 2;
9
- const DOGMATIC_CONSOLE_WIDTH = 78;
10
5
  const VIZ_JS_UNSUPPORTED_OUTPUT_FORMATS = ["pdf", "png"];
11
6
  const gGraphViz = await Graphviz.load();
12
7
  const renderVector = (pStateMachine, pOptions) => {
@@ -27,7 +22,7 @@ const renderVector = (pStateMachine, pOptions) => {
27
22
  "both formats.\n");
28
23
  }
29
24
  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));
25
+ process.stderr.write(` warning: GraphViz 'dot' executable not found. Falling back to wasm.\n\n`);
31
26
  return gGraphViz.layout(lDotProgram, lDotOptions.format, lDotOptions.engine);
32
27
  }
33
28
  };
@@ -1,5 +1,4 @@
1
- import cloneDeep from "lodash/cloneDeep.js";
2
- import reject from "lodash/reject.js";
1
+ import { cloneDeep } from "../utl.mjs";
3
2
  import StateMachineModel from "../state-machine-model.mjs";
4
3
  import utl from "./utl.mjs";
5
4
  function fuseTransitionAttribute(pIncomingThing, pOutgoingThing, pJoinChar) {
@@ -52,10 +51,12 @@ function deSugarPseudoStates(pMachine, pPseudoStateNames, pOutgoingTransitionMap
52
51
  function removeStatesCascading(pMachine, pStateNames) {
53
52
  const lMachine = cloneDeep(pMachine);
54
53
  if (lMachine.transitions) {
55
- lMachine.transitions = reject(lMachine.transitions, (pTransition) => pStateNames.some((pJunctionStateName) => pJunctionStateName === pTransition.from ||
54
+ lMachine.transitions = lMachine.transitions.filter((pTransition) => !pStateNames.some((pJunctionStateName) => pJunctionStateName === pTransition.from ||
56
55
  pJunctionStateName === pTransition.to));
57
56
  }
58
- lMachine.states = reject(lMachine.states, (pState) => pStateNames.includes(pState.name)).map((pState) => pState.statemachine
57
+ lMachine.states = lMachine.states
58
+ .filter((pState) => !pStateNames.includes(pState.name))
59
+ .map((pState) => pState.statemachine
59
60
  ? {
60
61
  ...pState,
61
62
  statemachine: removeStatesCascading(pState.statemachine, pStateNames),
package/dist/utl.mjs ADDED
@@ -0,0 +1,3 @@
1
+ export function cloneDeep(pObject) {
2
+ return JSON.parse(JSON.stringify(pObject));
3
+ }
package/dist/version.mjs CHANGED
@@ -1 +1 @@
1
- export const version = "11.1.3";
1
+ export const version = "11.1.4";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "state-machine-cat",
3
- "version": "11.1.3",
3
+ "version": "11.1.4",
4
4
  "description": "write beautiful state charts",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",
@@ -90,44 +90,36 @@
90
90
  "state-machine-cat": "bin/smcat.mjs"
91
91
  },
92
92
  "dependencies": {
93
- "@hpcc-js/wasm": "2.13.0",
93
+ "@hpcc-js/wasm": "2.13.1",
94
94
  "ajv": "8.12.0",
95
- "chalk": "5.3.0",
96
95
  "commander": "11.0.0",
97
- "fast-xml-parser": "4.2.6",
98
- "handlebars": "4.7.7",
96
+ "fast-xml-parser": "4.2.7",
97
+ "handlebars": "4.7.8",
99
98
  "he": "1.2.0",
100
- "indent-string": "5.0.0",
101
- "lodash": "4.17.21",
102
99
  "semver": "^7.5.4",
103
- "traverse": "0.6.7",
104
- "wrap-ansi": "8.1.0"
100
+ "traverse": "0.6.7"
105
101
  },
106
102
  "devDependencies": {
107
103
  "@types/chai": "4.3.5",
108
- "@types/chai-xml": "0.3.2",
109
104
  "@types/he": "1.2.0",
110
- "@types/lodash": "4.14.195",
105
+ "@types/lodash": "4.14.196",
111
106
  "@types/mocha": "10.0.1",
112
- "@typescript-eslint/eslint-plugin": "6.1.0",
113
- "@typescript-eslint/parser": "6.1.0",
114
- "c8": "8.0.0",
107
+ "@typescript-eslint/eslint-plugin": "6.2.1",
108
+ "@typescript-eslint/parser": "6.2.1",
109
+ "c8": "8.0.1",
115
110
  "chai": "4.3.7",
116
- "chai-as-promised": "7.1.1",
117
- "chai-json-schema": "1.5.1",
118
- "chai-xml": "0.4.1",
119
111
  "dependency-cruiser": "13.1.1",
120
- "esbuild": "0.18.16",
121
- "eslint": "8.45.0",
112
+ "esbuild": "0.18.17",
113
+ "eslint": "8.46.0",
122
114
  "eslint-config-moving-meadow": "4.0.2",
123
- "eslint-config-prettier": "8.8.0",
115
+ "eslint-config-prettier": "8.10.0",
124
116
  "eslint-plugin-budapestian": "5.0.1",
125
117
  "eslint-plugin-eslint-comments": "3.2.0",
126
- "eslint-plugin-import": "2.27.5",
118
+ "eslint-plugin-import": "2.28.0",
127
119
  "eslint-plugin-mocha": "10.1.0",
128
120
  "eslint-plugin-node": "11.1.0",
129
121
  "eslint-plugin-security": "1.7.1",
130
- "eslint-plugin-unicorn": "48.0.0",
122
+ "eslint-plugin-unicorn": "48.0.1",
131
123
  "husky": "8.0.3",
132
124
  "is-pdf": "1.0.0",
133
125
  "is-png": "3.0.1",
@@ -135,12 +127,12 @@
135
127
  "mocha": "10.2.0",
136
128
  "npm-run-all": "4.1.5",
137
129
  "peggy": "3.0.2",
138
- "prettier": "3.0.0",
130
+ "prettier": "3.0.1",
139
131
  "query-string": "8.1.0",
140
132
  "ts-node": "10.9.1",
141
133
  "typescript": "5.1.6",
142
134
  "upem": "8.0.0",
143
- "watskeburt": "0.11.6",
135
+ "watskeburt": "0.12.1",
144
136
  "xml-name-validator": "4.0.0"
145
137
  },
146
138
  "overrides": {