state-machine-cat 10.1.8 → 10.1.10
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/dist/commonjs/bundle.js +69 -69
- package/dist/esm/cli/attributes-parser.mjs +13 -5
- package/dist/esm/parse/scxml/index.mjs +34 -12
- package/dist/esm/parse/smcat/smcat-parser.mjs +17 -9
- package/dist/esm/version.mjs +1 -1
- package/package.json +12 -18
- package/src/cli/attributes-parser.mjs +0 -969
- package/src/parse/scxml/index.mjs +0 -252
- package/src/parse/smcat/smcat-parser.mjs +0 -2736
- package/src/render/dot/README.md +0 -12
- package/src/render/dot/dot.states.template.js +0 -1
- package/src/render/dot/dot.template.js +0 -1
- package/src/render/dot/index.mjs +0 -200
- package/src/render/scxml/render-from-scjson.js +0 -15
- package/src/render/scxml/scxml.states.template.js +0 -1
- package/src/render/scxml/scxml.template.js +0 -1
- package/src/render/smcat/smcat.template.js +0 -1
|
@@ -36,16 +36,19 @@ peg$SyntaxError.prototype.format = function (sources) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
var s = this.location.start;
|
|
39
|
-
var
|
|
39
|
+
var offset_s = (this.location.source && (typeof this.location.source.offset === "function"))
|
|
40
|
+
? this.location.source.offset(s)
|
|
41
|
+
: s;
|
|
42
|
+
var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
40
43
|
if (src) {
|
|
41
44
|
var e = this.location.end;
|
|
42
|
-
var filler = peg$padEnd("",
|
|
45
|
+
var filler = peg$padEnd("", offset_s.line.toString().length, ' ');
|
|
43
46
|
var line = src[s.line - 1];
|
|
44
47
|
var last = s.line === e.line ? e.column : line.length + 1;
|
|
45
48
|
var hatLen = (last - s.column) || 1;
|
|
46
49
|
str += "\n --> " + loc + "\n"
|
|
47
50
|
+ filler + " |\n"
|
|
48
|
-
+
|
|
51
|
+
+ offset_s.line + " | " + line + "\n"
|
|
49
52
|
+ filler + " | " + peg$padEnd("", s.column - 1, ' ')
|
|
50
53
|
+ peg$padEnd("", hatLen, "^");
|
|
51
54
|
}
|
|
@@ -270,10 +273,10 @@ function peg$parse(input, options) {
|
|
|
270
273
|
return details;
|
|
271
274
|
}
|
|
272
275
|
}
|
|
273
|
-
function peg$computeLocation(startPos, endPos) {
|
|
276
|
+
function peg$computeLocation(startPos, endPos, offset) {
|
|
274
277
|
var startPosDetails = peg$computePosDetails(startPos);
|
|
275
278
|
var endPosDetails = peg$computePosDetails(endPos);
|
|
276
|
-
|
|
279
|
+
var res = {
|
|
277
280
|
source: peg$source,
|
|
278
281
|
start: {
|
|
279
282
|
offset: startPos,
|
|
@@ -286,6 +289,11 @@ function peg$parse(input, options) {
|
|
|
286
289
|
column: endPosDetails.column
|
|
287
290
|
}
|
|
288
291
|
};
|
|
292
|
+
if (offset && peg$source && (typeof peg$source.offset === "function")) {
|
|
293
|
+
res.start = peg$source.offset(res.start);
|
|
294
|
+
res.end = peg$source.offset(res.end);
|
|
295
|
+
}
|
|
296
|
+
return res;
|
|
289
297
|
}
|
|
290
298
|
function peg$fail(expected) {
|
|
291
299
|
if (peg$currPos < peg$maxFailPos) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fastxml from "fast-xml-parser";
|
|
2
2
|
import he from "he";
|
|
3
3
|
import castArray from "lodash/castArray.js";
|
|
4
|
+
import traverse from "traverse";
|
|
4
5
|
import utl from "../../transform/utl.mjs";
|
|
5
6
|
import parserHelpers from "../parser-helpers.mjs";
|
|
6
7
|
import { normalizeMachine } from "./normalize-machine.mjs";
|
|
@@ -118,19 +119,40 @@ function mapMachine(pSCXMLStateMachine) {
|
|
|
118
119
|
}
|
|
119
120
|
return lReturnValue;
|
|
120
121
|
}
|
|
122
|
+
function deDuplicateAttributesAndTags(pObject, pAttributeNamePrefix) {
|
|
123
|
+
return traverse(pObject).map(function deDuplicate() {
|
|
124
|
+
if (this.key?.startsWith(pAttributeNamePrefix)) {
|
|
125
|
+
const pUnprefixedAttributeName = this.key.slice(pAttributeNamePrefix.length);
|
|
126
|
+
if (this.parent.keys.includes(pUnprefixedAttributeName)) {
|
|
127
|
+
this.remove();
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.parent.node[pUnprefixedAttributeName] = this.node;
|
|
131
|
+
this.remove();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
121
136
|
export function parse(pSCXMLString) {
|
|
122
137
|
const lTrimmedSCXMLString = pSCXMLString.trim();
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
138
|
+
const lAttributeNamePrefix = "@_";
|
|
139
|
+
let lXMLAsJSON = {};
|
|
140
|
+
const lXMLParser = new fastxml.XMLParser({
|
|
141
|
+
attributeNamePrefix: lAttributeNamePrefix,
|
|
142
|
+
ignoreAttributes: false,
|
|
143
|
+
parseTagValue: true,
|
|
144
|
+
processEntities: false,
|
|
145
|
+
tagValueProcessor: (_pTagName, pTagValue) => he.decode(pTagValue),
|
|
146
|
+
stopNodes: ["*.onentry", "*.onexit", "*.transition"],
|
|
147
|
+
});
|
|
148
|
+
try {
|
|
149
|
+
lXMLAsJSON = deDuplicateAttributesAndTags(lXMLParser.parse(lTrimmedSCXMLString, true), lAttributeNamePrefix);
|
|
150
|
+
}
|
|
151
|
+
catch (pError) {
|
|
152
|
+
throw new Error("That doesn't look like valid xml ...\n");
|
|
134
153
|
}
|
|
135
|
-
|
|
154
|
+
return mapMachine(lXMLAsJSON?.scxml ?? {
|
|
155
|
+
xmlns: "http://www.w3.org/2005/07/scxml",
|
|
156
|
+
version: "1.0",
|
|
157
|
+
});
|
|
136
158
|
}
|
|
@@ -37,16 +37,19 @@ peg$SyntaxError.prototype.format = function (sources) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
var s = this.location.start;
|
|
40
|
-
var
|
|
40
|
+
var offset_s = (this.location.source && (typeof this.location.source.offset === "function"))
|
|
41
|
+
? this.location.source.offset(s)
|
|
42
|
+
: s;
|
|
43
|
+
var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
41
44
|
if (src) {
|
|
42
45
|
var e = this.location.end;
|
|
43
|
-
var filler = peg$padEnd("",
|
|
46
|
+
var filler = peg$padEnd("", offset_s.line.toString().length, ' ');
|
|
44
47
|
var line = src[s.line - 1];
|
|
45
48
|
var last = s.line === e.line ? e.column : line.length + 1;
|
|
46
49
|
var hatLen = (last - s.column) || 1;
|
|
47
50
|
str += "\n --> " + loc + "\n"
|
|
48
51
|
+ filler + " |\n"
|
|
49
|
-
+
|
|
52
|
+
+ offset_s.line + " | " + line + "\n"
|
|
50
53
|
+ filler + " | " + peg$padEnd("", s.column - 1, ' ')
|
|
51
54
|
+ peg$padEnd("", hatLen, "^");
|
|
52
55
|
}
|
|
@@ -339,15 +342,15 @@ function peg$parse(input, options) {
|
|
|
339
342
|
parserHelpers.setIfNotEmpty(trans, 'note', notes);
|
|
340
343
|
return trans;
|
|
341
344
|
};
|
|
342
|
-
var peg$f20 = function (
|
|
345
|
+
var peg$f20 = function (from_, to) {
|
|
343
346
|
return {
|
|
344
|
-
from:
|
|
347
|
+
from: from_,
|
|
345
348
|
to: to
|
|
346
349
|
};
|
|
347
350
|
};
|
|
348
|
-
var peg$f21 = function (to,
|
|
351
|
+
var peg$f21 = function (to, from_) {
|
|
349
352
|
return {
|
|
350
|
-
from:
|
|
353
|
+
from: from_,
|
|
351
354
|
to: to
|
|
352
355
|
};
|
|
353
356
|
};
|
|
@@ -481,10 +484,10 @@ function peg$parse(input, options) {
|
|
|
481
484
|
return details;
|
|
482
485
|
}
|
|
483
486
|
}
|
|
484
|
-
function peg$computeLocation(startPos, endPos) {
|
|
487
|
+
function peg$computeLocation(startPos, endPos, offset) {
|
|
485
488
|
var startPosDetails = peg$computePosDetails(startPos);
|
|
486
489
|
var endPosDetails = peg$computePosDetails(endPos);
|
|
487
|
-
|
|
490
|
+
var res = {
|
|
488
491
|
source: peg$source,
|
|
489
492
|
start: {
|
|
490
493
|
offset: startPos,
|
|
@@ -497,6 +500,11 @@ function peg$parse(input, options) {
|
|
|
497
500
|
column: endPosDetails.column
|
|
498
501
|
}
|
|
499
502
|
};
|
|
503
|
+
if (offset && peg$source && (typeof peg$source.offset === "function")) {
|
|
504
|
+
res.start = peg$source.offset(res.start);
|
|
505
|
+
res.end = peg$source.offset(res.end);
|
|
506
|
+
}
|
|
507
|
+
return res;
|
|
500
508
|
}
|
|
501
509
|
function peg$fail(expected) {
|
|
502
510
|
if (peg$currPos < peg$maxFailPos) {
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "10.1.
|
|
1
|
+
export const version = "10.1.10";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "state-machine-cat",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.10",
|
|
4
4
|
"description": "write beautiful state charts",
|
|
5
5
|
"main": "./dist/commonjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.mjs",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "make clean dist pages",
|
|
25
25
|
"build:cli": "make cli-build && rm -rf dist/esm && tsc",
|
|
26
|
+
"build:fromscratch": "make clean dist pages cli-build && rm -rf dist/esm && tsc",
|
|
26
27
|
"check": "wireit",
|
|
27
28
|
"cachefolder": "wireit",
|
|
28
29
|
"depcruise": "wireit",
|
|
@@ -70,14 +71,11 @@
|
|
|
70
71
|
"upem-outdated": "npm outdated --json --long | upem --dry-run",
|
|
71
72
|
"upem:install": "npm install",
|
|
72
73
|
"upem:update": "npm outdated --json --long | upem | pbcopy && pbpaste",
|
|
73
|
-
"version": "run-s build depcruise:graph scm:stage"
|
|
74
|
+
"version": "run-s build:fromscratch depcruise:graph scm:stage"
|
|
74
75
|
},
|
|
75
76
|
"files": [
|
|
76
77
|
"bin/",
|
|
77
78
|
"dist/",
|
|
78
|
-
"src/**/*.js",
|
|
79
|
-
"src/**/*.mjs",
|
|
80
|
-
"src/**/*.json",
|
|
81
79
|
"types/",
|
|
82
80
|
"package.json",
|
|
83
81
|
"README.md",
|
|
@@ -85,11 +83,6 @@
|
|
|
85
83
|
],
|
|
86
84
|
"upem": {
|
|
87
85
|
"policies": [
|
|
88
|
-
{
|
|
89
|
-
"package": "fast-xml-parser",
|
|
90
|
-
"policy": "wanted",
|
|
91
|
-
"because": "fast-xml-parser 4 has some breaking changes we still need to grok (why? how?)"
|
|
92
|
-
},
|
|
93
86
|
{
|
|
94
87
|
"package": "viz.js",
|
|
95
88
|
"policy": "pin",
|
|
@@ -375,13 +368,14 @@
|
|
|
375
368
|
"ajv": "8.12.0",
|
|
376
369
|
"chalk": "5.2.0",
|
|
377
370
|
"commander": "10.0.0",
|
|
378
|
-
"fast-xml-parser": "
|
|
371
|
+
"fast-xml-parser": "4.1.3",
|
|
379
372
|
"get-stream": "6.0.1",
|
|
380
373
|
"handlebars": "4.7.7",
|
|
381
374
|
"he": "1.2.0",
|
|
382
375
|
"indent-string": "5.0.0",
|
|
383
376
|
"lodash": "4.17.21",
|
|
384
377
|
"semver": "^7.3.8",
|
|
378
|
+
"traverse": "0.6.7",
|
|
385
379
|
"viz.js": "1.8.2",
|
|
386
380
|
"wrap-ansi": "8.1.0"
|
|
387
381
|
},
|
|
@@ -391,16 +385,16 @@
|
|
|
391
385
|
"@types/he": "1.2.0",
|
|
392
386
|
"@types/lodash": "4.14.191",
|
|
393
387
|
"@types/mocha": "10.0.1",
|
|
394
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
395
|
-
"@typescript-eslint/parser": "5.
|
|
388
|
+
"@typescript-eslint/eslint-plugin": "5.54.0",
|
|
389
|
+
"@typescript-eslint/parser": "5.54.0",
|
|
396
390
|
"c8": "7.13.0",
|
|
397
391
|
"chai": "4.3.7",
|
|
398
392
|
"chai-as-promised": "7.1.1",
|
|
399
393
|
"chai-json-schema": "1.5.1",
|
|
400
394
|
"chai-xml": "0.4.0",
|
|
401
|
-
"dependency-cruiser": "12.
|
|
402
|
-
"esbuild": "0.17.
|
|
403
|
-
"eslint": "8.
|
|
395
|
+
"dependency-cruiser": "12.10.0",
|
|
396
|
+
"esbuild": "0.17.10",
|
|
397
|
+
"eslint": "8.35.0",
|
|
404
398
|
"eslint-config-moving-meadow": "4.0.2",
|
|
405
399
|
"eslint-config-prettier": "8.6.0",
|
|
406
400
|
"eslint-plugin-budapestian": "5.0.1",
|
|
@@ -416,13 +410,13 @@
|
|
|
416
410
|
"lint-staged": "13.1.2",
|
|
417
411
|
"mocha": "10.2.0",
|
|
418
412
|
"npm-run-all": "4.1.5",
|
|
419
|
-
"peggy": "
|
|
413
|
+
"peggy": "3.0.0",
|
|
420
414
|
"prettier": "2.8.4",
|
|
421
415
|
"query-string": "8.1.0",
|
|
422
416
|
"ts-node": "10.9.1",
|
|
423
417
|
"typescript": "4.9.5",
|
|
424
418
|
"upem": "7.3.2",
|
|
425
|
-
"watskeburt": "0.
|
|
419
|
+
"watskeburt": "0.10.0",
|
|
426
420
|
"wireit": "0.9.5",
|
|
427
421
|
"xml-name-validator": "4.0.0"
|
|
428
422
|
},
|