state-machine-cat 10.1.7 → 10.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -76,4 +76,4 @@
76
76
  `)),t.cond&&(e.cond=t.cond),t["#text"]&&(e.action=Q.default.decode(t["#text"]).trim()),t.type&&(e.type=t.type),e}function co(t){let e={};typeof t=="string"?e.action=Q.default.decode(t).trim():Object.assign(e,so(t));let n=lo(e.event,e.cond,e.action);return n&&(e.label=n),e}function uo(t){return(e,n)=>{let d=((n==null?void 0:n.target)??t.id).split(/\s+/),l=co(n);return e.concat(d.map(u=>({from:t.id,to:u,...l})))}}function Oe(t){return t.filter(e=>Object.prototype.hasOwnProperty.call(e,"transition")).reduce((e,n)=>e.concat((0,ve.default)(n.transition).reduce(uo(n),[])),[])}function dn(t){let e=mn(t),n={states:e.initial.map(oe("initial")).concat(e.state.map(oe("regular"))).concat(e.parallel.map(oe("parallel"))).concat(e.history.map(oe("history"))).concat(e.final.map(oe("final")))},d=Oe(e.initial).concat(Oe(e.state)).concat(Oe(e.parallel));return d.length>0&&(n.transitions=d),n}function hn(t){let e=t.trim();if(Pe.default.validate(e)===!0){let n=Pe.default.parse(e,{attributeNamePrefix:"",ignoreAttributes:!1,tagValueProcessor:d=>Q.default.decode(d),stopNodes:["onentry","onexit","transition"]});return dn((n==null?void 0:n.scxml)??{xmlns:"http://www.w3.org/2005/07/scxml",version:"1.0"})}throw new Error(`That doesn't look like valid xml ...
77
77
  `)}var gn={$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 yn=new vn.default;function fo(t,e){if(!yn.validate(t,e))throw new Error(`The provided JSON is not a valid state-machine-cat AST: ${yn.errorsText()}.
78
78
  `)}var bn={getAST(t,e){let n=t;return R.getOptionValue(e,"inputType")==="smcat"?n=fn(t):R.getOptionValue(e,"inputType")==="scxml"?n=hn(t):typeof t=="string"&&(n=JSON.parse(t)),fo(gn,n),n}};var _e=_(require("lodash/cloneDeep.js"),1),je=_(require("lodash/reject.js"),1);function mo(t,e,n){return t?`${t}${n}${e}`:e}function po(t,e){let n={...t,...e,from:t.from,to:e.to};return e.action&&(n.action=mo(t.action,e.action,`
