state-machine-cat 10.0.1 → 10.1.0-beta-1

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/README.md CHANGED
@@ -3,7 +3,6 @@
3
3
  _write beautiful state charts_
4
4
 
5
5
  [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/sverweij/state-machine-cat/install,%20lint,%20test%20-%20linux?label=actions&logo=github)](https://github.com/sverweij/state-machine-cat/actions)
6
- [![Build Status](https://travis-ci.org/sverweij/state-machine-cat.svg?branch=master)](https://travis-ci.org/sverweij/state-machine-cat)
7
6
  [![coverage report](https://gitlab.com/sverweij/state-machine-cat/badges/master/coverage.svg)](https://gitlab.com/sverweij/state-machine-cat/builds)
8
7
  [![Known Vulnerabilities](https://snyk.io/test/github/sverweij/state-machine-cat/badge.svg?targetFile=package.json)](https://snyk.io/test/github/sverweij/state-machine-cat?targetFile=package.json)
9
8
  [![Maintainability](https://api.codeclimate.com/v1/badges/e052b461624c043f32c7/maintainability)](https://codeclimate.com/github/sverweij/state-machine-cat/maintainability)
@@ -64,7 +64,7 @@ var Ta=Object.create;var ge=Object.defineProperty;var Ba=Object.getOwnPropertyDe
64
64
  `+m(typeof(t=(t=p(n,"action")||(e!=null?p(e,"action"):e))!=null?t:f)==v?t.call(s,{name:"action",hash:{},data:r,loc:{start:{line:13,column:12},end:{line:13,column:22}}}):t)+`
65
65
  </transition>
66
66
  `},12:function(t,e,n,d,r){var u=t.lookupProperty||function(s,f){if(Object.prototype.hasOwnProperty.call(s,f))return s[f]};return'event="'+t.escapeExpression(typeof(n=(n=u(n,"event")||(e!=null?u(e,"event"):e))!=null?n:t.hooks.helperMissing)=="function"?n.call(e??(t.nullContext||{}),{name:"event",hash:{},data:r,loc:{start:{line:12,column:40},end:{line:12,column:49}}}):n)+'" '},14:function(t,e,n,d,r){var u=t.lookupProperty||function(s,f){if(Object.prototype.hasOwnProperty.call(s,f))return s[f]};return'cond="'+t.escapeExpression(typeof(n=(n=u(n,"cond")||(e!=null?u(e,"cond"):e))!=null?n:t.hooks.helperMissing)=="function"?n.call(e??(t.nullContext||{}),{name:"cond",hash:{},data:r,loc:{start:{line:12,column:76},end:{line:12,column:84}}}):n)+'" '},16:function(t,e,n,d,r){var u=t.lookupProperty||function(s,f){if(Object.prototype.hasOwnProperty.call(s,f))return s[f]};return'type="'+t.escapeExpression(typeof(n=(n=u(n,"type")||(e!=null?u(e,"type"):e))!=null?n:t.hooks.helperMissing)=="function"?n.call(e??(t.nullContext||{}),{name:"type",hash:{},data:r,loc:{start:{line:12,column:111},end:{line:12,column:119}}}):n)+'" '},18:function(t,e,n,d,r){var u,s=e??(t.nullContext||{}),f=t.lookupProperty||function(v,m){if(Object.prototype.hasOwnProperty.call(v,m))return v[m]};return" <transition "+((u=f(n,"if").call(s,e!=null?f(e,"event"):e,{name:"if",hash:{},fn:t.program(12,r,0),inverse:t.noop,data:r,loc:{start:{line:16,column:20},end:{line:16,column:58}}}))!=null?u:"")+((u=f(n,"if").call(s,e!=null?f(e,"cond"):e,{name:"if",hash:{},fn:t.program(14,r,0),inverse:t.noop,data:r,loc:{start:{line:16,column:58},end:{line:16,column:93}}}))!=null?u:"")+((u=f(n,"if").call(s,e!=null?f(e,"type"):e,{name:"if",hash:{},fn:t.program(16,r,0),inverse:t.noop,data:r,loc:{start:{line:16,column:93},end:{line:16,column:128}}}))!=null?u:"")+'target="'+t.escapeExpression(typeof(u=(u=f(n,"target")||(e!=null?f(e,"target"):e))!=null?u:t.hooks.helperMissing)=="function"?u.call(s,{name:"target",hash:{},data:r,loc:{start:{line:16,column:136},end:{line:16,column:146}}}):u)+`"/>
67
- `},compiler:[8,">= 4.3.0"],main:function(t,e,n,d,r){var u=t.lookupProperty||function(s,f){if(Object.prototype.hasOwnProperty.call(s,f))return s[f]};return(n=u(n,"each").call(e??(t.nullContext||{}),e!=null?u(e,"states"):e,{name:"each",hash:{},fn:t.program(1,r,0),inverse:t.noop,data:r,loc:{start:{line:1,column:0},end:{line:20,column:9}}}))!=null?n:""},usePartial:!0,useData:!0})});var Un=z((Vs,zn)=>{var Ue=require("handlebars/dist/handlebars.runtime.js");Sn();Mn();Ue.registerPartial("scxml.states.template.hbs",Ue.templates["scxml.states.template.hbs"]);zn.exports=function(e){return Ue.templates["scxml.template.hbs"](e)}});var Ai={};Da(Ai,{default:()=>ji,getAllowedValues:()=>Zn,render:()=>Wn,version:()=>Yn});module.exports=La(Ai);var nn=Object.freeze({inputType:{default:"smcat",values:[{name:"smcat"},{name:"json"},{name:"scxml"}]},outputType:{default:"svg",values:[{name:"svg"},{name:"eps"},{name:"ps"},{name:"ps2"},{name:"dot"},{name:"smcat"},{name:"json"},{name:"ast"},{name:"scxml"},{name:"oldsvg"},{name:"oldps2"},{name:"oldeps"},{name:"scjson"}]},engine:{default:"dot",values:[{name:"dot"},{name:"circo"},{name:"fdp"},{name:"neato"},{name:"osage"},{name:"twopi"}]},direction:{default:"top-down",values:[{name:"top-down"},{name:"bottom-top"},{name:"left-right"},{name:"right-left"}]},desugar:{default:!1,values:[{name:!0},{name:!1}]}});function Va(t,e){return(t==null?void 0:t[e])??nn[e].default}function Na(){return nn}var H={getAllowedValues:Na,getOptionValue:Va};var bn=B(require("ajv"),1);function ln(t,e=!1){let n=[];return t.filter(d=>Boolean(d.statemachine)).forEach(d=>{Object.prototype.hasOwnProperty.call(d.statemachine,"states")&&(n=n.concat(ln(d.statemachine.states,!0)))}),n.concat(t.map(d=>({name:d.name,type:d.type,statemachine:Boolean(d.statemachine),hasParent:e})))}function rn(t){let e=[];return Object.prototype.hasOwnProperty.call(t,"transitions")&&(e=t.transitions),Object.prototype.hasOwnProperty.call(t,"states")&&t.states.filter(n=>Boolean(n.statemachine)).forEach(n=>{e=e.concat(rn(n.statemachine))}),e}var q=class{constructor(e){this._flattenedStates=ln(e.states||[]),this._flattenedTransitions=rn(e)}get flattenedTransitions(){return this._flattenedTransitions}findStateByName(e){return this._flattenedStates.find(n=>n.name===e)}findStatesByTypes(e){return this._flattenedStates.filter(n=>e.includes(n.type))}findExternalSelfTransitions(e){return this._flattenedTransitions.filter(n=>n.from===e&&n.to===e&&n.type!=="internal")}findTransitionsByFrom(e){return this._flattenedTransitions.filter(n=>n.from===e)}findTransitionsByTo(e){return this._flattenedTransitions.filter(n=>n.to===e)}};var Sa="^(entry|activity|exit)\\s*/\\s*([^\\n$]*)(\\n|$)",Ma=new RegExp(Sa);function an(t,e){return t.includes(e)}var za=[{re:/initial/,stateType:"initial"},{re:/final/,stateType:"final"},{re:/parallel/,stateType:"parallel"},{re:/(deep.*history)|(history.*deep)/,stateType:"deephistory"},{re:/history/,stateType:"history"},{re:/^\^.*/,stateType:"choice"},{re:/^].*/,stateType:"forkjoin"}];function Ua(t){return e=>e.re.test(t)}function on(t){return(za.find(Ua(t))||{stateType:"regular"}).stateType}function je(t){return{name:t,type:on(t)}}function sn(t){return Boolean(t.statemachine)}function cn(t){let e=t.states||[];return e.filter(sn).reduce((n,d)=>n.concat(cn(d.statemachine)),e.map(n=>n.name))}function un(t,e){e=e||cn(t),t.states=t.states||[];let n=t.transitions||[];return t.states.filter(sn).forEach(d=>{d.statemachine.states=un(d.statemachine,e)}),n.forEach(d=>{an(e,d.from)||(e.push(d.from),t.states.push(je(d.from))),an(e,d.to)||(e.push(d.to),t.states.push(je(d.to)))}),t.states}function Ga(t,e){let n="junction";return t<=1&&e>1&&(n="fork"),t>1&&e<=1&&(n="join"),n}function fn(t,e=new q(t)){return t.states=t.states.map(n=>{if(n.type==="forkjoin"&&!n.typeExplicitlySet){let d=e.findTransitionsByTo(n.name).length,r=e.findTransitionsByFrom(n.name).length;n.type=Ga(d,r)}return n.statemachine&&(n.statemachine=fn(n.statemachine,e)),n}),t}function Xa(t,e){return t.name===e.name}function Ja(t,e){return t.reduce((n,d)=>{let r=n.findIndex(u=>e(u,d));return r>-1?(n[r]=d,n):n.concat(d)},[])}function Qa(t){let e=/([^[/]+)?(\[[^\]]+\])?[^/]*(\/.+)?/,n={},d=t.match(e),r=1,u=2,s=3;return d[r]&&(n.event=d[r].trim()),d[u]&&(n.cond=d[u].slice(1,-1).trim()),d[s]&&(n.action=d[s].slice(1,d[s].length).trim()),n}function mn(t,e,n,d=r=>r){d(n)&&(t[e]=n)}function Wa(t,e,n){mn(t,e,n,d=>d&&d.length>0)}function Ya(t){let e=t.match(Ma),n=1,d=2;return e?{type:e[n],body:e[d]}:{type:"activity",body:t}}function Za(t){return t.split(/\n\s*/g).map(e=>e.trim()).map(Ya)}var R={initState:je,extractUndeclaredStates:un,classifyForkJoins:fn,getStateType:on,stateEqual:Xa,uniq:Ja,parseTransitionExpression:Qa,extractActions:Za,setIf:mn,setIfNotEmpty:Wa};function Ka(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n}function Q(t,e,n,d){var r=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(r,Q.prototype),r.expected=e,r.found=n,r.location=d,r.name="SyntaxError",r}Ka(Q,Error);function Ae(t,e,n){return n=n||" ",t.length>e?t:(e-=t.length,n+=n.repeat(e),t+n.slice(0,e))}Q.prototype.format=function(t){var e="Error: "+this.message;if(this.location){var n=null,d;for(d=0;d<t.length;d++)if(t[d].source===this.location.source){n=t[d].text.split(/\r\n|\n|\r/g);break}var r=this.location.start,u=this.location.source+":"+r.line+":"+r.column;if(n){var s=this.location.end,f=Ae("",r.line.toString().length," "),v=n[r.line-1],m=r.line===s.line?s.column:v.length+1,p=m-r.column||1;e+=`
67
+ `},compiler:[8,">= 4.3.0"],main:function(t,e,n,d,r){var u=t.lookupProperty||function(s,f){if(Object.prototype.hasOwnProperty.call(s,f))return s[f]};return(n=u(n,"each").call(e??(t.nullContext||{}),e!=null?u(e,"states"):e,{name:"each",hash:{},fn:t.program(1,r,0),inverse:t.noop,data:r,loc:{start:{line:1,column:0},end:{line:20,column:9}}}))!=null?n:""},usePartial:!0,useData:!0})});var Un=z((Vs,zn)=>{var Ue=require("handlebars/dist/handlebars.runtime.js");Sn();Mn();Ue.registerPartial("scxml.states.template.hbs",Ue.templates["scxml.states.template.hbs"]);zn.exports=function(e){return Ue.templates["scxml.template.hbs"](e)}});var Ai={};Da(Ai,{default:()=>ji,getAllowedValues:()=>Zn,render:()=>Wn,version:()=>Yn});module.exports=La(Ai);var nn=Object.freeze({inputType:{default:"smcat",values:[{name:"smcat"},{name:"json"},{name:"scxml"}]},outputType:{default:"svg",values:[{name:"svg"},{name:"eps"},{name:"ps"},{name:"ps2"},{name:"dot"},{name:"smcat"},{name:"json"},{name:"ast"},{name:"scxml"},{name:"oldsvg"},{name:"oldps2"},{name:"oldeps"},{name:"scjson"},{name:"pdf"},{name:"png"}]},engine:{default:"dot",values:[{name:"dot"},{name:"circo"},{name:"fdp"},{name:"neato"},{name:"osage"},{name:"twopi"}]},direction:{default:"top-down",values:[{name:"top-down"},{name:"bottom-top"},{name:"left-right"},{name:"right-left"}]},desugar:{default:!1,values:[{name:!0},{name:!1}]}});function Va(t,e){return(t==null?void 0:t[e])??nn[e].default}function Na(){return nn}var H={getAllowedValues:Na,getOptionValue:Va};var bn=B(require("ajv"),1);function ln(t,e=!1){let n=[];return t.filter(d=>Boolean(d.statemachine)).forEach(d=>{Object.prototype.hasOwnProperty.call(d.statemachine,"states")&&(n=n.concat(ln(d.statemachine.states,!0)))}),n.concat(t.map(d=>({name:d.name,type:d.type,statemachine:Boolean(d.statemachine),hasParent:e})))}function rn(t){let e=[];return Object.prototype.hasOwnProperty.call(t,"transitions")&&(e=t.transitions),Object.prototype.hasOwnProperty.call(t,"states")&&t.states.filter(n=>Boolean(n.statemachine)).forEach(n=>{e=e.concat(rn(n.statemachine))}),e}var q=class{constructor(e){this._flattenedStates=ln(e.states||[]),this._flattenedTransitions=rn(e)}get flattenedTransitions(){return this._flattenedTransitions}findStateByName(e){return this._flattenedStates.find(n=>n.name===e)}findStatesByTypes(e){return this._flattenedStates.filter(n=>e.includes(n.type))}findExternalSelfTransitions(e){return this._flattenedTransitions.filter(n=>n.from===e&&n.to===e&&n.type!=="internal")}findTransitionsByFrom(e){return this._flattenedTransitions.filter(n=>n.from===e)}findTransitionsByTo(e){return this._flattenedTransitions.filter(n=>n.to===e)}};var Sa="^(entry|activity|exit)\\s*/\\s*([^\\n$]*)(\\n|$)",Ma=new RegExp(Sa);function an(t,e){return t.includes(e)}var za=[{re:/initial/,stateType:"initial"},{re:/final/,stateType:"final"},{re:/parallel/,stateType:"parallel"},{re:/(deep.*history)|(history.*deep)/,stateType:"deephistory"},{re:/history/,stateType:"history"},{re:/^\^.*/,stateType:"choice"},{re:/^].*/,stateType:"forkjoin"}];function Ua(t){return e=>e.re.test(t)}function on(t){return(za.find(Ua(t))||{stateType:"regular"}).stateType}function je(t){return{name:t,type:on(t)}}function sn(t){return Boolean(t.statemachine)}function cn(t){let e=t.states||[];return e.filter(sn).reduce((n,d)=>n.concat(cn(d.statemachine)),e.map(n=>n.name))}function un(t,e){e=e||cn(t),t.states=t.states||[];let n=t.transitions||[];return t.states.filter(sn).forEach(d=>{d.statemachine.states=un(d.statemachine,e)}),n.forEach(d=>{an(e,d.from)||(e.push(d.from),t.states.push(je(d.from))),an(e,d.to)||(e.push(d.to),t.states.push(je(d.to)))}),t.states}function Ga(t,e){let n="junction";return t<=1&&e>1&&(n="fork"),t>1&&e<=1&&(n="join"),n}function fn(t,e=new q(t)){return t.states=t.states.map(n=>{if(n.type==="forkjoin"&&!n.typeExplicitlySet){let d=e.findTransitionsByTo(n.name).length,r=e.findTransitionsByFrom(n.name).length;n.type=Ga(d,r)}return n.statemachine&&(n.statemachine=fn(n.statemachine,e)),n}),t}function Xa(t,e){return t.name===e.name}function Ja(t,e){return t.reduce((n,d)=>{let r=n.findIndex(u=>e(u,d));return r>-1?(n[r]=d,n):n.concat(d)},[])}function Qa(t){let e=/([^[/]+)?(\[[^\]]+\])?[^/]*(\/.+)?/,n={},d=t.match(e),r=1,u=2,s=3;return d[r]&&(n.event=d[r].trim()),d[u]&&(n.cond=d[u].slice(1,-1).trim()),d[s]&&(n.action=d[s].slice(1,d[s].length).trim()),n}function mn(t,e,n,d=r=>r){d(n)&&(t[e]=n)}function Wa(t,e,n){mn(t,e,n,d=>d&&d.length>0)}function Ya(t){let e=t.match(Ma),n=1,d=2;return e?{type:e[n],body:e[d]}:{type:"activity",body:t}}function Za(t){return t.split(/\n\s*/g).map(e=>e.trim()).map(Ya)}var R={initState:je,extractUndeclaredStates:un,classifyForkJoins:fn,getStateType:on,stateEqual:Xa,uniq:Ja,parseTransitionExpression:Qa,extractActions:Za,setIf:mn,setIfNotEmpty:Wa};function Ka(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n}function Q(t,e,n,d){var r=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(r,Q.prototype),r.expected=e,r.found=n,r.location=d,r.name="SyntaxError",r}Ka(Q,Error);function Ae(t,e,n){return n=n||" ",t.length>e?t:(e-=t.length,n+=n.repeat(e),t+n.slice(0,e))}Q.prototype.format=function(t){var e="Error: "+this.message;if(this.location){var n=null,d;for(d=0;d<t.length;d++)if(t[d].source===this.location.source){n=t[d].text.split(/\r\n|\n|\r/g);break}var r=this.location.start,u=this.location.source+":"+r.line+":"+r.column;if(n){var s=this.location.end,f=Ae("",r.line.toString().length," "),v=n[r.line-1],m=r.line===s.line?s.column:v.length+1,p=m-r.column||1;e+=`
68
68
  --> `+u+`
69
69
  `+f+` |
70
70
  `+r.line+" | "+v+`
@@ -76,4 +76,4 @@ var Ta=Object.create;var ge=Object.defineProperty;var Ba=Object.getOwnPropertyDe
76
76
  `)),t.cond&&(e.cond=t.cond),t["#text"]&&(e.action=W.default.decode(t["#text"]).trim()),t.type&&(e.type=t.type),e}function co(t){let e={};typeof t=="string"?e.action=W.default.decode(t).trim():Object.assign(e,so(t));let n=ro(e.event,e.cond,e.action);return n&&(e.label=n),e}function uo(t){return(e,n)=>{let d=(n.target||t.id).split(/\s+/),r=co(n);return e.concat(d.map(u=>({from:t.id,to:u,...r})))}}function Fe(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 hn(t){let e=_e(t),n={};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")));let d=Fe(e.initial).concat(Fe(e.state)).concat(Fe(e.parallel));return d.length>0&&(n.transitions=d),n}function gn(t){let e=t.trim();if(Re.default.validate(e)===!0){let n=Re.default.parse(e,{attributeNamePrefix:"",ignoreAttributes:!1,tagValueProcessor:d=>W.default.decode(d),stopNodes:["onentry","onexit","transition"]});return hn((n==null?void 0:n.scxml)??{})}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 fo(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=pn(t):H.getOptionValue(e,"inputType")==="scxml"?n=gn(t):typeof t=="string"&&(n=JSON.parse(t)),fo(yn,n),n}};var Be=B(require("lodash/cloneDeep.js"),1),Te=B(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,r)=>(e.forEach((u,s)=>{u===r.to&&n[u]?d=d.concat(n[u].map(f=>po(r,f))):d=s===0?d.concat(r):d}),d),[])}function xn(t,e,n){let d=(0,Be.default)(t);return d.transitions&&e.length>0&&(d.transitions=ho(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,Be.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(s=>s.name),r=d.reduce((s,f)=>(s[f]=n.findTransitionsByFrom(f),s),{}),u=xn(t,d,r);return kn(u,d)};var Xn=B(require("lodash/has.js"),1),Jn=B(jn(),1);var Bn=B(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"}]},Ao=[{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"}],_o=[{name:"fontname",value:"Helvetica"},{name:"fontsize",value:10}];function Ie(t){return`${t.name}=${t.value}`}var be={buildGraphAttributes:(t,e,n)=>Oo.concat(Eo[t]||[]).concat(jo[e]||[]).concat(n||[]).map(Ie).join(" "),buildNodeAttributes:t=>Ao.concat(t||[]).map(Ie).join(" "),buildEdgeAttributes:t=>_o.concat(t||[]).map(Ie).join(" ")};function Fo(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 To(t){let e=t||"top-down";return e==="top-down"||e==="bottom-top"}function Bo(t,e){return e.from===e.to&&t.findStateByName(e.from).statemachine&&e.type!=="internal"}var N={escapeString:Fo,escapeLabelString:Ro,isVertical:To,isCompositeSelf:Bo};function An(t){return e=>e.type===t}function De(t){return e=>t.includes(e.type)}function Ho(t){return t.label=t.label||t.name,t}function qo(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 Do(t){return t==="activity"?"":`${t}/ `}function Lo(t){let e={...t};return t.actions&&(e.actions=t.actions.map(n=>`${Do(n.type)}${n.body}`)),e}function Vo(t){return Object.prototype.hasOwnProperty.call(t,"note")&&(t.noteFlattened=t.note.join("")),t}function No(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 So(t){return t.note&&(t.note=t.note.map(N.escapeString)),t}function Mo(t){return e=>De(["fork","join","forkjoin"])(e)?{sizingExtras:N.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=>An("regular")(e)?{...e,parentIsParallel:!0}:e)),t}var F={isType:An,isOneOfTypes:De,setLabel:Ho,classifyState:Io,nameNote:qo,flattenActions:Lo,flattenNote:Vo,recolor:No,escapeStateStrings:So,tipForkJoinStates:Mo,flagParallelChildren:zo};function Uo(t){return t.note&&(t.note=t.note.map(N.escapeString)),t.label&&(t.label=N.escapeLabelString(t.label)),t}function Go(t){return e=>{let n={};return e.isCompositeSelf&&(N.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 $e={escapeTransitionStrings:Uo,addPorts:Go,classifyTransition:Xo};var ie=class{constructor(){this.reset()}reset(){this.COUNTER=0}next(){return++this.COUNTER}nextAsString(){return this.next().toString(10)}};var Hn=B(Tn(),1);var qn={};function ei(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(ei(d))}function ti(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 ni(t){return e=>(t.findStateByName(e.from).statemachine&&(e.fromComposite=!0),t.findStateByName(e.to).statemachine&&(e.toComposite=!0),e)}function li(t){return e=>{let n={};return N.isCompositeSelf(t,e)&&(t.findStateByName(e.from).hasParent?n={hasParent:!0,isCompositeSelf:!0}:n={isCompositeSelf:!0}),{...e,...n}}}function ri(t){return t.name=`tr_${t.from}_${t.to}_${qn.nextAsString()}`,Boolean(t.note)&&(t.noteName=`note_${t.name}`),t}function ai(t,e){return t.flattenedTransitions.map(ri).map($e.escapeTransitionStrings).map($e.classifyTransition).map(F.flattenNote).map(ni(t)).map(li(t)).map($e.addPorts(e))}var xe=(t,e)=>{e=e||{},qn=new ie;let n=(0,Bn.default)(t),d=new q(n);return n.transitions=ai(d,e.direction),n.states=In(n.states,e.direction,e.dotNodeAttrs,d),n=ti(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,Hn.default)(n)};var Dn=B(require("viz.js"),1);var oi={oldsvg:"svg",oldps2:"ps2",oldeps:"eps"},Ne=(t,e)=>(0,Dn.default)(xe(t,e),{engine:H.getOptionValue(e,"engine"),format:oi[H.getOptionValue(e,"outputType")]||"svg"});var ii=/[\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,si=/[-|.|0-9|\u00B7|\u0300-\u036F|\u203F-\u2040]/g;function Ln(t){return t.replace(ii,"_")}function ci(t){let e=Ln(t);return e.match(si)&&(e=`_${t}`),e}var ke=t=>(t=t||"",t.length===0?"__empty":ci(t[0]).concat(Ln(t.slice(1))));var ui=/[\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,fi=/[.]/g;function Vn(t){return t.replace(ui,"_")}function mi(t){let e=Vn(t);return e.match(fi)&&(e=`_${t}`),e}function pi(t){return t=t.replace(/\s+/g," ").trim(),mi(t[0]).concat(Vn(t.slice(1)))}var Nn=t=>(t=t||"",t.length===0?"empty":t.split(/[\n\r]+/).filter(e=>e.length>0).map(pi).join(" "));var di={regular:"state",initial:"initial",final:"final",terminate:"final",parallel:"parallel",history:"history",deephistory:"history"};function hi(t){return di[t]||"state"}function gi(t){let e={target:ke(t.to)};return Boolean(t.event)&&(e.event=Nn(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 yi(t,e){return t.filter(n=>n.type===e).map(n=>n.body)}function Se(t,e,n,d){let r=yi(n,d);r.length>0&&(t[e]=(t[e]||[]).concat(r))}function vi(t,e){Boolean(e.actions)&&(Se(t,"onentries",e.actions,"entry"),Se(t,"onentries",e.actions,"activity"),Se(t,"onexits",e.actions,"exit"))}function bi(t,e,n){let d=n.filter(r=>r.from===e.name).map(gi);d.length>0&&(t.transitions=d)}function $i(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 xi(t){return t=t||[],e=>{let n={kind:hi(e.type),id:ke(e.name)};return e.type==="deephistory"&&(n.type="deep"),vi(n,e),bi(n,e,t),$i(n,e,t),n}}function ki(t){let e=null,n=t.states.filter(d=>d.type==="initial");return n.length>0&&(e=n[0].name),e}function wi(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=ki(t),r=wi(t,d),u={states:t.states.filter(s=>r&&r!==d?s.type!=="initial":!0).map(xi(n||new q(t).flattenedTransitions))};return r&&(u.initial=ke(r)),u}var Gn=B(Un(),1);function Ge(t){return(0,Gn.default)(ee(t))}function Xe(t){let e={smcat:Jn.default,dot:xe,svg:Ne,oldsvg:Ne,scjson:ee,scxml:Ge};return(0,Xn.default)(e,t)?e[t]:n=>n}var Qn="10.0.1";function Wn(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 Yn=Qn;function Zn(){return H.getAllowedValues()}var ji={render:Wn,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,r)=>(e.forEach((u,s)=>{u===r.to&&n[u]?d=d.concat(n[u].map(f=>po(r,f))):d=s===0?d.concat(r):d}),d),[])}function xn(t,e,n){let d=(0,Be.default)(t);return d.transitions&&e.length>0&&(d.transitions=ho(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,Be.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(s=>s.name),r=d.reduce((s,f)=>(s[f]=n.findTransitionsByFrom(f),s),{}),u=xn(t,d,r);return kn(u,d)};var Xn=B(require("lodash/has.js"),1),Jn=B(jn(),1);var Bn=B(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"}]},Ao=[{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"}],_o=[{name:"fontname",value:"Helvetica"},{name:"fontsize",value:10}];function Ie(t){return`${t.name}=${t.value}`}var be={buildGraphAttributes:(t,e,n)=>Oo.concat(Eo[t]||[]).concat(jo[e]||[]).concat(n||[]).map(Ie).join(" "),buildNodeAttributes:t=>Ao.concat(t||[]).map(Ie).join(" "),buildEdgeAttributes:t=>_o.concat(t||[]).map(Ie).join(" ")};function Fo(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 To(t){let e=t||"top-down";return e==="top-down"||e==="bottom-top"}function Bo(t,e){return e.from===e.to&&t.findStateByName(e.from).statemachine&&e.type!=="internal"}var N={escapeString:Fo,escapeLabelString:Ro,isVertical:To,isCompositeSelf:Bo};function An(t){return e=>e.type===t}function De(t){return e=>t.includes(e.type)}function Ho(t){return t.label=t.label||t.name,t}function qo(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 Do(t){return t==="activity"?"":`${t}/ `}function Lo(t){let e={...t};return t.actions&&(e.actions=t.actions.map(n=>`${Do(n.type)}${n.body}`)),e}function Vo(t){return Object.prototype.hasOwnProperty.call(t,"note")&&(t.noteFlattened=t.note.join("")),t}function No(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 So(t){return t.note&&(t.note=t.note.map(N.escapeString)),t}function Mo(t){return e=>De(["fork","join","forkjoin"])(e)?{sizingExtras:N.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=>An("regular")(e)?{...e,parentIsParallel:!0}:e)),t}var F={isType:An,isOneOfTypes:De,setLabel:Ho,classifyState:Io,nameNote:qo,flattenActions:Lo,flattenNote:Vo,recolor:No,escapeStateStrings:So,tipForkJoinStates:Mo,flagParallelChildren:zo};function Uo(t){return t.note&&(t.note=t.note.map(N.escapeString)),t.label&&(t.label=N.escapeLabelString(t.label)),t}function Go(t){return e=>{let n={};return e.isCompositeSelf&&(N.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 $e={escapeTransitionStrings:Uo,addPorts:Go,classifyTransition:Xo};var ie=class{constructor(){this.reset()}reset(){this.COUNTER=0}next(){return++this.COUNTER}nextAsString(){return this.next().toString(10)}};var Hn=B(Tn(),1);var qn={};function ei(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(ei(d))}function ti(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 ni(t){return e=>(t.findStateByName(e.from).statemachine&&(e.fromComposite=!0),t.findStateByName(e.to).statemachine&&(e.toComposite=!0),e)}function li(t){return e=>{let n={};return N.isCompositeSelf(t,e)&&(t.findStateByName(e.from).hasParent?n={hasParent:!0,isCompositeSelf:!0}:n={isCompositeSelf:!0}),{...e,...n}}}function ri(t){return t.name=`tr_${t.from}_${t.to}_${qn.nextAsString()}`,Boolean(t.note)&&(t.noteName=`note_${t.name}`),t}function ai(t,e){return t.flattenedTransitions.map(ri).map($e.escapeTransitionStrings).map($e.classifyTransition).map(F.flattenNote).map(ni(t)).map(li(t)).map($e.addPorts(e))}var xe=(t,e)=>{e=e||{},qn=new ie;let n=(0,Bn.default)(t),d=new q(n);return n.transitions=ai(d,e.direction),n.states=In(n.states,e.direction,e.dotNodeAttrs,d),n=ti(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,Hn.default)(n)};var Dn=B(require("viz.js"),1);var oi={oldsvg:"svg",oldps2:"ps2",oldeps:"eps"},Ne=(t,e)=>(0,Dn.default)(xe(t,e),{engine:H.getOptionValue(e,"engine"),format:oi[H.getOptionValue(e,"outputType")]||"svg"});var ii=/[\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,si=/[-|.|0-9|\u00B7|\u0300-\u036F|\u203F-\u2040]/g;function Ln(t){return t.replace(ii,"_")}function ci(t){let e=Ln(t);return e.match(si)&&(e=`_${t}`),e}var ke=t=>(t=t||"",t.length===0?"__empty":ci(t[0]).concat(Ln(t.slice(1))));var ui=/[\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,fi=/[.]/g;function Vn(t){return t.replace(ui,"_")}function mi(t){let e=Vn(t);return e.match(fi)&&(e=`_${t}`),e}function pi(t){return t=t.replace(/\s+/g," ").trim(),mi(t[0]).concat(Vn(t.slice(1)))}var Nn=t=>(t=t||"",t.length===0?"empty":t.split(/[\n\r]+/).filter(e=>e.length>0).map(pi).join(" "));var di={regular:"state",initial:"initial",final:"final",terminate:"final",parallel:"parallel",history:"history",deephistory:"history"};function hi(t){return di[t]||"state"}function gi(t){let e={target:ke(t.to)};return Boolean(t.event)&&(e.event=Nn(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 yi(t,e){return t.filter(n=>n.type===e).map(n=>n.body)}function Se(t,e,n,d){let r=yi(n,d);r.length>0&&(t[e]=(t[e]||[]).concat(r))}function vi(t,e){Boolean(e.actions)&&(Se(t,"onentries",e.actions,"entry"),Se(t,"onentries",e.actions,"activity"),Se(t,"onexits",e.actions,"exit"))}function bi(t,e,n){let d=n.filter(r=>r.from===e.name).map(gi);d.length>0&&(t.transitions=d)}function $i(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 xi(t){return t=t||[],e=>{let n={kind:hi(e.type),id:ke(e.name)};return e.type==="deephistory"&&(n.type="deep"),vi(n,e),bi(n,e,t),$i(n,e,t),n}}function ki(t){let e=null,n=t.states.filter(d=>d.type==="initial");return n.length>0&&(e=n[0].name),e}function wi(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=ki(t),r=wi(t,d),u={states:t.states.filter(s=>r&&r!==d?s.type!=="initial":!0).map(xi(n||new q(t).flattenedTransitions))};return r&&(u.initial=ke(r)),u}var Gn=B(Un(),1);function Ge(t){return(0,Gn.default)(ee(t))}function Xe(t){let e={smcat:Jn.default,dot:xe,svg:Ne,oldsvg:Ne,scjson:ee,scxml:Ge};return(0,Xn.default)(e,t)?e[t]:n=>n}var Qn="10.1.0-beta-1";function Wn(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 Yn=Qn;function Zn(){return H.getAllowedValues()}var ji={render:Wn,version:Yn,getAllowedValues:Zn};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "state-machine-cat",
3
- "version": "10.0.1",
3
+ "version": "10.1.0-beta-1",
4
4
  "description": "write beautiful state charts",
5
5
  "main": "./dist/commonjs/index.js",
6
6
  "module": "./src/index.mjs",
@@ -51,6 +51,7 @@
51
51
  "lint:fix:eslint": "wireit",
52
52
  "lint:fix:prettier": "wireit",
53
53
  "lint:fix:types": "wireit",
54
+ "prepare": "husky install",
54
55
  "scm:push": "run-p --aggregate-output scm:push:*",
55
56
  "scm:push:github": "run-p --aggregate-output scm:push:github:*",
56
57
  "scm:push:github:commits": "git push",
@@ -65,8 +66,9 @@
65
66
  "test": "wireit",
66
67
  "test:cover": "wireit",
67
68
  "update-dependencies": "run-s upem:update upem:install lint:fix check",
69
+ "upem-outdated": "npm outdated --json --long | upem --dry-run",
68
70
  "upem:install": "npm install",
69
- "upem:update": "npm outdated --json | upem",
71
+ "upem:update": "npm outdated --json --long | upem | pbcopy && pbpaste",
70
72
  "version": "run-s build depcruise:graph scm:stage"
71
73
  },
72
74
  "files": [
@@ -405,34 +407,35 @@
405
407
  "wrap-ansi": "8.0.1"
406
408
  },
407
409
  "devDependencies": {
408
- "@typescript-eslint/eslint-plugin": "5.31.0",
409
- "@typescript-eslint/parser": "5.31.0",
410
+ "@typescript-eslint/eslint-plugin": "5.36.1",
411
+ "@typescript-eslint/parser": "5.36.1",
410
412
  "c8": "7.12.0",
411
413
  "chai": "4.3.6",
412
414
  "chai-as-promised": "7.1.1",
413
415
  "chai-json-schema": "1.5.1",
414
416
  "chai-xml": "0.4.0",
415
- "dependency-cruiser": "11.14.0",
416
- "esbuild": "0.14.51",
417
- "eslint": "^8.20.0",
418
- "eslint-config-moving-meadow": "3.0.0",
417
+ "dependency-cruiser": "11.15.0",
418
+ "esbuild": "0.15.7",
419
+ "eslint": "8.23.0",
420
+ "eslint-config-moving-meadow": "4.0.2",
419
421
  "eslint-config-prettier": "8.5.0",
420
- "eslint-plugin-budapestian": "4.0.0",
422
+ "eslint-plugin-budapestian": "5.0.0",
423
+ "eslint-plugin-eslint-comments": "3.2.0",
421
424
  "eslint-plugin-import": "2.26.0",
422
425
  "eslint-plugin-mocha": "10.1.0",
423
426
  "eslint-plugin-node": "11.1.0",
424
427
  "eslint-plugin-security": "1.5.0",
425
- "eslint-plugin-unicorn": "^43.0.2",
426
- "husky": "4.3.8",
428
+ "eslint-plugin-unicorn": "43.0.2",
429
+ "husky": "8.0.1",
427
430
  "lint-staged": "13.0.3",
428
431
  "mocha": "10.0.0",
429
432
  "npm-run-all": "4.1.5",
430
433
  "peggy": "2.0.1",
431
- "prettier": "^2.7.1",
434
+ "prettier": "2.7.1",
432
435
  "query-string": "7.1.1",
433
- "typescript": "4.7.4",
434
- "upem": "^7.0.0",
435
- "watskeburt": "0.6.0",
436
+ "typescript": "4.8.2",
437
+ "upem": "7.3.0",
438
+ "watskeburt": "0.7.0",
436
439
  "wireit": "0.7.1",
437
440
  "xml-name-validator": "4.0.0"
438
441
  },
@@ -462,11 +465,6 @@
462
465
  "bugs": {
463
466
  "url": "https://github.com/sverweij/state-machine-cat/issues"
464
467
  },
465
- "husky": {
466
- "hooks": {
467
- "pre-commit": "lint-staged"
468
- }
469
- },
470
468
  "lint-staged": {
471
469
  "{src,test}/**/*.{js,cjs}": [
472
470
  "eslint --cache --cache-location .cache --fix",
@@ -49,7 +49,7 @@ export default {
49
49
  typeof lOutput === "string"
50
50
  ? lOutput
51
51
  : JSON.stringify(lOutput, null, " "),
52
- "utf8"
52
+ "binary"
53
53
  );
54
54
  });
55
55
  },
@@ -2,12 +2,22 @@
2
2
 
3
3
  import * as fs from "node:fs";
4
4
 
5
+ /**
6
+ *
7
+ * @param {string} pOutputTo
8
+ * @returns {import("node:fs").WriteStream}
9
+ */
5
10
  export function getOutStream(pOutputTo) {
6
11
  if ("-" === pOutputTo) {
7
12
  return process.stdout;
8
13
  }
9
14
  return fs.createWriteStream(pOutputTo);
10
15
  }
16
+ /**
17
+ *
18
+ * @param {string} pInputFrom
19
+ * @returns {import("node:fs").ReadStream}
20
+ */
11
21
  export function getInStream(pInputFrom) {
12
22
  if ("-" === pInputFrom) {
13
23
  return process.stdin;
@@ -1,7 +1,7 @@
1
1
  // seems eslint-plugin-import and eslint-plugin-node can't handle exports
2
2
  // fields yet. No man overboard not checking against this, because dependency-cruiser
3
3
  // will also find them
4
- // eslint-disable-next-line import/no-unresolved, node/no-missing-import
4
+
5
5
  import chalk from "chalk";
6
6
  import indentString from "indent-string";
7
7
  import wrapAnsi from "wrap-ansi";
package/src/options.mjs CHANGED
@@ -19,6 +19,8 @@ const ALLOWED_VALUES = Object.freeze({
19
19
  { name: "oldps2" },
20
20
  { name: "oldeps" },
21
21
  { name: "scjson" },
22
+ { name: "pdf" },
23
+ { name: "png" },
22
24
  ],
23
25
  },
24
26
  engine: {
@@ -18,6 +18,8 @@ export default function getRenderFunction(pOutputType) {
18
18
  oldsvg: oldVector,
19
19
  oldps2: oldVector,
20
20
  oldeps: oldVector,
21
+ pdf: vector,
22
+ png: vector,
21
23
  scjson,
22
24
  scxml,
23
25
  };
@@ -1,4 +1,3 @@
1
- // eslint-disable-next-line security/detect-child-process
2
1
  import { spawnSync } from "node:child_process";
3
2
 
4
3
  const DEFAULT_OPTIONS = {
@@ -35,7 +34,7 @@ function convert(pDot, pOptions) {
35
34
  // 1: error in the program
36
35
  // -2: executable not found
37
36
  if (status === 0) {
38
- return stdout.toString("utf8");
37
+ return stdout.toString("binary");
39
38
  } else if (error) {
40
39
  throw new Error(error);
41
40
  } else {
@@ -4,7 +4,7 @@ import wrapAnsi from "wrap-ansi";
4
4
  // seems eslint-plugin-import and eslint-plugin-node can't handle exports
5
5
  // fields yet. No man overboard not checking against this, because dependency-cruiser
6
6
  // will also find them
7
- // eslint-disable-next-line import/no-unresolved, node/no-missing-import
7
+
8
8
  import chalk from "chalk";
9
9
  import options from "../../options.mjs";
10
10
  import ast2dot from "../dot/index.mjs";
@@ -157,7 +157,6 @@ export default (
157
157
 
158
158
  const lOutgoingTransitionMap = lPseudoStateNames.reduce(
159
159
  (pAll, pStateName) => {
160
- // eslint-disable-next-line security/detect-object-injection
161
160
  pAll[pStateName] = lModel.findTransitionsByFrom(pStateName);
162
161
  return pAll;
163
162
  },
package/src/version.mjs CHANGED
@@ -1 +1 @@
1
- export const version = "10.0.1";
1
+ export const version = "10.1.0-beta-1";