state-machine-cat 10.1.9 → 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 +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +5 -8
- package/src/cli/attributes-parser.mjs +0 -977
- package/src/parse/scxml/index.mjs +0 -291
- package/src/parse/smcat/smcat-parser.mjs +0 -2744
- 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
package/dist/commonjs/bundle.js
CHANGED
|
@@ -76,4 +76,4 @@
|
|
|
76
76
|
`)),t.cond&&(e.cond=t.cond),t["#text"]&&(e.action=Y.default.decode(t["#text"]).trim()),t.type&&(e.type=t.type),e}function wo(t){let e={};typeof t=="string"?e.action=Y.default.decode(t).trim():Object.assign(e,Ao(t));let n=Eo(e.event,e.cond,e.action);return n&&(e.label=n),e}function Oo(t){return(e,n)=>{let m=((n==null?void 0:n.target)??t.id).split(/\s+/),a=wo(n);return e.concat(m.map(c=>({from:t.id,to:c,...a})))}}function Re(t){return t.filter(e=>Object.prototype.hasOwnProperty.call(e,"transition")).reduce((e,n)=>e.concat((0,Ee.default)(n.transition).reduce(Oo(n),[])),[])}function Tn(t){let e=In(t),n={states:e.initial.map(se("initial")).concat(e.state.map(se("regular"))).concat(e.parallel.map(se("parallel"))).concat(e.history.map(se("history"))).concat(e.final.map(se("final")))},m=Re(e.initial).concat(Re(e.state)).concat(Re(e.parallel));return m.length>0&&(n.transitions=m),n}function Co(t,e){return(0,Sn.default)(t).map(function(){var m;if((m=this.key)!=null&&m.startsWith(e)){let a=this.key.slice(e.length);this.parent.keys.includes(a)?this.remove():(this.parent.node[a]=this.node,this.remove())}})}function An(t){let e=t.trim(),n="@_",m={},a=new kn.default.XMLParser({attributeNamePrefix:n,ignoreAttributes:!1,parseTagValue:!0,processEntities:!1,tagValueProcessor:(c,i)=>Y.default.decode(i),stopNodes:["*.onentry","*.onexit","*.transition"]});try{m=Co(a.parse(e,!0),n)}catch{throw new Error(`That doesn't look like valid xml ...
|
|
77
77
|
`)}return Tn((m==null?void 0:m.scxml)??{xmlns:"http://www.w3.org/2005/07/scxml",version:"1.0"})}var wn={$schema:"http://json-schema.org/draft-07/schema#",title:"state-machine-cat abstract syntax tree schema",$ref:"#/definitions/StateMachineType",$id:"org.js.state-machine-cat/v7.4.0",definitions:{StateType:{type:"string",enum:["regular","initial","terminate","final","parallel","history","deephistory","choice","forkjoin","fork","join","junction"]},TransitionType:{type:"string",enum:["internal","external"]},NoteType:{type:"array",items:{type:"string"}},ActionTypeType:{type:"string",enum:["entry","activity","exit"]},ActionType:{type:"object",required:["type","body"],additionalProperties:!1,properties:{type:{$ref:"#/definitions/ActionTypeType"},body:{type:"string"}}},ClassType:{type:"string",pattern:"^[a-zA-Z0-9_\\- ]*$"},StateMachineType:{type:"object",additionalProperties:!1,required:["states"],properties:{states:{type:"array",items:{type:"object",required:["name","type"],additionalProperties:!1,properties:{name:{description:"The name and identifier of the state. Unique within the root state machine.",type:"string"},type:{description:"What kind of state (or pseudo state) this state is. E.g. 'regular' for normal states or 'initial', 'final', 'choice' etc for pseudo states. Most UML (pseudo-) states are supported.",$ref:"#/definitions/StateType"},label:{description:"The display label of the state. If it's not present, most renderers will use the states' name in stead.",type:"string"},color:{description:'Color to use for rendering the state. Accepts all css color names ("blue") and hex notation - with ("#0000FF77") or without ("#0000FF") transparency.',type:"string"},class:{description:"Class name to give the state in dot and svg output.",$ref:"#/definitions/ClassType"},active:{description:"If true the state is considered to be active and rendered as such.",type:"boolean"},typeExplicitlySet:{description:"The default parser derives the `type` from the `name` with inband signaling. The user can override that behavior by explicitly setting the `type`. This attribute is there to express that (and make sure that on next parses & processing it doesn't get accidentily re-derived from the name again).",type:"boolean"},isComposite:{description:"convenience, derived attribute - set to true if there's a state machine inside the state; false in all other cases. For internal use - @deprecated",type:"boolean"},actions:{type:"array",description:"A series of actions and their types. The type describe when the action takes place (on entry, exit, or otherwise ('activity'))",items:{$ref:"#/definitions/ActionType"}},note:{description:"Comments related to this state. Some renderers will use the note attribute to render a note (i.e. as a post-it) attached to the state.",$ref:"#/definitions/NoteType"},statemachine:{description:"state machine nested within the state.",$ref:"#/definitions/StateMachineType"}}}},transitions:{type:"array",items:{type:"object",required:["from","to"],additionalProperties:!1,properties:{from:{description:"The name of the state this transition transitions from",type:"string"},to:{description:"The name of the state this transition transitions to",type:"string"},label:{description:"A display label to represent this transition. Parsers can parse this label into events conditions and actions.",type:"string"},event:{description:"Event triggering the transition",type:"string"},cond:{description:"Condition for the transition to occur.",type:"string"},action:{description:"Action to execute when the transition occurs.",type:"string"},note:{description:"Comments related to this transition",$ref:"#/definitions/NoteType"},color:{description:'Color to use for rendering the transition. Accepts all css color names ("blue") and hex notation - with ("#0000FF77") or without ("#0000FF") transparency.',type:"string"},width:{description:"The line width to use for rendering the transition",type:"number",minimum:0,maximum:30},class:{description:"Class name to give the state in dot and svg output.",$ref:"#/definitions/ClassType"},type:{description:"Whether the transition is external (default) or internal. See https://www.w3.org/TR/scxml/#transition for details.",$ref:"#/definitions/TransitionType"}}}}}}}};var On=new Cn.default;function jo(t,e){if(!On.validate(t,e))throw new Error(`The provided JSON is not a valid state-machine-cat AST: ${On.errorsText()}.
|
|
78
78
|
`)}var jn={getAST(t,e){let n=t;return N.getOptionValue(e,"inputType")==="smcat"?n=hn(t):N.getOptionValue(e,"inputType")==="scxml"?n=An(t):typeof t=="string"&&(n=JSON.parse(t)),jo(wn,n),n}};var Ve=F(require("lodash/cloneDeep.js"),1),Ne=F(require("lodash/reject.js"),1);function Po(t,e,n){return t?`${t}${n}${e}`:e}function _o(t,e){let n={...t,...e,from:t.from,to:e.to};return e.action&&(n.action=Po(t.action,e.action,`
|
|
79
|
-
`)),(n.event||n.cond||n.action)&&(n.label=Ie.formatLabel(n.event,n.cond,n.action)),n}function Fo(t,e,n){return t.reduce((m,a)=>(e.forEach((c,i)=>{c===a.to&&n[c]?m=m.concat(n[c].map(f=>_o(a,f))):m=i===0?m.concat(a):m}),m),[])}function Pn(t,e,n){let m=(0,Ve.default)(t);return m.transitions&&e.length>0&&(m.transitions=Fo(m.transitions,e,n)),m.states=m.states.map(a=>a.statemachine?{...a,statemachine:Pn(a.statemachine,e,n)}:a),m}function _n(t,e){let n=(0,Ve.default)(t);return n.transitions&&(n.transitions=(0,Ne.default)(n.transitions,m=>e.some(a=>a===m.from||a===m.to))),n.states=(0,Ne.default)(n.states,m=>e.includes(m.name)).map(m=>m.statemachine?{...m,statemachine:_n(m.statemachine,e)}:m),n}var Fn=(t,e=["fork","junction","choice"])=>{let n=new L(t),m=n.findStatesByTypes(e).map(({name:i})=>i),a=m.reduce((i,f)=>(i[f]=n.findTransitionsByFrom(f),i),{}),c=Pn(t,m,a);return _n(c,m)};var lr=F(require("lodash/has.js"),1),or=F(Bn(),1);var Jn=F(require("lodash/cloneDeep.js"),1);var Uo=[{name:"fontname",value:'"Helvetica"'},{name:"fontsize",value:"12"},{name:"penwidth",value:"2.0"}],Jo={dot:[{name:"splines",value:"true"},{name:"ordering",value:"out"},{name:"compound",value:"true"},{name:"overlap",value:"scale"},{name:"nodesep",value:"0.3"},{name:"ranksep",value:"0.1"}],fdp:[{name:"K",value:"0.9"}],osage:[{name:"pack",value:"42"}],neato:[{name:"epsilon",value:"0.9"}]},Xo={"bottom-top":[{name:"rankdir",value:"BT"}],"left-right":[{name:"rankdir",value:"LR"}],"right-left":[{name:"rankdir",value:"RL"}]},Go=[{name:"shape",value:"plaintext"},{name:"style",value:"filled"},{name:"fillcolor",value:'"#FFFFFF01"'},{name:"fontname",value:"Helvetica"},{name:"fontsize",value:12},{name:"penwidth",value:"2.0"}],Wo=[{name:"fontname",value:"Helvetica"},{name:"fontsize",value:10}];function De(t){return`${t.name}=${t.value}`}var ke={buildGraphAttributes:(t,e,n)=>Uo.concat(Jo[t]||[]).concat(Xo[e]||[]).concat(n||[]).map(De).join(" "),buildNodeAttributes:t=>Go.concat(t||[]).map(De).join(" "),buildEdgeAttributes:t=>Wo.concat(t||[]).map(De).join(" ")};var Dn=F(require("lodash/cloneDeep.js"),1);function Qo(t){return t.replace(/\\/g,"\\\\").replace(/\n\s*/g,"\\l").replace(/"/g,'\\"').concat("\\l")}function Yo(t){return t.replace(/\\/g,"\\\\").replace(/\n\s*/g," \\l").replace(/"/g,'\\"').concat(" \\l")}function Zo(t){let e=t||"top-down";return e==="top-down"||e==="bottom-top"}function Ko(t,e){return e.from===e.to&&t.findStateByName(e.from).statemachine&&e.type!=="internal"}var M={escapeString:Qo,escapeLabelString:Yo,isVertical:Zo,isCompositeSelf:Ko};function Hn(t){return e=>e.type===t}function He(t){return e=>t.includes(e.type)}function ei(t){let e=(0,Dn.default)(t);return e.label=t.label||t.name,e}function ti(t){return t.note?{noteName:`note_${t.name}`,...t}:t}function ni(t){let e={...t},n=["state",t.type];return t.class&&n.push(t.class.trim().replace(/[ ]{2,}/g," ")),e.class=n.join(" "),e}function ri(t){return t==="activity"?"":`${t}/ `}function ai(t){return t.actions?{...t,actionStrings:t.actions.map(e=>`${ri(e.type)}${e.body}`)}:t}function li(t){return t.note?{...t,noteFlattened:t.note.join("")}:t}function oi(t){return e=>{var m;let n=(m=(t||[]).find(a=>a.name==="color"))==null?void 0:m.value;return n&&!e.color&&He(["initial","fork","join","junction","forkjoin","final"])(e)&&(e.color=n),e}}function ii(t){return t.note?{...t,note:t.note.map(M.escapeString)}:t}function si(t){return e=>He(["fork","join","forkjoin"])(e)?{sizingExtras:M.isVertical(t)?"height=0.1":"width=0.1",...e}:e}function ci(t){return t.type==="parallel"&&t.statemachine&&t.statemachine.states&&(t.statemachine.states=t.statemachine.states.map(e=>Hn("regular")(e)?{...e,parentIsParallel:!0}:e)),t}var j={isType:Hn,isOneOfTypes:He,setLabel:ei,classifyState:ni,nameNote:ti,flattenActions:ai,flattenNote:li,recolor:oi,escapeStateStrings:ii,tipForkJoinStates:si,flagParallelChildren:ci};function ui(t){let e={...t};return e.note&&(e.note=e.note.map(M.escapeString)),e.label&&(e.label=M.escapeLabelString(e.label)),e}function fi(t){return e=>{let n={};return e.isCompositeSelf&&(M.isVertical(t)?n={tailportflags:'tailport="e" headport="e"',headportflags:'tailport="w"'}:e.hasParent?n={tailportflags:'tailport="n" headport="n"',headportflags:'tailport="s"'}:n={tailportflags:'tailport="s" headport="s"',headportflags:'tailport="n"'}),{...e,...n}}}function pi(t){let e=["transition"];return t.type&&e.push(t.type),t.class&&e.push(t.class.trim().replace(/[ ]{2,}/g," ")),t.class=e.join(" "),t}var Se={escapeTransitionStrings:ui,addPorts:fi,classifyTransition:pi};var ce=class{COUNTER=0;constructor(){this.reset()}reset(){this.COUNTER=0}next(){return++this.COUNTER}nextAsString(){return this.next().toString(10)}};var Xn=F(Un(),1);function bi(t){return e=>(Object.prototype.hasOwnProperty.call(e,"statemachine")&&(e.nestedExternalSelfTransitions=t.findExternalSelfTransitions(e.name).map(n=>n.name)),e)}function Gn(t,e,n,m){return t.filter(a=>a.statemachine).forEach(a=>{a.statemachine.states=Gn(a.statemachine.states,e,n,m)}),t.map(j.setLabel).map(j.nameNote).map(j.classifyState).map(j.escapeStateStrings).map(j.flattenNote).map(j.flattenActions).map(j.flagParallelChildren).map(j.tipForkJoinStates(e)).map(j.recolor(n)).map(bi(m))}function xi(t){return t.initialStates=t.states.filter(j.isType("initial")),t.regularStates=t.states.filter(e=>j.isType("regular")(e)&&!e.statemachine),t.historyStates=t.states.filter(j.isType("history")),t.deepHistoryStates=t.states.filter(j.isType("deephistory")),t.choiceStates=t.states.filter(j.isType("choice")),t.forkjoinStates=t.states.filter(j.isOneOfTypes(["fork","join","forkjoin"])),t.junctionStates=t.states.filter(j.isType("junction")),t.terminateStates=t.states.filter(j.isType("terminate")),t.finalStates=t.states.filter(j.isType("final")),t.compositeStates=t.states.filter(e=>e.statemachine),t}function $i(t){return e=>(t.findStateByName(e.from).statemachine&&(e.fromComposite=!0),t.findStateByName(e.to).statemachine&&(e.toComposite=!0),e)}function Ii(t){return e=>{let n={};return M.isCompositeSelf(t,e)&&(t.findStateByName(e.from).hasParent?n={hasParent:!0,isCompositeSelf:!0}:n={isCompositeSelf:!0}),{...e,...n}}}function Ei(t){return e=>(e.name=`tr_${e.from}_${e.to}_${t.nextAsString()}`,Boolean(e.note)&&(e.noteName=`note_${e.name}`),e)}function ki(t,e,n){return t.flattenedTransitions.map(Ei(n)).map(Se.escapeTransitionStrings).map(Se.classifyTransition).map(j.flattenNote).map($i(t)).map(Ii(t)).map(Se.addPorts(e))}var Te=(t,e)=>{e=e||{};let n=(0,Jn.default)(t),m=new L(n);return n.transitions=ki(m,e.direction,new ce),n.states=Gn(n.states,e.direction,e.dotNodeAttrs,m),n=xi(n),n.graphAttributes=ke.buildGraphAttributes(N.getOptionValue(e,"engine"),N.getOptionValue(e,"direction"),e.dotGraphAttrs),n.nodeAttributes=ke.buildNodeAttributes(e.dotNodeAttrs),n.edgeAttributes=ke.buildEdgeAttributes(e.dotEdgeAttrs),(0,Xn.default)(n)};var Wn=F(require("viz.js"),1);var Si={oldsvg:"svg",oldps2:"ps2",oldeps:"eps"},Ti=(t,e)=>(0,Wn.default)(Te(t,e),{engine:N.getOptionValue(e,"engine"),format:Si[N.getOptionValue(e,"outputType")]||"svg"}),ze=Ti;var Ai=/[\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,wi=/[-|.|0-9|\u00B7|\u0300-\u036F|\u203F-\u2040]/g;function Qn(t){return t.replace(Ai,"_")}function Oi(t){let e=Qn(t);return e.match(wi)&&(e=`_${t}`),e}var Ae=t=>(t=t||"",t.length===0?"__empty":Oi(t[0]).concat(Qn(t.slice(1))));var Ci=/[\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,ji=/[.]/g;function Yn(t){return t.replace(Ci,"_")}function Pi(t){let e=Yn(t);return e.match(ji)&&(e=`_${t}`),e}function _i(t){return t=t.replace(/\s+/g," ").trim(),Pi(t[0]).concat(Yn(t.slice(1)))}var Zn=t=>{let e=t||"";return e.length===0?"empty":e.split(/[\n\r]+/).filter(n=>n.length>0).map(_i).join(" ")};var Fi={regular:"state",initial:"initial",final:"final",terminate:"final",parallel:"parallel",history:"history",deephistory:"history"};function Ri(t){return Fi[t]||"state"}function Ni(t){let e={target:Ae(t.to)};return t.event&&(e.event=Zn(t.event)),t.cond&&(e.cond=t.cond),t.action&&(e.action=t.action),t.type&&(e.type=t.type),e}function Vi(t,e){return t.filter(n=>n.type===e).map(n=>n.body)}function Ue(t,e,n,m){let a=Vi(n,m);a.length>0&&(t[e]=(t[e]||[]).concat(a))}function Li(t,e){e.actions&&(Ue(t,"onentries",e.actions,"entry"),Ue(t,"onentries",e.actions,"activity"),Ue(t,"onexits",e.actions,"exit"))}function Bi(t,e,n){let m=n.filter(a=>a.from===e.name).map(Ni);m.length>0&&(t.transitions=m)}function Di(t,e,n){if(e.statemachine){let m=ne(e.statemachine,void 0,n);t.states=(t.states||[]).concat(m.states),m.initial&&(t.initial=m.initial)}}function Hi(t){return t=t||[],e=>{let n={kind:Ri(e.type),id:Ae(e.name)};return e.type==="deephistory"&&(n.type="deep"),Li(n,e),Bi(n,e,t),Di(n,e,t),n}}function qi(t){let e=t.states.filter(n=>n.type==="initial");if(e.length>0)return e[0].name}function Mi(t,e){let n=e;if(e&&t.transitions){let m=t.transitions.filter(a=>a.from===e);m.length>0&&!m[0].action&&(n=m[0].to)}return n}function ne(t,e,n){let m=qi(t),a=Mi(t,m),c={states:t.states.filter(i=>a&&a!==m?i.type!=="initial":!0).map(Hi(n||new L(t).flattenedTransitions))};return a&&(c.initial=Ae(a)),c}var rr=F(nr(),1),Gi=t=>(0,rr.default)(ne(t)),ar=Gi;var Wi=or.default;function We(t){let e={smcat:Wi,dot:Te,svg:ze,oldsvg:ze,scjson:ne,scxml:ar};return(0,lr.default)(e,t)?e[t]:n=>n}var ir="10.1.
|
|
79
|
+
`)),(n.event||n.cond||n.action)&&(n.label=Ie.formatLabel(n.event,n.cond,n.action)),n}function Fo(t,e,n){return t.reduce((m,a)=>(e.forEach((c,i)=>{c===a.to&&n[c]?m=m.concat(n[c].map(f=>_o(a,f))):m=i===0?m.concat(a):m}),m),[])}function Pn(t,e,n){let m=(0,Ve.default)(t);return m.transitions&&e.length>0&&(m.transitions=Fo(m.transitions,e,n)),m.states=m.states.map(a=>a.statemachine?{...a,statemachine:Pn(a.statemachine,e,n)}:a),m}function _n(t,e){let n=(0,Ve.default)(t);return n.transitions&&(n.transitions=(0,Ne.default)(n.transitions,m=>e.some(a=>a===m.from||a===m.to))),n.states=(0,Ne.default)(n.states,m=>e.includes(m.name)).map(m=>m.statemachine?{...m,statemachine:_n(m.statemachine,e)}:m),n}var Fn=(t,e=["fork","junction","choice"])=>{let n=new L(t),m=n.findStatesByTypes(e).map(({name:i})=>i),a=m.reduce((i,f)=>(i[f]=n.findTransitionsByFrom(f),i),{}),c=Pn(t,m,a);return _n(c,m)};var lr=F(require("lodash/has.js"),1),or=F(Bn(),1);var Jn=F(require("lodash/cloneDeep.js"),1);var Uo=[{name:"fontname",value:'"Helvetica"'},{name:"fontsize",value:"12"},{name:"penwidth",value:"2.0"}],Jo={dot:[{name:"splines",value:"true"},{name:"ordering",value:"out"},{name:"compound",value:"true"},{name:"overlap",value:"scale"},{name:"nodesep",value:"0.3"},{name:"ranksep",value:"0.1"}],fdp:[{name:"K",value:"0.9"}],osage:[{name:"pack",value:"42"}],neato:[{name:"epsilon",value:"0.9"}]},Xo={"bottom-top":[{name:"rankdir",value:"BT"}],"left-right":[{name:"rankdir",value:"LR"}],"right-left":[{name:"rankdir",value:"RL"}]},Go=[{name:"shape",value:"plaintext"},{name:"style",value:"filled"},{name:"fillcolor",value:'"#FFFFFF01"'},{name:"fontname",value:"Helvetica"},{name:"fontsize",value:12},{name:"penwidth",value:"2.0"}],Wo=[{name:"fontname",value:"Helvetica"},{name:"fontsize",value:10}];function De(t){return`${t.name}=${t.value}`}var ke={buildGraphAttributes:(t,e,n)=>Uo.concat(Jo[t]||[]).concat(Xo[e]||[]).concat(n||[]).map(De).join(" "),buildNodeAttributes:t=>Go.concat(t||[]).map(De).join(" "),buildEdgeAttributes:t=>Wo.concat(t||[]).map(De).join(" ")};var Dn=F(require("lodash/cloneDeep.js"),1);function Qo(t){return t.replace(/\\/g,"\\\\").replace(/\n\s*/g,"\\l").replace(/"/g,'\\"').concat("\\l")}function Yo(t){return t.replace(/\\/g,"\\\\").replace(/\n\s*/g," \\l").replace(/"/g,'\\"').concat(" \\l")}function Zo(t){let e=t||"top-down";return e==="top-down"||e==="bottom-top"}function Ko(t,e){return e.from===e.to&&t.findStateByName(e.from).statemachine&&e.type!=="internal"}var M={escapeString:Qo,escapeLabelString:Yo,isVertical:Zo,isCompositeSelf:Ko};function Hn(t){return e=>e.type===t}function He(t){return e=>t.includes(e.type)}function ei(t){let e=(0,Dn.default)(t);return e.label=t.label||t.name,e}function ti(t){return t.note?{noteName:`note_${t.name}`,...t}:t}function ni(t){let e={...t},n=["state",t.type];return t.class&&n.push(t.class.trim().replace(/[ ]{2,}/g," ")),e.class=n.join(" "),e}function ri(t){return t==="activity"?"":`${t}/ `}function ai(t){return t.actions?{...t,actionStrings:t.actions.map(e=>`${ri(e.type)}${e.body}`)}:t}function li(t){return t.note?{...t,noteFlattened:t.note.join("")}:t}function oi(t){return e=>{var m;let n=(m=(t||[]).find(a=>a.name==="color"))==null?void 0:m.value;return n&&!e.color&&He(["initial","fork","join","junction","forkjoin","final"])(e)&&(e.color=n),e}}function ii(t){return t.note?{...t,note:t.note.map(M.escapeString)}:t}function si(t){return e=>He(["fork","join","forkjoin"])(e)?{sizingExtras:M.isVertical(t)?"height=0.1":"width=0.1",...e}:e}function ci(t){return t.type==="parallel"&&t.statemachine&&t.statemachine.states&&(t.statemachine.states=t.statemachine.states.map(e=>Hn("regular")(e)?{...e,parentIsParallel:!0}:e)),t}var j={isType:Hn,isOneOfTypes:He,setLabel:ei,classifyState:ni,nameNote:ti,flattenActions:ai,flattenNote:li,recolor:oi,escapeStateStrings:ii,tipForkJoinStates:si,flagParallelChildren:ci};function ui(t){let e={...t};return e.note&&(e.note=e.note.map(M.escapeString)),e.label&&(e.label=M.escapeLabelString(e.label)),e}function fi(t){return e=>{let n={};return e.isCompositeSelf&&(M.isVertical(t)?n={tailportflags:'tailport="e" headport="e"',headportflags:'tailport="w"'}:e.hasParent?n={tailportflags:'tailport="n" headport="n"',headportflags:'tailport="s"'}:n={tailportflags:'tailport="s" headport="s"',headportflags:'tailport="n"'}),{...e,...n}}}function pi(t){let e=["transition"];return t.type&&e.push(t.type),t.class&&e.push(t.class.trim().replace(/[ ]{2,}/g," ")),t.class=e.join(" "),t}var Se={escapeTransitionStrings:ui,addPorts:fi,classifyTransition:pi};var ce=class{COUNTER=0;constructor(){this.reset()}reset(){this.COUNTER=0}next(){return++this.COUNTER}nextAsString(){return this.next().toString(10)}};var Xn=F(Un(),1);function bi(t){return e=>(Object.prototype.hasOwnProperty.call(e,"statemachine")&&(e.nestedExternalSelfTransitions=t.findExternalSelfTransitions(e.name).map(n=>n.name)),e)}function Gn(t,e,n,m){return t.filter(a=>a.statemachine).forEach(a=>{a.statemachine.states=Gn(a.statemachine.states,e,n,m)}),t.map(j.setLabel).map(j.nameNote).map(j.classifyState).map(j.escapeStateStrings).map(j.flattenNote).map(j.flattenActions).map(j.flagParallelChildren).map(j.tipForkJoinStates(e)).map(j.recolor(n)).map(bi(m))}function xi(t){return t.initialStates=t.states.filter(j.isType("initial")),t.regularStates=t.states.filter(e=>j.isType("regular")(e)&&!e.statemachine),t.historyStates=t.states.filter(j.isType("history")),t.deepHistoryStates=t.states.filter(j.isType("deephistory")),t.choiceStates=t.states.filter(j.isType("choice")),t.forkjoinStates=t.states.filter(j.isOneOfTypes(["fork","join","forkjoin"])),t.junctionStates=t.states.filter(j.isType("junction")),t.terminateStates=t.states.filter(j.isType("terminate")),t.finalStates=t.states.filter(j.isType("final")),t.compositeStates=t.states.filter(e=>e.statemachine),t}function $i(t){return e=>(t.findStateByName(e.from).statemachine&&(e.fromComposite=!0),t.findStateByName(e.to).statemachine&&(e.toComposite=!0),e)}function Ii(t){return e=>{let n={};return M.isCompositeSelf(t,e)&&(t.findStateByName(e.from).hasParent?n={hasParent:!0,isCompositeSelf:!0}:n={isCompositeSelf:!0}),{...e,...n}}}function Ei(t){return e=>(e.name=`tr_${e.from}_${e.to}_${t.nextAsString()}`,Boolean(e.note)&&(e.noteName=`note_${e.name}`),e)}function ki(t,e,n){return t.flattenedTransitions.map(Ei(n)).map(Se.escapeTransitionStrings).map(Se.classifyTransition).map(j.flattenNote).map($i(t)).map(Ii(t)).map(Se.addPorts(e))}var Te=(t,e)=>{e=e||{};let n=(0,Jn.default)(t),m=new L(n);return n.transitions=ki(m,e.direction,new ce),n.states=Gn(n.states,e.direction,e.dotNodeAttrs,m),n=xi(n),n.graphAttributes=ke.buildGraphAttributes(N.getOptionValue(e,"engine"),N.getOptionValue(e,"direction"),e.dotGraphAttrs),n.nodeAttributes=ke.buildNodeAttributes(e.dotNodeAttrs),n.edgeAttributes=ke.buildEdgeAttributes(e.dotEdgeAttrs),(0,Xn.default)(n)};var Wn=F(require("viz.js"),1);var Si={oldsvg:"svg",oldps2:"ps2",oldeps:"eps"},Ti=(t,e)=>(0,Wn.default)(Te(t,e),{engine:N.getOptionValue(e,"engine"),format:Si[N.getOptionValue(e,"outputType")]||"svg"}),ze=Ti;var Ai=/[\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,wi=/[-|.|0-9|\u00B7|\u0300-\u036F|\u203F-\u2040]/g;function Qn(t){return t.replace(Ai,"_")}function Oi(t){let e=Qn(t);return e.match(wi)&&(e=`_${t}`),e}var Ae=t=>(t=t||"",t.length===0?"__empty":Oi(t[0]).concat(Qn(t.slice(1))));var Ci=/[\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,ji=/[.]/g;function Yn(t){return t.replace(Ci,"_")}function Pi(t){let e=Yn(t);return e.match(ji)&&(e=`_${t}`),e}function _i(t){return t=t.replace(/\s+/g," ").trim(),Pi(t[0]).concat(Yn(t.slice(1)))}var Zn=t=>{let e=t||"";return e.length===0?"empty":e.split(/[\n\r]+/).filter(n=>n.length>0).map(_i).join(" ")};var Fi={regular:"state",initial:"initial",final:"final",terminate:"final",parallel:"parallel",history:"history",deephistory:"history"};function Ri(t){return Fi[t]||"state"}function Ni(t){let e={target:Ae(t.to)};return t.event&&(e.event=Zn(t.event)),t.cond&&(e.cond=t.cond),t.action&&(e.action=t.action),t.type&&(e.type=t.type),e}function Vi(t,e){return t.filter(n=>n.type===e).map(n=>n.body)}function Ue(t,e,n,m){let a=Vi(n,m);a.length>0&&(t[e]=(t[e]||[]).concat(a))}function Li(t,e){e.actions&&(Ue(t,"onentries",e.actions,"entry"),Ue(t,"onentries",e.actions,"activity"),Ue(t,"onexits",e.actions,"exit"))}function Bi(t,e,n){let m=n.filter(a=>a.from===e.name).map(Ni);m.length>0&&(t.transitions=m)}function Di(t,e,n){if(e.statemachine){let m=ne(e.statemachine,void 0,n);t.states=(t.states||[]).concat(m.states),m.initial&&(t.initial=m.initial)}}function Hi(t){return t=t||[],e=>{let n={kind:Ri(e.type),id:Ae(e.name)};return e.type==="deephistory"&&(n.type="deep"),Li(n,e),Bi(n,e,t),Di(n,e,t),n}}function qi(t){let e=t.states.filter(n=>n.type==="initial");if(e.length>0)return e[0].name}function Mi(t,e){let n=e;if(e&&t.transitions){let m=t.transitions.filter(a=>a.from===e);m.length>0&&!m[0].action&&(n=m[0].to)}return n}function ne(t,e,n){let m=qi(t),a=Mi(t,m),c={states:t.states.filter(i=>a&&a!==m?i.type!=="initial":!0).map(Hi(n||new L(t).flattenedTransitions))};return a&&(c.initial=Ae(a)),c}var rr=F(nr(),1),Gi=t=>(0,rr.default)(ne(t)),ar=Gi;var Wi=or.default;function We(t){let e={smcat:Wi,dot:Te,svg:ze,oldsvg:ze,scjson:ne,scxml:ar};return(0,lr.default)(e,t)?e[t]:n=>n}var ir="10.1.10";function sr(t,e){let n=jn.getAST(t,e),m=N.getOptionValue(e,"desugar");return We(N.getOptionValue(e,"outputType"))(m?Fn(n):n,e)}var cr=ir;function ur(){return N.getAllowedValues()}var Qi={render:sr,version:cr,getAllowedValues:ur};
|
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",
|
|
@@ -76,9 +76,6 @@
|
|
|
76
76
|
"files": [
|
|
77
77
|
"bin/",
|
|
78
78
|
"dist/",
|
|
79
|
-
"src/**/*.js",
|
|
80
|
-
"src/**/*.mjs",
|
|
81
|
-
"src/**/*.json",
|
|
82
79
|
"types/",
|
|
83
80
|
"package.json",
|
|
84
81
|
"README.md",
|
|
@@ -371,7 +368,7 @@
|
|
|
371
368
|
"ajv": "8.12.0",
|
|
372
369
|
"chalk": "5.2.0",
|
|
373
370
|
"commander": "10.0.0",
|
|
374
|
-
"fast-xml-parser": "4.1.
|
|
371
|
+
"fast-xml-parser": "4.1.3",
|
|
375
372
|
"get-stream": "6.0.1",
|
|
376
373
|
"handlebars": "4.7.7",
|
|
377
374
|
"he": "1.2.0",
|
|
@@ -388,8 +385,8 @@
|
|
|
388
385
|
"@types/he": "1.2.0",
|
|
389
386
|
"@types/lodash": "4.14.191",
|
|
390
387
|
"@types/mocha": "10.0.1",
|
|
391
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
392
|
-
"@typescript-eslint/parser": "5.
|
|
388
|
+
"@typescript-eslint/eslint-plugin": "5.54.0",
|
|
389
|
+
"@typescript-eslint/parser": "5.54.0",
|
|
393
390
|
"c8": "7.13.0",
|
|
394
391
|
"chai": "4.3.7",
|
|
395
392
|
"chai-as-promised": "7.1.1",
|
|
@@ -397,7 +394,7 @@
|
|
|
397
394
|
"chai-xml": "0.4.0",
|
|
398
395
|
"dependency-cruiser": "12.10.0",
|
|
399
396
|
"esbuild": "0.17.10",
|
|
400
|
-
"eslint": "8.
|
|
397
|
+
"eslint": "8.35.0",
|
|
401
398
|
"eslint-config-moving-meadow": "4.0.2",
|
|
402
399
|
"eslint-config-prettier": "8.6.0",
|
|
403
400
|
"eslint-plugin-budapestian": "5.0.1",
|