1+ /**
2+ * @inline
3+ */
4+ interface ToString {
5+ toString ( ) : string ;
6+ }
7+ /**
8+ * @inline
9+ */
10+ type StringResolvableMap = {
11+ [ key : string ] : StringResolvable ;
12+ } ;
13+ type StringResolvable = ToString | StringResolvableMap ;
14+ declare class FormArguments {
15+ private _args ;
16+ set ( name : string , arg : StringResolvable ) : void ;
17+ setAll ( args : Record < string , StringResolvable > ) : void ;
18+ getAll ( ) : Record < string , StringResolvable > ;
19+ get < Arg extends StringResolvable > ( name : string ) : Arg ;
20+ resolvePath ( path : string ) : StringResolvable ;
21+ resolveTemplate ( template : string ) : string ;
22+ normalize ( content : TextContent ) : NormalizedTextContent ;
23+ }
124interface Translate {
225 translate : string ;
326 args ?: Array < TextContent > ;
@@ -14,10 +37,15 @@ type NormalizedTextContent = {
1437 type : "array" ;
1538 array : Array < NormalizedTextContent > ;
1639} ;
40+ interface EventAction {
41+ event : string ;
42+ args ?: Array < unknown > ;
43+ }
1744interface FormAction {
1845 form ?: string ;
19- event ?: string ;
46+ event ?: string | Array < EventAction > ;
2047 eventArgs ?: Array < unknown > ;
48+ setArgs ?: Record < string , StringResolvable > ;
2149 copyArgs ?: boolean ;
2250}
2351interface DualButtonForm {
@@ -88,29 +116,6 @@ interface MultiButtonElementButton {
88116 action ?: FormAction ;
89117}
90118type Form = MultiButtonForm | InputForm | DualButtonForm ;
91- /**
92- * @inline
93- */
94- interface ToString {
95- toString ( ) : string ;
96- }
97- /**
98- * @inline
99- */
100- type StringResolvableMap = {
101- [ key : string ] : StringResolvable ;
102- } ;
103- type StringResolvable = ToString | StringResolvableMap ;
104- declare class FormArguments {
105- private _args ;
106- set ( name : string , arg : StringResolvable ) : void ;
107- setAll ( args : Record < string , StringResolvable > ) : void ;
108- getAll ( ) : Record < string , StringResolvable > ;
109- get < Arg extends StringResolvable > ( name : string ) : Arg ;
110- resolvePath ( path : string ) : string ;
111- resolveTemplate ( template : string ) : string ;
112- normalize ( content : TextContent ) : NormalizedTextContent ;
113- }
114119declare class FormError extends Error {
115120 constructor ( msg : string ) ;
116121}
@@ -120,18 +125,33 @@ declare class FormArgumentError extends FormError {
120125 readonly current : unknown ;
121126 constructor ( path : string , step : string , current : unknown ) ;
122127}
128+ interface Entrypoint {
129+ form ?: string ;
130+ events ?: string | Array < EventAction > ;
131+ eventArgs ?: Array < unknown > ;
132+ }
123133interface FormHub {
124- entrypoint : string ;
134+ entrypoint : string | Entrypoint ;
125135 forms : Record < string , Form > ;
126136}
137+ declare class FormEventProducer {
138+ protected _hub : FormHub ;
139+ protected _formAction : FormAction | undefined ;
140+ protected _args : FormArguments ;
141+ static fromFormHub ( hub : FormHub ) : FormEventProducer ;
142+ constructor ( hub : FormHub , formAction ?: FormAction , previousArgs ?: FormArguments ) ;
143+ get args ( ) : FormArguments ;
144+ getInitialForm ( ) : Form | undefined ;
145+ iterator ( ) : Generator < FormEvent , void , unknown > ;
146+ }
127147declare class FormEvent {
128148 protected _form : Form | undefined ;
129149 protected _name : string | undefined ;
130150 protected _continueProcessing : boolean ;
131151 protected readonly _hub : FormHub ;
132152 protected _args : FormArguments ;
133153 protected _eventArgs : Array < unknown > ;
134- constructor ( hub : FormHub , action ?: FormAction , previousArgs ? : FormArguments ) ;
154+ constructor ( hub : FormHub , eventAction : EventAction | undefined , args : FormArguments ) ;
135155 loadForm ( name : string ) : Form ;
136156 loadForm ( name : string , type : "multi-button" ) : MultiButtonForm ;
137157 loadForm ( name : string , type : "input" ) : InputForm ;
@@ -153,6 +173,6 @@ type EventReceiverFunction = (event: FormEvent) => Promise<void>;
153173 */
154174type EventReceiverMap = Record < string , EventReceiverFunction > ;
155175type EventReceiver = EventReceiverFunction | EventReceiverMap | undefined ;
156- declare const triggerEvent : ( event : FormEvent , receiver : EventReceiver ) => Promise < Form | undefined > ;
176+ declare const triggerEvent : ( eventProducer : FormEventProducer , receiver : EventReceiver ) => Promise < Form | undefined > ;
157177declare const _ : ( value : string , ...args : Array < TextContent > ) => Translate ;
158- export { InputForm , InputValue , InputElement , InputElementSlider , InputElementDropdown , InputElementText , InputElementToggle , MultiButtonForm , MultiButtonElement , MultiButtonElementButton , DualButtonForm , DualButtonElement , DualButtonElementButton , Form , StringResolvable , FormArguments , FormError , FormArgumentError , FormEvent , EventReceiver , triggerEvent , FormHub , Translate , TextContent , NormalizedTextContent , FormAction , _ } ;
178+ export { InputForm , InputValue , InputElement , InputElementSlider , InputElementDropdown , InputElementText , InputElementToggle , MultiButtonForm , MultiButtonElement , MultiButtonElementButton , DualButtonForm , DualButtonElement , DualButtonElementButton , Form , StringResolvable , FormArguments , FormError , FormArgumentError , FormEventProducer , FormEvent , EventReceiver , triggerEvent , Entrypoint , FormHub , Translate , TextContent , NormalizedTextContent , EventAction , FormAction , _ } ;
0 commit comments