79
- `)),(n.event||n.cond||n.action)&&(n.label=ye.formatLabel(n.event,n.cond,n.action)),n}function ho(t,e,n){return t.reduce((d,l)=>(e.forEach((u,s)=>{u===l.to&&n[u]?d=d.concat(n[u].map(f=>po(l,f))):d=s===0?d.concat(l):d}),d),[])}function xn(t,e,n){let d=(0,_e.default)(t);return d.transitions&&e.length>0&&(d.transitions=ho(d.transitions,e,n)),d.states=d.states.map(l=>l.statemachine?{...l,statemachine:xn(l.statemachine,e,n)}:l),d}function $n(t,e){let n=(0,_e.default)(t);return n.transitions&&(n.transitions=(0,je.default)(n.transitions,d=>e.some(l=>l===d.from||l===d.to))),n.states=(0,je.default)(n.states,d=>e.includes(d.name)).map(d=>d.statemachine?{...d,statemachine:$n(d.statemachine,e)}:d),n}var In=(t,e=["fork","junction","choice"])=>{let n=new N(t),d=n.findStatesByTypes(e).map(({name:s})=>s),l=d.reduce((s,f)=>(s[f]=n.findTransitionsByFrom(f),s),{}),u=xn(t,d,l);return $n(u,d)};var Xn=_(require("lodash/has.js"),1),Gn=_(An(),1);var Fn=_(require("lodash/cloneDeep.js"),1);var ko=[{name:"fontname",value:'"Helvetica"'},{name:"fontsize",value:"12"},{name:"penwidth",value:"2.0"}],Ao={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"}]},wo={"bottom-top":[{name:"rankdir",value:"BT"}],"left-right":[{name:"rankdir",value:"LR"}],"right-left":[{name:"rankdir",value:"RL"}]},Co=[{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"}],Oo=[{name:"fontname",value:"Helvetica"},{name:"fontsize",value:10}];function Ne(t){return`${t.name}=${t.value}`}var be={buildGraphAttributes:(t,e,n)=>ko.concat(Ao[t]||[]).concat(wo[e]||[]).concat(n||[]).map(Ne).join(" "),buildNodeAttributes:t=>Co.concat(t||[]).map(Ne).join(" "),buildEdgeAttributes:t=>Oo.concat(t||[]).map(Ne).join(" ")};var wn=_(require("lodash/cloneDeep.js"),1);function Po(t){return t.replace(/\\/g,"\\\\").replace(/\n\s*/g,"\\l").replace(/"/g,'\\"').concat("\\l")}function jo(t){return t.replace(/\\/g,"\\\\").replace(/\n\s*/g," \\l").replace(/"/g,'\\"').concat(" \\l")}function _o(t){let e=t||"top-down";return e==="top-down"||e==="bottom-top"}function Fo(t,e){return e.from===e.to&&t.findStateByName(e.from).statemachine&&e.type!=="internal"}var q={escapeString:Po,escapeLabelString:jo,isVertical:_o,isCompositeSelf:Fo};function Cn(t){return e=>e.type===t}function Ve(t){return e=>t.includes(e.type)}function Ro(t){let e=(0,wn.default)(t);return e.label=t.label||t.name,e}function No(t){return t.note?{noteName:`note_${t.name}`,...t}:t}function Vo(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 Lo(t){return t==="activity"?"":`${t}/ `}function Bo(t){return t.actions?{...t,actionStrings:t.actions.map(e=>`${Lo(e.type)}${e.body}`)}:t}function Ho(t){return t.note?{...t,noteFlattened:t.note.join("")}:t}function qo(t){return e=>{var d;let n=(d=(t||[]).find(l=>l.name==="color"))==null?void 0:d.value;return n&&!e.color&&Ve(["initial","fork","join","junction","forkjoin","final"])(e)&&(e.color=n),e}}function Do(t){return t.note?{...t,note:t.note.map(q.escapeString)}:t}function Mo(t){return e=>Ve(["fork","join","forkjoin"])(e)?{sizingExtras:q.isVertical(t)?"height=0.1":"width=0.1",...e}:e}function zo(t){return t.type==="parallel"&&t.statemachine&&t.statemachine.states&&(t.statemachine.states=t.statemachine.states.map(e=>Cn("regular")(e)?{...e,parentIsParallel:!0}:e)),t}var P={isType:Cn,isOneOfTypes:Ve,setLabel:Ro,classifyState:Vo,nameNote:No,flattenActions:Bo,flattenNote:Ho,recolor:qo,escapeStateStrings:Do,tipForkJoinStates:Mo,flagParallelChildren:zo};function Uo(t){let e={...t};return e.note&&(e.note=e.note.map(q.escapeString)),e.label&&(e.label=q.escapeLabelString(e.label)),e}function Jo(t){return e=>{let n={};return e.isCompositeSelf&&(q.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 Xo(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 xe={escapeTransitionStrings:Uo,addPorts:Jo,classifyTransition:Xo};var ie=class{COUNTER=0;constructor(){this.reset()}reset(){this.COUNTER=0}next(){return++this.COUNTER}nextAsString(){return this.next().toString(10)}};var Rn=_(_n(),1);function ei(t){return e=>(Object.prototype.hasOwnProperty.call(e,"statemachine")&&(e.nestedExternalSelfTransitions=t.findExternalSelfTransitions(e.name).map(n=>n.name)),e)}function Nn(t,e,n,d){return t.filter(l=>l.statemachine).forEach(l=>{l.statemachine.states=Nn(l.statemachine.states,e,n,d)}),t.map(P.setLabel).map(P.nameNote).map(P.classifyState).map(P.escapeStateStrings).map(P.flattenNote).map(P.flattenActions).map(P.flagParallelChildren).map(P.tipForkJoinStates(e)).map(P.recolor(n)).map(ei(d))}function ti(t){return t.initialStates=t.states.filter(P.isType("initial")),t.regularStates=t.states.filter(e=>P.isType("regular")(e)&&!e.statemachine),t.historyStates=t.states.filter(P.isType("history")),t.deepHistoryStates=t.states.filter(P.isType("deephistory")),t.choiceStates=t.states.filter(P.isType("choice")),t.forkjoinStates=t.states.filter(P.isOneOfTypes(["fork","join","forkjoin"])),t.junctionStates=t.states.filter(P.isType("junction")),t.terminateStates=t.states.filter(P.isType("terminate")),t.finalStates=t.states.filter(P.isType("final")),t.compositeStates=t.states.filter(e=>e.statemachine),t}function ni(t){return e=>(t.findStateByName(e.from).statemachine&&(e.fromComposite=!0),t.findStateByName(e.to).statemachine&&(e.toComposite=!0),e)}function ri(t){return e=>{let n={};return q.isCompositeSelf(t,e)&&(t.findStateByName(e.from).hasParent?n={hasParent:!0,isCompositeSelf:!0}:n={isCompositeSelf:!0}),{...e,...n}}}function li(t){return e=>(e.name=`tr_${e.from}_${e.to}_${t.nextAsString()}`,Boolean(e.note)&&(e.noteName=`note_${e.name}`),e)}function ai(t,e,n){return t.flattenedTransitions.map(li(n)).map(xe.escapeTransitionStrings).map(xe.classifyTransition).map(P.flattenNote).map(ni(t)).map(ri(t)).map(xe.addPorts(e))}var $e=(t,e)=>{e=e||{};let n=(0,Fn.default)(t),d=new N(n);return n.transitions=ai(d,e.direction,new ie),n.states=Nn(n.states,e.direction,e.dotNodeAttrs,d),n=ti(n),n.graphAttributes=be.buildGraphAttributes(R.getOptionValue(e,"engine"),R.getOptionValue(e,"direction"),e.dotGraphAttrs),n.nodeAttributes=be.buildNodeAttributes(e.dotNodeAttrs),n.edgeAttributes=be.buildEdgeAttributes(e.dotEdgeAttrs),(0,Rn.default)(n)};var Vn=_(require("viz.js"),1);var oi={oldsvg:"svg",oldps2:"ps2",oldeps:"eps"},ii=(t,e)=>(0,Vn.default)($e(t,e),{engine:R.getOptionValue(e,"engine"),format:oi[R.getOptionValue(e,"outputType")]||"svg"}),He=ii;var si=/[\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,ci=/[-|.|0-9|\u00B7|\u0300-\u036F|\u203F-\u2040]/g;function Ln(t){return t.replace(si,"_")}function ui(t){let e=Ln(t);return e.match(ci)&&(e=`_${t}`),e}var Ie=t=>(t=t||"",t.length===0?"__empty":ui(t[0]).concat(Ln(t.slice(1))));var fi=/[\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,mi=/[.]/g;function Bn(t){return t.replace(fi,"_")}function pi(t){let e=Bn(t);return e.match(mi)&&(e=`_${t}`),e}function di(t){return t=t.replace(/\s+/g," ").trim(),pi(t[0]).concat(Bn(t.slice(1)))}var Hn=t=>{let e=t||"";return e.length===0?"empty":e.split(/[\n\r]+/).filter(n=>n.length>0).map(di).join(" ")};var hi={regular:"state",initial:"initial",final:"final",terminate:"final",parallel:"parallel",history:"history",deephistory:"history"};function gi(t){return hi[t]||"state"}function yi(t){let e={target:Ie(t.to)};return t.event&&(e.event=Hn(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 qe(t,e,n,d){let l=vi(n,d);l.length>0&&(t[e]=(t[e]||[]).concat(l))}function bi(t,e){e.actions&&(qe(t,"onentries",e.actions,"entry"),qe(t,"onentries",e.actions,"activity"),qe(t,"onexits",e.actions,"exit"))}function xi(t,e,n){let d=n.filter(l=>l.from===e.name).map(yi);d.length>0&&(t.transitions=d)}function $i(t,e,n){if(e.statemachine){let d=ee(e.statemachine,void 0,n);t.states=(t.states||[]).concat(d.states),d.initial&&(t.initial=d.initial)}}function Ii(t){return t=t||[],e=>{let n={kind:gi(e.type),id:Ie(e.name)};return e.type==="deephistory"&&(n.type="deep"),bi(n,e),xi(n,e,t),$i(n,e,t),n}}function Ei(t){let e=t.states.filter(n=>n.type==="initial");if(e.length>0)return e[0].name}function Si(t,e){let n=e;if(e&&t.transitions){let d=t.transitions.filter(l=>l.from===e);d.length>0&&!d[0].action&&(n=d[0].to)}return n}function ee(t,e,n){let d=Ei(t),l=Si(t,d),u={states:t.states.filter(s=>l&&l!==d?s.type!=="initial":!0).map(Ii(n||new N(t).flattenedTransitions))};return l&&(u.initial=Ie(l)),u}var Un=_(zn(),1),Ci=t=>(0,Un.default)(ee(t)),Jn=Ci;var Oi=Gn.default;function Ue(t){let e={smcat:Oi,dot:$e,svg:He,oldsvg:He,scjson:ee,scxml:Jn};return(0,Xn.default)(e,t)?e[t]:n=>n}var Wn="10.1.7";function Qn(t,e){let n=bn.getAST(t,e),d=R.getOptionValue(e,"desugar");return Ue(R.getOptionValue(e,"outputType"))(d?In(n):n,e)}var Yn=Wn;function Zn(){return R.getAllowedValues()}var Pi={render:Qn,version:Yn,getAllowedValues:Zn};
79
+ `)),(n.event||n.cond||n.action)&&(n.label=ye.formatLabel(n.event,n.cond,n.action)),n}function ho(t,e,n){return t.reduce((d,l)=>(e.forEach((u,s)=>{u===l.to&&n[u]?d=d.concat(n[u].map(f=>po(l,f))):d=s===0?d.concat(l):d}),d),[])}function xn(t,e,n){let d=(0,_e.default)(t);return d.transitions&&e.length>0&&(d.transitions=ho(d.transitions,e,n)),d.states=d.states.map(l=>l.statemachine?{...l,statemachine:xn(l.statemachine,e,n)}:l),d}function $n(t,e){let n=(0,_e.default)(t);return n.transitions&&(n.transitions=(0,je.default)(n.transitions,d=>e.some(l=>l===d.from||l===d.to))),n.states=(0,je.default)(n.states,d=>e.includes(d.name)).map(d=>d.statemachine?{...d,statemachine:$n(d.statemachine,e)}:d),n}var In=(t,e=["fork","junction","choice"])=>{let n=new N(t),d=n.findStatesByTypes(e).map(({name:s})=>s),l=d.reduce((s,f)=>(s[f]=n.findTransitionsByFrom(f),s),{}),u=xn(t,d,l);return $n(u,d)};var Xn=_(require("lodash/has.js"),1),Gn=_(An(),1);var Fn=_(require("lodash/cloneDeep.js"),1);var ko=[{name:"fontname",value:'"Helvetica"'},{name:"fontsize",value:"12"},{name:"penwidth",value:"2.0"}],Ao={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"}]},wo={"bottom-top":[{name:"rankdir",value:"BT"}],"left-right":[{name:"rankdir",value:"LR"}],"right-left":[{name:"rankdir",value:"RL"}]},Co=[{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"}],Oo=[{name:"fontname",value:"Helvetica"},{name:"fontsize",value:10}];function Ne(t){return`${t.name}=${t.value}`}var be={buildGraphAttributes:(t,e,n)=>ko.concat(Ao[t]||[]).concat(wo[e]||[]).concat(n||[]).map(Ne).join(" "),buildNodeAttributes:t=>Co.concat(t||[]).map(Ne).join(" "),buildEdgeAttributes:t=>Oo.concat(t||[]).map(Ne).join(" ")};var wn=_(require("lodash/cloneDeep.js"),1);function Po(t){return t.replace(/\\/g,"\\\\").replace(/\n\s*/g,"\\l").replace(/"/g,'\\"').concat("\\l")}function jo(t){return t.replace(/\\/g,"\\\\").replace(/\n\s*/g," \\l").replace(/"/g,'\\"').concat(" \\l")}function _o(t){let e=t||"top-down";return e==="top-down"||e==="bottom-top"}function Fo(t,e){return e.from===e.to&&t.findStateByName(e.from).statemachine&&e.type!=="internal"}var q={escapeString:Po,escapeLabelString:jo,isVertical:_o,isCompositeSelf:Fo};function Cn(t){return e=>e.type===t}function Ve(t){return e=>t.includes(e.type)}function Ro(t){let e=(0,wn.default)(t);return e.label=t.label||t.name,e}function No(t){return t.note?{noteName:`note_${t.name}`,...t}:t}function Vo(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 Lo(t){return t==="activity"?"":`${t}/ `}function Bo(t){return t.actions?{...t,actionStrings:t.actions.map(e=>`${Lo(e.type)}${e.body}`)}:t}function Ho(t){return t.note?{...t,noteFlattened:t.note.join("")}:t}function qo(t){return e=>{var d;let n=(d=(t||[]).find(l=>l.name==="color"))==null?void 0:d.value;return n&&!e.color&&Ve(["initial","fork","join","junction","forkjoin","final"])(e)&&(e.color=n),e}}function Do(t){return t.note?{...t,note:t.note.map(q.escapeString)}:t}function Mo(t){return e=>Ve(["fork","join","forkjoin"])(e)?{sizingExtras:q.isVertical(t)?"height=0.1":"width=0.1",...e}:e}function zo(t){return t.type==="parallel"&&t.statemachine&&t.statemachine.states&&(t.statemachine.states=t.statemachine.states.map(e=>Cn("regular")(e)?{...e,parentIsParallel:!0}:e)),t}var P={isType:Cn,isOneOfTypes:Ve,setLabel:Ro,classifyState:Vo,nameNote:No,flattenActions:Bo,flattenNote:Ho,recolor:qo,escapeStateStrings:Do,tipForkJoinStates:Mo,flagParallelChildren:zo};function Uo(t){let e={...t};return e.note&&(e.note=e.note.map(q.escapeString)),e.label&&(e.label=q.escapeLabelString(e.label)),e}function Jo(t){return e=>{let n={};return e.isCompositeSelf&&(q.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 Xo(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 xe={escapeTransitionStrings:Uo,addPorts:Jo,classifyTransition:Xo};var ie=class{COUNTER=0;constructor(){this.reset()}reset(){this.COUNTER=0}next(){return++this.COUNTER}nextAsString(){return this.next().toString(10)}};var Rn=_(_n(),1);function ei(t){return e=>(Object.prototype.hasOwnProperty.call(e,"statemachine")&&(e.nestedExternalSelfTransitions=t.findExternalSelfTransitions(e.name).map(n=>n.name)),e)}function Nn(t,e,n,d){return t.filter(l=>l.statemachine).forEach(l=>{l.statemachine.states=Nn(l.statemachine.states,e,n,d)}),t.map(P.setLabel).map(P.nameNote).map(P.classifyState).map(P.escapeStateStrings).map(P.flattenNote).map(P.flattenActions).map(P.flagParallelChildren).map(P.tipForkJoinStates(e)).map(P.recolor(n)).map(ei(d))}function ti(t){return t.initialStates=t.states.filter(P.isType("initial")),t.regularStates=t.states.filter(e=>P.isType("regular")(e)&&!e.statemachine),t.historyStates=t.states.filter(P.isType("history")),t.deepHistoryStates=t.states.filter(P.isType("deephistory")),t.choiceStates=t.states.filter(P.isType("choice")),t.forkjoinStates=t.states.filter(P.isOneOfTypes(["fork","join","forkjoin"])),t.junctionStates=t.states.filter(P.isType("junction")),t.terminateStates=t.states.filter(P.isType("terminate")),t.finalStates=t.states.filter(P.isType("final")),t.compositeStates=t.states.filter(e=>e.statemachine),t}function ni(t){return e=>(t.findStateByName(e.from).statemachine&&(e.fromComposite=!0),t.findStateByName(e.to).statemachine&&(e.toComposite=!0),e)}function ri(t){return e=>{let n={};return q.isCompositeSelf(t,e)&&(t.findStateByName(e.from).hasParent?n={hasParent:!0,isCompositeSelf:!0}:n={isCompositeSelf:!0}),{...e,...n}}}function li(t){return e=>(e.name=`tr_${e.from}_${e.to}_${t.nextAsString()}`,Boolean(e.note)&&(e.noteName=`note_${e.name}`),e)}function ai(t,e,n){return t.flattenedTransitions.map(li(n)).map(xe.escapeTransitionStrings).map(xe.classifyTransition).map(P.flattenNote).map(ni(t)).map(ri(t)).map(xe.addPorts(e))}var $e=(t,e)=>{e=e||{};let n=(0,Fn.default)(t),d=new N(n);return n.transitions=ai(d,e.direction,new ie),n.states=Nn(n.states,e.direction,e.dotNodeAttrs,d),n=ti(n),n.graphAttributes=be.buildGraphAttributes(R.getOptionValue(e,"engine"),R.getOptionValue(e,"direction"),e.dotGraphAttrs),n.nodeAttributes=be.buildNodeAttributes(e.dotNodeAttrs),n.edgeAttributes=be.buildEdgeAttributes(e.dotEdgeAttrs),(0,Rn.default)(n)};var Vn=_(require("viz.js"),1);var oi={oldsvg:"svg",oldps2:"ps2",oldeps:"eps"},ii=(t,e)=>(0,Vn.default)($e(t,e),{engine:R.getOptionValue(e,"engine"),format:oi[R.getOptionValue(e,"outputType")]||"svg"}),He=ii;var si=/[\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,ci=/[-|.|0-9|\u00B7|\u0300-\u036F|\u203F-\u2040]/g;function Ln(t){return t.replace(si,"_")}function ui(t){let e=Ln(t);return e.match(ci)&&(e=`_${t}`),e}var Ie=t=>(t=t||"",t.length===0?"__empty":ui(t[0]).concat(Ln(t.slice(1))));var fi=/[\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,mi=/[.]/g;function Bn(t){return t.replace(fi,"_")}function pi(t){let e=Bn(t);return e.match(mi)&&(e=`_${t}`),e}function di(t){return t=t.replace(/\s+/g," ").trim(),pi(t[0]).concat(Bn(t.slice(1)))}var Hn=t=>{let e=t||"";return e.length===0?"empty":e.split(/[\n\r]+/).filter(n=>n.length>0).map(di).join(" ")};var hi={regular:"state",initial:"initial",final:"final",terminate:"final",parallel:"parallel",history:"history",deephistory:"history"};function gi(t){return hi[t]||"state"}function yi(t){let e={target:Ie(t.to)};return t.event&&(e.event=Hn(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 qe(t,e,n,d){let l=vi(n,d);l.length>0&&(t[e]=(t[e]||[]).concat(l))}function bi(t,e){e.actions&&(qe(t,"onentries",e.actions,"entry"),qe(t,"onentries",e.actions,"activity"),qe(t,"onexits",e.actions,"exit"))}function xi(t,e,n){let d=n.filter(l=>l.from===e.name).map(yi);d.length>0&&(t.transitions=d)}function $i(t,e,n){if(e.statemachine){let d=ee(e.statemachine,void 0,n);t.states=(t.states||[]).concat(d.states),d.initial&&(t.initial=d.initial)}}function Ii(t){return t=t||[],e=>{let n={kind:gi(e.type),id:Ie(e.name)};return e.type==="deephistory"&&(n.type="deep"),bi(n,e),xi(n,e,t),$i(n,e,t),n}}function Ei(t){let e=t.states.filter(n=>n.type==="initial");if(e.length>0)return e[0].name}function Si(t,e){let n=e;if(e&&t.transitions){let d=t.transitions.filter(l=>l.from===e);d.length>0&&!d[0].action&&(n=d[0].to)}return n}function ee(t,e,n){let d=Ei(t),l=Si(t,d),u={states:t.states.filter(s=>l&&l!==d?s.type!=="initial":!0).map(Ii(n||new N(t).flattenedTransitions))};return l&&(u.initial=Ie(l)),u}var Un=_(zn(),1),Ci=t=>(0,Un.default)(ee(t)),Jn=Ci;var Oi=Gn.default;function Ue(t){let e={smcat:Oi,dot:$e,svg:He,oldsvg:He,scjson:ee,scxml:Jn};return(0,Xn.default)(e,t)?e[t]:n=>n}var Wn="10.1.8";function Qn(t,e){let n=bn.getAST(t,e),d=R.getOptionValue(e,"desugar");return Ue(R.getOptionValue(e,"outputType"))(d?In(n):n,e)}var Yn=Wn;function Zn(){return R.getAllowedValues()}var Pi={render:Qn,version:Yn,getAllowedValues:Zn};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "state-machine-cat",
3
- "version": "10.1.7",
3
+ "version": "10.1.8",
4
4
  "description": "write beautiful state charts",
5
5
  "main": "./dist/commonjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -393,7 +393,7 @@
393
393
  "@types/mocha": "10.0.1",
394
394
  "@typescript-eslint/eslint-plugin": "5.52.0",
395
395
  "@typescript-eslint/parser": "5.52.0",
396
- "c8": "7.12.0",
396
+ "c8": "7.13.0",
397
397
  "chai": "4.3.7",
398
398
  "chai-as-promised": "7.1.1",
399
399
  "chai-json-schema": "1.5.1",
@@ -421,8 +421,8 @@
421
421
  "query-string": "8.1.0",
422
422
  "ts-node": "10.9.1",
423
423
  "typescript": "4.9.5",
424
- "upem": "7.3.1",
425
- "watskeburt": "0.9.1",
424
+ "upem": "7.3.2",
425
+ "watskeburt": "0.9.2",
426
426
  "wireit": "0.9.5",
427
427
  "xml-name-validator": "4.0.0"
428
428
  },