@peter.naydenov/fsm-hub 2.1.0 → 2.1.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.
- package/Chaingelog.md +8 -0
- package/dist/fsm-hub.umd.js +1 -1
- package/package.json +9 -9
package/Chaingelog.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
## Release History
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
|
|
5
|
+
### 2.1.1 ( 2024-12-09)
|
|
6
|
+
- [x] Dev dependency update. @peter.naydenov/fsm - v.5.2.1;
|
|
7
|
+
- [x] Dev dependencies updates. Rollup@4.28.1;
|
|
8
|
+
- [x] Dev dependencies updates. Mocha@11.0.1;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
4
12
|
### 2.1.0 ( 2024-02-04)
|
|
5
13
|
- [x] Dependency update. ask-for-promise@2.0.3;
|
|
6
14
|
- [x] Dependency update. @peter.naydenov/stack@3.0.0;
|
package/dist/fsm-hub.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).fsmHub=n()}(this,(function(){"use strict";function e(e){
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).fsmHub=n()}(this,(function(){"use strict";function e(e){return e?function(e){let o=e.map((e=>n())),c=o.map((e=>e.promise));o.promises=o;let s=t(Promise.all(c));function i(e){let n="pending";return e.then((()=>n="fulfilled")).catch((()=>n="rejected")),n}function l(n,...t){o.forEach(((r,o)=>n({value:e[o],done:r.done,cancel:r.cancel,timeout:r.timeout,state:i(r.promise)},...t)))}const a={promise:Promise.all(c),promises:o,done:e=>{o.forEach((n=>n.done(e)))},cancel:e=>{o.forEach((n=>n.cancel(e)))},each:l,onComplete:s,timeout:()=>{}};return a.timeout=r(!0,a),a}(e):n()}function n(){let e,n;const o=new Promise(((t,r)=>{e=t,n=r})),c={promise:o,promises:null,done:e,cancel:n,each:()=>{},onComplete:t(o),timeout:()=>{}};return c.timeout=r(!1,c),c.each=(t,...r)=>{t({value:null,done:e,cancel:n,timeout:c.timeout},...r)},c}function t(e){return function(n,t=null){null===t?e.then((e=>n(e))):e.then((e=>n(e)),(e=>t(e)))}}function r(e,n){let r;return r=e?Promise.all(n.promises.map((e=>e.promise))):n.promise,function(e,o){let c,s=new Promise(((n,t)=>{c=setTimeout((()=>{n(o),Promise.resolve(r)}),e)}));return r.then((()=>clearTimeout(c))),n.onComplete=t(Promise.race([r,s])),n}}e.sequence=function(n,...t){const r=e(),o=[];const c=function*(e){for(const n of e)yield n}(n);return function e(n,...t){n.done?r.done(o):n.value(...t).then((n=>{o.push(n),e(c.next(),...t,n)}))}(c.next(),...t),r},e.all=function(n,...t){const r=e(),o=[],c=n.map(((e,n)=>"function"==typeof e?e(...t).then((e=>o[n]=e)):e.then((e=>o[n]=e))));return Promise.all(c).then((()=>r.done(o))),r};const o={_setTransitions:function(e,n){return function({reactivity:t,transformers:r},o={}){let c={},s={},i={},l={};return t.forEach(((t,r)=>{if(!(t instanceof Array))return void e._debugger(n.WRONG_REACTIVITY_RECORD,r+1);const o=t.length,[c,a,u,f]=t;if(!(4==o||3==o))return void e._debugger(n.WRONG_REACTIVITY_RECORD,r+1);const p=`${c}/${a}`;if(4==o){s[p]||(s[p]=[]),s[p].push(u);i[`${p}/${u}`]=f}3==o&&(l[p]||(l[p]=[]),l[p].push(u))})),r&&Object.keys(r).forEach((e=>{const n=r[e],t=o[n];t&&(c[e]=t)})),{transformers:c,subscribers:s,callbacks:l,actions:i}}},_debugger:function(e){return function(n,t){e.debug&&console.log(n,t)}},_callback:function(n,t){return function(r,o,c,s){const i=`${o}/${c}`,l=n.subscribers[i]||!1,a=n.callbacks[i]||!1,u=n.fnCallbacks,f=n.actions,p=[];let h;if(l||a){if(l&&l.forEach((e=>{if(!n.fsm[e])return void n._debugger(t.MISSING_FSM,l);const r=f[`${i}/${e}`],a=`${o}/${e}`,u=n.transformers[a];h="function"==typeof u?u(c,s):s,h||(h={},h.___internalFlag=!0);const m=n.fsm[e].update(r,h);p.push(m)})),a){let r=e();p.push(r.promise),a.forEach((e=>{const r=u[e],i=`${o}/${e}`,l=n.transformers[i];h="function"==typeof l?l(c,s):s,h.answer&&h.answer.hasOwnProperty("___internalFlag")&&(h.answer=void 0),"function"==typeof r?r(h):n._debugger(t.MISSING_FN,e)})),r.done()}Promise.all(p).then((()=>r.done()))}else r.done()}},addFsm:function(n,t){return function(r){Object.keys(r).forEach((o=>{function c(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,o,c]=t?n.cache.pull():n.cacheInternal.pull();n.cache.isEmpty()&&(n.lock=!1),n.cacheInternal.isEmpty()&&(n.haveInternalRequest=!1),s(r,o,c)}function s(t,r,o){let s;if(!n.lock)return n.lock=!0,s=e(),s.onComplete((e=>c(!1))),void n._callback(s,t,r,o);if(o){if(n.haveInternalRequest)return void n.cacheInternal.push([[t,r,o]]);let s=e();return s.onComplete((e=>c(!0))),n.haveInternalRequest=!0,void n._callback(s,t,r,o)}n.cache.push([[t,r,o]])}n.fsm[o]?n._debugger(t.REGISTERED_FSM_NAME,o):(n.fsm[o]=r[o],n.fsm[o].on("update",((e,n)=>s(o,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]}))}}},c={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(e={}){let n=[],{type:t,limit:r,onLimit:o}=Object.assign({},{type:"FIFO",limit:!1,onLimit:"update"},e),c="LIFO"===t.toUpperCase(),s=!1;function i(e=1,t=0){let r=[];return t>0&&Array.from({length:t}).map((()=>n.pop())),1==e?n.pop():(Array.from({length:e}).map((()=>{let e=n.pop();null!=e&&r.push(e)})),r)}function l(e=1,t=0){let r=[],o=n.length-t;return e>1&&Array.from({length:e}).map((()=>{null!=n[o-1]&&r.push(n[o-1]),o--})),1==e?n[n.length-1]:r}function a(){}return a.prototype={pull:i,pullReverse:function(e=1,n=0){let t=i(e,n);return t instanceof Array?t.reverse():t},peek:l,peekReverse:function(e=1,n=0){const t=l(e,n);return t instanceof Array?t.reverse():t},getSize:()=>n.length,isEmpty:()=>0==n.length,reset:()=>(n=[],!0),debug:()=>[...n]},a.prototype.push=c?function(e){const t=e instanceof Array,c=t?e.length:1;let l=!1;if("full"!==o||!s){if(r&&t&&c>r&&(e=e.slice(0,-c+r)),r){const c=(t?e.length:1)+n.length;c>=r&&"full"===o&&(e=e.slice(0,-(c-r))),c>=r&&"update"===o&&(l=i(c-r))}return n=e instanceof Array?n.concat(e):n.concat([e]),s=!!r&&n.length===r,l||void 0}}:function(e){const t=e instanceof Array,c=t?e.length:1;let l=!1;if("full"!==o||!s){if(r&&t&&c>r&&(e=e.slice(c-r)),r){const c=(t?e.length:1)+n.length;c>=r&&"full"===o&&(e=e.slice(0,-(c-r))),c>=r&&"update"===o&&(l=i(c-r))}return n=t?e.reduce(((e,n)=>[n,...e]),n):[e].reduce(((e,n)=>[n,...e]),n),s=!!r&&n.length===r,l||void 0}},new a}return function(n,t){const r=this,i=Object.keys(o);r.fsm={},r.fnCallbacks={},r.debug=n.debug||!1,r.cache=s({type:"FIFO"}),r.cacheInternal=s({type:"FIFO"}),r.wait=[],r.lock=!1,r.haveInternalRequest=!1,r.reactivityTask=!1,r.askForPromise=e,i.forEach((e=>{r[e]=o[e](r,c)}));const{transformers:l,subscribers:a,actions:u,callbacks:f}=r._setTransitions(n,t);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.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Peter Naydenov",
|
|
7
7
|
"main": "./dist/fsm-hub.umd.js",
|
|
@@ -23,17 +23,17 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@peter.naydenov/stack": "3.0.0",
|
|
26
|
-
"ask-for-promise": "
|
|
26
|
+
"ask-for-promise": "3.0.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@peter.naydenov/fsm": "5.2.
|
|
30
|
-
"@rollup/plugin-commonjs": "^
|
|
31
|
-
"@rollup/plugin-node-resolve": "^
|
|
29
|
+
"@peter.naydenov/fsm": "5.2.2",
|
|
30
|
+
"@rollup/plugin-commonjs": "^28.0.2",
|
|
31
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
32
32
|
"@rollup/plugin-terser": "^0.4.4",
|
|
33
|
-
"c8": "^
|
|
34
|
-
"chai": "5.
|
|
35
|
-
"mocha": "
|
|
36
|
-
"rollup": "^4.
|
|
33
|
+
"c8": "^10.1.3",
|
|
34
|
+
"chai": "5.1.2",
|
|
35
|
+
"mocha": "11.0.1",
|
|
36
|
+
"rollup": "^4.28.1"
|
|
37
37
|
},
|
|
38
38
|
"repository": {
|
|
39
39
|
"type": "git",
|