state-machine-cat 15.0.0 → 15.0.2

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.
@@ -1 +1 @@
1
- "use strict";export const validate=C;export default C;const z={type:"object",additionalProperties:!1,required:["states"],properties:{states:{type:"array",items:{type:"object",required:["name","type"],additionalProperties:!1,properties:{name:{type:"string"},type:{$ref:"#/definitions/StateType"},label:{type:"string"},color:{type:"string"},class:{$ref:"#/definitions/ClassType"},active:{type:"boolean"},typeExplicitlySet:{type:"boolean"},isComposite:{type:"boolean"},actions:{type:"array",items:{$ref:"#/definitions/ActionType"}},note:{$ref:"#/definitions/NoteType"},statemachine:{$ref:"#/definitions/StateMachineType"}}}},transitions:{type:"array",items:{type:"object",required:["id","from","to"],additionalProperties:!1,properties:{id:{type:"number"},from:{type:"string"},to:{type:"string"},label:{type:"string"},event:{type:"string"},cond:{type:"string"},action:{type:"string"},note:{$ref:"#/definitions/NoteType"},color:{type:"string"},width:{type:"number",minimum:0,maximum:30},class:{$ref:"#/definitions/ClassType"},type:{$ref:"#/definitions/TransitionType"}}}}}},R={type:"string",enum:["regular","initial","terminate","final","parallel","history","deephistory","choice","forkjoin","fork","join","junction"]};const B={type:"string",enum:["internal","external"]},Z=Object.prototype.hasOwnProperty,O=new RegExp("^[a-zA-Z0-9_\\- ]*$","u");const G={type:"string",enum:["entry","activity","exit"]};function c(y,{instancePath:r="",parentData:j,parentDataProperty:$,rootData:w=y}={}){let m=null,e=0;if(e===0)if(y&&typeof y=="object"&&!Array.isArray(y)){let n;if(y.type===void 0&&(n="type")||y.body===void 0&&(n="body"))return c.errors=[{instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:n},message:"must have required property '"+n+"'"}],!1;{const _=e;for(const f in y)if(!(f==="type"||f==="body")){return c.errors=[{instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"}],!1;break}if(_===e){if(y.type!==void 0){let f=y.type;const P=e;if(typeof f!="string")return c.errors=[{instancePath:r+"/type",schemaPath:"#/definitions/ActionTypeType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(f==="entry"||f==="activity"||f==="exit"))return c.errors=[{instancePath:r+"/type",schemaPath:"#/definitions/ActionTypeType/enum",keyword:"enum",params:{allowedValues:G.enum},message:"must be equal to one of the allowed values"}],!1;var g=P===e}else var g=!0;if(g)if(y.body!==void 0){const f=e;if(typeof y.body!="string")return c.errors=[{instancePath:r+"/body",schemaPath:"#/properties/body/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=f===e}else var g=!0}}}else return c.errors=[{instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return c.errors=m,e===0}const N={validate:i};function i(y,{instancePath:r="",parentData:j,parentDataProperty:$,rootData:w=y}={}){let m=null,e=0;if(e===0)if(y&&typeof y=="object"&&!Array.isArray(y)){let q;if(y.states===void 0&&(q="states"))return i.errors=[{instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:q},message:"must have required property '"+q+"'"}],!1;{const M=e;for(const u in y)if(!(u==="states"||u==="transitions")){return i.errors=[{instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"}],!1;break}if(M===e){if(y.states!==void 0){let u=y.states;const T=e;if(e===T)if(Array.isArray(u)){var g=!0;const V=u.length;for(let l=0;l<V;l++){let t=u[l];const p=e;if(e===p)if(t&&typeof t=="object"&&!Array.isArray(t)){let A;if(t.name===void 0&&(A="name")||t.type===void 0&&(A="type"))return i.errors=[{instancePath:r+"/states/"+l,schemaPath:"#/properties/states/items/required",keyword:"required",params:{missingProperty:A},message:"must have required property '"+A+"'"}],!1;{const v=e;for(const a in t)if(!Z.call(z.properties.states.items.properties,a)){return i.errors=[{instancePath:r+"/states/"+l,schemaPath:"#/properties/states/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"}],!1;break}if(v===e){if(t.name!==void 0){const a=e;if(typeof t.name!="string")return i.errors=[{instancePath:r+"/states/"+l+"/name",schemaPath:"#/properties/states/items/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var n=a===e}else var n=!0;if(n){if(t.type!==void 0){let a=t.type;const s=e;if(typeof a!="string")return i.errors=[{instancePath:r+"/states/"+l+"/type",schemaPath:"#/definitions/StateType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(a==="regular"||a==="initial"||a==="terminate"||a==="final"||a==="parallel"||a==="history"||a==="deephistory"||a==="choice"||a==="forkjoin"||a==="fork"||a==="join"||a==="junction"))return i.errors=[{instancePath:r+"/states/"+l+"/type",schemaPath:"#/definitions/StateType/enum",keyword:"enum",params:{allowedValues:R.enum},message:"must be equal to one of the allowed values"}],!1;var n=s===e}else var n=!0;if(n){if(t.label!==void 0){const a=e;if(typeof t.label!="string")return i.errors=[{instancePath:r+"/states/"+l+"/label",schemaPath:"#/properties/states/items/properties/label/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var n=a===e}else var n=!0;if(n){if(t.color!==void 0){const a=e;if(typeof t.color!="string")return i.errors=[{instancePath:r+"/states/"+l+"/color",schemaPath:"#/properties/states/items/properties/color/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var n=a===e}else var n=!0;if(n){if(t.class!==void 0){let a=t.class;const s=e;if(e===e)if(typeof a=="string"){if(!O.test(a))return i.errors=[{instancePath:r+"/states/"+l+"/class",schemaPath:"#/definitions/ClassType/pattern",keyword:"pattern",params:{pattern:"^[a-zA-Z0-9_\\- ]*$"},message:'must match pattern "^[a-zA-Z0-9_\\- ]*$"'}],!1}else return i.errors=[{instancePath:r+"/states/"+l+"/class",schemaPath:"#/definitions/ClassType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var n=s===e}else var n=!0;if(n){if(t.active!==void 0){const a=e;if(typeof t.active!="boolean")return i.errors=[{instancePath:r+"/states/"+l+"/active",schemaPath:"#/properties/states/items/properties/active/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var n=a===e}else var n=!0;if(n){if(t.typeExplicitlySet!==void 0){const a=e;if(typeof t.typeExplicitlySet!="boolean")return i.errors=[{instancePath:r+"/states/"+l+"/typeExplicitlySet",schemaPath:"#/properties/states/items/properties/typeExplicitlySet/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var n=a===e}else var n=!0;if(n){if(t.isComposite!==void 0){const a=e;if(typeof t.isComposite!="boolean")return i.errors=[{instancePath:r+"/states/"+l+"/isComposite",schemaPath:"#/properties/states/items/properties/isComposite/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var n=a===e}else var n=!0;if(n){if(t.actions!==void 0){let a=t.actions;const s=e;if(e===s)if(Array.isArray(a)){var _=!0;const x=a.length;for(let b=0;b<x;b++){const h=e;c(a[b],{instancePath:r+"/states/"+l+"/actions/"+b,parentData:a,parentDataProperty:b,rootData:w})||(m=m===null?c.errors:m.concat(c.errors),e=m.length);var _=h===e;if(!_)break}}else return i.errors=[{instancePath:r+"/states/"+l+"/actions",schemaPath:"#/properties/states/items/properties/actions/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var n=s===e}else var n=!0;if(n){if(t.note!==void 0){let a=t.note;const s=e;if(e===e)if(Array.isArray(a)){var f=!0;const b=a.length;for(let h=0;h<b;h++){const k=e;if(typeof a[h]!="string")return i.errors=[{instancePath:r+"/states/"+l+"/note/"+h,schemaPath:"#/definitions/NoteType/items/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var f=k===e;if(!f)break}}else return i.errors=[{instancePath:r+"/states/"+l+"/note",schemaPath:"#/definitions/NoteType/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var n=s===e}else var n=!0;if(n)if(t.statemachine!==void 0){const a=e;N.validate(t.statemachine,{instancePath:r+"/states/"+l+"/statemachine",parentData:t,parentDataProperty:"statemachine",rootData:w})||(m=m===null?N.validate.errors:m.concat(N.validate.errors),e=m.length);var n=a===e}else var n=!0}}}}}}}}}}}}else return i.errors=[{instancePath:r+"/states/"+l,schemaPath:"#/properties/states/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var g=p===e;if(!g)break}}else return i.errors=[{instancePath:r+"/states",schemaPath:"#/properties/states/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var P=T===e}else var P=!0;if(P)if(y.transitions!==void 0){let u=y.transitions;const T=e;if(e===T)if(Array.isArray(u)){var S=!0;const l=u.length;for(let t=0;t<l;t++){let p=u[t];const D=e;if(e===D)if(p&&typeof p=="object"&&!Array.isArray(p)){let v;if(p.id===void 0&&(v="id")||p.from===void 0&&(v="from")||p.to===void 0&&(v="to"))return i.errors=[{instancePath:r+"/transitions/"+t,schemaPath:"#/properties/transitions/items/required",keyword:"required",params:{missingProperty:v},message:"must have required property '"+v+"'"}],!1;{const a=e;for(const s in p)if(!Z.call(z.properties.transitions.items.properties,s)){return i.errors=[{instancePath:r+"/transitions/"+t,schemaPath:"#/properties/transitions/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:s},message:"must NOT have additional properties"}],!1;break}if(a===e){if(p.id!==void 0){let s=p.id;const d=e;if(!(typeof s=="number"&&isFinite(s)))return i.errors=[{instancePath:r+"/transitions/"+t+"/id",schemaPath:"#/properties/transitions/items/properties/id/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var o=d===e}else var o=!0;if(o){if(p.from!==void 0){const s=e;if(typeof p.from!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/from",schemaPath:"#/properties/transitions/items/properties/from/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.to!==void 0){const s=e;if(typeof p.to!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/to",schemaPath:"#/properties/transitions/items/properties/to/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.label!==void 0){const s=e;if(typeof p.label!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/label",schemaPath:"#/properties/transitions/items/properties/label/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.event!==void 0){const s=e;if(typeof p.event!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/event",schemaPath:"#/properties/transitions/items/properties/event/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.cond!==void 0){const s=e;if(typeof p.cond!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/cond",schemaPath:"#/properties/transitions/items/properties/cond/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.action!==void 0){const s=e;if(typeof p.action!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/action",schemaPath:"#/properties/transitions/items/properties/action/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.note!==void 0){let s=p.note;const d=e;if(e===e)if(Array.isArray(s)){var E=!0;const h=s.length;for(let k=0;k<h;k++){const F=e;if(typeof s[k]!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/note/"+k,schemaPath:"#/definitions/NoteType/items/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var E=F===e;if(!E)break}}else return i.errors=[{instancePath:r+"/transitions/"+t+"/note",schemaPath:"#/definitions/NoteType/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var o=d===e}else var o=!0;if(o){if(p.color!==void 0){const s=e;if(typeof p.color!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/color",schemaPath:"#/properties/transitions/items/properties/color/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.width!==void 0){let s=p.width;const d=e;if(e===d)if(typeof s=="number"&&isFinite(s)){if(s>30||isNaN(s))return i.errors=[{instancePath:r+"/transitions/"+t+"/width",schemaPath:"#/properties/transitions/items/properties/width/maximum",keyword:"maximum",params:{comparison:"<=",limit:30},message:"must be <= 30"}],!1;if(s<0||isNaN(s))return i.errors=[{instancePath:r+"/transitions/"+t+"/width",schemaPath:"#/properties/transitions/items/properties/width/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}else return i.errors=[{instancePath:r+"/transitions/"+t+"/width",schemaPath:"#/properties/transitions/items/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var o=d===e}else var o=!0;if(o){if(p.class!==void 0){let s=p.class;const d=e;if(e===e)if(typeof s=="string"){if(!O.test(s))return i.errors=[{instancePath:r+"/transitions/"+t+"/class",schemaPath:"#/definitions/ClassType/pattern",keyword:"pattern",params:{pattern:"^[a-zA-Z0-9_\\- ]*$"},message:'must match pattern "^[a-zA-Z0-9_\\- ]*$"'}],!1}else return i.errors=[{instancePath:r+"/transitions/"+t+"/class",schemaPath:"#/definitions/ClassType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=d===e}else var o=!0;if(o)if(p.type!==void 0){let s=p.type;const d=e;if(typeof s!="string")return i.errors=[{instancePath:r+"/transitions/"+t+"/type",schemaPath:"#/definitions/TransitionType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(s==="internal"||s==="external"))return i.errors=[{instancePath:r+"/transitions/"+t+"/type",schemaPath:"#/definitions/TransitionType/enum",keyword:"enum",params:{allowedValues:B.enum},message:"must be equal to one of the allowed values"}],!1;var o=d===e}else var o=!0}}}}}}}}}}}}}else return i.errors=[{instancePath:r+"/transitions/"+t,schemaPath:"#/properties/transitions/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var S=D===e;if(!S)break}}else return i.errors=[{instancePath:r+"/transitions",schemaPath:"#/properties/transitions/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var P=T===e}else var P=!0}}}else return i.errors=[{instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return i.errors=m,e===0}function C(y,{instancePath:r="",parentData:j,parentDataProperty:$,rootData:w=y}={}){let m=null,e=0;return i(y,{instancePath:r,parentData:j,parentDataProperty:$,rootData:w})||(m=m===null?i.errors:m.concat(i.errors),e=m.length),C.errors=m,e===0}
1
+ "use strict";export const validate=z;export default z;const E={type:"object",additionalProperties:!1,required:["states"],properties:{states:{type:"array",items:{type:"object",required:["name","type"],additionalProperties:!1,properties:{name:{type:"string"},type:{$ref:"#/definitions/StateType"},label:{type:"string"},color:{type:"string",pattern:"^[a-zA-Z0-9#,.:; ]*$"},class:{$ref:"#/definitions/ClassType"},active:{type:"boolean"},typeExplicitlySet:{type:"boolean"},isComposite:{type:"boolean"},actions:{type:"array",items:{$ref:"#/definitions/ActionType"}},note:{$ref:"#/definitions/NoteType"},statemachine:{$ref:"#/definitions/StateMachineType"}}}},transitions:{type:"array",items:{type:"object",required:["id","from","to"],additionalProperties:!1,properties:{id:{type:"number"},from:{type:"string"},to:{type:"string"},label:{type:"string"},event:{type:"string"},cond:{type:"string"},action:{type:"string"},note:{$ref:"#/definitions/NoteType"},color:{type:"string",pattern:"^[a-zA-Z0-9#,.:; ]*$"},width:{type:"number",minimum:0,maximum:30},class:{$ref:"#/definitions/ClassType"},type:{$ref:"#/definitions/TransitionType"}}}}}},B={type:"string",enum:["regular","initial","terminate","final","parallel","history","deephistory","choice","forkjoin","fork","join","junction"]};const G={type:"string",enum:["internal","external"]},D=Object.prototype.hasOwnProperty,O=new RegExp("^[a-zA-Z0-9#,.:; ]*$","u"),M=new RegExp("^[a-zA-Z0-9_\\- ]*$","u");const H={type:"string",enum:["entry","activity","exit"]};function u(y,{instancePath:t="",parentData:$,parentDataProperty:j,rootData:k=y}={}){let m=null,e=0;if(e===0)if(y&&typeof y=="object"&&!Array.isArray(y)){let n;if(y.type===void 0&&(n="type")||y.body===void 0&&(n="body"))return u.errors=[{instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:n},message:"must have required property '"+n+"'"}],!1;{const _=e;for(const d in y)if(!(d==="type"||d==="body")){return u.errors=[{instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"}],!1;break}if(_===e){if(y.type!==void 0){let d=y.type;const P=e;if(typeof d!="string")return u.errors=[{instancePath:t+"/type",schemaPath:"#/definitions/ActionTypeType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(d==="entry"||d==="activity"||d==="exit"))return u.errors=[{instancePath:t+"/type",schemaPath:"#/definitions/ActionTypeType/enum",keyword:"enum",params:{allowedValues:H.enum},message:"must be equal to one of the allowed values"}],!1;var g=P===e}else var g=!0;if(g)if(y.body!==void 0){const d=e;if(typeof y.body!="string")return u.errors=[{instancePath:t+"/body",schemaPath:"#/properties/body/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var g=d===e}else var g=!0}}}else return u.errors=[{instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return u.errors=m,e===0}const N={validate:i};function i(y,{instancePath:t="",parentData:$,parentDataProperty:j,rootData:k=y}={}){let m=null,e=0;if(e===0)if(y&&typeof y=="object"&&!Array.isArray(y)){let q;if(y.states===void 0&&(q="states"))return i.errors=[{instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:q},message:"must have required property '"+q+"'"}],!1;{const V=e;for(const c in y)if(!(c==="states"||c==="transitions")){return i.errors=[{instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"}],!1;break}if(V===e){if(y.states!==void 0){let c=y.states;const T=e;if(e===T)if(Array.isArray(c)){var g=!0;const F=c.length;for(let l=0;l<F;l++){let r=c[l];const p=e;if(e===p)if(r&&typeof r=="object"&&!Array.isArray(r)){let A;if(r.name===void 0&&(A="name")||r.type===void 0&&(A="type"))return i.errors=[{instancePath:t+"/states/"+l,schemaPath:"#/properties/states/items/required",keyword:"required",params:{missingProperty:A},message:"must have required property '"+A+"'"}],!1;{const v=e;for(const a in r)if(!D.call(E.properties.states.items.properties,a)){return i.errors=[{instancePath:t+"/states/"+l,schemaPath:"#/properties/states/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"}],!1;break}if(v===e){if(r.name!==void 0){const a=e;if(typeof r.name!="string")return i.errors=[{instancePath:t+"/states/"+l+"/name",schemaPath:"#/properties/states/items/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var n=a===e}else var n=!0;if(n){if(r.type!==void 0){let a=r.type;const s=e;if(typeof a!="string")return i.errors=[{instancePath:t+"/states/"+l+"/type",schemaPath:"#/definitions/StateType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(a==="regular"||a==="initial"||a==="terminate"||a==="final"||a==="parallel"||a==="history"||a==="deephistory"||a==="choice"||a==="forkjoin"||a==="fork"||a==="join"||a==="junction"))return i.errors=[{instancePath:t+"/states/"+l+"/type",schemaPath:"#/definitions/StateType/enum",keyword:"enum",params:{allowedValues:B.enum},message:"must be equal to one of the allowed values"}],!1;var n=s===e}else var n=!0;if(n){if(r.label!==void 0){const a=e;if(typeof r.label!="string")return i.errors=[{instancePath:t+"/states/"+l+"/label",schemaPath:"#/properties/states/items/properties/label/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var n=a===e}else var n=!0;if(n){if(r.color!==void 0){let a=r.color;const s=e;if(e===s)if(typeof a=="string"){if(!O.test(a))return i.errors=[{instancePath:t+"/states/"+l+"/color",schemaPath:"#/properties/states/items/properties/color/pattern",keyword:"pattern",params:{pattern:"^[a-zA-Z0-9#,.:; ]*$"},message:'must match pattern "^[a-zA-Z0-9#,.:; ]*$"'}],!1}else return i.errors=[{instancePath:t+"/states/"+l+"/color",schemaPath:"#/properties/states/items/properties/color/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var n=s===e}else var n=!0;if(n){if(r.class!==void 0){let a=r.class;const s=e;if(e===e)if(typeof a=="string"){if(!M.test(a))return i.errors=[{instancePath:t+"/states/"+l+"/class",schemaPath:"#/definitions/ClassType/pattern",keyword:"pattern",params:{pattern:"^[a-zA-Z0-9_\\- ]*$"},message:'must match pattern "^[a-zA-Z0-9_\\- ]*$"'}],!1}else return i.errors=[{instancePath:t+"/states/"+l+"/class",schemaPath:"#/definitions/ClassType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var n=s===e}else var n=!0;if(n){if(r.active!==void 0){const a=e;if(typeof r.active!="boolean")return i.errors=[{instancePath:t+"/states/"+l+"/active",schemaPath:"#/properties/states/items/properties/active/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var n=a===e}else var n=!0;if(n){if(r.typeExplicitlySet!==void 0){const a=e;if(typeof r.typeExplicitlySet!="boolean")return i.errors=[{instancePath:t+"/states/"+l+"/typeExplicitlySet",schemaPath:"#/properties/states/items/properties/typeExplicitlySet/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var n=a===e}else var n=!0;if(n){if(r.isComposite!==void 0){const a=e;if(typeof r.isComposite!="boolean")return i.errors=[{instancePath:t+"/states/"+l+"/isComposite",schemaPath:"#/properties/states/items/properties/isComposite/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var n=a===e}else var n=!0;if(n){if(r.actions!==void 0){let a=r.actions;const s=e;if(e===s)if(Array.isArray(a)){var _=!0;const x=a.length;for(let b=0;b<x;b++){const h=e;u(a[b],{instancePath:t+"/states/"+l+"/actions/"+b,parentData:a,parentDataProperty:b,rootData:k})||(m=m===null?u.errors:m.concat(u.errors),e=m.length);var _=h===e;if(!_)break}}else return i.errors=[{instancePath:t+"/states/"+l+"/actions",schemaPath:"#/properties/states/items/properties/actions/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var n=s===e}else var n=!0;if(n){if(r.note!==void 0){let a=r.note;const s=e;if(e===e)if(Array.isArray(a)){var d=!0;const b=a.length;for(let h=0;h<b;h++){const w=e;if(typeof a[h]!="string")return i.errors=[{instancePath:t+"/states/"+l+"/note/"+h,schemaPath:"#/definitions/NoteType/items/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var d=w===e;if(!d)break}}else return i.errors=[{instancePath:t+"/states/"+l+"/note",schemaPath:"#/definitions/NoteType/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var n=s===e}else var n=!0;if(n)if(r.statemachine!==void 0){const a=e;N.validate(r.statemachine,{instancePath:t+"/states/"+l+"/statemachine",parentData:r,parentDataProperty:"statemachine",rootData:k})||(m=m===null?N.validate.errors:m.concat(N.validate.errors),e=m.length);var n=a===e}else var n=!0}}}}}}}}}}}}else return i.errors=[{instancePath:t+"/states/"+l,schemaPath:"#/properties/states/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var g=p===e;if(!g)break}}else return i.errors=[{instancePath:t+"/states",schemaPath:"#/properties/states/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var P=T===e}else var P=!0;if(P)if(y.transitions!==void 0){let c=y.transitions;const T=e;if(e===T)if(Array.isArray(c)){var Z=!0;const l=c.length;for(let r=0;r<l;r++){let p=c[r];const S=e;if(e===S)if(p&&typeof p=="object"&&!Array.isArray(p)){let v;if(p.id===void 0&&(v="id")||p.from===void 0&&(v="from")||p.to===void 0&&(v="to"))return i.errors=[{instancePath:t+"/transitions/"+r,schemaPath:"#/properties/transitions/items/required",keyword:"required",params:{missingProperty:v},message:"must have required property '"+v+"'"}],!1;{const a=e;for(const s in p)if(!D.call(E.properties.transitions.items.properties,s)){return i.errors=[{instancePath:t+"/transitions/"+r,schemaPath:"#/properties/transitions/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:s},message:"must NOT have additional properties"}],!1;break}if(a===e){if(p.id!==void 0){let s=p.id;const f=e;if(!(typeof s=="number"&&isFinite(s)))return i.errors=[{instancePath:t+"/transitions/"+r+"/id",schemaPath:"#/properties/transitions/items/properties/id/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var o=f===e}else var o=!0;if(o){if(p.from!==void 0){const s=e;if(typeof p.from!="string")return i.errors=[{instancePath:t+"/transitions/"+r+"/from",schemaPath:"#/properties/transitions/items/properties/from/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.to!==void 0){const s=e;if(typeof p.to!="string")return i.errors=[{instancePath:t+"/transitions/"+r+"/to",schemaPath:"#/properties/transitions/items/properties/to/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.label!==void 0){const s=e;if(typeof p.label!="string")return i.errors=[{instancePath:t+"/transitions/"+r+"/label",schemaPath:"#/properties/transitions/items/properties/label/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.event!==void 0){const s=e;if(typeof p.event!="string")return i.errors=[{instancePath:t+"/transitions/"+r+"/event",schemaPath:"#/properties/transitions/items/properties/event/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.cond!==void 0){const s=e;if(typeof p.cond!="string")return i.errors=[{instancePath:t+"/transitions/"+r+"/cond",schemaPath:"#/properties/transitions/items/properties/cond/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.action!==void 0){const s=e;if(typeof p.action!="string")return i.errors=[{instancePath:t+"/transitions/"+r+"/action",schemaPath:"#/properties/transitions/items/properties/action/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=s===e}else var o=!0;if(o){if(p.note!==void 0){let s=p.note;const f=e;if(e===e)if(Array.isArray(s)){var C=!0;const h=s.length;for(let w=0;w<h;w++){const R=e;if(typeof s[w]!="string")return i.errors=[{instancePath:t+"/transitions/"+r+"/note/"+w,schemaPath:"#/definitions/NoteType/items/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var C=R===e;if(!C)break}}else return i.errors=[{instancePath:t+"/transitions/"+r+"/note",schemaPath:"#/definitions/NoteType/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var o=f===e}else var o=!0;if(o){if(p.color!==void 0){let s=p.color;const f=e;if(e===f)if(typeof s=="string"){if(!O.test(s))return i.errors=[{instancePath:t+"/transitions/"+r+"/color",schemaPath:"#/properties/transitions/items/properties/color/pattern",keyword:"pattern",params:{pattern:"^[a-zA-Z0-9#,.:; ]*$"},message:'must match pattern "^[a-zA-Z0-9#,.:; ]*$"'}],!1}else return i.errors=[{instancePath:t+"/transitions/"+r+"/color",schemaPath:"#/properties/transitions/items/properties/color/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=f===e}else var o=!0;if(o){if(p.width!==void 0){let s=p.width;const f=e;if(e===f)if(typeof s=="number"&&isFinite(s)){if(s>30||isNaN(s))return i.errors=[{instancePath:t+"/transitions/"+r+"/width",schemaPath:"#/properties/transitions/items/properties/width/maximum",keyword:"maximum",params:{comparison:"<=",limit:30},message:"must be <= 30"}],!1;if(s<0||isNaN(s))return i.errors=[{instancePath:t+"/transitions/"+r+"/width",schemaPath:"#/properties/transitions/items/properties/width/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}else return i.errors=[{instancePath:t+"/transitions/"+r+"/width",schemaPath:"#/properties/transitions/items/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var o=f===e}else var o=!0;if(o){if(p.class!==void 0){let s=p.class;const f=e;if(e===e)if(typeof s=="string"){if(!M.test(s))return i.errors=[{instancePath:t+"/transitions/"+r+"/class",schemaPath:"#/definitions/ClassType/pattern",keyword:"pattern",params:{pattern:"^[a-zA-Z0-9_\\- ]*$"},message:'must match pattern "^[a-zA-Z0-9_\\- ]*$"'}],!1}else return i.errors=[{instancePath:t+"/transitions/"+r+"/class",schemaPath:"#/definitions/ClassType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var o=f===e}else var o=!0;if(o)if(p.type!==void 0){let s=p.type;const f=e;if(typeof s!="string")return i.errors=[{instancePath:t+"/transitions/"+r+"/type",schemaPath:"#/definitions/TransitionType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!(s==="internal"||s==="external"))return i.errors=[{instancePath:t+"/transitions/"+r+"/type",schemaPath:"#/definitions/TransitionType/enum",keyword:"enum",params:{allowedValues:G.enum},message:"must be equal to one of the allowed values"}],!1;var o=f===e}else var o=!0}}}}}}}}}}}}}else return i.errors=[{instancePath:t+"/transitions/"+r,schemaPath:"#/properties/transitions/items/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var Z=S===e;if(!Z)break}}else return i.errors=[{instancePath:t+"/transitions",schemaPath:"#/properties/transitions/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var P=T===e}else var P=!0}}}else return i.errors=[{instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return i.errors=m,e===0}function z(y,{instancePath:t="",parentData:$,parentDataProperty:j,rootData:k=y}={}){let m=null,e=0;return i(y,{instancePath:t,parentData:$,parentDataProperty:j,rootData:k})||(m=m===null?i.errors:m.concat(i.errors),e=m.length),z.errors=m,e===0}
@@ -15,6 +15,7 @@ import {
15
15
  noteToLabel,
16
16
  normalizeState,
17
17
  stateNote,
18
+ escapeColorString,
18
19
  } from "./utl.mjs";
19
20
  function initial(pState, pIndent) {
20
21
  const lActiveAttribute = pState.active ? " penwidth=3.0" : "";
@@ -210,12 +211,6 @@ function states(pStates, pIndent, pOptions, pModel, pRenderedTransitions) {
210
211
  }
211
212
  function transition(pTransition, pIndent, pOptions, pModel) {
212
213
  const lLabel = `${escapeLabelString(pTransition.label ?? " ")}`;
213
- const lColorAttribute = pTransition.color
214
- ? ` color="${pTransition.color}"`
215
- : "";
216
- const lFontColorAttribute = pTransition.color
217
- ? ` fontcolor="${pTransition.color}"`
218
- : "";
219
214
  const lPenWidth = pTransition.width ? ` penwidth=${pTransition.width}` : "";
220
215
  const lClass = pTransition.class
221
216
  ? `transition${pTransition.type ? " " + pTransition.type + " " : " "}${pTransition.class}`
@@ -227,6 +222,13 @@ function transition(pTransition, pIndent, pOptions, pModel) {
227
222
  ? ` lhead="cluster_${pTransition.to}"`
228
223
  : "";
229
224
  const lTransitionName = `tr_${pTransition.from}_${pTransition.to}_${pTransition.id}`;
225
+ let lColorAttribute = "";
226
+ let lFontColorAttribute = "";
227
+ if (pTransition.color) {
228
+ const lSanitizedColor = escapeColorString(pTransition.color);
229
+ lColorAttribute = ` color="${lSanitizedColor}"`;
230
+ lFontColorAttribute = ` fontcolor="${lSanitizedColor}"`;
231
+ }
230
232
  if (isCompositeSelf(pModel, pTransition)) {
231
233
  const { lTailPorts, lHeadPorts } = getTransitionPorts(
232
234
  pOptions,
@@ -9,14 +9,19 @@ const COLORABLE_STATE_TYPES = new Set([
9
9
  "terminate",
10
10
  "final",
11
11
  ]);
12
+ export function escapeColorString(pString) {
13
+ return pString
14
+ .replaceAll("\\", String.raw`\\`)
15
+ .replaceAll('"', String.raw`\"`);
16
+ }
12
17
  function getStateColor(pState, pNodeAttributes) {
13
18
  const lNodeColor = (pNodeAttributes || []).find(
14
19
  (pAttribute) => pAttribute.name === "color",
15
20
  )?.value;
16
21
  if (lNodeColor && !pState.color && COLORABLE_STATE_TYPES.has(pState.type)) {
17
- return lNodeColor;
22
+ return escapeColorString(lNodeColor);
18
23
  }
19
- return pState.color ?? "black";
24
+ return escapeColorString(pState.color ?? "black");
20
25
  }
21
26
  export function escapeString(pString) {
22
27
  return pString
@@ -58,10 +63,14 @@ export function stateNote(pState, pIndent) {
58
63
  }
59
64
  export function normalizeState(pState, pOptions, pIndent) {
60
65
  const lReturnValue = structuredClone(pState);
61
- lReturnValue.colorAttribute = pState.color ? ` color="${pState.color}"` : "";
62
- lReturnValue.fontColorAttribute = pState.color
63
- ? ` fontcolor="${pState.color}"`
64
- : "";
66
+ if (pState.color) {
67
+ const lEscapedColor = escapeColorString(pState.color);
68
+ lReturnValue.colorAttribute = ` color="${lEscapedColor}"`;
69
+ lReturnValue.fontColorAttribute = ` fontcolor="${lEscapedColor}"`;
70
+ } else {
71
+ lReturnValue.colorAttribute = "";
72
+ lReturnValue.fontColorAttribute = "";
73
+ }
65
74
  lReturnValue.color = getStateColor(pState, pOptions.dotNodeAttrs);
66
75
  lReturnValue.class = pState.class
67
76
  ? `state ${pState.type} ${pState.class}`
package/dist/version.mjs CHANGED
@@ -1 +1 @@
1
- export const version = "15.0.0";
1
+ export const version = "15.0.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "state-machine-cat",
3
- "version": "15.0.0",
3
+ "version": "15.0.2",
4
4
  "description": "write beautiful state charts",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -41,8 +41,8 @@
41
41
  "state-machine-cat": "dist/cli/main.mjs"
42
42
  },
43
43
  "dependencies": {
44
- "@hpcc-js/wasm-graphviz": "1.21.2",
45
- "fast-xml-parser": "5.5.11",
44
+ "@hpcc-js/wasm-graphviz": "1.21.5",
45
+ "fast-xml-parser": "5.7.3",
46
46
  "he": "1.2.0",
47
47
  "neotraverse": "0.6.18"
48
48
  },
@@ -33,7 +33,7 @@ export interface IState {
33
33
  type: StateType;
34
34
  /**
35
35
  * The display label of the state. If it's not present, most renderers
36
- * will use the states' name in stead
36
+ * will use the states' name instead
37
37
  */
38
38
  label?: string;
39
39
  /**