@@ -5,39 +5,54 @@ import { type Reference, SYMBOL_INPUT_BOOLEAN } from '../../types'
55import { assert } from '../../utilities/assert'
66import { reducer } from './reducer'
77import {
8- type ActionDefault ,
9- type ActionDescription ,
10- type ActionOption ,
11- type ActionReference ,
12- type Actions ,
13- type ActionVariable ,
14- type Settings ,
15- type State ,
16- TypeAction ,
8+ type InputBooleanActionDefault ,
9+ type InputBooleanActionDescription ,
10+ type InputBooleanActionOption ,
11+ type InputBooleanActionReference ,
12+ type InputBooleanActions ,
13+ type InputBooleanActionVariable ,
14+ type InputBooleanSettings ,
15+ type InputBooleanState ,
16+ InputBooleanTypeAction ,
1717} from './types'
1818
19- const fluentReducer = ( log : Actions ) : State => {
19+ const fluentReducer = ( log : InputBooleanActions ) : InputBooleanState => {
2020 const reference = (
21- find ( log , ( action ) => action . type === TypeAction . Reference ) as ActionReference | undefined
21+ find ( log , ( action ) => action . type === InputBooleanTypeAction . Reference ) as
22+ | InputBooleanActionReference
23+ | undefined
2224 ) ?. payload
2325
24- const description = find ( log , ( action ) => action . type === TypeAction . Description ) ?. payload
26+ const description = find (
27+ log ,
28+ ( action ) => action . type === InputBooleanTypeAction . Description ,
29+ ) ?. payload
2530
2631 const _default = (
27- find ( log , ( action ) => action . type === TypeAction . Default ) as ActionDefault | undefined
32+ find ( log , ( action ) => action . type === InputBooleanTypeAction . Default ) as
33+ | InputBooleanActionDefault
34+ | undefined
2835 ) ?. payload
2936
3037 const isEmpty =
3138 log . length === 0 ||
32- ! some ( log , ( action ) => action . type === TypeAction . Option || action . type === TypeAction . Variable )
39+ ! some (
40+ log ,
41+ ( action ) =>
42+ action . type === InputBooleanTypeAction . Option ||
43+ action . type === InputBooleanTypeAction . Variable ,
44+ )
3345
3446 const rlog = reverse ( [ ...log ] )
3547
3648 const table = {
3749 options : assign (
3850 { } ,
3951 ...map (
40- filter ( rlog , ( { type } ) => type === TypeAction . Option ) as ActionOption [ ] ,
52+ filter (
53+ rlog ,
54+ ( { type } ) => type === InputBooleanTypeAction . Option ,
55+ ) as InputBooleanActionOption [ ] ,
4156 ( { payload } ) : { [ key : string ] : boolean } =>
4257 assign (
4358 { } ,
@@ -49,7 +64,10 @@ const fluentReducer = (log: Actions): State => {
4964 variables : assign (
5065 { } ,
5166 ...map (
52- filter ( rlog , ( { type } ) => type === TypeAction . Variable ) as ActionVariable [ ] ,
67+ filter (
68+ rlog ,
69+ ( { type } ) => type === InputBooleanTypeAction . Variable ,
70+ ) as InputBooleanActionVariable [ ] ,
5371 ( { payload } ) : { [ key : string ] : boolean } =>
5472 assign (
5573 { } ,
@@ -73,102 +91,104 @@ const fluentReducer = (log: Actions): State => {
7391 }
7492}
7593
76- export const boolean = builder < Settings > ( [
94+ export const boolean = builder < InputBooleanSettings > ( [
7795 {
7896 [ Options . Interface ] : ( dispatch ) => ( {
7997 reference ( reference : Reference ) {
8098 assert . reference ( reference )
8199
82- return dispatch < ActionReference > ( {
100+ return dispatch < InputBooleanActionReference > ( {
83101 payload : reference ,
84- type : TypeAction . Reference ,
102+ type : InputBooleanTypeAction . Reference ,
85103 } )
86104 } ,
87105 } ) ,
88106 [ Options . Keys ] : [ 'reference' ] ,
89107 [ Options . Once ] : true ,
90108 [ Options . Reducer ] : fluentReducer ,
91- [ Options . Type ] : TypeAction . Reference ,
109+ [ Options . Type ] : InputBooleanTypeAction . Reference ,
92110 } ,
93111 {
94- [ Options . Dependencies ] : [ TypeAction . Reference ] ,
112+ [ Options . Dependencies ] : [ InputBooleanTypeAction . Reference ] ,
95113 [ Options . Interface ] : ( dispatch ) => ( {
96114 description ( description : string ) {
97115 assert . string ( description )
98116
99- return dispatch < ActionDescription > ( {
117+ return dispatch < InputBooleanActionDescription > ( {
100118 payload : description ,
101- type : TypeAction . Description ,
119+ type : InputBooleanTypeAction . Description ,
102120 } )
103121 } ,
104122 } ) ,
105123 [ Options . Keys ] : [ 'description' ] ,
106124 [ Options . Once ] : true ,
107125 [ Options . Reducer ] : fluentReducer ,
108- [ Options . Type ] : TypeAction . Description ,
126+ [ Options . Type ] : InputBooleanTypeAction . Description ,
109127 } ,
110128 {
111- [ Options . Conflicts ] : [ TypeAction . Default ] ,
112- [ Options . Dependencies ] : [ TypeAction . Description ] ,
129+ [ Options . Conflicts ] : [ InputBooleanTypeAction . Default ] ,
130+ [ Options . Dependencies ] : [ InputBooleanTypeAction . Description ] ,
113131 [ Options . Interface ] : ( dispatch , _ , state ) => ( {
114132 option ( ...value : [ string | undefined , string | undefined ] ) {
115133 assert . inputDichotomousOption ( value , state . options )
116134
117- return dispatch < ActionOption > ( {
135+ return dispatch < InputBooleanActionOption > ( {
118136 payload : {
119137 false : value [ 1 ] ,
120138 true : value [ 0 ] ,
121139 } ,
122- type : TypeAction . Option ,
140+ type : InputBooleanTypeAction . Option ,
123141 } )
124142 } ,
125143 } ) ,
126144 [ Options . Keys ] : [ 'option' ] ,
127145 [ Options . Once ] : false ,
128146 [ Options . Reducer ] : fluentReducer ,
129- [ Options . Type ] : TypeAction . Option ,
147+ [ Options . Type ] : InputBooleanTypeAction . Option ,
130148 } ,
131149 {
132- [ Options . Conflicts ] : [ TypeAction . Default ] ,
133- [ Options . Dependencies ] : [ TypeAction . Description ] ,
150+ [ Options . Conflicts ] : [ InputBooleanTypeAction . Default ] ,
151+ [ Options . Dependencies ] : [ InputBooleanTypeAction . Description ] ,
134152 [ Options . Interface ] : ( dispatch , _ , state ) => ( {
135153 variable ( ...value : [ string | undefined , string | undefined ] ) {
136154 assert . inputBooleanVariable ( value , state . variables )
137155
138- return dispatch < ActionVariable > ( {
156+ return dispatch < InputBooleanActionVariable > ( {
139157 payload : {
140158 false : value [ 1 ] ,
141159 true : value [ 0 ] ,
142160 } ,
143- type : TypeAction . Variable ,
161+ type : InputBooleanTypeAction . Variable ,
144162 } )
145163 } ,
146164 } ) ,
147165 [ Options . Keys ] : [ 'variable' ] ,
148166 [ Options . Once ] : false ,
149167 [ Options . Reducer ] : fluentReducer ,
150- [ Options . Type ] : TypeAction . Variable ,
168+ [ Options . Type ] : InputBooleanTypeAction . Variable ,
151169 } ,
152170 {
153- [ Options . Dependencies ] : [ TypeAction . Description ] ,
171+ [ Options . Dependencies ] : [ InputBooleanTypeAction . Description ] ,
154172 [ Options . Enabled ] : ( log ) =>
155173 some (
156174 log ,
157- ( action ) => action . type === TypeAction . Option || action . type === TypeAction . Variable ,
175+ ( action ) =>
176+ action . type === InputBooleanTypeAction . Option ||
177+ action . type === InputBooleanTypeAction . Variable ,
158178 ) ,
159179 [ Options . Interface ] : ( dispatch ) => ( {
160180 default ( value : boolean ) {
161181 assert . boolean ( value )
162182
163- return dispatch < ActionDefault > ( {
183+ return dispatch < InputBooleanActionDefault > ( {
164184 payload : value ,
165- type : TypeAction . Default ,
185+ type : InputBooleanTypeAction . Default ,
166186 } )
167187 } ,
168188 } ) ,
169189 [ Options . Keys ] : [ 'default' ] ,
170190 [ Options . Once ] : true ,
171191 [ Options . Reducer ] : fluentReducer ,
172- [ Options . Type ] : TypeAction . Default ,
192+ [ Options . Type ] : InputBooleanTypeAction . Default ,
173193 } ,
174194] )
0 commit comments