@alwatr/fsm 2.0.5 → 3.0.0

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 CHANGED
@@ -3,42 +3,100 @@
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
- ## [2.0.5](https://github.com/Alwatr/signal/compare/@alwatr/fsm@2.0.4...@alwatr/fsm@2.0.5) (2023-12-19)
6
+ ## 3.0.0 (2024-09-15)
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * **fsm:** FiniteStateMachineBase state property renamed to message data structure
11
+
12
+ ### Features
13
+
14
+ * update all repo files from alwatr ([b85a3a6](https://github.com/Alwatr/flux/commit/b85a3a62a8c19f395cf33d72329b9c0f301cddfc)) by @AliMD
15
+
16
+ ### Bug Fixes
17
+
18
+ * all new repo path and packages dependencies ([21a6afa](https://github.com/Alwatr/flux/commit/21a6afa0badafe4051617d9a9e3bbfbaabd0c4ad)) by @
19
+ * cleanup old signal and fsm v1 ([bde0bea](https://github.com/Alwatr/flux/commit/bde0bea06a6750bebad49a127b75b57fd5e55ddd)) by @
20
+ * **fsm:** compatible with new logger api ([77db656](https://github.com/Alwatr/flux/commit/77db656d8b261da29376cf6dba7b9d4c35deeae8)) by @
21
+ * **fsm:** import issue ([9674f34](https://github.com/Alwatr/flux/commit/9674f34a7c63137fb9597d2b465b4fb123c963c1)) by @
22
+ * ts refrence path ([c2baa44](https://github.com/Alwatr/flux/commit/c2baa44999c72a0015481fc8fea25439329c3f37)) by @
23
+
24
+ ### Code Refactoring
25
+
26
+ * **fsm:** rename main ([60a52bd](https://github.com/Alwatr/flux/commit/60a52bdc1e5ae3126226a9518d81f3c8dbf238dc)) by @AliMD
27
+ * **fsm:** Update FiniteStateMachineBase class ([27a29ca](https://github.com/Alwatr/flux/commit/27a29ca45fb2c7998760ce2177a386c7085011f9)) by @AliMD
28
+ * **fsm:** Update FiniteStateMachineBase class to use class property for state and transition methods ([647a921](https://github.com/Alwatr/flux/commit/647a921dab405b5545aecdb66f5d1d44490795d4)) by @AliMD
29
+ * **fsm:** Update FiniteStateMachineBase state property to message ([be1ca78](https://github.com/Alwatr/flux/commit/be1ca7897b8ada4b44576c2eaf9f38f3c2903668)) by @AliMD
30
+ * **fsm:** Update import statement for type.ts ([6091385](https://github.com/Alwatr/flux/commit/6091385ae7a4c4d92aa74effe6446c8e3a7606e9)) by @AliMD
31
+ * Remove unused dependencies from @alwatr/fsm package ([da58900](https://github.com/Alwatr/flux/commit/da5890009c9ddea4f45949eef5a372dd3784ea7a)) by @AliMD
32
+ * Rename fetch-state-machine.ts base class name ([ab88730](https://github.com/Alwatr/flux/commit/ab88730b46b2db0baeaca09e3de8e51c55b1e361)) by @AliMD
33
+ * Update @alwatr/fsm package and add @alwatr/observable package ([d78b177](https://github.com/Alwatr/flux/commit/d78b1774978632d66c6831c8a46626f524746e81)) by @AliMD
34
+ * Update @alwatr/polyfill-has-own dependency to version ^1.0.9 in fsm package.json ([f1c82a6](https://github.com/Alwatr/flux/commit/f1c82a6d330c3f1bfbf435a00a52e92f0541b024)) by @AliMD
35
+ * Update all package URLs to point to the flux repository ([e7e56d2](https://github.com/Alwatr/flux/commit/e7e56d252d4a0e1b4b1fa20c06e8b61b1b7242ae)) by @AliMD
36
+ * Update AlwatrContext constructor to use AlwatrObservableConfig ([a8c75c6](https://github.com/Alwatr/flux/commit/a8c75c6f937419e628a0b11b053e0028c731bcaf)) by @AliMD
37
+ * Update package dependencies and references ([888f698](https://github.com/Alwatr/flux/commit/888f6987553a410e561da9fe21c0655f8f935db0)) by @AliMD
38
+
39
+ ### Miscellaneous Chores
40
+
41
+ * **deps-dev:** bump the development-dependencies group with 11 updates ([60f3075](https://github.com/Alwatr/flux/commit/60f3075872d3a4a9da979c589b5aa6b84065d48b)) by @
42
+ * **deps-dev:** bump the development-dependencies group with 14 updates ([c6ae70e](https://github.com/Alwatr/flux/commit/c6ae70e1534469fd36386f0828a52985001e2ef6)) by @
43
+ * **deps-dev:** bump the development-dependencies group with 8 updates ([c853aa2](https://github.com/Alwatr/flux/commit/c853aa2730b5c256049414e302a3d2d0c58ef61e)) by @
44
+ * **deps:** bump the alwatr-dependencies group with 3 updates ([f2a109d](https://github.com/Alwatr/flux/commit/f2a109d9b1775b67303d9407e20a5591cc69e4a7)) by @
45
+ * **deps:** bump the alwatr-dependencies group with 3 updates ([e5105eb](https://github.com/Alwatr/flux/commit/e5105eb0bbc450566b1ae6aee9241d541377bf94)) by @
46
+ * **deps:** bump the alwatr-dependencies group with 4 updates ([0019b83](https://github.com/Alwatr/flux/commit/0019b83ed56643b634972d8a15651ef2eaa2d735)) by @
47
+ * **deps:** bump the alwatr-dependencies group with 4 updates ([eb7fdfa](https://github.com/Alwatr/flux/commit/eb7fdfa545b5c1e040839a427326937acdcd8cb3)) by @
48
+ * **deps:** bump the alwatr-dependencies group with 4 updates ([4069863](https://github.com/Alwatr/flux/commit/40698638f3825b118d8c24fa115403f3f3b564a7)) by @
49
+ * **deps:** fix and update ([ab83ec7](https://github.com/Alwatr/flux/commit/ab83ec789d43245a8ff109e151b054a1fecb8e2a)) by @
50
+ * **deps:** update ([d7e2ef1](https://github.com/Alwatr/flux/commit/d7e2ef1a9de62fff6bfb2fd32af7dcfb4fcb048d)) by @njfamirm
51
+ * **deps:** upgrade ([7e60a62](https://github.com/Alwatr/flux/commit/7e60a6237f8b07b72dd9afd6bbaa140b187fe882)) by @
52
+ * **deps:** workspace dependencies ([627938e](https://github.com/Alwatr/flux/commit/627938e38e75a5e425388c3d56837feffd6716a2)) by @
53
+ * **fsm:** rename fsm2 ([f10fea0](https://github.com/Alwatr/flux/commit/f10fea017f75c3a26a26319b14284e8ee4bc605d)) by @
54
+ * rename core to packages ([9158c8e](https://github.com/Alwatr/flux/commit/9158c8e4c679d96c9b54e91ea6faa49364d47494)) by @
55
+ * update changelogs ([a965ecd](https://github.com/Alwatr/flux/commit/a965ecd095cb621b4a7748d2e048f4a82b0aa872)) by @
56
+ * **yarn:** pnp mode ([02bd406](https://github.com/Alwatr/flux/commit/02bd4064e381c483e31a8acbe7c72e7aed3e62b3)) by @
57
+
58
+ ### Dependencies update
59
+
60
+ * bump the alwatr-dependencies group with 6 updates ([4470fd8](https://github.com/Alwatr/flux/commit/4470fd8be49e1a73c17bdd5a09127b9f3a67b3bb)) by @dependabot[bot]
61
+ * update ([0128365](https://github.com/Alwatr/flux/commit/01283652b0798243aaac9643c5024e7856af169c)) by @AliMD
62
+ * update ([e8f8281](https://github.com/Alwatr/flux/commit/e8f8281beb24988466c6e29f724a963118870933)) by @AliMD
63
+
64
+ ## [2.0.5](https://github.com/Alwatr/flux/compare/@alwatr/fsm@2.0.4...@alwatr/fsm@2.0.5) (2023-12-19)
7
65
 
8
66
  **Note:** Version bump only for package @alwatr/fsm
9
67
 
10
- ## [2.0.4](https://github.com/Alwatr/signal/compare/@alwatr/fsm@2.0.2...@alwatr/fsm@2.0.4) (2023-12-19)
68
+ ## [2.0.4](https://github.com/Alwatr/flux/compare/@alwatr/fsm@2.0.2...@alwatr/fsm@2.0.4) (2023-12-19)
11
69
 
12
70
  **Note:** Version bump only for package @alwatr/fsm
13
71
 
14
- ## [2.0.3](https://github.com/Alwatr/signal/compare/@alwatr/fsm@2.0.2...@alwatr/fsm@2.0.3) (2023-11-09)
72
+ ## [2.0.3](https://github.com/Alwatr/flux/compare/@alwatr/fsm@2.0.2...@alwatr/fsm@2.0.3) (2023-11-09)
15
73
 
16
74
  **Note:** Version bump only for package @alwatr/fsm
17
75
 
18
- ## [2.0.2](https://github.com/AliMD/alwatr-signal/compare/@alwatr/fsm@2.0.1...@alwatr/fsm@2.0.2) (2023-11-01)
76
+ ## [2.0.2](https://github.com/Alwatr/flux/compare/@alwatr/fsm@2.0.1...@alwatr/fsm@2.0.2) (2023-11-01)
19
77
 
20
78
  **Note:** Version bump only for package @alwatr/fsm
21
79
 
22
- ## [2.0.1](https://github.com/AliMD/alwatr-signal/compare/@alwatr/fsm@2.0.0...@alwatr/fsm@2.0.1) (2023-10-23)
80
+ ## [2.0.1](https://github.com/Alwatr/flux/compare/@alwatr/fsm@2.0.0...@alwatr/fsm@2.0.1) (2023-10-23)
23
81
 
24
82
  ### Bug Fixes
25
83
 
26
- - **fsm:** compatible with new logger api ([77db656](https://github.com/AliMD/alwatr-signal/commit/77db656d8b261da29376cf6dba7b9d4c35deeae8)) by @
84
+ - **fsm:** compatible with new logger api ([77db656](https://github.com/Alwatr/flux/commit/77db656d8b261da29376cf6dba7b9d4c35deeae8)) by @
27
85
 
28
86
  # 2.0.0 (2023-09-19)
29
87
 
30
88
  ### Bug Fixes
31
89
 
32
- - all new repo path and packages dependencies ([21a6afa](https://github.com/AliMD/alwatr-signal/commit/21a6afa0badafe4051617d9a9e3bbfbaabd0c4ad)) by @AliMD
33
- - cleanup old signal and fsm v1 ([bde0bea](https://github.com/AliMD/alwatr-signal/commit/bde0bea06a6750bebad49a127b75b57fd5e55ddd)) by @AliMD
34
- - **fsm:** import issue ([9674f34](https://github.com/AliMD/alwatr-signal/commit/9674f34a7c63137fb9597d2b465b4fb123c963c1)) by @AliMD
35
- - ts refrence path ([c2baa44](https://github.com/AliMD/alwatr-signal/commit/c2baa44999c72a0015481fc8fea25439329c3f37)) by @AliMD
90
+ - all new repo path and packages dependencies ([21a6afa](https://github.com/Alwatr/flux/commit/21a6afa0badafe4051617d9a9e3bbfbaabd0c4ad)) by @AliMD
91
+ - cleanup old signal and fsm v1 ([bde0bea](https://github.com/Alwatr/flux/commit/bde0bea06a6750bebad49a127b75b57fd5e55ddd)) by @AliMD
92
+ - **fsm:** import issue ([9674f34](https://github.com/Alwatr/flux/commit/9674f34a7c63137fb9597d2b465b4fb123c963c1)) by @AliMD
93
+ - ts refrence path ([c2baa44](https://github.com/Alwatr/flux/commit/c2baa44999c72a0015481fc8fea25439329c3f37)) by @AliMD
36
94
 
37
- ## [1.1.2](https://github.com/AliMD/alwatr-signal/compare/@alwatr/fsm@1.1.1...@alwatr/fsm@1.1.2) (2023-09-12)
95
+ ## [1.1.2](https://github.com/Alwatr/flux/compare/@alwatr/fsm@1.1.1...@alwatr/fsm@1.1.2) (2023-09-12)
38
96
 
39
97
  **Note:** Version bump only for package @alwatr/fsm
40
98
 
41
- ## [1.1.1](https://github.com/AliMD/alwatr-signal/compare/@alwatr/fsm@1.1.0...@alwatr/fsm@1.1.1) (2023-09-12)
99
+ ## [1.1.1](https://github.com/Alwatr/flux/compare/@alwatr/fsm@1.1.0...@alwatr/fsm@1.1.1) (2023-09-12)
42
100
 
43
101
  **Note:** Version bump only for package @alwatr/fsm
44
102
 
@@ -52,96 +110,96 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
52
110
 
53
111
  ### Bug Fixes
54
112
 
55
- - **fms:** import path ([f6770a0](https://github.com/AliMD/alwatr-signal/commit/f6770a07fdf6855ccd63a85822d44d5ef9c72dee))
56
- - **fsm:** action maybe async ([50efffa](https://github.com/AliMD/alwatr-signal/commit/50efffa34a2ea5a3515561d7425da0c109631f36))
57
- - **fsm:** autoSignalUnsubscribe type ([f7db30b](https://github.com/AliMD/alwatr-signal/commit/f7db30bf5a90ff3d163f036b313a412a5149ff2b))
58
- - **fsm:** call render states function in there own this ([a950478](https://github.com/AliMD/alwatr-signal/commit/a95047811366e375785b2cd8fb176b1176638cab))
59
- - **fsm:** fix order of `initFsmInstance` args ([3b60138](https://github.com/AliMD/alwatr-signal/commit/3b60138ecebcbcb4d732e4d1a3e79f5b8661ae47))
60
- - **fsm:** initial exec actions ([e7dd5c8](https://github.com/AliMD/alwatr-signal/commit/e7dd5c8aaf9760c9856e4392cc899020f7e796d9))
61
- - **fsm:** last reported bugs in set state ([e7435c8](https://github.com/AliMD/alwatr-signal/commit/e7435c870a054b0ec3e4004f13c6db7610610be0))
62
- - **fsm:** review reset process ([af6e81c](https://github.com/AliMD/alwatr-signal/commit/af6e81c068b467d8b3aa96f2431e13ac479f018c))
63
- - **fsm:** run init entry actions ([777ae45](https://github.com/AliMD/alwatr-signal/commit/777ae459f2b77f79696daf3a0ca355d6d78e57d3))
64
- - new logger api ([9d83a7d](https://github.com/AliMD/alwatr-signal/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
113
+ - **fms:** import path ([f6770a0](https://github.com/Alwatr/flux/commit/f6770a07fdf6855ccd63a85822d44d5ef9c72dee))
114
+ - **fsm:** action maybe async ([50efffa](https://github.com/Alwatr/flux/commit/50efffa34a2ea5a3515561d7425da0c109631f36))
115
+ - **fsm:** autoSignalUnsubscribe type ([f7db30b](https://github.com/Alwatr/flux/commit/f7db30bf5a90ff3d163f036b313a412a5149ff2b))
116
+ - **fsm:** call render states function in there own this ([a950478](https://github.com/Alwatr/flux/commit/a95047811366e375785b2cd8fb176b1176638cab))
117
+ - **fsm:** fix order of `initFsmInstance` args ([3b60138](https://github.com/Alwatr/flux/commit/3b60138ecebcbcb4d732e4d1a3e79f5b8661ae47))
118
+ - **fsm:** initial exec actions ([e7dd5c8](https://github.com/Alwatr/flux/commit/e7dd5c8aaf9760c9856e4392cc899020f7e796d9))
119
+ - **fsm:** last reported bugs in set state ([e7435c8](https://github.com/Alwatr/flux/commit/e7435c870a054b0ec3e4004f13c6db7610610be0))
120
+ - **fsm:** review reset process ([af6e81c](https://github.com/Alwatr/flux/commit/af6e81c068b467d8b3aa96f2431e13ac479f018c))
121
+ - **fsm:** run init entry actions ([777ae45](https://github.com/Alwatr/flux/commit/777ae459f2b77f79696daf3a0ca355d6d78e57d3))
122
+ - new logger api ([9d83a7d](https://github.com/Alwatr/flux/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
65
123
 
66
124
  ### Features
67
125
 
68
- - **fsm:** add `signalRecord` to config ([1a35291](https://github.com/AliMD/alwatr-signal/commit/1a352915fba978da141513517655d1e07350c3ec))
69
- - **fsm:** add unsubscribe ([85ed3c3](https://github.com/AliMD/alwatr-signal/commit/85ed3c3439e1f40c2760f6011df112242f10be06))
70
- - **fsm:** callback in provider signals ([772818b](https://github.com/AliMD/alwatr-signal/commit/772818baa7953b6fbb4d4128fcee76733f42cc2d))
71
- - **fsm:** custom signal callback ([47c22e9](https://github.com/AliMD/alwatr-signal/commit/47c22e92a8a8085148b44b316d649b695ff8071a))
72
- - **fsm:** destroy and expire api ([e1a1c15](https://github.com/AliMD/alwatr-signal/commit/e1a1c150d81f4428718bd18f039235c7fce9caf2))
73
- - **fsm:** new types ([2866e3b](https://github.com/AliMD/alwatr-signal/commit/2866e3bd5ff56fd2b5bddcaed3673a5868bae4bb))
74
- - **fsm:** rewrite state machine ([7f24695](https://github.com/AliMD/alwatr-signal/commit/7f246959e5a80b21c1c4b21e895e75f8fbe56798))
75
- - **fsm:** subscribe ([2af4f44](https://github.com/AliMD/alwatr-signal/commit/2af4f44f0e8a2dee39cde10dcaa3281075632e6a))
126
+ - **fsm:** add `signalRecord` to config ([1a35291](https://github.com/Alwatr/flux/commit/1a352915fba978da141513517655d1e07350c3ec))
127
+ - **fsm:** add unsubscribe ([85ed3c3](https://github.com/Alwatr/flux/commit/85ed3c3439e1f40c2760f6011df112242f10be06))
128
+ - **fsm:** callback in provider signals ([772818b](https://github.com/Alwatr/flux/commit/772818baa7953b6fbb4d4128fcee76733f42cc2d))
129
+ - **fsm:** custom signal callback ([47c22e9](https://github.com/Alwatr/flux/commit/47c22e92a8a8085148b44b316d649b695ff8071a))
130
+ - **fsm:** destroy and expire api ([e1a1c15](https://github.com/Alwatr/flux/commit/e1a1c150d81f4428718bd18f039235c7fce9caf2))
131
+ - **fsm:** new types ([2866e3b](https://github.com/Alwatr/flux/commit/2866e3bd5ff56fd2b5bddcaed3673a5868bae4bb))
132
+ - **fsm:** rewrite state machine ([7f24695](https://github.com/Alwatr/flux/commit/7f246959e5a80b21c1c4b21e895e75f8fbe56798))
133
+ - **fsm:** subscribe ([2af4f44](https://github.com/Alwatr/flux/commit/2af4f44f0e8a2dee39cde10dcaa3281075632e6a))
76
134
 
77
135
  # 0.30.0 (2023-03-06)
78
136
 
79
137
  ### Bug Fixes
80
138
 
81
- - **fsm:** every signal mather ([0dc504d](https://github.com/AliMD/alwatr-signal/commit/0dc504dacbb1ec68f154244619d644ff8e43cc04))
82
- - **fsm:** remove additional import ([231337b](https://github.com/AliMD/alwatr-signal/commit/231337b95ee7b046fe35429f50931ddf85be291f))
83
- - **fsm:** update context in transition bug ([28a21d0](https://github.com/AliMD/alwatr-signal/commit/28a21d00d903b6189d814303c72ba6e784852f33))
139
+ - **fsm:** every signal mather ([0dc504d](https://github.com/Alwatr/flux/commit/0dc504dacbb1ec68f154244619d644ff8e43cc04))
140
+ - **fsm:** remove additional import ([231337b](https://github.com/Alwatr/flux/commit/231337b95ee7b046fe35429f50931ddf85be291f))
141
+ - **fsm:** update context in transition bug ([28a21d0](https://github.com/Alwatr/flux/commit/28a21d00d903b6189d814303c72ba6e784852f33))
84
142
 
85
143
  ### Features
86
144
 
87
- - Alwatr Finite State Machines ([d5900b4](https://github.com/AliMD/alwatr-signal/commit/d5900b4ee8685b120188888871405853f5a69417))
88
- - **fsm:** $all and $self state ([69adf41](https://github.com/AliMD/alwatr-signal/commit/69adf41064ca0f55497484c50e298ebc26c42dcc))
89
- - **fsm:** enhance types ([3b13046](https://github.com/AliMD/alwatr-signal/commit/3b130463a102f59c38603b0de470be5c87ee88c9))
90
- - **fsm:** make simple state machine ([ff9ae1c](https://github.com/AliMD/alwatr-signal/commit/ff9ae1ca04156e8b811899ff0f62480e1c37af72))
91
- - **fsm:** new state context type with {to, from, by} ([11423e6](https://github.com/AliMD/alwatr-signal/commit/11423e6a89159b92e82cfd1e774ad37983581090))
92
- - **fsm:** rewrite with signal power ([01a1651](https://github.com/AliMD/alwatr-signal/commit/01a1651e231a817d5eebb54cf84d51d620bfd6e8))
93
- - **fsm:** share state events ([de42522](https://github.com/AliMD/alwatr-signal/commit/de42522a97fdf6be8bee73d91a35820e2a5e6efb))
94
- - **fsm:** transition with partial context set ([823377e](https://github.com/AliMD/alwatr-signal/commit/823377e65028ea3e713f060ae678776c609c1661))
145
+ - Alwatr Finite State Machines ([d5900b4](https://github.com/Alwatr/flux/commit/d5900b4ee8685b120188888871405853f5a69417))
146
+ - **fsm:** $all and $self state ([69adf41](https://github.com/Alwatr/flux/commit/69adf41064ca0f55497484c50e298ebc26c42dcc))
147
+ - **fsm:** enhance types ([3b13046](https://github.com/Alwatr/flux/commit/3b130463a102f59c38603b0de470be5c87ee88c9))
148
+ - **fsm:** make simple state machine ([ff9ae1c](https://github.com/Alwatr/flux/commit/ff9ae1ca04156e8b811899ff0f62480e1c37af72))
149
+ - **fsm:** new state context type with {to, from, by} ([11423e6](https://github.com/Alwatr/flux/commit/11423e6a89159b92e82cfd1e774ad37983581090))
150
+ - **fsm:** rewrite with signal power ([01a1651](https://github.com/Alwatr/flux/commit/01a1651e231a817d5eebb54cf84d51d620bfd6e8))
151
+ - **fsm:** share state events ([de42522](https://github.com/Alwatr/flux/commit/de42522a97fdf6be8bee73d91a35820e2a5e6efb))
152
+ - **fsm:** transition with partial context set ([823377e](https://github.com/Alwatr/flux/commit/823377e65028ea3e713f060ae678776c609c1661))
95
153
 
96
- # [1.0.0](https://github.com/AliMD/alwatr-signal/compare/v0.32.0...v1.0.0) (2023-06-14)
154
+ # [1.0.0](https://github.com/Alwatr/flux/compare/v0.32.0...v1.0.0) (2023-06-14)
97
155
 
98
156
  **Note:** Version bump only for package @alwatr/fsm
99
157
 
100
- # [0.32.0](https://github.com/AliMD/alwatr-signal/compare/v0.31.0...v0.32.0) (2023-05-27)
158
+ # [0.32.0](https://github.com/Alwatr/flux/compare/v0.31.0...v0.32.0) (2023-05-27)
101
159
 
102
160
  **Note:** Version bump only for package @alwatr/fsm
103
161
 
104
- # [0.31.0](https://github.com/AliMD/alwatr-signal/compare/v0.30.0...v0.31.0) (2023-05-08)
162
+ # [0.31.0](https://github.com/Alwatr/flux/compare/v0.30.0...v0.31.0) (2023-05-08)
105
163
 
106
164
  ### Bug Fixes
107
165
 
108
- - **fms:** import path ([f6770a0](https://github.com/AliMD/alwatr-signal/commit/f6770a07fdf6855ccd63a85822d44d5ef9c72dee))
109
- - **fsm:** action maybe async ([50efffa](https://github.com/AliMD/alwatr-signal/commit/50efffa34a2ea5a3515561d7425da0c109631f36))
110
- - **fsm:** autoSignalUnsubscribe type ([f7db30b](https://github.com/AliMD/alwatr-signal/commit/f7db30bf5a90ff3d163f036b313a412a5149ff2b))
111
- - **fsm:** call render states function in there own this ([a950478](https://github.com/AliMD/alwatr-signal/commit/a95047811366e375785b2cd8fb176b1176638cab))
112
- - **fsm:** fix order of `initFsmInstance` args ([3b60138](https://github.com/AliMD/alwatr-signal/commit/3b60138ecebcbcb4d732e4d1a3e79f5b8661ae47))
113
- - **fsm:** initial exec actions ([e7dd5c8](https://github.com/AliMD/alwatr-signal/commit/e7dd5c8aaf9760c9856e4392cc899020f7e796d9))
114
- - **fsm:** last reported bugs in set state ([e7435c8](https://github.com/AliMD/alwatr-signal/commit/e7435c870a054b0ec3e4004f13c6db7610610be0))
115
- - **fsm:** review reset process ([af6e81c](https://github.com/AliMD/alwatr-signal/commit/af6e81c068b467d8b3aa96f2431e13ac479f018c))
116
- - **fsm:** run init entry actions ([777ae45](https://github.com/AliMD/alwatr-signal/commit/777ae459f2b77f79696daf3a0ca355d6d78e57d3))
117
- - new logger api ([9d83a7d](https://github.com/AliMD/alwatr-signal/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
166
+ - **fms:** import path ([f6770a0](https://github.com/Alwatr/flux/commit/f6770a07fdf6855ccd63a85822d44d5ef9c72dee))
167
+ - **fsm:** action maybe async ([50efffa](https://github.com/Alwatr/flux/commit/50efffa34a2ea5a3515561d7425da0c109631f36))
168
+ - **fsm:** autoSignalUnsubscribe type ([f7db30b](https://github.com/Alwatr/flux/commit/f7db30bf5a90ff3d163f036b313a412a5149ff2b))
169
+ - **fsm:** call render states function in there own this ([a950478](https://github.com/Alwatr/flux/commit/a95047811366e375785b2cd8fb176b1176638cab))
170
+ - **fsm:** fix order of `initFsmInstance` args ([3b60138](https://github.com/Alwatr/flux/commit/3b60138ecebcbcb4d732e4d1a3e79f5b8661ae47))
171
+ - **fsm:** initial exec actions ([e7dd5c8](https://github.com/Alwatr/flux/commit/e7dd5c8aaf9760c9856e4392cc899020f7e796d9))
172
+ - **fsm:** last reported bugs in set state ([e7435c8](https://github.com/Alwatr/flux/commit/e7435c870a054b0ec3e4004f13c6db7610610be0))
173
+ - **fsm:** review reset process ([af6e81c](https://github.com/Alwatr/flux/commit/af6e81c068b467d8b3aa96f2431e13ac479f018c))
174
+ - **fsm:** run init entry actions ([777ae45](https://github.com/Alwatr/flux/commit/777ae459f2b77f79696daf3a0ca355d6d78e57d3))
175
+ - new logger api ([9d83a7d](https://github.com/Alwatr/flux/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
118
176
 
119
177
  ### Features
120
178
 
121
- - **fsm:** add `signalRecord` to config ([1a35291](https://github.com/AliMD/alwatr-signal/commit/1a352915fba978da141513517655d1e07350c3ec))
122
- - **fsm:** add unsubscribe ([85ed3c3](https://github.com/AliMD/alwatr-signal/commit/85ed3c3439e1f40c2760f6011df112242f10be06))
123
- - **fsm:** callback in provider signals ([772818b](https://github.com/AliMD/alwatr-signal/commit/772818baa7953b6fbb4d4128fcee76733f42cc2d))
124
- - **fsm:** custom signal callback ([47c22e9](https://github.com/AliMD/alwatr-signal/commit/47c22e92a8a8085148b44b316d649b695ff8071a))
125
- - **fsm:** destroy and expire api ([e1a1c15](https://github.com/AliMD/alwatr-signal/commit/e1a1c150d81f4428718bd18f039235c7fce9caf2))
126
- - **fsm:** new types ([2866e3b](https://github.com/AliMD/alwatr-signal/commit/2866e3bd5ff56fd2b5bddcaed3673a5868bae4bb))
127
- - **fsm:** rewrite state machine ([7f24695](https://github.com/AliMD/alwatr-signal/commit/7f246959e5a80b21c1c4b21e895e75f8fbe56798))
128
- - **fsm:** subscribe ([2af4f44](https://github.com/AliMD/alwatr-signal/commit/2af4f44f0e8a2dee39cde10dcaa3281075632e6a))
179
+ - **fsm:** add `signalRecord` to config ([1a35291](https://github.com/Alwatr/flux/commit/1a352915fba978da141513517655d1e07350c3ec))
180
+ - **fsm:** add unsubscribe ([85ed3c3](https://github.com/Alwatr/flux/commit/85ed3c3439e1f40c2760f6011df112242f10be06))
181
+ - **fsm:** callback in provider signals ([772818b](https://github.com/Alwatr/flux/commit/772818baa7953b6fbb4d4128fcee76733f42cc2d))
182
+ - **fsm:** custom signal callback ([47c22e9](https://github.com/Alwatr/flux/commit/47c22e92a8a8085148b44b316d649b695ff8071a))
183
+ - **fsm:** destroy and expire api ([e1a1c15](https://github.com/Alwatr/flux/commit/e1a1c150d81f4428718bd18f039235c7fce9caf2))
184
+ - **fsm:** new types ([2866e3b](https://github.com/Alwatr/flux/commit/2866e3bd5ff56fd2b5bddcaed3673a5868bae4bb))
185
+ - **fsm:** rewrite state machine ([7f24695](https://github.com/Alwatr/flux/commit/7f246959e5a80b21c1c4b21e895e75f8fbe56798))
186
+ - **fsm:** subscribe ([2af4f44](https://github.com/Alwatr/flux/commit/2af4f44f0e8a2dee39cde10dcaa3281075632e6a))
129
187
 
130
- # [0.30.0](https://github.com/AliMD/alwatr-signal/compare/v0.29.0...v0.30.0) (2023-03-06)
188
+ # [0.30.0](https://github.com/Alwatr/flux/compare/v0.29.0...v0.30.0) (2023-03-06)
131
189
 
132
190
  ### Bug Fixes
133
191
 
134
- - **fsm:** every signal mather ([0dc504d](https://github.com/AliMD/alwatr-signal/commit/0dc504dacbb1ec68f154244619d644ff8e43cc04))
135
- - **fsm:** remove additional import ([231337b](https://github.com/AliMD/alwatr-signal/commit/231337b95ee7b046fe35429f50931ddf85be291f))
136
- - **fsm:** update context in transition bug ([28a21d0](https://github.com/AliMD/alwatr-signal/commit/28a21d00d903b6189d814303c72ba6e784852f33))
192
+ - **fsm:** every signal mather ([0dc504d](https://github.com/Alwatr/flux/commit/0dc504dacbb1ec68f154244619d644ff8e43cc04))
193
+ - **fsm:** remove additional import ([231337b](https://github.com/Alwatr/flux/commit/231337b95ee7b046fe35429f50931ddf85be291f))
194
+ - **fsm:** update context in transition bug ([28a21d0](https://github.com/Alwatr/flux/commit/28a21d00d903b6189d814303c72ba6e784852f33))
137
195
 
138
196
  ### Features
139
197
 
140
- - Alwatr Finite State Machines ([d5900b4](https://github.com/AliMD/alwatr-signal/commit/d5900b4ee8685b120188888871405853f5a69417))
141
- - **fsm:** $all and $self state ([69adf41](https://github.com/AliMD/alwatr-signal/commit/69adf41064ca0f55497484c50e298ebc26c42dcc))
142
- - **fsm:** enhance types ([3b13046](https://github.com/AliMD/alwatr-signal/commit/3b130463a102f59c38603b0de470be5c87ee88c9))
143
- - **fsm:** make simple state machine ([ff9ae1c](https://github.com/AliMD/alwatr-signal/commit/ff9ae1ca04156e8b811899ff0f62480e1c37af72))
144
- - **fsm:** new state context type with {to, from, by} ([11423e6](https://github.com/AliMD/alwatr-signal/commit/11423e6a89159b92e82cfd1e774ad37983581090))
145
- - **fsm:** rewrite with signal power ([01a1651](https://github.com/AliMD/alwatr-signal/commit/01a1651e231a817d5eebb54cf84d51d620bfd6e8))
146
- - **fsm:** share state events ([de42522](https://github.com/AliMD/alwatr-signal/commit/de42522a97fdf6be8bee73d91a35820e2a5e6efb))
147
- - **fsm:** transition with partial context set ([823377e](https://github.com/AliMD/alwatr-signal/commit/823377e65028ea3e713f060ae678776c609c1661))
198
+ - Alwatr Finite State Machines ([d5900b4](https://github.com/Alwatr/flux/commit/d5900b4ee8685b120188888871405853f5a69417))
199
+ - **fsm:** $all and $self state ([69adf41](https://github.com/Alwatr/flux/commit/69adf41064ca0f55497484c50e298ebc26c42dcc))
200
+ - **fsm:** enhance types ([3b13046](https://github.com/Alwatr/flux/commit/3b130463a102f59c38603b0de470be5c87ee88c9))
201
+ - **fsm:** make simple state machine ([ff9ae1c](https://github.com/Alwatr/flux/commit/ff9ae1ca04156e8b811899ff0f62480e1c37af72))
202
+ - **fsm:** new state context type with {to, from, by} ([11423e6](https://github.com/Alwatr/flux/commit/11423e6a89159b92e82cfd1e774ad37983581090))
203
+ - **fsm:** rewrite with signal power ([01a1651](https://github.com/Alwatr/flux/commit/01a1651e231a817d5eebb54cf84d51d620bfd6e8))
204
+ - **fsm:** share state events ([de42522](https://github.com/Alwatr/flux/commit/de42522a97fdf6be8bee73d91a35820e2a5e6efb))
205
+ - **fsm:** transition with partial context set ([823377e](https://github.com/Alwatr/flux/commit/823377e65028ea3e713f060ae678776c609c1661))
package/README.md CHANGED
@@ -1,3 +1,94 @@
1
- # Alwatr Finite State Machines - `@alwatr/fsm`
1
+ # @alwatr/fsm
2
2
 
3
- Managing invocations finite-state machines for lit-element written in tiny TypeScript module.
3
+ A robust TypeScript library for implementing Flux (Finite) State Machines, enabling clear and organized management of application state and transitions.
4
+
5
+ ## Features
6
+
7
+ * **Clear State Management:** Model your application's behavior with well-defined states and transitions.
8
+ * **TypeScript Support:** Written in TypeScript with full type definitions for improved code quality and developer experience.
9
+ * **Flexible Actions:** Attach custom actions to state transitions and events.
10
+ * **Observable Integration:** Built-in integration with `@alwatr/observable` for reactive state updates.
11
+ * **Built-in Logging:** Integrated logging for debugging and monitoring state machine behavior.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @alwatr/fsm
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```typescript
22
+ import {FluxStateMachineBase} from '@alwatr/fsm';
23
+
24
+ // Define your states and events
25
+ type MyState = 'idle' | 'loading' | 'success' | 'error';
26
+ type MyEvent = 'fetch' | 'success' | 'error';
27
+
28
+ class MyStateMachine extends FluxStateMachineBase<MyState, MyEvent> {
29
+ constructor() {
30
+ super({
31
+ name: 'my-state-machine',
32
+ initialState: 'idle',
33
+ });
34
+
35
+ // Define state transitions
36
+ this.stateRecord_ = {
37
+ idle: {
38
+ fetch: 'loading',
39
+ },
40
+ loading: {
41
+ success: 'success',
42
+ error: 'error',
43
+ },
44
+ success: {}, // Terminal state
45
+ error: {}, // Terminal state
46
+ };
47
+
48
+ // Define actions (optional)
49
+ this.actionRecord_ = {
50
+ '_on_fetch': this.handleFetch,
51
+ '_on_success': this.handleSuccess,
52
+ '_on_error': this.handleError,
53
+ };
54
+ }
55
+
56
+ // ... (Implement your action methods: handleFetch, handleSuccess, handleError)
57
+
58
+ // Trigger a state transition
59
+ fetchData() {
60
+ this.transition_('fetch');
61
+ }
62
+ }
63
+ ```
64
+
65
+ ## API
66
+
67
+ ### `FluxStateMachineBase<S extends string, E extends string>`
68
+
69
+ * **`constructor(config: {name: string; loggerPrefix?: string; initialState: S})`:**
70
+ * `config.name`: The name of the state machine (used for logging).
71
+ * `config.loggerPrefix`: Optional prefix for log messages.
72
+ * `config.initialState`: The initial state of the machine.
73
+
74
+ * **`stateRecord_: StateRecord<S, E>`:** Defines the states and their possible transitions based on events.
75
+
76
+ * **`actionRecord_: ActionRecord<S, E>`:** Binds action names to class methods for execution during transitions.
77
+
78
+ * **`transition_(event: E)`:** Triggers a state transition based on the provided event.
79
+
80
+ * **`shouldTransition_(_eventDetail: StateEventDetail<S, E>): MaybePromise<boolean>`:** (Optional) Allows you to define custom conditions for transitions.
81
+
82
+ * **`postTransition__(eventDetail: StateEventDetail<S, E>)`:** Executes actions associated with state transitions and events.
83
+
84
+ * **`execAction__(name: ActionName<S, E>, eventDetail: StateEventDetail<S, E>)`:** Executes a specific action if defined in the `actionRecord_`.
85
+
86
+ * **`resetToInitialState_()`:** Resets the machine to its initial state without notifying subscribers.
87
+
88
+ ## Contributing
89
+
90
+ Contributions are welcome! Please read the contributing guidelines before submitting a pull request.
91
+
92
+ ## License
93
+
94
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
package/dist/base.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ import { AlwatrObservable, type AlwatrObservableConfig } from '@alwatr/observable';
2
+ import '@alwatr/polyfill-has-own';
3
+ import type { ActionRecord, StateEventDetail, StateRecord } from './type.js';
4
+ import type { MaybePromise } from '@alwatr/type-helper';
5
+ export interface AlwatrFluxStateMachineConfig<S extends string> extends AlwatrObservableConfig {
6
+ initialState: S;
7
+ }
8
+ /**
9
+ * Flux (Finite) State Machine Base Class
10
+ */
11
+ export declare abstract class AlwatrFluxStateMachineBase<S extends string, E extends string> extends AlwatrObservable<{
12
+ state: S;
13
+ }> {
14
+ /**
15
+ * States and transitions config.
16
+ */
17
+ protected stateRecord_: StateRecord<S, E>;
18
+ /**
19
+ * Bind actions name to class methods
20
+ */
21
+ protected actionRecord_: ActionRecord<S, E>;
22
+ protected initialState_: S;
23
+ protected message_: {
24
+ state: S;
25
+ };
26
+ constructor(config: AlwatrFluxStateMachineConfig<S>);
27
+ /**
28
+ * Reset machine to initial state without notify.
29
+ */
30
+ protected resetToInitialState_(): void;
31
+ /**
32
+ * Transition condition.
33
+ */
34
+ protected shouldTransition_(_eventDetail: StateEventDetail<S, E>): MaybePromise<boolean>;
35
+ /**
36
+ * Transition flux state machine instance to new state.
37
+ */
38
+ protected transition_(event: E): Promise<void>;
39
+ /**
40
+ * Execute all actions for current state.
41
+ */
42
+ private postTransition__;
43
+ /**
44
+ * Execute action name if defined in _actionRecord.
45
+ */
46
+ private execAction__;
47
+ }
48
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAE,KAAK,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AACjF,OAAO,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAa,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAC,MAAM,WAAW,CAAC;AAEvF,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAItD,MAAM,WAAW,4BAA4B,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,sBAAsB;IAC5F,YAAY,EAAE,CAAC,CAAC;CACjB;AAGD;;GAEG;AACH,8BAAsB,0BAA0B,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAE,SAAQ,gBAAgB,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAC,CAAC;IACvH;;OAEG;IACH,SAAS,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAM;IAE/C;;OAEG;IACH,SAAS,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAM;IAEjD,SAAS,CAAC,aAAa,EAAE,CAAC,CAAC;IAE3B,UAAmB,QAAQ,EAAE;QAAC,KAAK,EAAE,CAAC,CAAA;KAAC,CAAC;gBAE5B,MAAM,EAAE,4BAA4B,CAAC,CAAC,CAAC;IAMnD;;OAEG;IACH,SAAS,CAAC,oBAAoB,IAAI,IAAI;IAKtC;;OAEG;IACH,SAAS,CAAC,iBAAiB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC;IAKxF;;OAEG;cACa,WAAW,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBpD;;OAEG;YACW,gBAAgB;IAqB9B;;OAEG;IACH,OAAO,CAAC,YAAY;CAOrB"}
package/dist/fsm.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { AlwatrFluxStateMachineBase } from './base.js';
2
+ /**
3
+ * Flux (Finite) State Machine Base Class
4
+ */
5
+ export declare abstract class AlwatrFluxStateMachine<S extends string, E extends string> extends AlwatrFluxStateMachineBase<S, E> {
6
+ /**
7
+ * Current state.
8
+ */
9
+ get state(): S;
10
+ /**
11
+ * Transition flux state machine instance to new state.
12
+ */
13
+ transition(event: E): void;
14
+ }
15
+ //# sourceMappingURL=fsm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fsm.d.ts","sourceRoot":"","sources":["../src/fsm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,0BAA0B,EAAC,MAAM,WAAW,CAAC;AAErD;;GAEG;AACH,8BAAsB,sBAAsB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAE,SAAQ,0BAA0B,CAAC,CAAC,EAAE,CAAC,CAAC;IACvH;;OAEG;IACH,IAAI,KAAK,IAAI,CAAC,CAEb;IAED;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;CAG3B"}
package/dist/main.cjs ADDED
@@ -0,0 +1,3 @@
1
+ /* @alwatr/fsm v3.0.0 */
2
+ "use strict";var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var g=(r,o)=>{for(var t in o)a(r,t,{get:o[t],enumerable:!0})},S=(r,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of l(o))!m.call(r,e)&&e!==t&&a(r,e,{get:()=>o[e],enumerable:!(i=h(o,e))||i.enumerable});return r};var p=r=>S(a({},"__esModule",{value:!0}),r);var f={};g(f,{AlwatrFluxStateMachine:()=>n,AlwatrFluxStateMachineBase:()=>s});module.exports=p(f);var d=require("@alwatr/logger"),c=require("@alwatr/observable"),u=require("@alwatr/polyfill-has-own");(0,d.definePackage)("@alwatr/fsm","3.0.0");var s=class extends c.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 i=this.message_.state,e=this.stateRecord_[i]?.[t]??this.stateRecord_._all?.[t];if(this.logger_.logMethodArgs?.("transition_",{fromState:i,event:t,toState:e}),e==null){this.logger_.incident?.("transition","invalid_target_state",{fromState:i,event:t});return}let _={from:i,event:t,to:e};await this.shouldTransition_(_)===!0&&(this.notify_({state:e}),this.e(_))}async e(t){this.logger_.logMethodArgs?.("_transitioned",t),await this.t(`_on_${t.event}`,t),t.from!==t.to&&(await this.t("_on_state_exit",t),await this.t(`_on_${t.from}_exit`,t),await this.t("_on_state_enter",t),await this.t(`_on_${t.to}_enter`,t)),Object.hasOwn(this,`_on_${t.from}_${t.event}`)?this.t(`_on_${t.from}_${t.event}`,t):this.t(`_on_all_${t.event}`,t)}t(t,i){let e=this.actionRecord_[t];if(typeof e=="function")return this.logger_.logMethodArgs?.("_$execAction",t),e.call(this,i)}};var n=class extends s{get state(){return this.message_.state}transition(o){this.transition_(o)}};0&&(module.exports={AlwatrFluxStateMachine,AlwatrFluxStateMachineBase});
3
+ //# sourceMappingURL=main.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/main.ts", "../src/base.ts", "../src/fsm.ts"],
4
+ "sourcesContent": ["export * from './base.js';\nexport * from './fsm.js';\nexport * from './type.js';\n", "import {definePackage} from '@alwatr/logger';\nimport {AlwatrObservable, type AlwatrObservableConfig} from '@alwatr/observable';\nimport '@alwatr/polyfill-has-own';\n\nimport type {ActionName, ActionRecord, StateEventDetail, StateRecord} from './type.js';\nimport type {} from '@alwatr/nano-build';\nimport type {MaybePromise} from '@alwatr/type-helper';\n\ndefinePackage('@alwatr/fsm', __package_version__);\n\nexport interface AlwatrFluxStateMachineConfig<S extends string> extends AlwatrObservableConfig {\n initialState: S;\n}\n\n\n/**\n * Flux (Finite) State Machine Base Class\n */\nexport abstract class AlwatrFluxStateMachineBase<S extends string, E extends string> extends AlwatrObservable<{state: S}> {\n /**\n * States and transitions config.\n */\n protected stateRecord_: StateRecord<S, E> = {};\n\n /**\n * Bind actions name to class methods\n */\n protected actionRecord_: ActionRecord<S, E> = {};\n\n protected initialState_: S;\n\n protected override message_: {state: S};\n\n constructor(config: AlwatrFluxStateMachineConfig<S>) {\n config.loggerPrefix ??= 'flux-state-machine';\n super(config);\n this.message_ = {state: this.initialState_ = config.initialState};\n }\n\n /**\n * Reset machine to initial state without notify.\n */\n protected resetToInitialState_(): void {\n this.logger_.logMethod?.('resetToInitialState_');\n this.message_ = {state: this.initialState_};\n }\n\n /**\n * Transition condition.\n */\n protected shouldTransition_(_eventDetail: StateEventDetail<S, E>): MaybePromise<boolean> {\n this.logger_.logMethodFull?.('shouldTransition_', _eventDetail, true);\n return true;\n }\n\n /**\n * Transition flux state machine instance to new state.\n */\n protected async transition_(event: E): Promise<void> {\n const fromState = this.message_.state;\n const toState = this.stateRecord_[fromState]?.[event] ?? this.stateRecord_._all?.[event];\n\n this.logger_.logMethodArgs?.('transition_', {fromState, event, toState});\n\n if (toState == null) {\n this.logger_.incident?.('transition', 'invalid_target_state', {\n fromState,\n event,\n });\n return;\n }\n\n const eventDetail: StateEventDetail<S, E> = {from: fromState, event, to: toState};\n\n if ((await this.shouldTransition_(eventDetail)) !== true) return;\n\n this.notify_({state: toState});\n\n this.postTransition__(eventDetail);\n }\n\n /**\n * Execute all actions for current state.\n */\n private async postTransition__(eventDetail: StateEventDetail<S, E>): Promise<void> {\n this.logger_.logMethodArgs?.('_transitioned', eventDetail);\n\n await this.execAction__(`_on_${eventDetail.event}`, eventDetail);\n\n if (eventDetail.from !== eventDetail.to) {\n await this.execAction__(`_on_state_exit`, eventDetail);\n await this.execAction__(`_on_${eventDetail.from}_exit`, eventDetail);\n await this.execAction__(`_on_state_enter`, eventDetail);\n await this.execAction__(`_on_${eventDetail.to}_enter`, eventDetail);\n }\n\n if (Object.hasOwn(this, `_on_${eventDetail.from}_${eventDetail.event}`)) {\n this.execAction__(`_on_${eventDetail.from}_${eventDetail.event}`, eventDetail);\n }\n else {\n // The action `all_eventName` is executed only if the action `fromState_eventName` is not defined.\n this.execAction__(`_on_all_${eventDetail.event}`, eventDetail);\n }\n }\n\n /**\n * Execute action name if defined in _actionRecord.\n */\n private execAction__(name: ActionName<S, E>, eventDetail: StateEventDetail<S, E>): MaybePromise<void> {\n const actionFn = this.actionRecord_[name];\n if (typeof actionFn === 'function') {\n this.logger_.logMethodArgs?.('_$execAction', name);\n return actionFn.call(this, eventDetail);\n }\n }\n}\n", "import {AlwatrFluxStateMachineBase} from './base.js';\n\n/**\n * Flux (Finite) State Machine Base Class\n */\nexport abstract class AlwatrFluxStateMachine<S extends string, E extends string> extends AlwatrFluxStateMachineBase<S, E> {\n /**\n * Current state.\n */\n get state(): S {\n return this.message_.state;\n }\n\n /**\n * Transition flux state machine instance to new state.\n */\n transition(event: E): void {\n this.transition_(event);\n }\n}\n"],
5
+ "mappings": ";yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,EAAA,+BAAAC,IAAA,eAAAC,EAAAJ,GCAA,IAAAK,EAA4B,0BAC5BC,EAA4D,8BAC5DC,EAAO,uCAMP,iBAAc,cAAe,OAAmB,EAUzC,IAAeC,EAAf,cAAsF,kBAA6B,CAexH,YAAYC,EAAyC,CACnDA,EAAO,eAAPA,EAAO,aAAiB,sBACxB,MAAMA,CAAM,EAbd,KAAU,aAAkC,CAAC,EAK7C,KAAU,cAAoC,CAAC,EAS7C,KAAK,SAAW,CAAC,MAAO,KAAK,cAAgBA,EAAO,YAAY,CAClE,CAKU,sBAA6B,CACrC,KAAK,QAAQ,YAAY,sBAAsB,EAC/C,KAAK,SAAW,CAAC,MAAO,KAAK,aAAa,CAC5C,CAKU,kBAAkBC,EAA6D,CACvF,YAAK,QAAQ,gBAAgB,oBAAqBA,EAAc,EAAI,EAC7D,EACT,CAKA,MAAgB,YAAYC,EAAyB,CACnD,IAAMC,EAAY,KAAK,SAAS,MAC1BC,EAAU,KAAK,aAAaD,CAAS,IAAID,CAAK,GAAK,KAAK,aAAa,OAAOA,CAAK,EAIvF,GAFA,KAAK,QAAQ,gBAAgB,cAAe,CAAC,UAAAC,EAAW,MAAAD,EAAO,QAAAE,CAAO,CAAC,EAEnEA,GAAW,KAAM,CACnB,KAAK,QAAQ,WAAW,aAAc,uBAAwB,CAC5D,UAAAD,EACA,MAAAD,CACF,CAAC,EACD,MACF,CAEA,IAAMG,EAAsC,CAAC,KAAMF,EAAW,MAAAD,EAAO,GAAIE,CAAO,EAE3E,MAAM,KAAK,kBAAkBC,CAAW,IAAO,KAEpD,KAAK,QAAQ,CAAC,MAAOD,CAAO,CAAC,EAE7B,KAAKE,EAAiBD,CAAW,EACnC,CAKA,MAAcC,EAAiBD,EAAoD,CACjF,KAAK,QAAQ,gBAAgB,gBAAiBA,CAAW,EAEzD,MAAM,KAAKE,EAAa,OAAOF,EAAY,KAAK,GAAIA,CAAW,EAE3DA,EAAY,OAASA,EAAY,KACnC,MAAM,KAAKE,EAAa,iBAAkBF,CAAW,EACrD,MAAM,KAAKE,EAAa,OAAOF,EAAY,IAAI,QAASA,CAAW,EACnE,MAAM,KAAKE,EAAa,kBAAmBF,CAAW,EACtD,MAAM,KAAKE,EAAa,OAAOF,EAAY,EAAE,SAAUA,CAAW,GAGhE,OAAO,OAAO,KAAM,OAAOA,EAAY,IAAI,IAAIA,EAAY,KAAK,EAAE,EACpE,KAAKE,EAAa,OAAOF,EAAY,IAAI,IAAIA,EAAY,KAAK,GAAIA,CAAW,EAI7E,KAAKE,EAAa,WAAWF,EAAY,KAAK,GAAIA,CAAW,CAEjE,CAKQE,EAAaC,EAAwBH,EAAyD,CACpG,IAAMI,EAAW,KAAK,cAAcD,CAAI,EACxC,GAAI,OAAOC,GAAa,WACtB,YAAK,QAAQ,gBAAgB,eAAgBD,CAAI,EAC1CC,EAAS,KAAK,KAAMJ,CAAW,CAE1C,CACF,EC9GO,IAAeK,EAAf,cAAkFC,CAAiC,CAIxH,IAAI,OAAW,CACb,OAAO,KAAK,SAAS,KACvB,CAKA,WAAWC,EAAgB,CACzB,KAAK,YAAYA,CAAK,CACxB,CACF",
6
+ "names": ["main_exports", "__export", "AlwatrFluxStateMachine", "AlwatrFluxStateMachineBase", "__toCommonJS", "import_logger", "import_observable", "import_polyfill_has_own", "AlwatrFluxStateMachineBase", "config", "_eventDetail", "event", "fromState", "toState", "eventDetail", "postTransition__", "execAction__", "name", "actionFn", "AlwatrFluxStateMachine", "AlwatrFluxStateMachineBase", "event"]
7
+ }
@@ -1,4 +1,4 @@
1
1
  export * from './base.js';
2
2
  export * from './fsm.js';
3
3
  export * from './type.js';
4
- //# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
package/dist/main.mjs ADDED
@@ -0,0 +1,3 @@
1
+ /* @alwatr/fsm v3.0.0 */
2
+ import{definePackage as _}from"@alwatr/logger";import{AlwatrObservable as d}from"@alwatr/observable";import"@alwatr/polyfill-has-own";_("@alwatr/fsm","3.0.0");var r=class extends d{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.e(s))}async e(t){this.logger_.logMethodArgs?.("_transitioned",t),await this.t(`_on_${t.event}`,t),t.from!==t.to&&(await this.t("_on_state_exit",t),await this.t(`_on_${t.from}_exit`,t),await this.t("_on_state_enter",t),await this.t(`_on_${t.to}_enter`,t)),Object.hasOwn(this,`_on_${t.from}_${t.event}`)?this.t(`_on_${t.from}_${t.event}`,t):this.t(`_on_all_${t.event}`,t)}t(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 r{get state(){return this.message_.state}transition(i){this.transition_(i)}};export{a as AlwatrFluxStateMachine,r as AlwatrFluxStateMachineBase};
3
+ //# sourceMappingURL=main.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/base.ts", "../src/fsm.ts"],
4
+ "sourcesContent": ["import {definePackage} from '@alwatr/logger';\nimport {AlwatrObservable, type AlwatrObservableConfig} from '@alwatr/observable';\nimport '@alwatr/polyfill-has-own';\n\nimport type {ActionName, ActionRecord, StateEventDetail, StateRecord} from './type.js';\nimport type {} from '@alwatr/nano-build';\nimport type {MaybePromise} from '@alwatr/type-helper';\n\ndefinePackage('@alwatr/fsm', __package_version__);\n\nexport interface AlwatrFluxStateMachineConfig<S extends string> extends AlwatrObservableConfig {\n initialState: S;\n}\n\n\n/**\n * Flux (Finite) State Machine Base Class\n */\nexport abstract class AlwatrFluxStateMachineBase<S extends string, E extends string> extends AlwatrObservable<{state: S}> {\n /**\n * States and transitions config.\n */\n protected stateRecord_: StateRecord<S, E> = {};\n\n /**\n * Bind actions name to class methods\n */\n protected actionRecord_: ActionRecord<S, E> = {};\n\n protected initialState_: S;\n\n protected override message_: {state: S};\n\n constructor(config: AlwatrFluxStateMachineConfig<S>) {\n config.loggerPrefix ??= 'flux-state-machine';\n super(config);\n this.message_ = {state: this.initialState_ = config.initialState};\n }\n\n /**\n * Reset machine to initial state without notify.\n */\n protected resetToInitialState_(): void {\n this.logger_.logMethod?.('resetToInitialState_');\n this.message_ = {state: this.initialState_};\n }\n\n /**\n * Transition condition.\n */\n protected shouldTransition_(_eventDetail: StateEventDetail<S, E>): MaybePromise<boolean> {\n this.logger_.logMethodFull?.('shouldTransition_', _eventDetail, true);\n return true;\n }\n\n /**\n * Transition flux state machine instance to new state.\n */\n protected async transition_(event: E): Promise<void> {\n const fromState = this.message_.state;\n const toState = this.stateRecord_[fromState]?.[event] ?? this.stateRecord_._all?.[event];\n\n this.logger_.logMethodArgs?.('transition_', {fromState, event, toState});\n\n if (toState == null) {\n this.logger_.incident?.('transition', 'invalid_target_state', {\n fromState,\n event,\n });\n return;\n }\n\n const eventDetail: StateEventDetail<S, E> = {from: fromState, event, to: toState};\n\n if ((await this.shouldTransition_(eventDetail)) !== true) return;\n\n this.notify_({state: toState});\n\n this.postTransition__(eventDetail);\n }\n\n /**\n * Execute all actions for current state.\n */\n private async postTransition__(eventDetail: StateEventDetail<S, E>): Promise<void> {\n this.logger_.logMethodArgs?.('_transitioned', eventDetail);\n\n await this.execAction__(`_on_${eventDetail.event}`, eventDetail);\n\n if (eventDetail.from !== eventDetail.to) {\n await this.execAction__(`_on_state_exit`, eventDetail);\n await this.execAction__(`_on_${eventDetail.from}_exit`, eventDetail);\n await this.execAction__(`_on_state_enter`, eventDetail);\n await this.execAction__(`_on_${eventDetail.to}_enter`, eventDetail);\n }\n\n if (Object.hasOwn(this, `_on_${eventDetail.from}_${eventDetail.event}`)) {\n this.execAction__(`_on_${eventDetail.from}_${eventDetail.event}`, eventDetail);\n }\n else {\n // The action `all_eventName` is executed only if the action `fromState_eventName` is not defined.\n this.execAction__(`_on_all_${eventDetail.event}`, eventDetail);\n }\n }\n\n /**\n * Execute action name if defined in _actionRecord.\n */\n private execAction__(name: ActionName<S, E>, eventDetail: StateEventDetail<S, E>): MaybePromise<void> {\n const actionFn = this.actionRecord_[name];\n if (typeof actionFn === 'function') {\n this.logger_.logMethodArgs?.('_$execAction', name);\n return actionFn.call(this, eventDetail);\n }\n }\n}\n", "import {AlwatrFluxStateMachineBase} from './base.js';\n\n/**\n * Flux (Finite) State Machine Base Class\n */\nexport abstract class AlwatrFluxStateMachine<S extends string, E extends string> extends AlwatrFluxStateMachineBase<S, E> {\n /**\n * Current state.\n */\n get state(): S {\n return this.message_.state;\n }\n\n /**\n * Transition flux state machine instance to new state.\n */\n transition(event: E): void {\n this.transition_(event);\n }\n}\n"],
5
+ "mappings": ";AAAA,OAAQ,iBAAAA,MAAoB,iBAC5B,OAAQ,oBAAAC,MAAoD,qBAC5D,MAAO,2BAMPD,EAAc,cAAe,OAAmB,EAUzC,IAAeE,EAAf,cAAsFD,CAA6B,CAexH,YAAYE,EAAyC,CACnDA,EAAO,eAAPA,EAAO,aAAiB,sBACxB,MAAMA,CAAM,EAbd,KAAU,aAAkC,CAAC,EAK7C,KAAU,cAAoC,CAAC,EAS7C,KAAK,SAAW,CAAC,MAAO,KAAK,cAAgBA,EAAO,YAAY,CAClE,CAKU,sBAA6B,CACrC,KAAK,QAAQ,YAAY,sBAAsB,EAC/C,KAAK,SAAW,CAAC,MAAO,KAAK,aAAa,CAC5C,CAKU,kBAAkBC,EAA6D,CACvF,YAAK,QAAQ,gBAAgB,oBAAqBA,EAAc,EAAI,EAC7D,EACT,CAKA,MAAgB,YAAYC,EAAyB,CACnD,IAAMC,EAAY,KAAK,SAAS,MAC1BC,EAAU,KAAK,aAAaD,CAAS,IAAID,CAAK,GAAK,KAAK,aAAa,OAAOA,CAAK,EAIvF,GAFA,KAAK,QAAQ,gBAAgB,cAAe,CAAC,UAAAC,EAAW,MAAAD,EAAO,QAAAE,CAAO,CAAC,EAEnEA,GAAW,KAAM,CACnB,KAAK,QAAQ,WAAW,aAAc,uBAAwB,CAC5D,UAAAD,EACA,MAAAD,CACF,CAAC,EACD,MACF,CAEA,IAAMG,EAAsC,CAAC,KAAMF,EAAW,MAAAD,EAAO,GAAIE,CAAO,EAE3E,MAAM,KAAK,kBAAkBC,CAAW,IAAO,KAEpD,KAAK,QAAQ,CAAC,MAAOD,CAAO,CAAC,EAE7B,KAAKE,EAAiBD,CAAW,EACnC,CAKA,MAAcC,EAAiBD,EAAoD,CACjF,KAAK,QAAQ,gBAAgB,gBAAiBA,CAAW,EAEzD,MAAM,KAAKE,EAAa,OAAOF,EAAY,KAAK,GAAIA,CAAW,EAE3DA,EAAY,OAASA,EAAY,KACnC,MAAM,KAAKE,EAAa,iBAAkBF,CAAW,EACrD,MAAM,KAAKE,EAAa,OAAOF,EAAY,IAAI,QAASA,CAAW,EACnE,MAAM,KAAKE,EAAa,kBAAmBF,CAAW,EACtD,MAAM,KAAKE,EAAa,OAAOF,EAAY,EAAE,SAAUA,CAAW,GAGhE,OAAO,OAAO,KAAM,OAAOA,EAAY,IAAI,IAAIA,EAAY,KAAK,EAAE,EACpE,KAAKE,EAAa,OAAOF,EAAY,IAAI,IAAIA,EAAY,KAAK,GAAIA,CAAW,EAI7E,KAAKE,EAAa,WAAWF,EAAY,KAAK,GAAIA,CAAW,CAEjE,CAKQE,EAAaC,EAAwBH,EAAyD,CACpG,IAAMI,EAAW,KAAK,cAAcD,CAAI,EACxC,GAAI,OAAOC,GAAa,WACtB,YAAK,QAAQ,gBAAgB,eAAgBD,CAAI,EAC1CC,EAAS,KAAK,KAAMJ,CAAW,CAE1C,CACF,EC9GO,IAAeK,EAAf,cAAkFC,CAAiC,CAIxH,IAAI,OAAW,CACb,OAAO,KAAK,SAAS,KACvB,CAKA,WAAWC,EAAgB,CACzB,KAAK,YAAYA,CAAK,CACxB,CACF",
6
+ "names": ["definePackage", "AlwatrObservable", "AlwatrFluxStateMachineBase", "config", "_eventDetail", "event", "fromState", "toState", "eventDetail", "postTransition__", "execAction__", "name", "actionFn", "AlwatrFluxStateMachine", "AlwatrFluxStateMachineBase", "event"]
7
+ }
@@ -1,4 +1,4 @@
1
- import type { MaybePromise } from '@alwatr/type';
1
+ import type { MaybePromise } from '@alwatr/type-helper';
2
2
  export interface StateEventDetail<S, E> {
3
3
  from: S;
4
4
  event: E;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAEtD,MAAM,WAAW,gBAAgB,CAAC,CAAC,EAAE,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,CAAC,CAAC;IACT,EAAE,EAAE,CAAC,CAAC;CACP;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;AAEtH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IACrD,OAAO,CAAC,EAAE,GACV,gBAAgB,GAChB,iBAAiB,GACjB,OAAO,CAAC,OAAO,GACf,OAAO,CAAC,QAAQ,GAChB,OAAO,CAAC,IAAI,CAAC,EAAE,GACf,WAAW,CAAC,EAAE,CAAC;AAEnB,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,46 +1,75 @@
1
1
  {
2
2
  "name": "@alwatr/fsm",
3
- "version": "2.0.5",
4
- "description": "Managing invocations finite-state machines for lit-element written in tiny TypeScript module.",
3
+ "version": "3.0.0",
4
+ "description": "A robust TypeScript library for implementing Flux (Finite) State Machines, enabling clear and organized management of application state and transitions.",
5
+ "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com> (https://ali.mihandoost.com)",
5
6
  "keywords": [
6
7
  "state",
8
+ "flux",
7
9
  "finite",
8
10
  "machine",
9
- "lit",
10
- "lit-element",
11
- "lit-html",
12
11
  "typescript",
13
12
  "esm",
14
13
  "alwatr"
15
14
  ],
16
- "main": "index.js",
17
15
  "type": "module",
18
- "types": "index.d.ts",
19
- "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
16
+ "main": "./dist/main.cjs",
17
+ "module": "./dist/main.mjs",
18
+ "types": "./dist/main.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/main.d.ts",
22
+ "import": "./dist/main.mjs",
23
+ "require": "./dist/main.cjs"
24
+ }
25
+ },
20
26
  "license": "MIT",
21
27
  "files": [
22
- "**/*.{d.ts.map,d.ts,js.map,js,html,md}"
28
+ "**/*.{js,mjs,cjs,map,d.ts,html,md}",
29
+ "!demo/**/*"
23
30
  ],
24
31
  "publishConfig": {
25
32
  "access": "public"
26
33
  },
27
34
  "repository": {
28
35
  "type": "git",
29
- "url": "https://github.com/Alwatr/signal",
36
+ "url": "https://github.com/Alwatr/flux",
30
37
  "directory": "packages/fsm"
31
38
  },
32
- "homepage": "https://github.com/Alwatr/signal/tree/next/packages/fsm#readme",
39
+ "homepage": "https://github.com/Alwatr/flux/tree/next/packages/fsm#readme",
33
40
  "bugs": {
34
- "url": "https://github.com/Alwatr/signal/issues"
41
+ "url": "https://github.com/Alwatr/flux/issues"
42
+ },
43
+ "prettier": "@alwatr/prettier-config",
44
+ "scripts": {
45
+ "b": "yarn run build",
46
+ "t": "yarn run test",
47
+ "w": "yarn run watch",
48
+ "c": "yarn run clean",
49
+ "cb": "yarn run clean && yarn run build",
50
+ "d": "yarn run build:es && yarn node --enable-source-maps --trace-warnings",
51
+ "build": "yarn run build:ts & yarn run build:es",
52
+ "build:es": "nano-build --preset=module",
53
+ "build:ts": "tsc --build",
54
+ "test": "NODE_OPTIONS=\"$NODE_OPTIONS --enable-source-maps --experimental-vm-modules\" jest",
55
+ "watch": "yarn run watch:ts & yarn run watch:es",
56
+ "watch:es": "yarn run build:es --watch",
57
+ "watch:ts": "yarn run build:ts --watch --preserveWatchOutput",
58
+ "clean": "rm -rfv dist *.tsbuildinfo"
35
59
  },
36
60
  "dependencies": {
37
- "@alwatr/logger": "^2.4.1",
38
- "@alwatr/signal": "^2.0.5",
39
- "@alwatr/type": "^1.2.4",
40
- "tslib": "^2.6.2"
61
+ "@alwatr/logger": "^3.2.13",
62
+ "@alwatr/observable": "^3.0.0",
63
+ "@alwatr/polyfill-has-own": "^1.0.9"
41
64
  },
42
65
  "devDependencies": {
43
- "@types/node": "^20.10.5"
66
+ "@alwatr/nano-build": "^1.3.9",
67
+ "@alwatr/prettier-config": "^1.0.4",
68
+ "@alwatr/tsconfig-base": "^1.2.0",
69
+ "@alwatr/type-helper": "^1.2.6",
70
+ "@types/node": "^22.5.5",
71
+ "jest": "^29.7.0",
72
+ "typescript": "^5.6.2"
44
73
  },
45
- "gitHead": "bb15a99985f6643ab3435db3cec31ba39cc9c616"
74
+ "gitHead": "6c8830345d35da730c386adb047ca2cdcb3c36f0"
46
75
  }
package/base.d.ts DELETED
@@ -1,47 +0,0 @@
1
- import { AlwatrObservable } from '@alwatr/signal';
2
- import type { ActionName, ActionRecord, StateEventDetail, StateRecord } from './type.js';
3
- import type { MaybePromise } from '@alwatr/type';
4
- /**
5
- * Finite State Machine Base Class
6
- */
7
- export declare abstract class FiniteStateMachineBase<S extends string, E extends string> extends AlwatrObservable<S> {
8
- /**
9
- * Current state
10
- */
11
- protected get _state(): S;
12
- /**
13
- * States and transitions config.
14
- */
15
- protected _stateRecord: StateRecord<S, E>;
16
- /**
17
- * Bind actions name to class methods
18
- */
19
- protected _actionRecord: ActionRecord<S, E>;
20
- protected _initialState: S;
21
- constructor(config: {
22
- name: string;
23
- loggerPrefix?: string;
24
- initialState: S;
25
- });
26
- /**
27
- * Transition condition.
28
- */
29
- protected _shouldTransition(_eventDetail: StateEventDetail<S, E>): MaybePromise<boolean>;
30
- /**
31
- * Transition finite state machine instance to new state.
32
- */
33
- protected _transition(event: E): Promise<void>;
34
- /**
35
- * Execute all actions for current state.
36
- */
37
- protected _transitioned(eventDetail: StateEventDetail<S, E>): Promise<void>;
38
- /**
39
- * Execute action name if defined in _actionRecord.
40
- */
41
- protected _$execAction(name: ActionName<S, E>, eventDetail: StateEventDetail<S, E>): MaybePromise<void>;
42
- /**
43
- * Reset machine to initial state.
44
- */
45
- protected _reset(): void;
46
- }
47
- //# sourceMappingURL=base.d.ts.map
package/base.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["src/base.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAC,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAC,MAAM,WAAW,CAAC;AACvF,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAI/C;;GAEG;AACH,8BAAsB,sBAAsB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAE,SAAQ,gBAAgB,CAAC,CAAC,CAAC;IAC1G;;OAEG;IACH,SAAS,KAAK,MAAM,IAAI,CAAC,CAExB;IAED;;OAEG;IACH,SAAS,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAM;IAE/C;;OAEG;IACH,SAAS,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAM;IAEjD,SAAS,CAAC,aAAa,EAAE,CAAC,CAAC;gBAEf,MAAM,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,CAAC,CAAA;KAAC;IAO1E;;OAEG;IACH,SAAS,CAAC,iBAAiB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC;IAKxF;;OAEG;cACa,WAAW,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBpD;;OAEG;cACa,aAAa,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBjF;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC;IAQvG;;OAEG;IACH,SAAS,CAAC,MAAM,IAAI,IAAI;CAGzB"}
package/base.js DELETED
@@ -1,92 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import { definePackage } from '@alwatr/logger';
3
- import { AlwatrObservable } from '@alwatr/signal';
4
- definePackage('fsm', '2.x');
5
- /**
6
- * Finite State Machine Base Class
7
- */
8
- export class FiniteStateMachineBase extends AlwatrObservable {
9
- /**
10
- * Current state
11
- */
12
- get _state() {
13
- return this._getData();
14
- }
15
- constructor(config) {
16
- config.loggerPrefix ?? (config.loggerPrefix = 'fsm');
17
- super(config);
18
- /**
19
- * States and transitions config.
20
- */
21
- this._stateRecord = {};
22
- /**
23
- * Bind actions name to class methods
24
- */
25
- this._actionRecord = {};
26
- this._initialState = config.initialState;
27
- this._reset();
28
- }
29
- /**
30
- * Transition condition.
31
- */
32
- _shouldTransition(_eventDetail) {
33
- this._logger.logMethodFull?.('_shouldTransition', _eventDetail, true);
34
- return true;
35
- }
36
- /**
37
- * Transition finite state machine instance to new state.
38
- */
39
- async _transition(event) {
40
- const fromState = this._state;
41
- const toState = this._stateRecord[fromState]?.[event] ?? this._stateRecord._all?.[event];
42
- this._logger.logMethodArgs?.('_transition', { fromState, event, toState });
43
- if (toState == null) {
44
- this._logger.incident?.('transition', 'invalid_target_state', {
45
- fromState,
46
- event,
47
- });
48
- return;
49
- }
50
- const eventDetail = { from: fromState, event, to: toState };
51
- if ((await this._shouldTransition(eventDetail)) !== true)
52
- return;
53
- this._notify(toState);
54
- this._transitioned(eventDetail);
55
- }
56
- /**
57
- * Execute all actions for current state.
58
- */
59
- async _transitioned(eventDetail) {
60
- this._logger.logMethodArgs?.('_transitioned', eventDetail);
61
- await this._$execAction(`_on_${eventDetail.event}`, eventDetail);
62
- if (eventDetail.from !== eventDetail.to) {
63
- await this._$execAction(`_on_state_exit`, eventDetail);
64
- await this._$execAction(`_on_${eventDetail.from}_exit`, eventDetail);
65
- await this._$execAction(`_on_state_enter`, eventDetail);
66
- await this._$execAction(`_on_${eventDetail.to}_enter`, eventDetail);
67
- }
68
- if (`_on_${eventDetail.from}_${eventDetail.event}` in this) {
69
- this._$execAction(`_on_${eventDetail.from}_${eventDetail.event}`, eventDetail);
70
- }
71
- else {
72
- this._$execAction(`_on_all_${eventDetail.event}`, eventDetail);
73
- }
74
- }
75
- /**
76
- * Execute action name if defined in _actionRecord.
77
- */
78
- _$execAction(name, eventDetail) {
79
- const actionFn = this._actionRecord[name];
80
- if (typeof actionFn === 'function') {
81
- this._logger.logMethodArgs?.('_$execAction', name);
82
- return this._actionRecord[name]?.call(this, eventDetail);
83
- }
84
- }
85
- /**
86
- * Reset machine to initial state.
87
- */
88
- _reset() {
89
- this._$data = this._initialState;
90
- }
91
- }
92
- //# sourceMappingURL=base.js.map
package/base.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["src/base.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AAKhD,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAE5B;;GAEG;AACH,MAAM,OAAgB,sBAA2D,SAAQ,gBAAmB;IAC1G;;OAEG;IACH,IAAc,MAAM;QAClB,OAAO,IAAI,CAAC,QAAQ,EAAG,CAAC;IAC1B,CAAC;IAcD,YAAY,MAA8D;QACxE,MAAM,CAAC,YAAY,KAAnB,MAAM,CAAC,YAAY,GAAK,KAAK,EAAC;QAC9B,KAAK,CAAC,MAAM,CAAC,CAAC;QAdhB;;WAEG;QACO,iBAAY,GAAsB,EAAE,CAAC;QAE/C;;WAEG;QACO,kBAAa,GAAuB,EAAE,CAAC;QAO/C,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC;QACzC,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED;;OAEG;IACO,iBAAiB,CAAC,YAAoC;QAC9D,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,mBAAmB,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;QACtE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,WAAW,CAAC,KAAQ;QAClC,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC;QAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;QAEzF,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,aAAa,EAAE,EAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAC,CAAC,CAAC;QAEzE,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,YAAY,EAAE,sBAAsB,EAAE;gBAC5D,SAAS;gBACT,KAAK;aACN,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAED,MAAM,WAAW,GAA2B,EAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAC,CAAC;QAElF,IAAI,CAAC,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,KAAK,IAAI;YAAE,OAAO;QAEjE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAEtB,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,aAAa,CAAC,WAAmC;QAC/D,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;QAE3D,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,WAAW,CAAC,KAAK,EAAE,EAAE,WAAW,CAAC,CAAC;QAEjE,IAAI,WAAW,CAAC,IAAI,KAAK,WAAW,CAAC,EAAE,EAAE,CAAC;YACxC,MAAM,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC;YACvD,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,WAAW,CAAC,IAAI,OAAO,EAAE,WAAW,CAAC,CAAC;YACrE,MAAM,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;YACxD,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,WAAW,CAAC,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;QACtE,CAAC;QAED,IAAI,OAAO,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,KAAK,EAAE,IAAI,IAAI,EAAE,CAAC;YAC3D,IAAI,CAAC,YAAY,CAAC,OAAO,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,KAAK,EAAE,EAAE,WAAW,CAAC,CAAC;QACjF,CAAC;aACI,CAAC;YACJ,IAAI,CAAC,YAAY,CAAC,WAAW,WAAW,CAAC,KAAK,EAAE,EAAE,WAAW,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED;;OAEG;IACO,YAAY,CAAC,IAAsB,EAAE,WAAmC;QAChF,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;YACnC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;YACnD,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAED;;OAEG;IACO,MAAM;QACd,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC;IACnC,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport {definePackage} from '@alwatr/logger';\nimport {AlwatrObservable} from '@alwatr/signal';\n\nimport type {ActionName, ActionRecord, StateEventDetail, StateRecord} from './type.js';\nimport type {MaybePromise} from '@alwatr/type';\n\ndefinePackage('fsm', '2.x');\n\n/**\n * Finite State Machine Base Class\n */\nexport abstract class FiniteStateMachineBase<S extends string, E extends string> extends AlwatrObservable<S> {\n /**\n * Current state\n */\n protected get _state(): S {\n return this._getData()!;\n }\n\n /**\n * States and transitions config.\n */\n protected _stateRecord: StateRecord<S, E> = {};\n\n /**\n * Bind actions name to class methods\n */\n protected _actionRecord: ActionRecord<S, E> = {};\n\n protected _initialState: S;\n\n constructor(config: {name: string; loggerPrefix?: string; initialState: S}) {\n config.loggerPrefix ??= 'fsm';\n super(config);\n this._initialState = config.initialState;\n this._reset();\n }\n\n /**\n * Transition condition.\n */\n protected _shouldTransition(_eventDetail: StateEventDetail<S, E>): MaybePromise<boolean> {\n this._logger.logMethodFull?.('_shouldTransition', _eventDetail, true);\n return true;\n }\n\n /**\n * Transition finite state machine instance to new state.\n */\n protected async _transition(event: E): Promise<void> {\n const fromState = this._state;\n const toState = this._stateRecord[fromState]?.[event] ?? this._stateRecord._all?.[event];\n\n this._logger.logMethodArgs?.('_transition', {fromState, event, toState});\n\n if (toState == null) {\n this._logger.incident?.('transition', 'invalid_target_state', {\n fromState,\n event,\n });\n return;\n }\n\n const eventDetail: StateEventDetail<S, E> = {from: fromState, event, to: toState};\n\n if ((await this._shouldTransition(eventDetail)) !== true) return;\n\n this._notify(toState);\n\n this._transitioned(eventDetail);\n }\n\n /**\n * Execute all actions for current state.\n */\n protected async _transitioned(eventDetail: StateEventDetail<S, E>): Promise<void> {\n this._logger.logMethodArgs?.('_transitioned', eventDetail);\n\n await this._$execAction(`_on_${eventDetail.event}`, eventDetail);\n\n if (eventDetail.from !== eventDetail.to) {\n await this._$execAction(`_on_state_exit`, eventDetail);\n await this._$execAction(`_on_${eventDetail.from}_exit`, eventDetail);\n await this._$execAction(`_on_state_enter`, eventDetail);\n await this._$execAction(`_on_${eventDetail.to}_enter`, eventDetail);\n }\n\n if (`_on_${eventDetail.from}_${eventDetail.event}` in this) {\n this._$execAction(`_on_${eventDetail.from}_${eventDetail.event}`, eventDetail);\n }\n else {\n this._$execAction(`_on_all_${eventDetail.event}`, eventDetail);\n }\n }\n\n /**\n * Execute action name if defined in _actionRecord.\n */\n protected _$execAction(name: ActionName<S, E>, eventDetail: StateEventDetail<S, E>): MaybePromise<void> {\n const actionFn = this._actionRecord[name];\n if (typeof actionFn === 'function') {\n this._logger.logMethodArgs?.('_$execAction', name);\n return this._actionRecord[name]?.call(this, eventDetail);\n }\n }\n\n /**\n * Reset machine to initial state.\n */\n protected _reset(): void {\n this._$data = this._initialState;\n }\n}\n"]}
package/fsm.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import { FiniteStateMachineBase } from './base.js';
2
- /**
3
- * Finite State Machine Base Class
4
- */
5
- export declare abstract class FiniteStateMachine<S extends string, E extends string> extends FiniteStateMachineBase<S, E> {
6
- /**
7
- * Current state.
8
- */
9
- get state(): S;
10
- /**
11
- * Transition finite state machine instance to new state.
12
- */
13
- transition(event: E): void;
14
- }
15
- //# sourceMappingURL=fsm.d.ts.map
package/fsm.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"fsm.d.ts","sourceRoot":"","sources":["src/fsm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,WAAW,CAAC;AAEjD;;GAEG;AACH,8BAAsB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAE,SAAQ,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC;IAC/G;;OAEG;IACH,IAAI,KAAK,IAAI,CAAC,CAEb;IAED;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;CAG3B"}
package/fsm.js DELETED
@@ -1,19 +0,0 @@
1
- import { FiniteStateMachineBase } from './base.js';
2
- /**
3
- * Finite State Machine Base Class
4
- */
5
- export class FiniteStateMachine extends FiniteStateMachineBase {
6
- /**
7
- * Current state.
8
- */
9
- get state() {
10
- return super._state;
11
- }
12
- /**
13
- * Transition finite state machine instance to new state.
14
- */
15
- transition(event) {
16
- super._transition(event);
17
- }
18
- }
19
- //# sourceMappingURL=fsm.js.map
package/fsm.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"fsm.js","sourceRoot":"","sources":["src/fsm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,WAAW,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAgB,kBAAuD,SAAQ,sBAA4B;IAC/G;;OAEG;IACH,IAAI,KAAK;QACP,OAAO,KAAK,CAAC,MAAM,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,KAAQ;QACjB,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;CACF","sourcesContent":["import {FiniteStateMachineBase} from './base.js';\n\n/**\n * Finite State Machine Base Class\n */\nexport abstract class FiniteStateMachine<S extends string, E extends string> extends FiniteStateMachineBase<S, E> {\n /**\n * Current state.\n */\n get state(): S {\n return super._state;\n }\n\n /**\n * Transition finite state machine instance to new state.\n */\n transition(event: E): void {\n super._transition(event);\n }\n}\n"]}
package/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './base.js';
2
- export * from './fsm.js';
3
- export * from './type.js';
4
- //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC","sourcesContent":["export * from './base.js';\nexport * from './fsm.js';\nexport * from './type.js';\n"]}
package/type.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["src/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,gBAAgB,CAAC,CAAC,EAAE,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,CAAC,CAAC;IACT,EAAE,EAAE,CAAC,CAAC;CACP;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;AAEtH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IACrD,OAAO,CAAC,EAAE,GACV,gBAAgB,GAChB,iBAAiB,GACjB,OAAO,CAAC,OAAO,GACf,OAAO,CAAC,QAAQ,GAChB,OAAO,CAAC,IAAI,CAAC,EAAE,GACf,WAAW,CAAC,EAAE,CAAC;AAEnB,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC"}
package/type.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=type.js.map
package/type.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["src/type.ts"],"names":[],"mappings":"","sourcesContent":["import type {MaybePromise} from '@alwatr/type';\n\nexport interface StateEventDetail<S, E> {\n from: S;\n event: E;\n to: S;\n}\n\nexport type StateRecord<S extends string, E extends string> = Partial<Record<S | '_all', Partial<Record<E, S>>>>;\n\nexport type Action<S extends string, E extends string> = (eventDetail?: StateEventDetail<S, E>) => MaybePromise<void>;\n\nexport type ActionName<S extends string, E extends string> =\n | `_on_${E}`\n | `_on_state_exit`\n | `_on_state_enter`\n | `_on_${S}_exit`\n | `_on_${S}_enter`\n | `_on_${S}_${E}`\n | `_on_all_${E}`;\n\nexport type ActionRecord<S extends string, E extends string> = Partial<Record<ActionName<S, E>, Action<S, E>>>;\n"]}