@peter.naydenov/fsm-hub 2.1.3 → 2.1.5
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/Chaingelog.md +11 -0
- package/dist/fsm-hub.cjs +1 -1
- package/dist/fsm-hub.esm.mjs +1 -1
- package/dist/fsm-hub.umd.js +1 -1
- package/package.json +18 -11
package/Chaingelog.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
## Release History
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
### 2.1.5 ( 2026-07-21)
|
|
5
|
+
- [x] Dependency update. ask-for-promise@3.2.0;
|
|
6
|
+
- [x] Dev dependency update. @peter.naydenov/fsm - v.5.2.6;
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### 2.1.4 ( 2026-05-11)
|
|
11
|
+
- [x] Dependency update. ask-for-promise@3.1.1;
|
|
12
|
+
- [x] Dev dependency update. @peter.naydenov/fsm - v.5.2.5;
|
|
13
|
+
|
|
14
|
+
|
|
4
15
|
|
|
5
16
|
### 2.1.2 ( 2024-11-13)
|
|
6
17
|
- [x] Dependency update. Ask-for-promise@3.1.0;
|
package/dist/fsm-hub.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("ask-for-promise"),n=require("@peter.naydenov/stack");const r={_setTransitions:function(e,n){return function({reactivity:r,transformers:t},s={}){let a={},c={},o={},i={};return r.forEach((
|
|
1
|
+
"use strict";var e=require("ask-for-promise"),n=require("@peter.naydenov/stack");const r={_setTransitions:function(e,n){return function({reactivity:r,transformers:t},s={}){let a={},c={},o={},i={};return r.forEach((r,t)=>{if(!(r instanceof Array))return void e._debugger(n.WRONG_REACTIVITY_RECORD,t+1);const s=r.length,[a,u,l,f]=r;if(!(4==s||3==s))return void e._debugger(n.WRONG_REACTIVITY_RECORD,t+1);const h=`${a}/${u}`;if(4==s){c[h]||(c[h]=[]),c[h].push(l);o[`${h}/${l}`]=f}3==s&&(i[h]||(i[h]=[]),i[h].push(l))}),t&&Object.keys(t).forEach(e=>{const n=t[e],r=s[n];r&&(a[e]=r)}),{transformers:a,subscribers:c,callbacks:i,actions:o}}},_debugger:function(e){return function(n,r){e.debug&&console.log(n,r)}},_callback:function(n,r){return function(t,s,a,c){const o=`${s}/${a}`,i=n.subscribers[o]||!1,u=n.callbacks[o]||!1,l=n.fnCallbacks,f=n.actions,h=[];let d;if(i||u){if(i&&i.forEach(e=>{if(!n.fsm[e])return void n._debugger(r.MISSING_FSM,i);const t=f[`${o}/${e}`],u=`${s}/${e}`,l=n.transformers[u];d="function"==typeof l?l(a,c):c,d||(d={},d.___internalFlag=!0);const _=n.fsm[e].update(t,d);h.push(_)}),u){let t=e();h.push(t.promise),u.forEach(e=>{const t=l[e],o=`${s}/${e}`,i=n.transformers[o];d="function"==typeof i?i(a,c):c,d.answer&&d.answer.hasOwnProperty("___internalFlag")&&(d.answer=void 0),"function"==typeof t?t(d):n._debugger(r.MISSING_FN,e)}),t.done()}Promise.all(h).then(()=>t.done())}else t.done()}},addFsm:function(n,r){return function(t){Object.keys(t).forEach(s=>{function a(e){if(e&&(n.haveInternalRequest=!1),n.haveInternalRequest)return;let r=n.cacheInternal.isEmpty();if(n.cache.isEmpty()&&r)return void(n.lock=!1);let[t,s,a]=r?n.cache.pull():n.cacheInternal.pull();n.cache.isEmpty()&&(n.lock=!1),n.cacheInternal.isEmpty()&&(n.haveInternalRequest=!1),c(t,s,a)}function c(r,t,s){let c;if(!n.lock)return n.lock=!0,c=e(),c.onComplete(e=>a(!1)),void n._callback(c,r,t,s);if(s){if(n.haveInternalRequest)return void n.cacheInternal.push([[r,t,s]]);let c=e();return c.onComplete(e=>a(!0)),n.haveInternalRequest=!0,void n._callback(c,r,t,s)}n.cache.push([[r,t,s]])}n.fsm[s]?n._debugger(r.REGISTERED_FSM_NAME,s):(n.fsm[s]=t[s],n.fsm[s].on("update",(e,n)=>c(s,e,n)))})}},addFunctions:function(e,n){return function(r){Object.keys(r).forEach(t=>{e.fnCallbacks[t]?e._debugger(n.REGISTERED_FUNCTION_NAME,t):e.fnCallbacks[t]=r[t]})}}},t={WRONG_REACTIVITY_RECORD:"Error: Wrong reactivity record on row %s.",REGISTERED_FSM_NAME:'Warning: FSM "%s" is already registered.',REGISTERED_FUNCTION_NAME:'Warning: Function "%s" is already registered.',MISSING_FSM:'Warning: Fsm "%s" is not registered to the hub.',MISSING_FN:'Warning: Function "%s" is not registered to the hub.'};module.exports=function(s,a){const c=this,o=Object.keys(r);c.fsm={},c.fnCallbacks={},c.debug=s.debug||!1,c.cache=n({type:"FIFO"}),c.cacheInternal=n({type:"FIFO"}),c.wait=[],c.lock=!1,c.haveInternalRequest=!1,c.reactivityTask=!1,c.askForPromise=e,o.forEach(e=>{c[e]=r[e](c,t)});const{transformers:i,subscribers:u,actions:l,callbacks:f}=c._setTransitions(s,a);c.transformers=i,c.subscribers=u,c.actions=l,c.callbacks=f};
|
package/dist/fsm-hub.esm.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"ask-for-promise";import n from"@peter.naydenov/stack";const t={_setTransitions:function(e,n){return function({reactivity:t,transformers:r},s={}){let a={},c={},o={},i={};return t.forEach((
|
|
1
|
+
import e from"ask-for-promise";import n from"@peter.naydenov/stack";const t={_setTransitions:function(e,n){return function({reactivity:t,transformers:r},s={}){let a={},c={},o={},i={};return t.forEach((t,r)=>{if(!(t instanceof Array))return void e._debugger(n.WRONG_REACTIVITY_RECORD,r+1);const s=t.length,[a,u,l,f]=t;if(!(4==s||3==s))return void e._debugger(n.WRONG_REACTIVITY_RECORD,r+1);const h=`${a}/${u}`;if(4==s){c[h]||(c[h]=[]),c[h].push(l);o[`${h}/${l}`]=f}3==s&&(i[h]||(i[h]=[]),i[h].push(l))}),r&&Object.keys(r).forEach(e=>{const n=r[e],t=s[n];t&&(a[e]=t)}),{transformers:a,subscribers:c,callbacks:i,actions:o}}},_debugger:function(e){return function(n,t){e.debug&&console.log(n,t)}},_callback:function(n,t){return function(r,s,a,c){const o=`${s}/${a}`,i=n.subscribers[o]||!1,u=n.callbacks[o]||!1,l=n.fnCallbacks,f=n.actions,h=[];let d;if(i||u){if(i&&i.forEach(e=>{if(!n.fsm[e])return void n._debugger(t.MISSING_FSM,i);const r=f[`${o}/${e}`],u=`${s}/${e}`,l=n.transformers[u];d="function"==typeof l?l(a,c):c,d||(d={},d.___internalFlag=!0);const _=n.fsm[e].update(r,d);h.push(_)}),u){let r=e();h.push(r.promise),u.forEach(e=>{const r=l[e],o=`${s}/${e}`,i=n.transformers[o];d="function"==typeof i?i(a,c):c,d.answer&&d.answer.hasOwnProperty("___internalFlag")&&(d.answer=void 0),"function"==typeof r?r(d):n._debugger(t.MISSING_FN,e)}),r.done()}Promise.all(h).then(()=>r.done())}else r.done()}},addFsm:function(n,t){return function(r){Object.keys(r).forEach(s=>{function a(e){if(e&&(n.haveInternalRequest=!1),n.haveInternalRequest)return;let t=n.cacheInternal.isEmpty();if(n.cache.isEmpty()&&t)return void(n.lock=!1);let[r,s,a]=t?n.cache.pull():n.cacheInternal.pull();n.cache.isEmpty()&&(n.lock=!1),n.cacheInternal.isEmpty()&&(n.haveInternalRequest=!1),c(r,s,a)}function c(t,r,s){let c;if(!n.lock)return n.lock=!0,c=e(),c.onComplete(e=>a(!1)),void n._callback(c,t,r,s);if(s){if(n.haveInternalRequest)return void n.cacheInternal.push([[t,r,s]]);let c=e();return c.onComplete(e=>a(!0)),n.haveInternalRequest=!0,void n._callback(c,t,r,s)}n.cache.push([[t,r,s]])}n.fsm[s]?n._debugger(t.REGISTERED_FSM_NAME,s):(n.fsm[s]=r[s],n.fsm[s].on("update",(e,n)=>c(s,e,n)))})}},addFunctions:function(e,n){return function(t){Object.keys(t).forEach(r=>{e.fnCallbacks[r]?e._debugger(n.REGISTERED_FUNCTION_NAME,r):e.fnCallbacks[r]=t[r]})}}},r={WRONG_REACTIVITY_RECORD:"Error: Wrong reactivity record on row %s.",REGISTERED_FSM_NAME:'Warning: FSM "%s" is already registered.',REGISTERED_FUNCTION_NAME:'Warning: Function "%s" is already registered.',MISSING_FSM:'Warning: Fsm "%s" is not registered to the hub.',MISSING_FN:'Warning: Function "%s" is not registered to the hub.'};function s(s,a){const c=this,o=Object.keys(t);c.fsm={},c.fnCallbacks={},c.debug=s.debug||!1,c.cache=n({type:"FIFO"}),c.cacheInternal=n({type:"FIFO"}),c.wait=[],c.lock=!1,c.haveInternalRequest=!1,c.reactivityTask=!1,c.askForPromise=e,o.forEach(e=>{c[e]=t[e](c,r)});const{transformers:i,subscribers:u,actions:l,callbacks:f}=c._setTransitions(s,a);c.transformers=i,c.subscribers=u,c.actions=l,c.callbacks=f}export{s as default};
|
package/dist/fsm-hub.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).fsmHub=t()}(this,function(){"use strict";function e(e){return e?function(e){let i=e.map(e=>t()),o=i.map(e=>e.promise);i.promises=i;let c=n(Promise.all(o));const s={promise:Promise.all(o),promises:i,_list:e,_activeTimer:null,each:()=>{},onComplete:c,timeout:()=>{},done:function(e){null!==this._activeTimer&&(clearTimeout(this._activeTimer),this._activeTimer=null),this.promises.forEach(t=>t.done(e))},cancel:function(e){null!==this._activeTimer&&(clearTimeout(this._activeTimer),this._activeTimer=null),this.promises.forEach(t=>t.cancel(e))}};return s.each=function(e,...t){this.promises.forEach((n,r)=>e({value:this._list[r],done:n.done,cancel:n.cancel,timeout:n.timeout},r,...t))},s.timeout=r(!0),s}(e):t()}function t(){let e,t;const i=new Promise((n,r)=>{e=n,t=r}),o={promise:i,promises:null,_activeTimer:null,each:()=>{},onComplete:n(i),timeout:()=>{}},c=new WeakRef(o);return o.done=function(t){const n=c.deref();void 0!==n&&null!==n._activeTimer&&(clearTimeout(n._activeTimer),n._activeTimer=null),e(t)},o.cancel=function(e){const n=c.deref();void 0!==n&&null!==n._activeTimer&&(clearTimeout(n._activeTimer),n._activeTimer=null),t(e)},o.timeout=r(!1),o.each=function(e,...t){e({value:null,done:o.done,cancel:o.cancel,timeout:this.timeout},...t)},o}function n(e){return function(t,n=null){null===n?e.then(e=>t(e)):e.then(e=>t(e),e=>n(e))}}function r(e){return function(t,r){const i=new WeakRef(this);let o,c;o=e?Promise.all(this.promises.map(e=>e.promise)):this.promise;const s=new Promise((e,n)=>{c=setTimeout(()=>{const t=i.deref();void 0!==t&&t.done(r),e(r)},t)});return this._activeTimer=c,o.then(()=>clearTimeout(c)),this.onComplete=n(Promise.race([o,s])),this}}e.sequence=function(t,...n){const r=e(),i=[];const o=function*(e){for(const t of e)yield t}(t);try{!function e(t,...n){t.done?r.done(i):Promise.resolve().then(()=>t.value(...n)).then(t=>{i.push(t),e(o.next(),...n,t)},e=>{r.cancel(e)})}(o.next(),...n)}catch(e){r.cancel(e)}return r},e.all=function(t,...n){const r=e(),i=[];let o;try{o=t.map((e,t)=>Promise.resolve().then(()=>"function"==typeof e?e(...n):e).then(e=>i[t]=e,e=>{throw e}))}catch(e){return r.cancel(e),r}return Promise.all(o).then(()=>r.done(i),e=>r.cancel(e)),r};const i={_setTransitions:function(e,t){return function({reactivity:n,transformers:r},i={}){let o={},c={},s={},l={};return n.forEach((n,r)=>{if(!(n instanceof Array))return void e._debugger(t.WRONG_REACTIVITY_RECORD,r+1);const i=n.length,[o,a,u,f]=n;if(!(4==i||3==i))return void e._debugger(t.WRONG_REACTIVITY_RECORD,r+1);const m=`${o}/${a}`;if(4==i){c[m]||(c[m]=[]),c[m].push(u);s[`${m}/${u}`]=f}3==i&&(l[m]||(l[m]=[]),l[m].push(u))}),r&&Object.keys(r).forEach(e=>{const t=r[e],n=i[t];n&&(o[e]=n)}),{transformers:o,subscribers:c,callbacks:l,actions:s}}},_debugger:function(e){return function(t,n){e.debug&&console.log(t,n)}},_callback:function(t,n){return function(r,i,o,c){const s=`${i}/${o}`,l=t.subscribers[s]||!1,a=t.callbacks[s]||!1,u=t.fnCallbacks,f=t.actions,m=[];let h;if(l||a){if(l&&l.forEach(e=>{if(!t.fsm[e])return void t._debugger(n.MISSING_FSM,l);const r=f[`${s}/${e}`],a=`${i}/${e}`,u=t.transformers[a];h="function"==typeof u?u(o,c):c,h||(h={},h.___internalFlag=!0);const p=t.fsm[e].update(r,h);m.push(p)}),a){let r=e();m.push(r.promise),a.forEach(e=>{const r=u[e],s=`${i}/${e}`,l=t.transformers[s];h="function"==typeof l?l(o,c):c,h.answer&&h.answer.hasOwnProperty("___internalFlag")&&(h.answer=void 0),"function"==typeof r?r(h):t._debugger(n.MISSING_FN,e)}),r.done()}Promise.all(m).then(()=>r.done())}else r.done()}},addFsm:function(t,n){return function(r){Object.keys(r).forEach(i=>{function o(e){if(e&&(t.haveInternalRequest=!1),t.haveInternalRequest)return;let n=t.cacheInternal.isEmpty();if(t.cache.isEmpty()&&n)return void(t.lock=!1);let[r,i,o]=n?t.cache.pull():t.cacheInternal.pull();t.cache.isEmpty()&&(t.lock=!1),t.cacheInternal.isEmpty()&&(t.haveInternalRequest=!1),c(r,i,o)}function c(n,r,i){let c;if(!t.lock)return t.lock=!0,c=e(),c.onComplete(e=>o(!1)),void t._callback(c,n,r,i);if(i){if(t.haveInternalRequest)return void t.cacheInternal.push([[n,r,i]]);let c=e();return c.onComplete(e=>o(!0)),t.haveInternalRequest=!0,void t._callback(c,n,r,i)}t.cache.push([[n,r,i]])}t.fsm[i]?t._debugger(n.REGISTERED_FSM_NAME,i):(t.fsm[i]=r[i],t.fsm[i].on("update",(e,t)=>c(i,e,t)))})}},addFunctions:function(e,t){return function(n){Object.keys(n).forEach(r=>{e.fnCallbacks[r]?e._debugger(t.REGISTERED_FUNCTION_NAME,r):e.fnCallbacks[r]=n[r]})}}},o={WRONG_REACTIVITY_RECORD:"Error: Wrong reactivity record on row %s.",REGISTERED_FSM_NAME:'Warning: FSM "%s" is already registered.',REGISTERED_FUNCTION_NAME:'Warning: Function "%s" is already registered.',MISSING_FSM:'Warning: Fsm "%s" is not registered to the hub.',MISSING_FN:'Warning: Function "%s" is not registered to the hub.'};function c(e={}){let t=[],{type:n,limit:r,onLimit:i}=Object.assign({},{type:"FIFO",limit:!1,onLimit:"update"},e),o="LIFO"===n.toUpperCase(),c=!1;function s(e=1,n=0){let r=[];return n>0&&Array.from({length:n}).map(()=>t.pop()),1==e?t.pop():(Array.from({length:e}).map(()=>{let e=t.pop();null!=e&&r.push(e)}),r)}function l(e=1,n=0){let r=[],i=t.length-n;return e>1&&Array.from({length:e}).map(()=>{null!=t[i-1]&&r.push(t[i-1]),i--}),1==e?t[t.length-1]:r}function a(){}return a.prototype={pull:s,pullReverse:function(e=1,t=0){let n=s(e,t);return n instanceof Array?n.reverse():n},peek:l,peekReverse:function(e=1,t=0){const n=l(e,t);return n instanceof Array?n.reverse():n},getSize:()=>t.length,isEmpty:()=>0==t.length,reset:()=>(t=[],!0),debug:()=>[...t]},a.prototype.push=o?function(e){const n=e instanceof Array,o=n?e.length:1;let l=!1;if("full"!==i||!c){if(r&&n&&o>r&&(e=e.slice(0,-o+r)),r){const o=(n?e.length:1)+t.length;o>=r&&"full"===i&&(e=e.slice(0,-(o-r))),o>=r&&"update"===i&&(l=s(o-r))}return t=e instanceof Array?t.concat(e):t.concat([e]),c=!!r&&t.length===r,l||void 0}}:function(e){const n=e instanceof Array,o=n?e.length:1;let l=!1;if("full"!==i||!c){if(r&&n&&o>r&&(e=e.slice(o-r)),r){const o=(n?e.length:1)+t.length;o>=r&&"full"===i&&(e=e.slice(0,-(o-r))),o>=r&&"update"===i&&(l=s(o-r))}return t=n?e.reduce((e,t)=>[t,...e],t):[e].reduce((e,t)=>[t,...e],t),c=!!r&&t.length===r,l||void 0}},new a}return function(t,n){const r=this,s=Object.keys(i);r.fsm={},r.fnCallbacks={},r.debug=t.debug||!1,r.cache=c({type:"FIFO"}),r.cacheInternal=c({type:"FIFO"}),r.wait=[],r.lock=!1,r.haveInternalRequest=!1,r.reactivityTask=!1,r.askForPromise=e,s.forEach(e=>{r[e]=i[e](r,o)});const{transformers:l,subscribers:a,actions:u,callbacks:f}=r._setTransitions(t,n);r.transformers=l,r.subscribers=a,r.actions=u,r.callbacks=f}});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peter.naydenov/fsm-hub",
|
|
3
3
|
"description": "FSM orchestration and state-managment tool",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.5",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Peter Naydenov",
|
|
7
7
|
"main": "./dist/fsm-hub.umd.js",
|
|
@@ -22,18 +22,22 @@
|
|
|
22
22
|
"build": "rollup -c"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@peter.naydenov/stack": "3.0.0",
|
|
26
|
-
"ask-for-promise": "3.
|
|
25
|
+
"@peter.naydenov/stack": "^3.0.0",
|
|
26
|
+
"ask-for-promise": "^3.2.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@peter.naydenov/fsm": "5.2.
|
|
30
|
-
"@rollup/plugin-commonjs": "^29.0.
|
|
29
|
+
"@peter.naydenov/fsm": "5.2.6",
|
|
30
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
31
31
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
32
|
-
"@rollup/plugin-terser": "^0.
|
|
33
|
-
"c8": "^
|
|
34
|
-
"chai": "6.2.
|
|
35
|
-
"mocha": "11.7.
|
|
36
|
-
"rollup": "^4.
|
|
32
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
33
|
+
"c8": "^12.0.0",
|
|
34
|
+
"chai": "6.2.2",
|
|
35
|
+
"mocha": "11.7.6",
|
|
36
|
+
"rollup": "^4.62.2"
|
|
37
|
+
},
|
|
38
|
+
"overrides": {
|
|
39
|
+
"diff": "^8.0.4",
|
|
40
|
+
"serialize-javascript": "^7.0.5"
|
|
37
41
|
},
|
|
38
42
|
"repository": {
|
|
39
43
|
"type": "git",
|
|
@@ -56,5 +60,8 @@
|
|
|
56
60
|
"fsm",
|
|
57
61
|
"state-managment",
|
|
58
62
|
"orchestration"
|
|
59
|
-
]
|
|
63
|
+
],
|
|
64
|
+
"allowScripts": {
|
|
65
|
+
"fsevents@2.3.3": true
|
|
66
|
+
}
|
|
60
67
|
}
|