state-machine-cat 12.0.6 → 12.0.7
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/cli/actions.mjs +34 -31
- package/dist/cli/attributes-parser.mjs +914 -889
- package/dist/cli/execute-command-line.mjs +98 -48
- package/dist/cli/file-name-to-stream.mjs +8 -8
- package/dist/cli/normalize.mjs +89 -70
- package/dist/cli/validations.mjs +72 -52
- package/dist/index-node.mjs +12 -9
- package/dist/index.mjs +10 -7
- package/dist/options.mjs +53 -53
- package/dist/parse/index.mjs +17 -17
- package/dist/parse/parser-helpers.mjs +159 -139
- package/dist/parse/scxml/index.mjs +152 -129
- package/dist/parse/scxml/normalize-machine.mjs +36 -35
- package/dist/parse/scxml/utl.mjs +1 -1
- package/dist/parse/smcat/smcat-parser.mjs +2794 -2844
- package/dist/parse/smcat-ast.schema.mjs +185 -168
- package/dist/render/dot/attributebuilder.mjs +40 -37
- package/dist/render/dot/counter.mjs +14 -14
- package/dist/render/dot/dot.states.template.js +1 -26
- package/dist/render/dot/dot.template.js +1 -14
- package/dist/render/dot/index.mjs +129 -82
- package/dist/render/dot/render-dot-from-ast.mjs +33 -16
- package/dist/render/dot/state-transformers.mjs +96 -85
- package/dist/render/dot/transition-transformers.mjs +39 -41
- package/dist/render/dot/utl.mjs +21 -19
- package/dist/render/index-node.mjs +16 -16
- package/dist/render/index.mjs +9 -9
- package/dist/render/scjson/index.mjs +111 -94
- package/dist/render/scjson/make-valid-event-names.mjs +21 -18
- package/dist/render/scjson/make-valid-xml-name.mjs +17 -13
- package/dist/render/scxml/index.mjs +2 -1
- package/dist/render/scxml/render-from-scjson.mjs +5 -2
- package/dist/render/scxml/scxml.states.template.js +1 -14
- package/dist/render/scxml/scxml.template.js +1 -6
- package/dist/render/smcat/index.mjs +54 -39
- package/dist/render/smcat/smcat.template.js +1 -13
- package/dist/render/vector/dot-to-vector-native.mjs +30 -26
- package/dist/render/vector/vector-native-dot-with-fallback.mjs +27 -20
- package/dist/render/vector/vector-with-wasm.mjs +13 -6
- package/dist/state-machine-model.mjs +67 -52
- package/dist/transform/desugar.mjs +115 -66
- package/dist/transform/utl.mjs +12 -12
- package/dist/version.mjs +1 -1
- package/package.json +74 -74
- package/types/state-machine-cat.d.mts +209 -209
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
const EVENT_CHAR_FORBIDDEN_RE =
|
|
1
|
+
const EVENT_CHAR_FORBIDDEN_RE =
|
|
2
|
+
/[\u00B7\u0300-\u036F\u203F-\u2040\u0000-\u0029\u002B-\u002C\u002F\u003B-\u0040\u005B-\u0060\u007B-\u00BF\u00D7\u00F7\u0300-\u036F\u037E\u2000-\u200B\u200E-\u206F\u2190-\u2BFF\u2FF0-\u3000\uD800-\uF8FF\uFDD0-\uFDEF\uFFFE-\uFFFF]/g;
|
|
2
3
|
const START_EVENT_CHAR_FORBIDDEN_EXTRA_RE = /[.]/g;
|
|
3
4
|
function makeValidEventChar(pCandidateEventStringTail) {
|
|
4
|
-
|
|
5
|
+
return pCandidateEventStringTail.replace(EVENT_CHAR_FORBIDDEN_RE, "_");
|
|
5
6
|
}
|
|
6
7
|
function makeValidEventStartChar(pCandidateEventStringStart) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
let lReturnValue = makeValidEventChar(pCandidateEventStringStart);
|
|
9
|
+
if (lReturnValue.match(START_EVENT_CHAR_FORBIDDEN_EXTRA_RE)) {
|
|
10
|
+
lReturnValue = `_${pCandidateEventStringStart}`;
|
|
11
|
+
}
|
|
12
|
+
return lReturnValue;
|
|
12
13
|
}
|
|
13
14
|
function makeValidEventName(pCandidateEventName) {
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
pCandidateEventName = pCandidateEventName.replace(/\s+/g, " ").trim();
|
|
16
|
+
return makeValidEventStartChar(pCandidateEventName[0]).concat(
|
|
17
|
+
makeValidEventChar(pCandidateEventName.slice(1)),
|
|
18
|
+
);
|
|
16
19
|
}
|
|
17
20
|
export default (pCandidateEventNames) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
const lCandidateEventNames = pCandidateEventNames || "";
|
|
22
|
+
if (lCandidateEventNames.length === 0) {
|
|
23
|
+
return "empty";
|
|
24
|
+
}
|
|
25
|
+
return lCandidateEventNames
|
|
26
|
+
.split(/[\n\r]+/)
|
|
27
|
+
.filter((pCandidateEventName) => pCandidateEventName.length > 0)
|
|
28
|
+
.map(makeValidEventName)
|
|
29
|
+
.join(" ");
|
|
27
30
|
};
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
const NAME_CHAR_FORBIDDEN_RE =
|
|
2
|
-
|
|
1
|
+
const NAME_CHAR_FORBIDDEN_RE =
|
|
2
|
+
/[\u0000-\u002C\u002F\u003B-\u0040\u005B-\u0060\u007B-\u00BF\u00D7\u00F7\u0300-\u036F\u037E\u2000-\u200B\u200E-\u206F\u2190-\u2BFF\u2FF0-\u3000\uD800-\uF8FF\uFDD0-\uFDEF\uFFFE-\uFFFF]/g;
|
|
3
|
+
const START_NAME_CHAR_FORBIDDEN_EXTRA_RE =
|
|
4
|
+
/[-.0-9\u00B7\u0300-\u036F\u203F-\u2040]/g;
|
|
3
5
|
function makeValidNameChars(pCandidateNameTail) {
|
|
4
|
-
|
|
6
|
+
return pCandidateNameTail.replace(NAME_CHAR_FORBIDDEN_RE, "_");
|
|
5
7
|
}
|
|
6
8
|
function makeValidNameStartChar(pCandidateChar) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
let lReturnValue = makeValidNameChars(pCandidateChar);
|
|
10
|
+
if (lReturnValue.match(START_NAME_CHAR_FORBIDDEN_EXTRA_RE)) {
|
|
11
|
+
lReturnValue = `_${pCandidateChar}`;
|
|
12
|
+
}
|
|
13
|
+
return lReturnValue;
|
|
12
14
|
}
|
|
13
15
|
export default (pCandidateName) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
pCandidateName = pCandidateName || "";
|
|
17
|
+
if (pCandidateName.length === 0) {
|
|
18
|
+
return `__empty`;
|
|
19
|
+
}
|
|
20
|
+
return makeValidNameStartChar(pCandidateName[0]).concat(
|
|
21
|
+
makeValidNameChars(pCandidateName.slice(1)),
|
|
22
|
+
);
|
|
19
23
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ast2scjson from "../scjson/index.mjs";
|
|
2
2
|
import renderFomSCJSON from "./render-from-scjson.mjs";
|
|
3
|
-
const renderSCXML = (pStateMachine) =>
|
|
3
|
+
const renderSCXML = (pStateMachine) =>
|
|
4
|
+
renderFomSCJSON(ast2scjson(pStateMachine));
|
|
4
5
|
export default renderSCXML;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import Handlebars from "handlebars/dist/handlebars.runtime.js";
|
|
2
2
|
await import("./scxml.template.js");
|
|
3
3
|
await import("./scxml.states.template.js");
|
|
4
|
-
Handlebars.registerPartial(
|
|
4
|
+
Handlebars.registerPartial(
|
|
5
|
+
"scxml.states.template.hbs",
|
|
6
|
+
Handlebars.templates["scxml.states.template.hbs"],
|
|
7
|
+
);
|
|
5
8
|
export default function renderSCXML(pSCJSON) {
|
|
6
|
-
|
|
9
|
+
return Handlebars.templates["scxml.template.hbs"](pSCJSON);
|
|
7
10
|
}
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var Handlebars = require("handlebars/dist/handlebars.runtime"), template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
|
|
4
|
-
templates["scxml.states.template.hbs"] = template({ 1: function (n, l, e, t, o) { var a, r, i = null != l ? l : n.nullContext || {}, u = n.hooks.helperMissing, c = "function", s = n.escapeExpression, p = n.lookupProperty || function (n, l) { if (Object.prototype.hasOwnProperty.call(n, l))
|
|
5
|
-
return n[l]; }; return " <" + s(typeof (r = null != (r = p(e, "kind") || (null != l ? p(l, "kind") : l)) ? r : u) == c ? r.call(i, { name: "kind", hash: {}, data: o, loc: { start: { line: 2, column: 5 }, end: { line: 2, column: 13 } } }) : r) + ' id="' + s(typeof (r = null != (r = p(e, "id") || (null != l ? p(l, "id") : l)) ? r : u) == c ? r.call(i, { name: "id", hash: {}, data: o, loc: { start: { line: 2, column: 18 }, end: { line: 2, column: 24 } } }) : r) + '"' + (null != (a = p(e, "if").call(i, null != l ? p(l, "initial") : l, { name: "if", hash: {}, fn: n.program(2, o, 0), inverse: n.noop, data: o, loc: { start: { line: 2, column: 25 }, end: { line: 2, column: 69 } } })) ? a : "") + (null != (a = p(e, "if").call(i, null != l ? p(l, "type") : l, { name: "if", hash: {}, fn: n.program(4, o, 0), inverse: n.noop, data: o, loc: { start: { line: 2, column: 69 }, end: { line: 2, column: 104 } } })) ? a : "") + ">\n" + (null != (a = n.invokePartial(p(t, "scxml.states.template.hbs"), l, { name: "scxml.states.template.hbs", data: o, indent: " ", helpers: e, partials: t, decorators: n.decorators })) ? a : "") + (null != (a = p(e, "each").call(i, null != l ? p(l, "onentries") : l, { name: "each", hash: {}, fn: n.program(6, o, 0), inverse: n.noop, data: o, loc: { start: { line: 4, column: 4 }, end: { line: 6, column: 13 } } })) ? a : "") + (null != (a = p(e, "each").call(i, null != l ? p(l, "onexits") : l, { name: "each", hash: {}, fn: n.program(8, o, 0), inverse: n.noop, data: o, loc: { start: { line: 7, column: 4 }, end: { line: 9, column: 13 } } })) ? a : "") + (null != (a = p(e, "each").call(i, null != l ? p(l, "transitions") : l, { name: "each", hash: {}, fn: n.program(10, o, 0), inverse: n.noop, data: o, loc: { start: { line: 10, column: 4 }, end: { line: 18, column: 13 } } })) ? a : "") + " </" + s(typeof (r = null != (r = p(e, "kind") || (null != l ? p(l, "kind") : l)) ? r : u) == c ? r.call(i, { name: "kind", hash: {}, data: o, loc: { start: { line: 19, column: 6 }, end: { line: 19, column: 14 } } }) : r) + ">\n"; }, 2: function (n, l, e, t, o) { var a = n.lookupProperty || function (n, l) { if (Object.prototype.hasOwnProperty.call(n, l))
|
|
6
|
-
return n[l]; }; return ' initial="' + n.escapeExpression("function" == typeof (e = null != (e = a(e, "initial") || (null != l ? a(l, "initial") : l)) ? e : n.hooks.helperMissing) ? e.call(null != l ? l : n.nullContext || {}, { name: "initial", hash: {}, data: o, loc: { start: { line: 2, column: 50 }, end: { line: 2, column: 61 } } }) : e) + '"'; }, 4: function (n, l, e, t, o) { var a = n.lookupProperty || function (n, l) { if (Object.prototype.hasOwnProperty.call(n, l))
|
|
7
|
-
return n[l]; }; return ' type="' + n.escapeExpression("function" == typeof (e = null != (e = a(e, "type") || (null != l ? a(l, "type") : l)) ? e : n.hooks.helperMissing) ? e.call(null != l ? l : n.nullContext || {}, { name: "type", hash: {}, data: o, loc: { start: { line: 2, column: 88 }, end: { line: 2, column: 96 } } }) : e) + '"'; }, 6: function (n, l, e, t, o) { return " <onentry>" + n.escapeExpression(n.lambda(l, l)) + "</onentry>\n"; }, 8: function (n, l, e, t, o) { return " <onexit>" + n.escapeExpression(n.lambda(l, l)) + "</onexit>\n"; }, 10: function (n, l, e, t, o) { var a = n.lookupProperty || function (n, l) { if (Object.prototype.hasOwnProperty.call(n, l))
|
|
8
|
-
return n[l]; }; return null != (e = a(e, "if").call(null != l ? l : n.nullContext || {}, null != l ? a(l, "action") : l, { name: "if", hash: {}, fn: n.program(11, o, 0), inverse: n.program(18, o, 0), data: o, loc: { start: { line: 11, column: 8 }, end: { line: 17, column: 15 } } })) ? e : ""; }, 11: function (n, l, e, t, o) { var a, r = null != l ? l : n.nullContext || {}, i = n.hooks.helperMissing, u = "function", c = n.escapeExpression, s = n.lookupProperty || function (n, l) { if (Object.prototype.hasOwnProperty.call(n, l))
|
|
9
|
-
return n[l]; }; return " <transition " + (null != (a = s(e, "if").call(r, null != l ? s(l, "event") : l, { name: "if", hash: {}, fn: n.program(12, o, 0), inverse: n.noop, data: o, loc: { start: { line: 12, column: 20 }, end: { line: 12, column: 58 } } })) ? a : "") + (null != (a = s(e, "if").call(r, null != l ? s(l, "cond") : l, { name: "if", hash: {}, fn: n.program(14, o, 0), inverse: n.noop, data: o, loc: { start: { line: 12, column: 58 }, end: { line: 12, column: 93 } } })) ? a : "") + (null != (a = s(e, "if").call(r, null != l ? s(l, "type") : l, { name: "if", hash: {}, fn: n.program(16, o, 0), inverse: n.noop, data: o, loc: { start: { line: 12, column: 93 }, end: { line: 12, column: 128 } } })) ? a : "") + 'target="' + c(typeof (n = null != (n = s(e, "target") || (null != l ? s(l, "target") : l)) ? n : i) == u ? n.call(r, { name: "target", hash: {}, data: o, loc: { start: { line: 12, column: 136 }, end: { line: 12, column: 146 } } }) : n) + '">\n ' + c(typeof (n = null != (n = s(e, "action") || (null != l ? s(l, "action") : l)) ? n : i) == u ? n.call(r, { name: "action", hash: {}, data: o, loc: { start: { line: 13, column: 12 }, end: { line: 13, column: 22 } } }) : n) + "\n </transition>\n"; }, 12: function (n, l, e, t, o) { var a = n.lookupProperty || function (n, l) { if (Object.prototype.hasOwnProperty.call(n, l))
|
|
10
|
-
return n[l]; }; return 'event="' + n.escapeExpression("function" == typeof (e = null != (e = a(e, "event") || (null != l ? a(l, "event") : l)) ? e : n.hooks.helperMissing) ? e.call(null != l ? l : n.nullContext || {}, { name: "event", hash: {}, data: o, loc: { start: { line: 12, column: 40 }, end: { line: 12, column: 49 } } }) : e) + '" '; }, 14: function (n, l, e, t, o) { var a = n.lookupProperty || function (n, l) { if (Object.prototype.hasOwnProperty.call(n, l))
|
|
11
|
-
return n[l]; }; return 'cond="' + n.escapeExpression("function" == typeof (e = null != (e = a(e, "cond") || (null != l ? a(l, "cond") : l)) ? e : n.hooks.helperMissing) ? e.call(null != l ? l : n.nullContext || {}, { name: "cond", hash: {}, data: o, loc: { start: { line: 12, column: 76 }, end: { line: 12, column: 84 } } }) : e) + '" '; }, 16: function (n, l, e, t, o) { var a = n.lookupProperty || function (n, l) { if (Object.prototype.hasOwnProperty.call(n, l))
|
|
12
|
-
return n[l]; }; return 'type="' + n.escapeExpression("function" == typeof (e = null != (e = a(e, "type") || (null != l ? a(l, "type") : l)) ? e : n.hooks.helperMissing) ? e.call(null != l ? l : n.nullContext || {}, { name: "type", hash: {}, data: o, loc: { start: { line: 12, column: 111 }, end: { line: 12, column: 119 } } }) : e) + '" '; }, 18: function (n, l, e, t, o) { var a, r = null != l ? l : n.nullContext || {}, i = n.lookupProperty || function (n, l) { if (Object.prototype.hasOwnProperty.call(n, l))
|
|
13
|
-
return n[l]; }; return " <transition " + (null != (a = i(e, "if").call(r, null != l ? i(l, "event") : l, { name: "if", hash: {}, fn: n.program(12, o, 0), inverse: n.noop, data: o, loc: { start: { line: 16, column: 20 }, end: { line: 16, column: 58 } } })) ? a : "") + (null != (a = i(e, "if").call(r, null != l ? i(l, "cond") : l, { name: "if", hash: {}, fn: n.program(14, o, 0), inverse: n.noop, data: o, loc: { start: { line: 16, column: 58 }, end: { line: 16, column: 93 } } })) ? a : "") + (null != (a = i(e, "if").call(r, null != l ? i(l, "type") : l, { name: "if", hash: {}, fn: n.program(16, o, 0), inverse: n.noop, data: o, loc: { start: { line: 16, column: 93 }, end: { line: 16, column: 128 } } })) ? a : "") + 'target="' + n.escapeExpression("function" == typeof (a = null != (a = i(e, "target") || (null != l ? i(l, "target") : l)) ? a : n.hooks.helperMissing) ? a.call(r, { name: "target", hash: {}, data: o, loc: { start: { line: 16, column: 136 }, end: { line: 16, column: 146 } } }) : a) + '"/>\n'; }, compiler: [8, ">= 4.3.0"], main: function (n, l, e, t, o) { var a = n.lookupProperty || function (n, l) { if (Object.prototype.hasOwnProperty.call(n, l))
|
|
14
|
-
return n[l]; }; return null != (e = a(e, "each").call(null != l ? l : n.nullContext || {}, null != l ? a(l, "states") : l, { name: "each", hash: {}, fn: n.program(1, o, 0), inverse: n.noop, data: o, loc: { start: { line: 1, column: 0 }, end: { line: 20, column: 9 } } })) ? e : ""; }, usePartial: !0, useData: !0 });
|
|
1
|
+
var Handlebars=require("handlebars/dist/handlebars.runtime"),template=Handlebars.template,templates=Handlebars.templates=Handlebars.templates||{};templates["scxml.states.template.hbs"]=template({1:function(n,l,e,t,o){var a,r,i=null!=l?l:n.nullContext||{},u=n.hooks.helperMissing,c="function",s=n.escapeExpression,p=n.lookupProperty||function(n,l){if(Object.prototype.hasOwnProperty.call(n,l))return n[l]};return" <"+s(typeof(r=null!=(r=p(e,"kind")||(null!=l?p(l,"kind"):l))?r:u)==c?r.call(i,{name:"kind",hash:{},data:o,loc:{start:{line:2,column:5},end:{line:2,column:13}}}):r)+' id="'+s(typeof(r=null!=(r=p(e,"id")||(null!=l?p(l,"id"):l))?r:u)==c?r.call(i,{name:"id",hash:{},data:o,loc:{start:{line:2,column:18},end:{line:2,column:24}}}):r)+'"'+(null!=(a=p(e,"if").call(i,null!=l?p(l,"initial"):l,{name:"if",hash:{},fn:n.program(2,o,0),inverse:n.noop,data:o,loc:{start:{line:2,column:25},end:{line:2,column:69}}}))?a:"")+(null!=(a=p(e,"if").call(i,null!=l?p(l,"type"):l,{name:"if",hash:{},fn:n.program(4,o,0),inverse:n.noop,data:o,loc:{start:{line:2,column:69},end:{line:2,column:104}}}))?a:"")+">\n"+(null!=(a=n.invokePartial(p(t,"scxml.states.template.hbs"),l,{name:"scxml.states.template.hbs",data:o,indent:" ",helpers:e,partials:t,decorators:n.decorators}))?a:"")+(null!=(a=p(e,"each").call(i,null!=l?p(l,"onentries"):l,{name:"each",hash:{},fn:n.program(6,o,0),inverse:n.noop,data:o,loc:{start:{line:4,column:4},end:{line:6,column:13}}}))?a:"")+(null!=(a=p(e,"each").call(i,null!=l?p(l,"onexits"):l,{name:"each",hash:{},fn:n.program(8,o,0),inverse:n.noop,data:o,loc:{start:{line:7,column:4},end:{line:9,column:13}}}))?a:"")+(null!=(a=p(e,"each").call(i,null!=l?p(l,"transitions"):l,{name:"each",hash:{},fn:n.program(10,o,0),inverse:n.noop,data:o,loc:{start:{line:10,column:4},end:{line:18,column:13}}}))?a:"")+" </"+s(typeof(r=null!=(r=p(e,"kind")||(null!=l?p(l,"kind"):l))?r:u)==c?r.call(i,{name:"kind",hash:{},data:o,loc:{start:{line:19,column:6},end:{line:19,column:14}}}):r)+">\n"},2:function(n,l,e,t,o){var a=n.lookupProperty||function(n,l){if(Object.prototype.hasOwnProperty.call(n,l))return n[l]};return' initial="'+n.escapeExpression("function"==typeof(e=null!=(e=a(e,"initial")||(null!=l?a(l,"initial"):l))?e:n.hooks.helperMissing)?e.call(null!=l?l:n.nullContext||{},{name:"initial",hash:{},data:o,loc:{start:{line:2,column:50},end:{line:2,column:61}}}):e)+'"'},4:function(n,l,e,t,o){var a=n.lookupProperty||function(n,l){if(Object.prototype.hasOwnProperty.call(n,l))return n[l]};return' type="'+n.escapeExpression("function"==typeof(e=null!=(e=a(e,"type")||(null!=l?a(l,"type"):l))?e:n.hooks.helperMissing)?e.call(null!=l?l:n.nullContext||{},{name:"type",hash:{},data:o,loc:{start:{line:2,column:88},end:{line:2,column:96}}}):e)+'"'},6:function(n,l,e,t,o){return" <onentry>"+n.escapeExpression(n.lambda(l,l))+"</onentry>\n"},8:function(n,l,e,t,o){return" <onexit>"+n.escapeExpression(n.lambda(l,l))+"</onexit>\n"},10:function(n,l,e,t,o){var a=n.lookupProperty||function(n,l){if(Object.prototype.hasOwnProperty.call(n,l))return n[l]};return null!=(e=a(e,"if").call(null!=l?l:n.nullContext||{},null!=l?a(l,"action"):l,{name:"if",hash:{},fn:n.program(11,o,0),inverse:n.program(18,o,0),data:o,loc:{start:{line:11,column:8},end:{line:17,column:15}}}))?e:""},11:function(n,l,e,t,o){var a,r=null!=l?l:n.nullContext||{},i=n.hooks.helperMissing,u="function",c=n.escapeExpression,s=n.lookupProperty||function(n,l){if(Object.prototype.hasOwnProperty.call(n,l))return n[l]};return" <transition "+(null!=(a=s(e,"if").call(r,null!=l?s(l,"event"):l,{name:"if",hash:{},fn:n.program(12,o,0),inverse:n.noop,data:o,loc:{start:{line:12,column:20},end:{line:12,column:58}}}))?a:"")+(null!=(a=s(e,"if").call(r,null!=l?s(l,"cond"):l,{name:"if",hash:{},fn:n.program(14,o,0),inverse:n.noop,data:o,loc:{start:{line:12,column:58},end:{line:12,column:93}}}))?a:"")+(null!=(a=s(e,"if").call(r,null!=l?s(l,"type"):l,{name:"if",hash:{},fn:n.program(16,o,0),inverse:n.noop,data:o,loc:{start:{line:12,column:93},end:{line:12,column:128}}}))?a:"")+'target="'+c(typeof(n=null!=(n=s(e,"target")||(null!=l?s(l,"target"):l))?n:i)==u?n.call(r,{name:"target",hash:{},data:o,loc:{start:{line:12,column:136},end:{line:12,column:146}}}):n)+'">\n '+c(typeof(n=null!=(n=s(e,"action")||(null!=l?s(l,"action"):l))?n:i)==u?n.call(r,{name:"action",hash:{},data:o,loc:{start:{line:13,column:12},end:{line:13,column:22}}}):n)+"\n </transition>\n"},12:function(n,l,e,t,o){var a=n.lookupProperty||function(n,l){if(Object.prototype.hasOwnProperty.call(n,l))return n[l]};return'event="'+n.escapeExpression("function"==typeof(e=null!=(e=a(e,"event")||(null!=l?a(l,"event"):l))?e:n.hooks.helperMissing)?e.call(null!=l?l:n.nullContext||{},{name:"event",hash:{},data:o,loc:{start:{line:12,column:40},end:{line:12,column:49}}}):e)+'" '},14:function(n,l,e,t,o){var a=n.lookupProperty||function(n,l){if(Object.prototype.hasOwnProperty.call(n,l))return n[l]};return'cond="'+n.escapeExpression("function"==typeof(e=null!=(e=a(e,"cond")||(null!=l?a(l,"cond"):l))?e:n.hooks.helperMissing)?e.call(null!=l?l:n.nullContext||{},{name:"cond",hash:{},data:o,loc:{start:{line:12,column:76},end:{line:12,column:84}}}):e)+'" '},16:function(n,l,e,t,o){var a=n.lookupProperty||function(n,l){if(Object.prototype.hasOwnProperty.call(n,l))return n[l]};return'type="'+n.escapeExpression("function"==typeof(e=null!=(e=a(e,"type")||(null!=l?a(l,"type"):l))?e:n.hooks.helperMissing)?e.call(null!=l?l:n.nullContext||{},{name:"type",hash:{},data:o,loc:{start:{line:12,column:111},end:{line:12,column:119}}}):e)+'" '},18:function(n,l,e,t,o){var a,r=null!=l?l:n.nullContext||{},i=n.lookupProperty||function(n,l){if(Object.prototype.hasOwnProperty.call(n,l))return n[l]};return" <transition "+(null!=(a=i(e,"if").call(r,null!=l?i(l,"event"):l,{name:"if",hash:{},fn:n.program(12,o,0),inverse:n.noop,data:o,loc:{start:{line:16,column:20},end:{line:16,column:58}}}))?a:"")+(null!=(a=i(e,"if").call(r,null!=l?i(l,"cond"):l,{name:"if",hash:{},fn:n.program(14,o,0),inverse:n.noop,data:o,loc:{start:{line:16,column:58},end:{line:16,column:93}}}))?a:"")+(null!=(a=i(e,"if").call(r,null!=l?i(l,"type"):l,{name:"if",hash:{},fn:n.program(16,o,0),inverse:n.noop,data:o,loc:{start:{line:16,column:93},end:{line:16,column:128}}}))?a:"")+'target="'+n.escapeExpression("function"==typeof(a=null!=(a=i(e,"target")||(null!=l?i(l,"target"):l))?a:n.hooks.helperMissing)?a.call(r,{name:"target",hash:{},data:o,loc:{start:{line:16,column:136},end:{line:16,column:146}}}):a)+'"/>\n'},compiler:[8,">= 4.3.0"],main:function(n,l,e,t,o){var a=n.lookupProperty||function(n,l){if(Object.prototype.hasOwnProperty.call(n,l))return n[l]};return null!=(e=a(e,"each").call(null!=l?l:n.nullContext||{},null!=l?a(l,"states"):l,{name:"each",hash:{},fn:n.program(1,o,0),inverse:n.noop,data:o,loc:{start:{line:1,column:0},end:{line:20,column:9}}}))?e:""},usePartial:!0,useData:!0});
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var Handlebars = require("handlebars/dist/handlebars.runtime"), template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
|
|
4
|
-
templates["scxml.template.hbs"] = template({ 1: function (e, l, t, n, a) { var r = e.lookupProperty || function (e, l) { if (Object.prototype.hasOwnProperty.call(e, l))
|
|
5
|
-
return e[l]; }; return 'initial="' + e.escapeExpression("function" == typeof (t = null != (t = r(t, "initial") || (null != l ? r(l, "initial") : l)) ? t : e.hooks.helperMissing) ? t.call(null != l ? l : e.nullContext || {}, { name: "initial", hash: {}, data: a, loc: { start: { line: 2, column: 71 }, end: { line: 2, column: 82 } } }) : t) + '" '; }, compiler: [8, ">= 4.3.0"], main: function (e, l, t, n, a) { var r, s = e.lookupProperty || function (e, l) { if (Object.prototype.hasOwnProperty.call(e, l))
|
|
6
|
-
return e[l]; }; return '<?xml version="1.0" encoding="UTF-8"?>\n<scxml xmlns="http://www.w3.org/2005/07/scxml" ' + (null != (r = s(t, "if").call(null != l ? l : e.nullContext || {}, null != l ? s(l, "initial") : l, { name: "if", hash: {}, fn: e.program(1, a, 0), inverse: e.noop, data: a, loc: { start: { line: 2, column: 47 }, end: { line: 2, column: 91 } } })) ? r : "") + 'version="1.0">\n' + (null != (r = e.invokePartial(s(n, "scxml.states.template.hbs"), l, { name: "scxml.states.template.hbs", data: a, helpers: t, partials: n, decorators: e.decorators })) ? r : "") + "</scxml>\n"; }, usePartial: !0, useData: !0 });
|
|
1
|
+
var Handlebars=require("handlebars/dist/handlebars.runtime"),template=Handlebars.template,templates=Handlebars.templates=Handlebars.templates||{};templates["scxml.template.hbs"]=template({1:function(e,l,t,n,a){var r=e.lookupProperty||function(e,l){if(Object.prototype.hasOwnProperty.call(e,l))return e[l]};return'initial="'+e.escapeExpression("function"==typeof(t=null!=(t=r(t,"initial")||(null!=l?r(l,"initial"):l))?t:e.hooks.helperMissing)?t.call(null!=l?l:e.nullContext||{},{name:"initial",hash:{},data:a,loc:{start:{line:2,column:71},end:{line:2,column:82}}}):t)+'" '},compiler:[8,">= 4.3.0"],main:function(e,l,t,n,a){var r,s=e.lookupProperty||function(e,l){if(Object.prototype.hasOwnProperty.call(e,l))return e[l]};return'<?xml version="1.0" encoding="UTF-8"?>\n<scxml xmlns="http://www.w3.org/2005/07/scxml" '+(null!=(r=s(t,"if").call(null!=l?l:e.nullContext||{},null!=l?s(l,"initial"):l,{name:"if",hash:{},fn:e.program(1,a,0),inverse:e.noop,data:a,loc:{start:{line:2,column:47},end:{line:2,column:91}}}))?r:"")+'version="1.0">\n'+(null!=(r=e.invokePartial(s(n,"scxml.states.template.hbs"),l,{name:"scxml.states.template.hbs",data:a,helpers:t,partials:n,decorators:e.decorators}))?r:"")+"</scxml>\n"},usePartial:!0,useData:!0});
|
|
@@ -4,57 +4,72 @@ const NAME_QUOTABLE = /;|,|{| |\[/;
|
|
|
4
4
|
const ACTIONS_QUOTABLE = /;|,|{/;
|
|
5
5
|
const LABEL_QUOTABLE = /;|{/;
|
|
6
6
|
function quoteIfNecessary(pRegExp, pString) {
|
|
7
|
-
|
|
7
|
+
return pRegExp.test(pString) ? `"${pString}"` : pString;
|
|
8
8
|
}
|
|
9
|
-
Handlebars.registerPartial(
|
|
9
|
+
Handlebars.registerPartial(
|
|
10
|
+
"smcat.template.hbs",
|
|
11
|
+
Handlebars.templates["smcat.template.hbs"],
|
|
12
|
+
);
|
|
10
13
|
function formatActionType(pString) {
|
|
11
|
-
|
|
14
|
+
return pString === "activity" ? "" : `${pString}/ `;
|
|
12
15
|
}
|
|
13
16
|
function flattenActions(pState) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
return {
|
|
18
|
+
...pState,
|
|
19
|
+
actions: (pState.actions || [])
|
|
20
|
+
.map((pAction) => `${formatActionType(pAction.type)}${pAction.body}`)
|
|
21
|
+
.join("\n "),
|
|
22
|
+
};
|
|
20
23
|
}
|
|
21
24
|
function flagExtendedStateAttributes(pState) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
if (
|
|
26
|
+
Object.prototype.hasOwnProperty.call(pState, "label") ||
|
|
27
|
+
Object.prototype.hasOwnProperty.call(pState, "typeExplicitlySet") ||
|
|
28
|
+
Object.prototype.hasOwnProperty.call(pState, "color") ||
|
|
29
|
+
Object.prototype.hasOwnProperty.call(pState, "active") ||
|
|
30
|
+
Object.prototype.hasOwnProperty.call(pState, "class")
|
|
31
|
+
) {
|
|
32
|
+
pState.hasExtendedAttributes = true;
|
|
33
|
+
}
|
|
34
|
+
return pState;
|
|
30
35
|
}
|
|
31
36
|
function transformStates(pStates) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
pStates
|
|
38
|
+
.map(flagExtendedStateAttributes)
|
|
39
|
+
.filter((pState) => pState.statemachine)
|
|
40
|
+
.forEach((pState) => {
|
|
41
|
+
pState.statemachine.states = transformStates(pState.statemachine.states);
|
|
42
|
+
});
|
|
43
|
+
return pStates.map(flattenActions);
|
|
39
44
|
}
|
|
40
45
|
function flagExtendedTransitionAttributes(pTransition) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
if (
|
|
47
|
+
Object.prototype.hasOwnProperty.call(pTransition, "type") ||
|
|
48
|
+
Object.prototype.hasOwnProperty.call(pTransition, "color") ||
|
|
49
|
+
Object.prototype.hasOwnProperty.call(pTransition, "class")
|
|
50
|
+
) {
|
|
51
|
+
pTransition.hasExtendedAttributes = true;
|
|
52
|
+
}
|
|
53
|
+
return pTransition;
|
|
47
54
|
}
|
|
48
55
|
function transformTransitions(pTransitions) {
|
|
49
|
-
|
|
56
|
+
return pTransitions.map(flagExtendedTransitionAttributes);
|
|
50
57
|
}
|
|
51
|
-
Handlebars.registerHelper("quotifyState", (pItem) =>
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
Handlebars.registerHelper("quotifyState", (pItem) =>
|
|
59
|
+
quoteIfNecessary(NAME_QUOTABLE, pItem),
|
|
60
|
+
);
|
|
61
|
+
Handlebars.registerHelper("quotifyLabel", (pItem) =>
|
|
62
|
+
quoteIfNecessary(LABEL_QUOTABLE, pItem),
|
|
63
|
+
);
|
|
64
|
+
Handlebars.registerHelper("quotifyActions", (pItem) =>
|
|
65
|
+
quoteIfNecessary(ACTIONS_QUOTABLE, pItem),
|
|
66
|
+
);
|
|
54
67
|
export default function renderSmcat(pStateMachine) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
68
|
+
return Handlebars.templates["smcat.template.hbs"]({
|
|
69
|
+
...pStateMachine,
|
|
70
|
+
states: transformStates(structuredClone(pStateMachine.states)),
|
|
71
|
+
transitions: transformTransitions(
|
|
72
|
+
structuredClone(pStateMachine.transitions || []),
|
|
73
|
+
),
|
|
74
|
+
});
|
|
60
75
|
}
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var Handlebars = require("handlebars/dist/handlebars.runtime"), template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
|
|
4
|
-
templates["smcat.template.hbs"] = template({ 1: function (l, n, e, t, o) { var a = null != n ? n : l.nullContext || {}, r = l.hooks.helperMissing, u = "function", i = l.hooks.blockHelperMissing, c = l.lookupProperty || function (l, n) { if (Object.prototype.hasOwnProperty.call(l, n))
|
|
5
|
-
return l[n]; }, s = "", p = null != (p = c(e, "note") || (null != n ? c(n, "note") : n)) ? p : r, m = { name: "note", hash: {}, fn: l.program(2, o, 0), inverse: l.noop, data: o, loc: { start: { line: 2, column: 0 }, end: { line: 4, column: 9 } } }, f = typeof p == u ? p.call(a, m) : p; return null != (f = c(e, "note") ? f : i.call(n, f, m)) && (s += f), s += null != (f = (c(e, "quotifyState") || n && c(n, "quotifyState") || r).call(a, null != n ? c(n, "name") : n, { name: "quotifyState", hash: {}, fn: l.program(4, o, 0), inverse: l.noop, data: o, loc: { start: { line: 5, column: 0 }, end: { line: 5, column: 40 } } })) ? f : "", p = null != (p = c(e, "hasExtendedAttributes") || (null != n ? c(n, "hasExtendedAttributes") : n)) ? p : r, m = { name: "hasExtendedAttributes", hash: {}, fn: l.program(6, o, 0), inverse: l.noop, data: o, loc: { start: { line: 6, column: 4 }, end: { line: 6, column: 270 } } }, f = typeof p == u ? p.call(a, m) : p, null != (f = c(e, "hasExtendedAttributes") ? f : i.call(n, f, m)) && (s += f), s += null != (f = c(e, "if").call(a, null != n ? c(n, "actions") : n, { name: "if", hash: {}, fn: l.program(18, o, 0), inverse: l.noop, data: o, loc: { start: { line: 7, column: 4 }, end: { line: 7, column: 28 } } })) ? f : "", p = null != (p = c(e, "actions") || (null != n ? c(n, "actions") : n)) ? p : r, m = { name: "actions", hash: {}, fn: l.program(20, o, 0), inverse: l.noop, data: o, loc: { start: { line: 7, column: 28 }, end: { line: 7, column: 93 } } }, f = typeof p == u ? p.call(a, m) : p, null != (f = c(e, "actions") ? f : i.call(n, f, m)) && (s += f), p = null != (p = c(e, "statemachine") || (null != n ? c(n, "statemachine") : n)) ? p : r, m = { name: "statemachine", hash: {}, fn: l.program(22, o, 0), inverse: l.noop, data: o, loc: { start: { line: 8, column: 4 }, end: { line: 10, column: 19 } } }, f = typeof p == u ? p.call(a, m) : p, null != (f = c(e, "statemachine") ? f : i.call(n, f, m)) && (s += f), s + (null != (f = c(e, "if").call(a, o && c(o, "last"), { name: "if", hash: {}, fn: l.program(24, o, 0), inverse: l.program(26, o, 0), data: o, loc: { start: { line: 11, column: 0 }, end: { line: 11, column: 30 } } })) ? f : "") + "\n"; }, 2: function (l, n, e, t, o) { return "# " + (null != (l = l.lambda(n, n)) ? l : "") + "\n"; }, 4: function (l, n, e, t, o) { return ""; }, 6: function (l, n, e, t, o) { var a = null != n ? n : l.nullContext || {}, r = l.hooks.helperMissing, u = "function", i = l.hooks.blockHelperMissing, c = l.lookupProperty || function (l, n) { if (Object.prototype.hasOwnProperty.call(l, n))
|
|
6
|
-
return l[n]; }, s = " [", p = null != (p = c(e, "typeExplicitlySet") || (null != n ? c(n, "typeExplicitlySet") : n)) ? p : r, m = { name: "typeExplicitlySet", hash: {}, fn: l.program(7, o, 0), inverse: l.noop, data: o, loc: { start: { line: 6, column: 32 }, end: { line: 6, column: 107 } } }, f = typeof p == u ? p.call(a, m) : p; return null != (f = c(e, "typeExplicitlySet") ? f : i.call(n, f, m)) && (s += f), p = null != (p = c(e, "label") || (null != n ? c(n, "label") : n)) ? p : r, m = { name: "label", hash: {}, fn: l.program(10, o, 0), inverse: l.noop, data: o, loc: { start: { line: 6, column: 107 }, end: { line: 6, column: 142 } } }, f = typeof p == u ? p.call(a, m) : p, null != (f = c(e, "label") ? f : i.call(n, f, m)) && (s += f), p = null != (p = c(e, "color") || (null != n ? c(n, "color") : n)) ? p : r, m = { name: "color", hash: {}, fn: l.program(12, o, 0), inverse: l.noop, data: o, loc: { start: { line: 6, column: 142 }, end: { line: 6, column: 178 } } }, f = typeof p == u ? p.call(a, m) : p, null != (f = c(e, "color") ? f : i.call(n, f, m)) && (s += f), p = null != (p = c(e, "class") || (null != n ? c(n, "class") : n)) ? p : r, m = { name: "class", hash: {}, fn: l.program(14, o, 0), inverse: l.noop, data: o, loc: { start: { line: 6, column: 178 }, end: { line: 6, column: 214 } } }, f = typeof p == u ? p.call(a, m) : p, null != (f = c(e, "class") ? f : i.call(n, f, m)) && (s += f), s + (null != (f = c(e, "if").call(a, null != n ? c(n, "active") : n, { name: "if", hash: {}, fn: l.program(16, o, 0), inverse: l.noop, data: o, loc: { start: { line: 6, column: 214 }, end: { line: 6, column: 242 } } })) ? f : "") + "]"; }, 7: function (l, n, e, t, o) { var a = l.lookupProperty || function (l, n) { if (Object.prototype.hasOwnProperty.call(l, n))
|
|
7
|
-
return l[n]; }, r = null != (r = a(e, "type") || (null != n ? a(n, "type") : n)) ? r : l.hooks.helperMissing, o = { name: "type", hash: {}, fn: l.program(8, o, 0), inverse: l.noop, data: o, loc: { start: { line: 6, column: 54 }, end: { line: 6, column: 85 } } }, r = "function" == typeof r ? r.call(null != n ? n : l.nullContext || {}, o) : r; return null != (r = a(e, "type") ? r : l.hooks.blockHelperMissing.call(n, r, o)) ? r : ""; }, 8: function (l, n, e, t, o) { return "type=" + (null != (l = l.lambda(n, n)) ? l : "") + " "; }, 10: function (l, n, e, t, o) { return 'label="' + (null != (l = l.lambda(n, n)) ? l : "") + '"'; }, 12: function (l, n, e, t, o) { return ' color="' + (null != (l = l.lambda(n, n)) ? l : "") + '"'; }, 14: function (l, n, e, t, o) { return ' class="' + (null != (l = l.lambda(n, n)) ? l : "") + '"'; }, 16: function (l, n, e, t, o) { return " active"; }, 18: function (l, n, e, t, o) { return ": "; }, 20: function (l, n, e, t, o) { var a = l.lookupProperty || function (l, n) { if (Object.prototype.hasOwnProperty.call(l, n))
|
|
8
|
-
return l[n]; }; return null != (e = (a(e, "quotifyActions") || n && a(n, "quotifyActions") || l.hooks.helperMissing).call(null != n ? n : l.nullContext || {}, n, { name: "quotifyActions", hash: {}, fn: l.program(4, o, 0), inverse: l.noop, data: o, loc: { start: { line: 7, column: 40 }, end: { line: 7, column: 80 } } })) ? e : ""; }, 22: function (l, n, e, t, o) { var a = l.lookupProperty || function (l, n) { if (Object.prototype.hasOwnProperty.call(l, n))
|
|
9
|
-
return l[n]; }; return " {\n" + (null != (a = l.invokePartial(a(t, "smcat.template.hbs"), n, { name: "smcat.template.hbs", data: o, indent: " ", helpers: e, partials: t, decorators: l.decorators })) ? a : "") + "}"; }, 24: function (l, n, e, t, o) { return ";"; }, 26: function (l, n, e, t, o) { return ","; }, 28: function (l, n, e, t, o) { var a = null != n ? n : l.nullContext || {}, r = l.hooks.helperMissing, u = "function", i = l.hooks.blockHelperMissing, c = l.lookupProperty || function (l, n) { if (Object.prototype.hasOwnProperty.call(l, n))
|
|
10
|
-
return l[n]; }, s = "", p = null != (p = c(e, "note") || (null != n ? c(n, "note") : n)) ? p : r, m = { name: "note", hash: {}, fn: l.program(2, o, 0), inverse: l.noop, data: o, loc: { start: { line: 15, column: 0 }, end: { line: 17, column: 9 } } }, f = typeof p == u ? p.call(a, m) : p; return null != (f = c(e, "note") ? f : i.call(n, f, m)) && (s += f), s += (null != (f = (c(e, "quotifyState") || n && c(n, "quotifyState") || r).call(a, null != n ? c(n, "from") : n, { name: "quotifyState", hash: {}, fn: l.program(4, o, 0), inverse: l.noop, data: o, loc: { start: { line: 18, column: 0 }, end: { line: 18, column: 39 } } })) ? f : "") + " => " + (null != (f = (c(e, "quotifyState") || n && c(n, "quotifyState") || r).call(a, null != n ? c(n, "to") : n, { name: "quotifyState", hash: {}, fn: l.program(4, o, 0), inverse: l.noop, data: o, loc: { start: { line: 18, column: 43 }, end: { line: 18, column: 81 } } })) ? f : ""), p = null != (p = c(e, "hasExtendedAttributes") || (null != n ? c(n, "hasExtendedAttributes") : n)) ? p : r, m = { name: "hasExtendedAttributes", hash: {}, fn: l.program(29, o, 0), inverse: l.noop, data: o, loc: { start: { line: 19, column: 4 }, end: { line: 19, column: 130 } } }, f = typeof p == u ? p.call(a, m) : p, null != (f = c(e, "hasExtendedAttributes") ? f : i.call(n, f, m)) && (s += f), p = null != (p = c(e, "label") || (null != n ? c(n, "label") : n)) ? p : r, m = { name: "label", hash: {}, fn: l.program(34, o, 0), inverse: l.noop, data: o, loc: { start: { line: 20, column: 4 }, end: { line: 20, column: 62 } } }, f = typeof p == u ? p.call(a, m) : p, null != (f = c(e, "label") ? f : i.call(n, f, m)) && (s += f), s + ";\n"; }, 29: function (l, n, e, t, o) { var a = null != n ? n : l.nullContext || {}, r = l.hooks.helperMissing, u = "function", i = l.hooks.blockHelperMissing, c = l.lookupProperty || function (l, n) { if (Object.prototype.hasOwnProperty.call(l, n))
|
|
11
|
-
return l[n]; }, s = " [", p = null != (p = c(e, "color") || (null != n ? c(n, "color") : n)) ? p : r, m = { name: "color", hash: {}, fn: l.program(30, o, 0), inverse: l.noop, data: o, loc: { start: { line: 19, column: 32 }, end: { line: 19, column: 68 } } }, f = typeof p == u ? p.call(a, m) : p; return null != (f = c(e, "color") ? f : i.call(n, f, m)) && (s += f), p = null != (p = c(e, "type") || (null != n ? c(n, "type") : n)) ? p : r, m = { name: "type", hash: {}, fn: l.program(32, o, 0), inverse: l.noop, data: o, loc: { start: { line: 19, column: 69 }, end: { line: 19, column: 102 } } }, f = typeof p == u ? p.call(a, m) : p, null != (f = c(e, "type") ? f : i.call(n, f, m)) && (s += f), s + "]"; }, 30: function (l, n, e, t, o) { return 'color="' + (null != (l = l.lambda(n, n)) ? l : "") + '"'; }, 32: function (l, n, e, t, o) { return " type=" + (null != (l = l.lambda(n, n)) ? l : ""); }, 34: function (l, n, e, t, o) { var a = l.lookupProperty || function (l, n) { if (Object.prototype.hasOwnProperty.call(l, n))
|
|
12
|
-
return l[n]; }; return ": " + (null != (e = (a(e, "quotifyLabel") || n && a(n, "quotifyLabel") || l.hooks.helperMissing).call(null != n ? n : l.nullContext || {}, n, { name: "quotifyLabel", hash: {}, fn: l.program(4, o, 0), inverse: l.noop, data: o, loc: { start: { line: 20, column: 16 }, end: { line: 20, column: 52 } } })) ? e : ""); }, compiler: [8, ">= 4.3.0"], main: function (l, n, e, t, o) { var a = null != n ? n : l.nullContext || {}, r = l.lookupProperty || function (l, n) { if (Object.prototype.hasOwnProperty.call(l, n))
|
|
13
|
-
return l[n]; }, u = (null != (c = r(e, "each").call(a, null != n ? r(n, "states") : n, { name: "each", hash: {}, fn: l.program(1, o, 0), inverse: l.noop, data: o, loc: { start: { line: 1, column: 0 }, end: { line: 12, column: 9 } } })) ? c : "") + "\n", i = null != (i = r(e, "transitions") || (null != n ? r(n, "transitions") : n)) ? i : l.hooks.helperMissing, o = { name: "transitions", hash: {}, fn: l.program(28, o, 0), inverse: l.noop, data: o, loc: { start: { line: 14, column: 0 }, end: { line: 21, column: 16 } } }, c = "function" == typeof i ? i.call(a, o) : i; return null != (c = r(e, "transitions") ? c : l.hooks.blockHelperMissing.call(n, c, o)) && (u += c), u; }, usePartial: !0, useData: !0 });
|
|
1
|
+
var Handlebars=require("handlebars/dist/handlebars.runtime"),template=Handlebars.template,templates=Handlebars.templates=Handlebars.templates||{};templates["smcat.template.hbs"]=template({1:function(l,n,e,t,o){var a=null!=n?n:l.nullContext||{},r=l.hooks.helperMissing,u="function",i=l.hooks.blockHelperMissing,c=l.lookupProperty||function(l,n){if(Object.prototype.hasOwnProperty.call(l,n))return l[n]},s="",p=null!=(p=c(e,"note")||(null!=n?c(n,"note"):n))?p:r,m={name:"note",hash:{},fn:l.program(2,o,0),inverse:l.noop,data:o,loc:{start:{line:2,column:0},end:{line:4,column:9}}},f=typeof p==u?p.call(a,m):p;return null!=(f=c(e,"note")?f:i.call(n,f,m))&&(s+=f),s+=null!=(f=(c(e,"quotifyState")||n&&c(n,"quotifyState")||r).call(a,null!=n?c(n,"name"):n,{name:"quotifyState",hash:{},fn:l.program(4,o,0),inverse:l.noop,data:o,loc:{start:{line:5,column:0},end:{line:5,column:40}}}))?f:"",p=null!=(p=c(e,"hasExtendedAttributes")||(null!=n?c(n,"hasExtendedAttributes"):n))?p:r,m={name:"hasExtendedAttributes",hash:{},fn:l.program(6,o,0),inverse:l.noop,data:o,loc:{start:{line:6,column:4},end:{line:6,column:270}}},f=typeof p==u?p.call(a,m):p,null!=(f=c(e,"hasExtendedAttributes")?f:i.call(n,f,m))&&(s+=f),s+=null!=(f=c(e,"if").call(a,null!=n?c(n,"actions"):n,{name:"if",hash:{},fn:l.program(18,o,0),inverse:l.noop,data:o,loc:{start:{line:7,column:4},end:{line:7,column:28}}}))?f:"",p=null!=(p=c(e,"actions")||(null!=n?c(n,"actions"):n))?p:r,m={name:"actions",hash:{},fn:l.program(20,o,0),inverse:l.noop,data:o,loc:{start:{line:7,column:28},end:{line:7,column:93}}},f=typeof p==u?p.call(a,m):p,null!=(f=c(e,"actions")?f:i.call(n,f,m))&&(s+=f),p=null!=(p=c(e,"statemachine")||(null!=n?c(n,"statemachine"):n))?p:r,m={name:"statemachine",hash:{},fn:l.program(22,o,0),inverse:l.noop,data:o,loc:{start:{line:8,column:4},end:{line:10,column:19}}},f=typeof p==u?p.call(a,m):p,null!=(f=c(e,"statemachine")?f:i.call(n,f,m))&&(s+=f),s+(null!=(f=c(e,"if").call(a,o&&c(o,"last"),{name:"if",hash:{},fn:l.program(24,o,0),inverse:l.program(26,o,0),data:o,loc:{start:{line:11,column:0},end:{line:11,column:30}}}))?f:"")+"\n"},2:function(l,n,e,t,o){return"# "+(null!=(l=l.lambda(n,n))?l:"")+"\n"},4:function(l,n,e,t,o){return""},6:function(l,n,e,t,o){var a=null!=n?n:l.nullContext||{},r=l.hooks.helperMissing,u="function",i=l.hooks.blockHelperMissing,c=l.lookupProperty||function(l,n){if(Object.prototype.hasOwnProperty.call(l,n))return l[n]},s=" [",p=null!=(p=c(e,"typeExplicitlySet")||(null!=n?c(n,"typeExplicitlySet"):n))?p:r,m={name:"typeExplicitlySet",hash:{},fn:l.program(7,o,0),inverse:l.noop,data:o,loc:{start:{line:6,column:32},end:{line:6,column:107}}},f=typeof p==u?p.call(a,m):p;return null!=(f=c(e,"typeExplicitlySet")?f:i.call(n,f,m))&&(s+=f),p=null!=(p=c(e,"label")||(null!=n?c(n,"label"):n))?p:r,m={name:"label",hash:{},fn:l.program(10,o,0),inverse:l.noop,data:o,loc:{start:{line:6,column:107},end:{line:6,column:142}}},f=typeof p==u?p.call(a,m):p,null!=(f=c(e,"label")?f:i.call(n,f,m))&&(s+=f),p=null!=(p=c(e,"color")||(null!=n?c(n,"color"):n))?p:r,m={name:"color",hash:{},fn:l.program(12,o,0),inverse:l.noop,data:o,loc:{start:{line:6,column:142},end:{line:6,column:178}}},f=typeof p==u?p.call(a,m):p,null!=(f=c(e,"color")?f:i.call(n,f,m))&&(s+=f),p=null!=(p=c(e,"class")||(null!=n?c(n,"class"):n))?p:r,m={name:"class",hash:{},fn:l.program(14,o,0),inverse:l.noop,data:o,loc:{start:{line:6,column:178},end:{line:6,column:214}}},f=typeof p==u?p.call(a,m):p,null!=(f=c(e,"class")?f:i.call(n,f,m))&&(s+=f),s+(null!=(f=c(e,"if").call(a,null!=n?c(n,"active"):n,{name:"if",hash:{},fn:l.program(16,o,0),inverse:l.noop,data:o,loc:{start:{line:6,column:214},end:{line:6,column:242}}}))?f:"")+"]"},7:function(l,n,e,t,o){var a=l.lookupProperty||function(l,n){if(Object.prototype.hasOwnProperty.call(l,n))return l[n]},r=null!=(r=a(e,"type")||(null!=n?a(n,"type"):n))?r:l.hooks.helperMissing,o={name:"type",hash:{},fn:l.program(8,o,0),inverse:l.noop,data:o,loc:{start:{line:6,column:54},end:{line:6,column:85}}},r="function"==typeof r?r.call(null!=n?n:l.nullContext||{},o):r;return null!=(r=a(e,"type")?r:l.hooks.blockHelperMissing.call(n,r,o))?r:""},8:function(l,n,e,t,o){return"type="+(null!=(l=l.lambda(n,n))?l:"")+" "},10:function(l,n,e,t,o){return'label="'+(null!=(l=l.lambda(n,n))?l:"")+'"'},12:function(l,n,e,t,o){return' color="'+(null!=(l=l.lambda(n,n))?l:"")+'"'},14:function(l,n,e,t,o){return' class="'+(null!=(l=l.lambda(n,n))?l:"")+'"'},16:function(l,n,e,t,o){return" active"},18:function(l,n,e,t,o){return": "},20:function(l,n,e,t,o){var a=l.lookupProperty||function(l,n){if(Object.prototype.hasOwnProperty.call(l,n))return l[n]};return null!=(e=(a(e,"quotifyActions")||n&&a(n,"quotifyActions")||l.hooks.helperMissing).call(null!=n?n:l.nullContext||{},n,{name:"quotifyActions",hash:{},fn:l.program(4,o,0),inverse:l.noop,data:o,loc:{start:{line:7,column:40},end:{line:7,column:80}}}))?e:""},22:function(l,n,e,t,o){var a=l.lookupProperty||function(l,n){if(Object.prototype.hasOwnProperty.call(l,n))return l[n]};return" {\n"+(null!=(a=l.invokePartial(a(t,"smcat.template.hbs"),n,{name:"smcat.template.hbs",data:o,indent:" ",helpers:e,partials:t,decorators:l.decorators}))?a:"")+"}"},24:function(l,n,e,t,o){return";"},26:function(l,n,e,t,o){return","},28:function(l,n,e,t,o){var a=null!=n?n:l.nullContext||{},r=l.hooks.helperMissing,u="function",i=l.hooks.blockHelperMissing,c=l.lookupProperty||function(l,n){if(Object.prototype.hasOwnProperty.call(l,n))return l[n]},s="",p=null!=(p=c(e,"note")||(null!=n?c(n,"note"):n))?p:r,m={name:"note",hash:{},fn:l.program(2,o,0),inverse:l.noop,data:o,loc:{start:{line:15,column:0},end:{line:17,column:9}}},f=typeof p==u?p.call(a,m):p;return null!=(f=c(e,"note")?f:i.call(n,f,m))&&(s+=f),s+=(null!=(f=(c(e,"quotifyState")||n&&c(n,"quotifyState")||r).call(a,null!=n?c(n,"from"):n,{name:"quotifyState",hash:{},fn:l.program(4,o,0),inverse:l.noop,data:o,loc:{start:{line:18,column:0},end:{line:18,column:39}}}))?f:"")+" => "+(null!=(f=(c(e,"quotifyState")||n&&c(n,"quotifyState")||r).call(a,null!=n?c(n,"to"):n,{name:"quotifyState",hash:{},fn:l.program(4,o,0),inverse:l.noop,data:o,loc:{start:{line:18,column:43},end:{line:18,column:81}}}))?f:""),p=null!=(p=c(e,"hasExtendedAttributes")||(null!=n?c(n,"hasExtendedAttributes"):n))?p:r,m={name:"hasExtendedAttributes",hash:{},fn:l.program(29,o,0),inverse:l.noop,data:o,loc:{start:{line:19,column:4},end:{line:19,column:130}}},f=typeof p==u?p.call(a,m):p,null!=(f=c(e,"hasExtendedAttributes")?f:i.call(n,f,m))&&(s+=f),p=null!=(p=c(e,"label")||(null!=n?c(n,"label"):n))?p:r,m={name:"label",hash:{},fn:l.program(34,o,0),inverse:l.noop,data:o,loc:{start:{line:20,column:4},end:{line:20,column:62}}},f=typeof p==u?p.call(a,m):p,null!=(f=c(e,"label")?f:i.call(n,f,m))&&(s+=f),s+";\n"},29:function(l,n,e,t,o){var a=null!=n?n:l.nullContext||{},r=l.hooks.helperMissing,u="function",i=l.hooks.blockHelperMissing,c=l.lookupProperty||function(l,n){if(Object.prototype.hasOwnProperty.call(l,n))return l[n]},s=" [",p=null!=(p=c(e,"color")||(null!=n?c(n,"color"):n))?p:r,m={name:"color",hash:{},fn:l.program(30,o,0),inverse:l.noop,data:o,loc:{start:{line:19,column:32},end:{line:19,column:68}}},f=typeof p==u?p.call(a,m):p;return null!=(f=c(e,"color")?f:i.call(n,f,m))&&(s+=f),p=null!=(p=c(e,"type")||(null!=n?c(n,"type"):n))?p:r,m={name:"type",hash:{},fn:l.program(32,o,0),inverse:l.noop,data:o,loc:{start:{line:19,column:69},end:{line:19,column:102}}},f=typeof p==u?p.call(a,m):p,null!=(f=c(e,"type")?f:i.call(n,f,m))&&(s+=f),s+"]"},30:function(l,n,e,t,o){return'color="'+(null!=(l=l.lambda(n,n))?l:"")+'"'},32:function(l,n,e,t,o){return" type="+(null!=(l=l.lambda(n,n))?l:"")},34:function(l,n,e,t,o){var a=l.lookupProperty||function(l,n){if(Object.prototype.hasOwnProperty.call(l,n))return l[n]};return": "+(null!=(e=(a(e,"quotifyLabel")||n&&a(n,"quotifyLabel")||l.hooks.helperMissing).call(null!=n?n:l.nullContext||{},n,{name:"quotifyLabel",hash:{},fn:l.program(4,o,0),inverse:l.noop,data:o,loc:{start:{line:20,column:16},end:{line:20,column:52}}}))?e:"")},compiler:[8,">= 4.3.0"],main:function(l,n,e,t,o){var a=null!=n?n:l.nullContext||{},r=l.lookupProperty||function(l,n){if(Object.prototype.hasOwnProperty.call(l,n))return l[n]},u=(null!=(c=r(e,"each").call(a,null!=n?r(n,"states"):n,{name:"each",hash:{},fn:l.program(1,o,0),inverse:l.noop,data:o,loc:{start:{line:1,column:0},end:{line:12,column:9}}}))?c:"")+"\n",i=null!=(i=r(e,"transitions")||(null!=n?r(n,"transitions"):n))?i:l.hooks.helperMissing,o={name:"transitions",hash:{},fn:l.program(28,o,0),inverse:l.noop,data:o,loc:{start:{line:14,column:0},end:{line:21,column:16}}},c="function"==typeof i?i.call(a,o):i;return null!=(c=r(e,"transitions")?c:l.hooks.blockHelperMissing.call(n,c,o))&&(u+=c),u},usePartial:!0,useData:!0});
|
|
@@ -1,35 +1,39 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
2
|
const DEFAULT_OPTIONS = {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
exec: "dot",
|
|
4
|
+
format: "svg",
|
|
5
5
|
};
|
|
6
6
|
function convert(pDot, pOptions) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
const lOptions = {
|
|
8
|
+
...DEFAULT_OPTIONS,
|
|
9
|
+
...pOptions,
|
|
10
|
+
};
|
|
11
|
+
const { stdout, status, error } = spawnSync(
|
|
12
|
+
lOptions.exec,
|
|
13
|
+
[`-T${lOptions.format}`],
|
|
14
|
+
{
|
|
15
|
+
input: pDot,
|
|
16
|
+
},
|
|
17
|
+
);
|
|
18
|
+
if (status === 0) {
|
|
19
|
+
return stdout.toString("binary");
|
|
20
|
+
} else if (error) {
|
|
21
|
+
throw new Error(error);
|
|
22
|
+
} else {
|
|
23
|
+
throw new Error(`Unexpected error occurred. Exit code ${status}`);
|
|
24
|
+
}
|
|
23
25
|
}
|
|
24
26
|
function isAvailable(pOptions) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const lOptions = {
|
|
28
|
+
...DEFAULT_OPTIONS,
|
|
29
|
+
...pOptions,
|
|
30
|
+
};
|
|
31
|
+
const { status, stderr } = spawnSync(lOptions.exec, ["-V"]);
|
|
32
|
+
return (
|
|
33
|
+
status === 0 && stderr.toString("utf8").startsWith("dot - graphviz version")
|
|
34
|
+
);
|
|
31
35
|
}
|
|
32
36
|
export default {
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
convert,
|
|
38
|
+
isAvailable,
|
|
35
39
|
};
|
|
@@ -5,25 +5,32 @@ import dotToVectorNative from "./dot-to-vector-native.mjs";
|
|
|
5
5
|
const VIZ_JS_UNSUPPORTED_OUTPUT_FORMATS = ["pdf", "png"];
|
|
6
6
|
const gGraphViz = await Graphviz.load();
|
|
7
7
|
const renderVector = (pStateMachine, pOptions) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
8
|
+
const lDotProgram = ast2dot(pStateMachine, pOptions);
|
|
9
|
+
const lDotOptions = {
|
|
10
|
+
engine: options.getOptionValue(pOptions, "engine"),
|
|
11
|
+
format: options.getOptionValue(pOptions, "outputType"),
|
|
12
|
+
};
|
|
13
|
+
if (dotToVectorNative.isAvailable(pOptions)) {
|
|
14
|
+
return dotToVectorNative.convert(lDotProgram, lDotOptions);
|
|
15
|
+
} else {
|
|
16
|
+
if (VIZ_JS_UNSUPPORTED_OUTPUT_FORMATS.includes(lDotOptions.format)) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"GraphViz 'dot' executable not found. Falling back to wasm.\n\n" +
|
|
19
|
+
"The compiled-to-wasm version of GraphViz we use doesn't support the " +
|
|
20
|
+
"'pdf' and 'png' output formats. Either select a format that it does " +
|
|
21
|
+
"support or install GraphViz (recommended), which has support for " +
|
|
22
|
+
"both formats.\n",
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
if (!pOptions?.noDotNativeWarning)
|
|
26
|
+
process.stderr.write(
|
|
27
|
+
` warning: GraphViz 'dot' executable not found. Falling back to wasm.\n\n`,
|
|
28
|
+
);
|
|
29
|
+
return gGraphViz.layout(
|
|
30
|
+
lDotProgram,
|
|
31
|
+
lDotOptions.format,
|
|
32
|
+
lDotOptions.engine,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
28
35
|
};
|
|
29
36
|
export default renderVector;
|
|
@@ -2,16 +2,23 @@ import { Graphviz } from "@hpcc-js/wasm/graphviz";
|
|
|
2
2
|
import options from "../../options.mjs";
|
|
3
3
|
import ast2dot from "../dot/index.mjs";
|
|
4
4
|
const OUTPUT_TYPE2FORMAT = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
oldsvg: "svg",
|
|
6
|
+
oldps2: "ps2",
|
|
7
|
+
oldeps: "eps",
|
|
8
8
|
};
|
|
9
9
|
const gGraphViz = await Graphviz.load();
|
|
10
10
|
function getFormat(pOptions) {
|
|
11
|
-
|
|
11
|
+
return (
|
|
12
|
+
OUTPUT_TYPE2FORMAT[options.getOptionValue(pOptions, "outputType")] || "svg"
|
|
13
|
+
);
|
|
12
14
|
}
|
|
13
15
|
function getEngine(pOptions) {
|
|
14
|
-
|
|
16
|
+
return options.getOptionValue(pOptions, "engine");
|
|
15
17
|
}
|
|
16
|
-
const renderVectorWithWasm = (pStateMachine, pOptions) =>
|
|
18
|
+
const renderVectorWithWasm = (pStateMachine, pOptions) =>
|
|
19
|
+
gGraphViz.layout(
|
|
20
|
+
ast2dot(pStateMachine, pOptions),
|
|
21
|
+
getFormat(pOptions),
|
|
22
|
+
getEngine(pOptions),
|
|
23
|
+
);
|
|
17
24
|
export default renderVectorWithWasm;
|