@alwatr/fsm 3.1.0 → 3.1.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/CHANGELOG.md +11 -0
- package/README.md +5 -5
- package/dist/main.cjs +2 -2
- package/dist/main.mjs +2 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.1.1](https://github.com/Alwatr/flux/compare/v3.1.0...v3.1.1) (2024-09-29)
|
|
7
|
+
|
|
8
|
+
### Miscellaneous Chores
|
|
9
|
+
|
|
10
|
+
* edited README ([fff9b3f](https://github.com/Alwatr/flux/commit/fff9b3f6ccc52e2257bdfe306e032ded07497b4a)) by @ArmanAsadian
|
|
11
|
+
* **fsm:** change the license to AGPL-3.0 ([babc4a8](https://github.com/Alwatr/flux/commit/babc4a82bd0421981ec40c150f0de262f0f81f42)) by @ArmanAsadian
|
|
12
|
+
|
|
13
|
+
### Dependencies update
|
|
14
|
+
|
|
15
|
+
* update ([fb148fd](https://github.com/Alwatr/flux/commit/fb148fdbe7f84acc3eda625e5e8c5773747d32e9)) by @
|
|
16
|
+
|
|
6
17
|
## [3.1.0](https://github.com/Alwatr/flux/compare/v3.0.3...v3.1.0) (2024-09-26)
|
|
7
18
|
|
|
8
19
|
### Features
|
package/README.md
CHANGED
|
@@ -87,14 +87,14 @@ class MyStateMachine extends FluxStateMachineBase<MyState, MyEvent> {
|
|
|
87
87
|
|
|
88
88
|
## Sponsors
|
|
89
89
|
|
|
90
|
-
The following companies, organizations, and individuals support
|
|
90
|
+
The following companies, organizations, and individuals support flux ongoing maintenance and development. Become a Sponsor to get your logo on our README and website.
|
|
91
91
|
|
|
92
92
|
[](https://exirstudio.com)
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
### Contributing
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
Contributions are welcome! Please read our [contribution guidelines](https://github.com/Alwatr/.github/blob/next/CONTRIBUTING.md) before submitting a pull request.
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
### License
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
This project is licensed under the [AGPL-3.0 License](LICENSE).
|
package/dist/main.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @alwatr/fsm v3.1.
|
|
2
|
-
"use strict";var a=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var m=(i,o)=>{for(var t in o)a(i,t,{get:o[t],enumerable:!0})},g=(i,o,t,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of h(o))!S.call(i,e)&&e!==t&&a(i,e,{get:()=>o[e],enumerable:!(r=l(o,e))||r.enumerable});return i};var p=i=>g(a({},"__esModule",{value:!0}),i);var x={};m(x,{AlwatrFluxStateMachine:()=>n,AlwatrFluxStateMachineBase:()=>s});module.exports=p(x);var c=require("@alwatr/logger"),d=require("@alwatr/observable"),A=require("@alwatr/polyfill-has-own");(0,c.definePackage)("@alwatr/fsm","3.1.
|
|
1
|
+
/* @alwatr/fsm v3.1.1 */
|
|
2
|
+
"use strict";var a=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var m=(i,o)=>{for(var t in o)a(i,t,{get:o[t],enumerable:!0})},g=(i,o,t,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of h(o))!S.call(i,e)&&e!==t&&a(i,e,{get:()=>o[e],enumerable:!(r=l(o,e))||r.enumerable});return i};var p=i=>g(a({},"__esModule",{value:!0}),i);var x={};m(x,{AlwatrFluxStateMachine:()=>n,AlwatrFluxStateMachineBase:()=>s});module.exports=p(x);var c=require("@alwatr/logger"),d=require("@alwatr/observable"),A=require("@alwatr/polyfill-has-own");(0,c.definePackage)("@alwatr/fsm","3.1.1");var s=class extends d.AlwatrObservable{constructor(t){t.loggerPrefix??(t.loggerPrefix="flux-state-machine");super(t);this.stateRecord_={};this.actionRecord_={};this.message_={state:this.initialState_=t.initialState}}resetToInitialState_(){this.logger_.logMethod?.("resetToInitialState_"),this.message_={state:this.initialState_}}shouldTransition_(t){return this.logger_.logMethodFull?.("shouldTransition_",t,!0),!0}async transition_(t){let r=this.message_.state,e=this.stateRecord_[r]?.[t]??this.stateRecord_._all?.[t];if(this.logger_.logMethodArgs?.("transition_",{fromState:r,event:t,toState:e}),e==null){this.logger_.incident?.("transition","invalid_target_state",{fromState:r,event:t});return}let _={from:r,event:t,to:e};await this.shouldTransition_(_)===!0&&(this.notify_({state:e}),this.postTransition__(_))}async postTransition__(t){this.logger_.logMethodArgs?.("_transitioned",t),await this.execAction__(`on_${t.event}`,t),t.from!==t.to&&(await this.execAction__("on_state_exit",t),await this.execAction__(`on_${t.from}_exit`,t),await this.execAction__("on_state_enter",t),await this.execAction__(`on_${t.to}_enter`,t)),Object.hasOwn(this,`on_${t.from}_${t.event}`)?this.execAction__(`on_${t.from}_${t.event}`,t):this.execAction__(`on_all_${t.event}`,t)}execAction__(t,r){let e=this.actionRecord_[t];if(typeof e=="function")return this.logger_.logMethodArgs?.("_$execAction",t),e.call(this,r)}};var n=class extends s{get state(){return this.message_.state}transition(o){this.transition_(o)}resetToInitialState(){this.resetToInitialState_()}};0&&(module.exports={AlwatrFluxStateMachine,AlwatrFluxStateMachineBase});
|
|
3
3
|
//# sourceMappingURL=main.cjs.map
|
package/dist/main.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @alwatr/fsm v3.1.
|
|
2
|
-
import{definePackage as _}from"@alwatr/logger";import{AlwatrObservable as c}from"@alwatr/observable";import"@alwatr/polyfill-has-own";_("@alwatr/fsm","3.1.
|
|
1
|
+
/* @alwatr/fsm v3.1.1 */
|
|
2
|
+
import{definePackage as _}from"@alwatr/logger";import{AlwatrObservable as c}from"@alwatr/observable";import"@alwatr/polyfill-has-own";_("@alwatr/fsm","3.1.1");var i=class extends c{constructor(t){t.loggerPrefix??(t.loggerPrefix="flux-state-machine");super(t);this.stateRecord_={};this.actionRecord_={};this.message_={state:this.initialState_=t.initialState}}resetToInitialState_(){this.logger_.logMethod?.("resetToInitialState_"),this.message_={state:this.initialState_}}shouldTransition_(t){return this.logger_.logMethodFull?.("shouldTransition_",t,!0),!0}async transition_(t){let o=this.message_.state,e=this.stateRecord_[o]?.[t]??this.stateRecord_._all?.[t];if(this.logger_.logMethodArgs?.("transition_",{fromState:o,event:t,toState:e}),e==null){this.logger_.incident?.("transition","invalid_target_state",{fromState:o,event:t});return}let s={from:o,event:t,to:e};await this.shouldTransition_(s)===!0&&(this.notify_({state:e}),this.postTransition__(s))}async postTransition__(t){this.logger_.logMethodArgs?.("_transitioned",t),await this.execAction__(`on_${t.event}`,t),t.from!==t.to&&(await this.execAction__("on_state_exit",t),await this.execAction__(`on_${t.from}_exit`,t),await this.execAction__("on_state_enter",t),await this.execAction__(`on_${t.to}_enter`,t)),Object.hasOwn(this,`on_${t.from}_${t.event}`)?this.execAction__(`on_${t.from}_${t.event}`,t):this.execAction__(`on_all_${t.event}`,t)}execAction__(t,o){let e=this.actionRecord_[t];if(typeof e=="function")return this.logger_.logMethodArgs?.("_$execAction",t),e.call(this,o)}};var a=class extends i{get state(){return this.message_.state}transition(r){this.transition_(r)}resetToInitialState(){this.resetToInitialState_()}};export{a as AlwatrFluxStateMachine,i as AlwatrFluxStateMachineBase};
|
|
3
3
|
//# sourceMappingURL=main.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/fsm",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "A robust TypeScript library for implementing Flux (Finite) State Machines, enabling clear and organized management of application state and transitions.",
|
|
5
5
|
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com> (https://ali.mihandoost.com)",
|
|
6
6
|
"keywords": [
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"require": "./dist/main.cjs"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
|
-
"license": "
|
|
26
|
+
"license": "AGPL-3.0-only",
|
|
27
27
|
"files": [
|
|
28
28
|
"**/*.{js,mjs,cjs,map,d.ts,html,md}",
|
|
29
29
|
"!demo/**/*"
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@alwatr/logger": "^3.2.14",
|
|
62
|
-
"@alwatr/observable": "^3.1.
|
|
62
|
+
"@alwatr/observable": "^3.1.1",
|
|
63
63
|
"@alwatr/polyfill-has-own": "^1.0.10"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"@alwatr/prettier-config": "^1.0.4",
|
|
68
68
|
"@alwatr/tsconfig-base": "^1.2.0",
|
|
69
69
|
"@alwatr/type-helper": "^1.2.6",
|
|
70
|
-
"@types/node": "^22.7.
|
|
70
|
+
"@types/node": "^22.7.4",
|
|
71
71
|
"jest": "^29.7.0",
|
|
72
72
|
"typescript": "^5.6.2"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "e0a53586929eaaf25cdde4a0845650b8c7012ab7"
|
|
75
75
|
}
|