state-machine-cat 10.1.5 → 10.1.6
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/package.json +11 -11
- package/src/version.mjs +1 -1
package/dist/commonjs/bundle.js
CHANGED
|
@@ -76,4 +76,4 @@ var Ba=Object.create;var ge=Object.defineProperty;var Ha=Object.getOwnPropertyDe
|
|
|
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 co(t){let e={};typeof t=="string"?e.action=Y.default.decode(t).trim():Object.assign(e,uo(t));let n=ao(e.event,e.cond,e.action);return n&&(e.label=n),e}function fo(t){return(e,n)=>{let d=((n==null?void 0:n.target)??t.id).split(/\s+/),r=co(n);return e.concat(d.map(c=>({from:t.id,to:c,...r})))}}function _e(t){return t.filter(e=>Object.prototype.hasOwnProperty.call(e,"transition")).reduce((e,n)=>e.concat((0,ve.default)(n.transition).reduce(fo(n),[])),[])}function hn(t){let e=pn(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=_e(e.initial).concat(_e(e.state)).concat(_e(e.parallel));return d.length>0&&(n.transitions=d),n}function gn(t){let e=t.trim();if(Fe.default.validate(e)===!0){let n=Fe.default.parse(e,{attributeNamePrefix:"",ignoreAttributes:!1,tagValueProcessor:d=>Y.default.decode(d),stopNodes:["onentry","onexit","transition"]});return hn((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 yn={$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 vn=new bn.default;function mo(t,e){if(!vn.validate(t,e))throw new Error(`The provided JSON is not a valid state-machine-cat AST: ${vn.errorsText()}.
|
|
78
78
|
`)}var $n={getAST(t,e){let n=t;return H.getOptionValue(e,"inputType")==="smcat"?n=mn(t):H.getOptionValue(e,"inputType")==="scxml"?n=gn(t):typeof t=="string"&&(n=JSON.parse(t)),mo(yn,n),n}};var Re=R(require("lodash/cloneDeep.js"),1),Te=R(require("lodash/reject.js"),1);function po(t,e,n){return t?`${t}${n}${e}`:e}function ho(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=ye.formatLabel(n.event,n.cond,n.action)),n}function go(t,e,n){return t.reduce((d,r)=>(e.forEach((c,i)=>{c===r.to&&n[c]?d=d.concat(n[c].map(f=>ho(r,f))):d=i===0?d.concat(r):d}),d),[])}function xn(t,e,n){let d=(0,Re.default)(t);return d.transitions&&e.length>0&&(d.transitions=go(d.transitions,e,n)),d.states=d.states.map(r=>r.statemachine?{...r,statemachine:xn(r.statemachine,e,n)}:r),d}function kn(t,e){let n=(0,Re.default)(t);return n.transitions&&(n.transitions=(0,Te.default)(n.transitions,d=>e.some(r=>r===d.from||r===d.to))),n.states=(0,Te.default)(n.states,d=>e.includes(d.name)).map(d=>d.statemachine?{...d,statemachine:kn(d.statemachine,e)}:d),n}var wn=(t,e=["fork","junction","choice"])=>{let n=new q(t),d=n.findStatesByTypes(e).map(({name:i})=>i),r=d.reduce((i,f)=>(i[f]=n.findTransitionsByFrom(f),i),{}),c=xn(t,d,r);return kn(c,d)};var Qn=R(require("lodash/has.js"),1),Wn=R(En(),1);var Hn=R(require("lodash/cloneDeep.js"),1);var Oo=[{name:"fontname",value:'"Helvetica"'},{name:"fontsize",value:"12"},{name:"penwidth",value:"2.0"}],Eo={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"}]},jo={"bottom-top":[{name:"rankdir",value:"BT"}],"left-right":[{name:"rankdir",value:"LR"}],"right-left":[{name:"rankdir",value:"RL"}]},_o=[{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"}],Fo=[{name:"fontname",value:"Helvetica"},{name:"fontsize",value:10}];function qe(t){return`${t.name}=${t.value}`}var be={buildGraphAttributes:(t,e,n)=>Oo.concat(Eo[t]||[]).concat(jo[e]||[]).concat(n||[]).map(qe).join(" "),buildNodeAttributes:t=>_o.concat(t||[]).map(qe).join(" "),buildEdgeAttributes:t=>Fo.concat(t||[]).map(qe).join(" ")};var jn=R(require("lodash/cloneDeep.js"),1);function To(t){return t.replace(/\\/g,"\\\\").replace(/\n\s*/g,"\\l").replace(/"/g,'\\"').concat("\\l")}function Ro(t){return t.replace(/\\/g,"\\\\").replace(/\n\s*/g," \\l").replace(/"/g,'\\"').concat(" \\l")}function Bo(t){let e=t||"top-down";return e==="top-down"||e==="bottom-top"}function Ho(t,e){return e.from===e.to&&t.findStateByName(e.from).statemachine&&e.type!=="internal"}var V={escapeString:To,escapeLabelString:Ro,isVertical:Bo,isCompositeSelf:Ho};function _n(t){return e=>e.type===t}function De(t){return e=>t.includes(e.type)}function qo(t){let e=(0,jn.default)(t);return e.label=t.label||t.name,e}function Do(t){return Object.prototype.hasOwnProperty.call(t,"note")&&(t.noteName=`note_${t.name}`),t}function Io(t){let e=["state",t.type];return Object.prototype.hasOwnProperty.call(t,"class")&&e.push(t.class.trim().replace(/[ ]{2,}/g," ")),t.class=e.join(" "),t}function Lo(t){return t==="activity"?"":`${t}/ `}function No(t){let e={...t};return t.actions&&(e.actions=t.actions.map(n=>`${Lo(n.type)}${n.body}`)),e}function Vo(t){return Object.prototype.hasOwnProperty.call(t,"note")&&(t.noteFlattened=t.note.join("")),t}function So(t){return e=>{var d;let n=(d=(t||[]).find(r=>r.name==="color"))==null?void 0:d.value;return n&&!e.color&&De(["initial","fork","join","junction","forkjoin","final"])(e)&&(e.color=n),e}}function zo(t){return t.note&&(t.note=t.note.map(V.escapeString)),t}function Uo(t){return e=>De(["fork","join","forkjoin"])(e)?{sizingExtras:V.isVertical(t)?"height=0.1":"width=0.1",...e}:e}function Go(t){return t.type==="parallel"&&t.statemachine&&t.statemachine.states&&(t.statemachine.states=t.statemachine.states.map(e=>_n("regular")(e)?{...e,parentIsParallel:!0}:e)),t}var F={isType:_n,isOneOfTypes:De,setLabel:qo,classifyState:Io,nameNote:Do,flattenActions:No,flattenNote:Vo,recolor:So,escapeStateStrings:zo,tipForkJoinStates:Uo,flagParallelChildren:Go};function Xo(t){return t.note&&(t.note=t.note.map(V.escapeString)),t.label&&(t.label=V.escapeLabelString(t.label)),t}function Jo(t){return e=>{let n={};return e.isCompositeSelf&&(V.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 Qo(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 $e={escapeTransitionStrings:Xo,addPorts:Jo,classifyTransition:Qo};var se=class{constructor(){this.reset()}reset(){this.COUNTER=0}next(){return++this.COUNTER}nextAsString(){return this.next().toString(10)}};var qn=R(Bn(),1);var Dn={};function ts(t){return e=>(Object.prototype.hasOwnProperty.call(e,"statemachine")&&(e.nestedExternalSelfTransitions=t.findExternalSelfTransitions(e.name).map(n=>n.name)),e)}function In(t,e,n,d){return t.filter(r=>r.statemachine).forEach(r=>{r.statemachine.states=In(r.statemachine.states,e,n,d)}),t.map(F.setLabel).map(F.nameNote).map(F.classifyState).map(F.escapeStateStrings).map(F.flattenNote).map(F.flattenActions).map(F.flagParallelChildren).map(F.tipForkJoinStates(e)).map(F.recolor(n)).map(ts(d))}function ns(t){return t.initialStates=t.states.filter(F.isType("initial")),t.regularStates=t.states.filter(e=>F.isType("regular")(e)&&!e.statemachine),t.historyStates=t.states.filter(F.isType("history")),t.deepHistoryStates=t.states.filter(F.isType("deephistory")),t.choiceStates=t.states.filter(F.isType("choice")),t.forkjoinStates=t.states.filter(F.isOneOfTypes(["fork","join","forkjoin"])),t.junctionStates=t.states.filter(F.isType("junction")),t.terminateStates=t.states.filter(F.isType("terminate")),t.finalStates=t.states.filter(F.isType("final")),t.compositeStates=t.states.filter(e=>e.statemachine),t}function ls(t){return e=>(t.findStateByName(e.from).statemachine&&(e.fromComposite=!0),t.findStateByName(e.to).statemachine&&(e.toComposite=!0),e)}function rs(t){return e=>{let n={};return V.isCompositeSelf(t,e)&&(t.findStateByName(e.from).hasParent?n={hasParent:!0,isCompositeSelf:!0}:n={isCompositeSelf:!0}),{...e,...n}}}function as(t){return t.name=`tr_${t.from}_${t.to}_${Dn.nextAsString()}`,Boolean(t.note)&&(t.noteName=`note_${t.name}`),t}function os(t,e){return t.flattenedTransitions.map(as).map($e.escapeTransitionStrings).map($e.classifyTransition).map(F.flattenNote).map(ls(t)).map(rs(t)).map($e.addPorts(e))}var xe=(t,e)=>{e=e||{},Dn=new se;let n=(0,Hn.default)(t),d=new q(n);return n.transitions=os(d,e.direction),n.states=In(n.states,e.direction,e.dotNodeAttrs,d),n=ns(n),n.graphAttributes=be.buildGraphAttributes(H.getOptionValue(e,"engine"),H.getOptionValue(e,"direction"),e.dotGraphAttrs),n.nodeAttributes=be.buildNodeAttributes(e.dotNodeAttrs),n.edgeAttributes=be.buildEdgeAttributes(e.dotEdgeAttrs),(0,qn.default)(n)};var Ln=R(require("viz.js"),1);var ss={oldsvg:"svg",oldps2:"ps2",oldeps:"eps"},Ne=(t,e)=>(0,Ln.default)(xe(t,e),{engine:H.getOptionValue(e,"engine"),format:ss[H.getOptionValue(e,"outputType")]||"svg"});var is=/[\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,us=/[-|.|0-9|\u00B7|\u0300-\u036F|\u203F-\u2040]/g;function Nn(t){return t.replace(is,"_")}function cs(t){let e=Nn(t);return e.match(us)&&(e=`_${t}`),e}var ke=t=>(t=t||"",t.length===0?"__empty":cs(t[0]).concat(Nn(t.slice(1))));var fs=/[\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,ms=/[.]/g;function Vn(t){return t.replace(fs,"_")}function ps(t){let e=Vn(t);return e.match(ms)&&(e=`_${t}`),e}function ds(t){return t=t.replace(/\s+/g," ").trim(),ps(t[0]).concat(Vn(t.slice(1)))}var Sn=t=>(t=t||"",t.length===0?"empty":t.split(/[\n\r]+/).filter(e=>e.length>0).map(ds).join(" "));var hs={regular:"state",initial:"initial",final:"final",terminate:"final",parallel:"parallel",history:"history",deephistory:"history"};function gs(t){return hs[t]||"state"}function ys(t){let e={target:ke(t.to)};return Boolean(t.event)&&(e.event=Sn(t.event)),Boolean(t.cond)&&(e.cond=t.cond),Boolean(t.action)&&(e.action=t.action),Boolean(t.type)&&(e.type=t.type),e}function vs(t,e){return t.filter(n=>n.type===e).map(n=>n.body)}function Ve(t,e,n,d){let r=vs(n,d);r.length>0&&(t[e]=(t[e]||[]).concat(r))}function bs(t,e){Boolean(e.actions)&&(Ve(t,"onentries",e.actions,"entry"),Ve(t,"onentries",e.actions,"activity"),Ve(t,"onexits",e.actions,"exit"))}function $s(t,e,n){let d=n.filter(r=>r.from===e.name).map(ys);d.length>0&&(t.transitions=d)}function xs(t,e,n){if(Boolean(e.statemachine)){let d=ee(e.statemachine,null,n);t.states=(t.states||[]).concat(d.states),d.initial&&(t.initial=d.initial)}}function ks(t){return t=t||[],e=>{let n={kind:gs(e.type),id:ke(e.name)};return e.type==="deephistory"&&(n.type="deep"),bs(n,e),$s(n,e,t),xs(n,e,t),n}}function ws(t){let e=null,n=t.states.filter(d=>d.type==="initial");return n.length>0&&(e=n[0].name),e}function As(t,e){let n=e;if(e&&t.transitions){let d=t.transitions.filter(r=>r.from===e);d.length>0&&!d[0].action&&(n=d[0].to)}return n}function ee(t,e,n){let d=ws(t),r=As(t,d),c={states:t.states.filter(i=>r&&r!==d?i.type!=="initial":!0).map(ks(n||new q(t).flattenedTransitions))};return r&&(c.initial=ke(r)),c}var Jn=R(Xn(),1);function Ge(t){return(0,Jn.default)(ee(t))}function Xe(t){let e={smcat:Wn.default,dot:xe,svg:Ne,oldsvg:Ne,scjson:ee,scxml:Ge};return(0,Qn.default)(e,t)?e[t]:n=>n}var Yn="10.1.5";function Zn(t,e){let n=$n.getAST(t,e),d=H.getOptionValue(e,"desugar");return Xe(H.getOptionValue(e,"outputType"))(d?wn(n):n,e)}var Kn=Yn;function Mn(){return H.getAllowedValues()}var js={render:Zn,version:Kn,getAllowedValues:Mn};
|
|
79
|
+
`)),(n.event||n.cond||n.action)&&(n.label=ye.formatLabel(n.event,n.cond,n.action)),n}function go(t,e,n){return t.reduce((d,r)=>(e.forEach((c,i)=>{c===r.to&&n[c]?d=d.concat(n[c].map(f=>ho(r,f))):d=i===0?d.concat(r):d}),d),[])}function xn(t,e,n){let d=(0,Re.default)(t);return d.transitions&&e.length>0&&(d.transitions=go(d.transitions,e,n)),d.states=d.states.map(r=>r.statemachine?{...r,statemachine:xn(r.statemachine,e,n)}:r),d}function kn(t,e){let n=(0,Re.default)(t);return n.transitions&&(n.transitions=(0,Te.default)(n.transitions,d=>e.some(r=>r===d.from||r===d.to))),n.states=(0,Te.default)(n.states,d=>e.includes(d.name)).map(d=>d.statemachine?{...d,statemachine:kn(d.statemachine,e)}:d),n}var wn=(t,e=["fork","junction","choice"])=>{let n=new q(t),d=n.findStatesByTypes(e).map(({name:i})=>i),r=d.reduce((i,f)=>(i[f]=n.findTransitionsByFrom(f),i),{}),c=xn(t,d,r);return kn(c,d)};var Qn=R(require("lodash/has.js"),1),Wn=R(En(),1);var Hn=R(require("lodash/cloneDeep.js"),1);var Oo=[{name:"fontname",value:'"Helvetica"'},{name:"fontsize",value:"12"},{name:"penwidth",value:"2.0"}],Eo={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"}]},jo={"bottom-top":[{name:"rankdir",value:"BT"}],"left-right":[{name:"rankdir",value:"LR"}],"right-left":[{name:"rankdir",value:"RL"}]},_o=[{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"}],Fo=[{name:"fontname",value:"Helvetica"},{name:"fontsize",value:10}];function qe(t){return`${t.name}=${t.value}`}var be={buildGraphAttributes:(t,e,n)=>Oo.concat(Eo[t]||[]).concat(jo[e]||[]).concat(n||[]).map(qe).join(" "),buildNodeAttributes:t=>_o.concat(t||[]).map(qe).join(" "),buildEdgeAttributes:t=>Fo.concat(t||[]).map(qe).join(" ")};var jn=R(require("lodash/cloneDeep.js"),1);function To(t){return t.replace(/\\/g,"\\\\").replace(/\n\s*/g,"\\l").replace(/"/g,'\\"').concat("\\l")}function Ro(t){return t.replace(/\\/g,"\\\\").replace(/\n\s*/g," \\l").replace(/"/g,'\\"').concat(" \\l")}function Bo(t){let e=t||"top-down";return e==="top-down"||e==="bottom-top"}function Ho(t,e){return e.from===e.to&&t.findStateByName(e.from).statemachine&&e.type!=="internal"}var V={escapeString:To,escapeLabelString:Ro,isVertical:Bo,isCompositeSelf:Ho};function _n(t){return e=>e.type===t}function De(t){return e=>t.includes(e.type)}function qo(t){let e=(0,jn.default)(t);return e.label=t.label||t.name,e}function Do(t){return Object.prototype.hasOwnProperty.call(t,"note")&&(t.noteName=`note_${t.name}`),t}function Io(t){let e=["state",t.type];return Object.prototype.hasOwnProperty.call(t,"class")&&e.push(t.class.trim().replace(/[ ]{2,}/g," ")),t.class=e.join(" "),t}function Lo(t){return t==="activity"?"":`${t}/ `}function No(t){let e={...t};return t.actions&&(e.actions=t.actions.map(n=>`${Lo(n.type)}${n.body}`)),e}function Vo(t){return Object.prototype.hasOwnProperty.call(t,"note")&&(t.noteFlattened=t.note.join("")),t}function So(t){return e=>{var d;let n=(d=(t||[]).find(r=>r.name==="color"))==null?void 0:d.value;return n&&!e.color&&De(["initial","fork","join","junction","forkjoin","final"])(e)&&(e.color=n),e}}function zo(t){return t.note&&(t.note=t.note.map(V.escapeString)),t}function Uo(t){return e=>De(["fork","join","forkjoin"])(e)?{sizingExtras:V.isVertical(t)?"height=0.1":"width=0.1",...e}:e}function Go(t){return t.type==="parallel"&&t.statemachine&&t.statemachine.states&&(t.statemachine.states=t.statemachine.states.map(e=>_n("regular")(e)?{...e,parentIsParallel:!0}:e)),t}var F={isType:_n,isOneOfTypes:De,setLabel:qo,classifyState:Io,nameNote:Do,flattenActions:No,flattenNote:Vo,recolor:So,escapeStateStrings:zo,tipForkJoinStates:Uo,flagParallelChildren:Go};function Xo(t){return t.note&&(t.note=t.note.map(V.escapeString)),t.label&&(t.label=V.escapeLabelString(t.label)),t}function Jo(t){return e=>{let n={};return e.isCompositeSelf&&(V.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 Qo(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 $e={escapeTransitionStrings:Xo,addPorts:Jo,classifyTransition:Qo};var se=class{constructor(){this.reset()}reset(){this.COUNTER=0}next(){return++this.COUNTER}nextAsString(){return this.next().toString(10)}};var qn=R(Bn(),1);var Dn={};function ts(t){return e=>(Object.prototype.hasOwnProperty.call(e,"statemachine")&&(e.nestedExternalSelfTransitions=t.findExternalSelfTransitions(e.name).map(n=>n.name)),e)}function In(t,e,n,d){return t.filter(r=>r.statemachine).forEach(r=>{r.statemachine.states=In(r.statemachine.states,e,n,d)}),t.map(F.setLabel).map(F.nameNote).map(F.classifyState).map(F.escapeStateStrings).map(F.flattenNote).map(F.flattenActions).map(F.flagParallelChildren).map(F.tipForkJoinStates(e)).map(F.recolor(n)).map(ts(d))}function ns(t){return t.initialStates=t.states.filter(F.isType("initial")),t.regularStates=t.states.filter(e=>F.isType("regular")(e)&&!e.statemachine),t.historyStates=t.states.filter(F.isType("history")),t.deepHistoryStates=t.states.filter(F.isType("deephistory")),t.choiceStates=t.states.filter(F.isType("choice")),t.forkjoinStates=t.states.filter(F.isOneOfTypes(["fork","join","forkjoin"])),t.junctionStates=t.states.filter(F.isType("junction")),t.terminateStates=t.states.filter(F.isType("terminate")),t.finalStates=t.states.filter(F.isType("final")),t.compositeStates=t.states.filter(e=>e.statemachine),t}function ls(t){return e=>(t.findStateByName(e.from).statemachine&&(e.fromComposite=!0),t.findStateByName(e.to).statemachine&&(e.toComposite=!0),e)}function rs(t){return e=>{let n={};return V.isCompositeSelf(t,e)&&(t.findStateByName(e.from).hasParent?n={hasParent:!0,isCompositeSelf:!0}:n={isCompositeSelf:!0}),{...e,...n}}}function as(t){return t.name=`tr_${t.from}_${t.to}_${Dn.nextAsString()}`,Boolean(t.note)&&(t.noteName=`note_${t.name}`),t}function os(t,e){return t.flattenedTransitions.map(as).map($e.escapeTransitionStrings).map($e.classifyTransition).map(F.flattenNote).map(ls(t)).map(rs(t)).map($e.addPorts(e))}var xe=(t,e)=>{e=e||{},Dn=new se;let n=(0,Hn.default)(t),d=new q(n);return n.transitions=os(d,e.direction),n.states=In(n.states,e.direction,e.dotNodeAttrs,d),n=ns(n),n.graphAttributes=be.buildGraphAttributes(H.getOptionValue(e,"engine"),H.getOptionValue(e,"direction"),e.dotGraphAttrs),n.nodeAttributes=be.buildNodeAttributes(e.dotNodeAttrs),n.edgeAttributes=be.buildEdgeAttributes(e.dotEdgeAttrs),(0,qn.default)(n)};var Ln=R(require("viz.js"),1);var ss={oldsvg:"svg",oldps2:"ps2",oldeps:"eps"},Ne=(t,e)=>(0,Ln.default)(xe(t,e),{engine:H.getOptionValue(e,"engine"),format:ss[H.getOptionValue(e,"outputType")]||"svg"});var is=/[\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,us=/[-|.|0-9|\u00B7|\u0300-\u036F|\u203F-\u2040]/g;function Nn(t){return t.replace(is,"_")}function cs(t){let e=Nn(t);return e.match(us)&&(e=`_${t}`),e}var ke=t=>(t=t||"",t.length===0?"__empty":cs(t[0]).concat(Nn(t.slice(1))));var fs=/[\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,ms=/[.]/g;function Vn(t){return t.replace(fs,"_")}function ps(t){let e=Vn(t);return e.match(ms)&&(e=`_${t}`),e}function ds(t){return t=t.replace(/\s+/g," ").trim(),ps(t[0]).concat(Vn(t.slice(1)))}var Sn=t=>(t=t||"",t.length===0?"empty":t.split(/[\n\r]+/).filter(e=>e.length>0).map(ds).join(" "));var hs={regular:"state",initial:"initial",final:"final",terminate:"final",parallel:"parallel",history:"history",deephistory:"history"};function gs(t){return hs[t]||"state"}function ys(t){let e={target:ke(t.to)};return Boolean(t.event)&&(e.event=Sn(t.event)),Boolean(t.cond)&&(e.cond=t.cond),Boolean(t.action)&&(e.action=t.action),Boolean(t.type)&&(e.type=t.type),e}function vs(t,e){return t.filter(n=>n.type===e).map(n=>n.body)}function Ve(t,e,n,d){let r=vs(n,d);r.length>0&&(t[e]=(t[e]||[]).concat(r))}function bs(t,e){Boolean(e.actions)&&(Ve(t,"onentries",e.actions,"entry"),Ve(t,"onentries",e.actions,"activity"),Ve(t,"onexits",e.actions,"exit"))}function $s(t,e,n){let d=n.filter(r=>r.from===e.name).map(ys);d.length>0&&(t.transitions=d)}function xs(t,e,n){if(Boolean(e.statemachine)){let d=ee(e.statemachine,null,n);t.states=(t.states||[]).concat(d.states),d.initial&&(t.initial=d.initial)}}function ks(t){return t=t||[],e=>{let n={kind:gs(e.type),id:ke(e.name)};return e.type==="deephistory"&&(n.type="deep"),bs(n,e),$s(n,e,t),xs(n,e,t),n}}function ws(t){let e=null,n=t.states.filter(d=>d.type==="initial");return n.length>0&&(e=n[0].name),e}function As(t,e){let n=e;if(e&&t.transitions){let d=t.transitions.filter(r=>r.from===e);d.length>0&&!d[0].action&&(n=d[0].to)}return n}function ee(t,e,n){let d=ws(t),r=As(t,d),c={states:t.states.filter(i=>r&&r!==d?i.type!=="initial":!0).map(ks(n||new q(t).flattenedTransitions))};return r&&(c.initial=ke(r)),c}var Jn=R(Xn(),1);function Ge(t){return(0,Jn.default)(ee(t))}function Xe(t){let e={smcat:Wn.default,dot:xe,svg:Ne,oldsvg:Ne,scjson:ee,scxml:Ge};return(0,Qn.default)(e,t)?e[t]:n=>n}var Yn="10.1.6";function Zn(t,e){let n=$n.getAST(t,e),d=H.getOptionValue(e,"desugar");return Xe(H.getOptionValue(e,"outputType"))(d?wn(n):n,e)}var Kn=Yn;function Mn(){return H.getAllowedValues()}var js={render:Zn,version:Kn,getAllowedValues:Mn};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "state-machine-cat",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.6",
|
|
4
4
|
"description": "write beautiful state charts",
|
|
5
5
|
"main": "./dist/commonjs/index.js",
|
|
6
6
|
"module": "./src/index.mjs",
|
|
@@ -382,19 +382,19 @@
|
|
|
382
382
|
"lodash": "4.17.21",
|
|
383
383
|
"semver": "^7.3.8",
|
|
384
384
|
"viz.js": "1.8.2",
|
|
385
|
-
"wrap-ansi": "8.0
|
|
385
|
+
"wrap-ansi": "8.1.0"
|
|
386
386
|
},
|
|
387
387
|
"devDependencies": {
|
|
388
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
389
|
-
"@typescript-eslint/parser": "5.
|
|
388
|
+
"@typescript-eslint/eslint-plugin": "5.50.0",
|
|
389
|
+
"@typescript-eslint/parser": "5.50.0",
|
|
390
390
|
"c8": "7.12.0",
|
|
391
391
|
"chai": "4.3.7",
|
|
392
392
|
"chai-as-promised": "7.1.1",
|
|
393
393
|
"chai-json-schema": "1.5.1",
|
|
394
394
|
"chai-xml": "0.4.0",
|
|
395
|
-
"dependency-cruiser": "12.
|
|
396
|
-
"esbuild": "0.17.
|
|
397
|
-
"eslint": "8.
|
|
395
|
+
"dependency-cruiser": "12.7.0",
|
|
396
|
+
"esbuild": "0.17.5",
|
|
397
|
+
"eslint": "8.33.0",
|
|
398
398
|
"eslint-config-moving-meadow": "4.0.2",
|
|
399
399
|
"eslint-config-prettier": "8.6.0",
|
|
400
400
|
"eslint-plugin-budapestian": "5.0.1",
|
|
@@ -402,7 +402,7 @@
|
|
|
402
402
|
"eslint-plugin-import": "2.27.5",
|
|
403
403
|
"eslint-plugin-mocha": "10.1.0",
|
|
404
404
|
"eslint-plugin-node": "11.1.0",
|
|
405
|
-
"eslint-plugin-security": "1.
|
|
405
|
+
"eslint-plugin-security": "1.7.1",
|
|
406
406
|
"eslint-plugin-unicorn": "45.0.2",
|
|
407
407
|
"husky": "8.0.3",
|
|
408
408
|
"is-pdf": "1.0.0",
|
|
@@ -413,10 +413,10 @@
|
|
|
413
413
|
"peggy": "2.0.1",
|
|
414
414
|
"prettier": "2.8.3",
|
|
415
415
|
"query-string": "8.1.0",
|
|
416
|
-
"typescript": "4.9.
|
|
416
|
+
"typescript": "4.9.5",
|
|
417
417
|
"upem": "7.3.1",
|
|
418
|
-
"watskeburt": "0.9.
|
|
419
|
-
"wireit": "0.9.
|
|
418
|
+
"watskeburt": "0.9.1",
|
|
419
|
+
"wireit": "0.9.4",
|
|
420
420
|
"xml-name-validator": "4.0.0"
|
|
421
421
|
},
|
|
422
422
|
"eslintIgnore": [
|
package/src/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by tools/get-version.mjs - edits will be overwritten
|
|
2
|
-
export const version = "10.1.
|
|
2
|
+
export const version = "10.1.6";
|