-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjCFSM.min.js
1 lines (1 loc) · 3.13 KB
/
jCFSM.min.js
1
"use strict";var jCFSM;!function(t){class i{constructor(t){this.t=!1,this.i={},this.h={},this.StateAdd(t),this.o=t}StateAdd(t){let i=!1;return void 0===this.i[t]&&(this.i[t]={OnEnter:[],OnLeave:[]},this.h[t]={},i=!0),i}StateDel(t){let i=!1;if(void 0!==this.i[t]){delete this.i[t],void 0!==this.h[t]&&delete this.h[t];for(const i in this.h)void 0!==this.h[i][t]&&delete this.h[i][t];i=!0}return i}StateOnEnterAdd(t,i){let s=!1;return void 0!==this.i[t]&&(this.i[t].OnEnter.includes(i)||(this.i[t].OnEnter.push(i),s=!0)),s}StateOnEnterDel(t,i){let s=!1;if(void 0!==this.i[t]){const h=this.i[t].OnEnter.indexOf(i);-1!==h&&(this.i[t].OnEnter.splice(h,1),s=!0)}return s}StateOnLeaveAdd(t,i){let s=!1;return void 0!==this.i[t]&&(this.i[t].OnLeave.includes(i)||(this.i[t].OnLeave.push(i),s=!0)),s}StateOnLeaveDel(t,i){let s=!1;if(void 0!==this.i[t]){const h=this.i[t].OnLeave.indexOf(i);-1!==h&&(this.i[t].OnLeave.splice(h,1),s=!0)}return s}TransitionAdd(t,i){let s=!1;return void 0!==this.i[t]&&void 0!==this.i[i]&&void 0===this.h[t][i]&&(this.h[t][i]={OnBefore:[],OnAfter:[]},s=!0),s}TransitionDel(t,i){let s=!1;return void 0!==this.i[t]&&void 0!==this.i[i]&&void 0!==this.h[t][i]&&(delete this.h[t][i],s=!0),s}TransitionOnBeforeAdd(t,i,s){let h=!1;return void 0!==this.i[t]&&void 0!==this.i[i]&&void 0!==this.h[t][i]&&(this.h[t][i].OnBefore.push(s),h=!0),h}TransitionOnBeforeDel(t,i,s){let h=!1;if(void 0!==this.i[t]&&void 0!==this.i[i]&&void 0!==this.h[t][i]){const e=this.h[t][i].OnBefore.indexOf(s);-1!==e&&(this.h[t][i].OnBefore.splice(e,1),h=!0)}return h}TransitionOnAfterAdd(t,i,s){let h=!1;return void 0!==this.i[t]&&void 0!==this.i[i]&&void 0!==this.h[t][i]&&(this.h[t][i].OnAfter.push(s),h=!0),h}TransitionOnAfterDel(t,i,s){let h=!1;if(void 0!==this.i[t]&&void 0!==this.i[i]&&void 0!==this.h[t][i]){const e=this.h[t][i].OnAfter.indexOf(s);-1!==e&&(this.h[t][i].OnAfter.splice(e,1),h=!0)}return h}StateGet(){return this.o}async StateSet(t){let i=!1;if(!this.t){if(this.t=!0,void 0!==this.i[t]&&void 0!==this.h[this.o]&&void 0!==this.h[this.o][t]){let s;i=!0,s=this.h[this.o][t].OnBefore.length;for(let h=0;i&&h<s;h++)if("function"==typeof this.h[this.o][t].OnBefore[h]){let s=null;s="AsyncFunction"===this.h[this.o][t].OnBefore[h].constructor.name?await this.h[this.o][t].OnBefore[h]():this.h[this.o][t].OnBefore[h](),i=!1!==s}if(i){s=this.i[this.o].OnLeave.length;for(let i=0;i<s;i++)"function"==typeof this.i[this.o].OnLeave[i]&&("AsyncFunction"===this.i[this.o].OnLeave[i].constructor.name?await this.i[this.o].OnLeave[i](this.o,t):this.i[this.o].OnLeave[i](this.o,t));let i=this.o;this.o=t,s=this.h[i][this.o].OnAfter.length;for(let t=0;t<s;t++)"function"==typeof this.h[i][this.o].OnAfter[t]&&("AsyncFunction"===this.h[i][this.o].OnAfter[t].constructor.name?await this.h[i][this.o].OnAfter[t]():this.h[i][this.o].OnAfter[t]());s=this.i[this.o].OnEnter.length;for(let t=0;t<s;t++)"function"==typeof this.i[this.o].OnEnter[t]&&("AsyncFunction"===this.i[this.o].OnEnter[t].constructor.name?await this.i[this.o].OnEnter[t](this.o,i):this.i[this.o].OnEnter[t](this.o,i))}}this.t=!1}return i}}t.Create=function(t){return new i(t)}}(jCFSM||(jCFSM={})),"object"==typeof exports&&(exports.Create=jCFSM.Create);