sygnal 4.0.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +19 -20
- package/dist/jsx.cjs.js +0 -1
- package/dist/jsx.esm.js +0 -1
- package/package.json +1 -1
- package/src/index.d.ts +19 -19
- package/src/sygnal.d.ts +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -51,22 +51,22 @@ type Event<DATA=any> = { type: string, data: DATA }
|
|
|
51
51
|
* - true: Whatever value is received from the intent for this action is passed on as-is.
|
|
52
52
|
* - Function: A reducer
|
|
53
53
|
*/
|
|
54
|
-
type SinkValue<STATE, PROPS, ACTIONS, DATA, RETURN> = true | Reducer<STATE, PROPS, ACTIONS, DATA, RETURN>
|
|
54
|
+
type SinkValue<STATE, PROPS, ACTIONS, DATA, RETURN, CALCULATED> = true | Reducer<STATE & CALCULATED, PROPS, ACTIONS, DATA, RETURN>
|
|
55
55
|
|
|
56
|
-
type DefaultSinks<STATE, PROPS, ACTIONS, DATA> = {
|
|
57
|
-
STATE?: SinkValue<STATE, PROPS, ACTIONS, DATA, STATE>;
|
|
58
|
-
EVENTS?: SinkValue<STATE, PROPS, ACTIONS, DATA, Event>;
|
|
59
|
-
LOG?: SinkValue<STATE, PROPS, ACTIONS, DATA, any>;
|
|
60
|
-
PARENT?: SinkValue<STATE, PROPS, ACTIONS, DATA, any>;
|
|
56
|
+
type DefaultSinks<STATE, PROPS, ACTIONS, DATA, CALCULATED> = {
|
|
57
|
+
STATE?: SinkValue<STATE, PROPS, ACTIONS, DATA, STATE, CALCULATED>;
|
|
58
|
+
EVENTS?: SinkValue<STATE, PROPS, ACTIONS, DATA, Event, CALCULATED>;
|
|
59
|
+
LOG?: SinkValue<STATE, PROPS, ACTIONS, DATA, any, CALCULATED>;
|
|
60
|
+
PARENT?: SinkValue<STATE, PROPS, ACTIONS, DATA, any, CALCULATED>;
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
type CustomDriverSinks<STATE, PROPS, DRIVERS, ACTIONS, ACTION_ENTRY> = keyof DRIVERS extends never ? {
|
|
64
|
-
[driver: string]: SinkValue<STATE, PROPS, ACTIONS, any, any>;
|
|
63
|
+
type CustomDriverSinks<STATE, PROPS, DRIVERS, ACTIONS, ACTION_ENTRY, CALCULATED> = keyof DRIVERS extends never ? {
|
|
64
|
+
[driver: string]: SinkValue<STATE, PROPS, ACTIONS, any, any, CALCULATED>;
|
|
65
65
|
} : {
|
|
66
|
-
[DRIVER_KEY in keyof DRIVERS]: SinkValue<STATE, PROPS, ACTIONS, ACTION_ENTRY, DRIVERS[DRIVER_KEY]>;
|
|
66
|
+
[DRIVER_KEY in keyof DRIVERS]: SinkValue<STATE, PROPS, ACTIONS, ACTION_ENTRY, DRIVERS[DRIVER_KEY] extends { source: any, sink: any } ? DRIVERS[DRIVER_KEY]["sink"] : any, CALCULATED>;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
type ModelEntry<STATE, PROPS, DRIVERS, ACTIONS, ACTION_ENTRY> = SinkValue<STATE, PROPS, ACTIONS, ACTION_ENTRY, STATE> | Partial<DefaultSinks<STATE, PROPS, ACTIONS, ACTION_ENTRY> & CustomDriverSinks<STATE, PROPS, DRIVERS, ACTIONS, ACTION_ENTRY>>;
|
|
69
|
+
type ModelEntry<STATE, PROPS, DRIVERS, ACTIONS, ACTION_ENTRY, CALCULATED> = SinkValue<STATE, PROPS, ACTIONS, ACTION_ENTRY, STATE, CALCULATED> | Partial<DefaultSinks<STATE, PROPS, ACTIONS, ACTION_ENTRY, CALCULATED> & CustomDriverSinks<STATE, PROPS, DRIVERS, ACTIONS, ACTION_ENTRY, CALCULATED>>;
|
|
70
70
|
|
|
71
71
|
type WithDefaultActions<STATE, ACTIONS> = ACTIONS & {
|
|
72
72
|
BOOTSTRAP?: never;
|
|
@@ -74,10 +74,10 @@ type WithDefaultActions<STATE, ACTIONS> = ACTIONS & {
|
|
|
74
74
|
HYDRATE?: any;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
type ComponentModel<STATE, PROPS, DRIVERS, ACTIONS> = keyof ACTIONS extends never ? {
|
|
78
|
-
[action: string]: ModelEntry<STATE, PROPS, DRIVERS, WithDefaultActions<STATE,
|
|
77
|
+
type ComponentModel<STATE, PROPS, DRIVERS, ACTIONS, CALCULATED> = keyof ACTIONS extends never ? {
|
|
78
|
+
[action: string]: ModelEntry<STATE, PROPS, DRIVERS, WithDefaultActions<STATE, { [action: string]: any }>, any, CALCULATED>;
|
|
79
79
|
} : {
|
|
80
|
-
[ACTION_KEY in keyof WithDefaultActions<STATE, ACTIONS>]?: ModelEntry<STATE, PROPS, DRIVERS, WithDefaultActions<STATE, ACTIONS>, WithDefaultActions<STATE, ACTIONS>[ACTION_KEY]>;
|
|
80
|
+
[ACTION_KEY in keyof WithDefaultActions<STATE, ACTIONS>]?: ModelEntry<STATE, PROPS, DRIVERS, WithDefaultActions<STATE, ACTIONS>, WithDefaultActions<STATE, ACTIONS>[ACTION_KEY], CALCULATED>;
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
type ChildSource = {
|
|
@@ -140,7 +140,7 @@ type Lense<PARENT_STATE=any, CHILD_STATE=any> = {
|
|
|
140
140
|
set: (state: PARENT_STATE, childState: CHILD_STATE) => PARENT_STATE;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
type Filter<
|
|
143
|
+
type Filter<ITEM=any> = (item: ITEM) => boolean
|
|
144
144
|
|
|
145
145
|
type SortFunction<ITEM=any> = (a: ITEM, b: ITEM) => number
|
|
146
146
|
type SortObject<ITEM=any> = {
|
|
@@ -162,17 +162,17 @@ type FixDrivers<DRIVERS> =
|
|
|
162
162
|
* @template CALCULATED - Calculated state values (key = calculated variable name; value = type of the calculated variable)
|
|
163
163
|
* @template CONTEXT - Context (key = context variable name; value = type of the context variable)
|
|
164
164
|
*/
|
|
165
|
-
type Component<STATE=any, PROPS={[prop: string]: any}, DRIVERS={}, ACTIONS={}, CALCULATED={}, CONTEXT={}> = ComponentProps<STATE, PROPS, CONTEXT> & {
|
|
165
|
+
type Component<STATE=any, PROPS={[prop: string]: any}, DRIVERS={}, ACTIONS={}, CALCULATED={}, CONTEXT={}> = ComponentProps<STATE & CALCULATED, PROPS, CONTEXT> & {
|
|
166
166
|
label?: string;
|
|
167
167
|
DOMSourceName?: string;
|
|
168
168
|
stateSourceName?: string;
|
|
169
169
|
requestSourceName?: string;
|
|
170
|
-
model?: ComponentModel<STATE, PROPS, FixDrivers<DRIVERS>, ACTIONS>;
|
|
171
|
-
intent?: ComponentIntent<STATE, FixDrivers<DRIVERS>, ACTIONS>;
|
|
170
|
+
model?: ComponentModel<STATE, PROPS, FixDrivers<DRIVERS>, ACTIONS, CALCULATED>;
|
|
171
|
+
intent?: ComponentIntent<STATE & CALCULATED, FixDrivers<DRIVERS>, ACTIONS>;
|
|
172
172
|
initialState?: STATE;
|
|
173
173
|
calculated?: Calculated<STATE, CALCULATED>;
|
|
174
174
|
storeCalculatedInState?: boolean;
|
|
175
|
-
context?: Context<STATE, CONTEXT>;
|
|
175
|
+
context?: Context<STATE & CALCULATED, CONTEXT>;
|
|
176
176
|
peers?: { [name: string]: Component };
|
|
177
177
|
components?: { [name: string]: Component };
|
|
178
178
|
debug?: boolean;
|
|
@@ -181,13 +181,12 @@ type Component<STATE=any, PROPS={[prop: string]: any}, DRIVERS={}, ACTIONS={}, C
|
|
|
181
181
|
/**
|
|
182
182
|
* Sygnal Root Component
|
|
183
183
|
* @template STATE - State
|
|
184
|
-
* @template PROPS - Props (from JSX element)
|
|
185
184
|
* @template DRIVERS - Custom Drivers (default drivers are automatically applied)
|
|
186
185
|
* @template ACTIONS - Actions (key = action name; value = type expected for Observable values for that action)
|
|
187
186
|
* @template CALCULATED - Calculated state values (key = calculated variable name; value = type of the calculated variable)
|
|
188
187
|
* @template CONTEXT - Context (key = context variable name; value = type of the context variable)
|
|
189
188
|
*/
|
|
190
|
-
type RootComponent<STATE=any, DRIVERS={}, ACTIONS=
|
|
189
|
+
type RootComponent<STATE=any, DRIVERS={}, ACTIONS={}, CALCULATED=any, CONTEXT=any> = Component<STATE, any, DRIVERS, ACTIONS, CALCULATED, CONTEXT>
|
|
191
190
|
|
|
192
191
|
type CollectionProps<PROPS=any> = {
|
|
193
192
|
of: any;
|
package/dist/jsx.cjs.js
CHANGED
package/dist/jsx.esm.js
CHANGED
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -51,22 +51,22 @@ export type Event<DATA=any> = { type: string, data: DATA }
|
|
|
51
51
|
* - true: Whatever value is received from the intent for this action is passed on as-is.
|
|
52
52
|
* - Function: A reducer
|
|
53
53
|
*/
|
|
54
|
-
type SinkValue<STATE, PROPS, ACTIONS, DATA, RETURN> = true | Reducer<STATE, PROPS, ACTIONS, DATA, RETURN>
|
|
54
|
+
type SinkValue<STATE, PROPS, ACTIONS, DATA, RETURN, CALCULATED> = true | Reducer<STATE & CALCULATED, PROPS, ACTIONS, DATA, RETURN>
|
|
55
55
|
|
|
56
|
-
type DefaultSinks<STATE, PROPS, ACTIONS, DATA> = {
|
|
57
|
-
STATE?: SinkValue<STATE, PROPS, ACTIONS, DATA, STATE>;
|
|
58
|
-
EVENTS?: SinkValue<STATE, PROPS, ACTIONS, DATA, Event>;
|
|
59
|
-
LOG?: SinkValue<STATE, PROPS, ACTIONS, DATA, any>;
|
|
60
|
-
PARENT?: SinkValue<STATE, PROPS, ACTIONS, DATA, any>;
|
|
56
|
+
type DefaultSinks<STATE, PROPS, ACTIONS, DATA, CALCULATED> = {
|
|
57
|
+
STATE?: SinkValue<STATE, PROPS, ACTIONS, DATA, STATE, CALCULATED>;
|
|
58
|
+
EVENTS?: SinkValue<STATE, PROPS, ACTIONS, DATA, Event, CALCULATED>;
|
|
59
|
+
LOG?: SinkValue<STATE, PROPS, ACTIONS, DATA, any, CALCULATED>;
|
|
60
|
+
PARENT?: SinkValue<STATE, PROPS, ACTIONS, DATA, any, CALCULATED>;
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
type CustomDriverSinks<STATE, PROPS, DRIVERS, ACTIONS, ACTION_ENTRY> = keyof DRIVERS extends never ? {
|
|
64
|
-
[driver: string]: SinkValue<STATE, PROPS, ACTIONS, any, any>;
|
|
63
|
+
type CustomDriverSinks<STATE, PROPS, DRIVERS, ACTIONS, ACTION_ENTRY, CALCULATED> = keyof DRIVERS extends never ? {
|
|
64
|
+
[driver: string]: SinkValue<STATE, PROPS, ACTIONS, any, any, CALCULATED>;
|
|
65
65
|
} : {
|
|
66
|
-
[DRIVER_KEY in keyof DRIVERS]: SinkValue<STATE, PROPS, ACTIONS, ACTION_ENTRY, DRIVERS[DRIVER_KEY]>;
|
|
66
|
+
[DRIVER_KEY in keyof DRIVERS]: SinkValue<STATE, PROPS, ACTIONS, ACTION_ENTRY, DRIVERS[DRIVER_KEY] extends { source: any, sink: any } ? DRIVERS[DRIVER_KEY]["sink"] : any, CALCULATED>;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
type ModelEntry<STATE, PROPS, DRIVERS, ACTIONS, ACTION_ENTRY> = SinkValue<STATE, PROPS, ACTIONS, ACTION_ENTRY, STATE> | Partial<DefaultSinks<STATE, PROPS, ACTIONS, ACTION_ENTRY> & CustomDriverSinks<STATE, PROPS, DRIVERS, ACTIONS, ACTION_ENTRY>>;
|
|
69
|
+
type ModelEntry<STATE, PROPS, DRIVERS, ACTIONS, ACTION_ENTRY, CALCULATED> = SinkValue<STATE, PROPS, ACTIONS, ACTION_ENTRY, STATE, CALCULATED> | Partial<DefaultSinks<STATE, PROPS, ACTIONS, ACTION_ENTRY, CALCULATED> & CustomDriverSinks<STATE, PROPS, DRIVERS, ACTIONS, ACTION_ENTRY, CALCULATED>>;
|
|
70
70
|
|
|
71
71
|
type WithDefaultActions<STATE, ACTIONS> = ACTIONS & {
|
|
72
72
|
BOOTSTRAP?: never;
|
|
@@ -74,10 +74,10 @@ type WithDefaultActions<STATE, ACTIONS> = ACTIONS & {
|
|
|
74
74
|
HYDRATE?: any;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
type ComponentModel<STATE, PROPS, DRIVERS, ACTIONS> = keyof ACTIONS extends never ? {
|
|
78
|
-
[action: string]: ModelEntry<STATE, PROPS, DRIVERS, WithDefaultActions<STATE,
|
|
77
|
+
type ComponentModel<STATE, PROPS, DRIVERS, ACTIONS, CALCULATED> = keyof ACTIONS extends never ? {
|
|
78
|
+
[action: string]: ModelEntry<STATE, PROPS, DRIVERS, WithDefaultActions<STATE, { [action: string]: any }>, any, CALCULATED>;
|
|
79
79
|
} : {
|
|
80
|
-
[ACTION_KEY in keyof WithDefaultActions<STATE, ACTIONS>]?: ModelEntry<STATE, PROPS, DRIVERS, WithDefaultActions<STATE, ACTIONS>, WithDefaultActions<STATE, ACTIONS>[ACTION_KEY]>;
|
|
80
|
+
[ACTION_KEY in keyof WithDefaultActions<STATE, ACTIONS>]?: ModelEntry<STATE, PROPS, DRIVERS, WithDefaultActions<STATE, ACTIONS>, WithDefaultActions<STATE, ACTIONS>[ACTION_KEY], CALCULATED>;
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
type ChildSource = {
|
|
@@ -140,7 +140,7 @@ export type Lense<PARENT_STATE=any, CHILD_STATE=any> = {
|
|
|
140
140
|
set: (state: PARENT_STATE, childState: CHILD_STATE) => PARENT_STATE;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
export type Filter<
|
|
143
|
+
export type Filter<ITEM=any> = (item: ITEM) => boolean
|
|
144
144
|
|
|
145
145
|
export type SortFunction<ITEM=any> = (a: ITEM, b: ITEM) => number
|
|
146
146
|
export type SortObject<ITEM=any> = {
|
|
@@ -162,17 +162,17 @@ type FixDrivers<DRIVERS> =
|
|
|
162
162
|
* @template CALCULATED - Calculated state values (key = calculated variable name; value = type of the calculated variable)
|
|
163
163
|
* @template CONTEXT - Context (key = context variable name; value = type of the context variable)
|
|
164
164
|
*/
|
|
165
|
-
export type Component<STATE=any, PROPS={[prop: string]: any}, DRIVERS={}, ACTIONS={}, CALCULATED={}, CONTEXT={}> = ComponentProps<STATE, PROPS, CONTEXT> & {
|
|
165
|
+
export type Component<STATE=any, PROPS={[prop: string]: any}, DRIVERS={}, ACTIONS={}, CALCULATED={}, CONTEXT={}> = ComponentProps<STATE & CALCULATED, PROPS, CONTEXT> & {
|
|
166
166
|
label?: string;
|
|
167
167
|
DOMSourceName?: string;
|
|
168
168
|
stateSourceName?: string;
|
|
169
169
|
requestSourceName?: string;
|
|
170
|
-
model?: ComponentModel<STATE, PROPS, FixDrivers<DRIVERS>, ACTIONS>;
|
|
171
|
-
intent?: ComponentIntent<STATE, FixDrivers<DRIVERS>, ACTIONS>;
|
|
170
|
+
model?: ComponentModel<STATE, PROPS, FixDrivers<DRIVERS>, ACTIONS, CALCULATED>;
|
|
171
|
+
intent?: ComponentIntent<STATE & CALCULATED, FixDrivers<DRIVERS>, ACTIONS>;
|
|
172
172
|
initialState?: STATE;
|
|
173
173
|
calculated?: Calculated<STATE, CALCULATED>;
|
|
174
174
|
storeCalculatedInState?: boolean;
|
|
175
|
-
context?: Context<STATE, CONTEXT>;
|
|
175
|
+
context?: Context<STATE & CALCULATED, CONTEXT>;
|
|
176
176
|
peers?: { [name: string]: Component };
|
|
177
177
|
components?: { [name: string]: Component };
|
|
178
178
|
debug?: boolean;
|
|
@@ -186,7 +186,7 @@ export type Component<STATE=any, PROPS={[prop: string]: any}, DRIVERS={}, ACTION
|
|
|
186
186
|
* @template CALCULATED - Calculated state values (key = calculated variable name; value = type of the calculated variable)
|
|
187
187
|
* @template CONTEXT - Context (key = context variable name; value = type of the context variable)
|
|
188
188
|
*/
|
|
189
|
-
export type RootComponent<STATE=any, DRIVERS={}, ACTIONS=
|
|
189
|
+
export type RootComponent<STATE=any, DRIVERS={}, ACTIONS={}, CALCULATED=any, CONTEXT=any> = Component<STATE, any, DRIVERS, ACTIONS, CALCULATED, CONTEXT>
|
|
190
190
|
|
|
191
191
|
export type CollectionProps<PROPS=any> = {
|
|
192
192
|
of: any;
|
package/src/sygnal.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ type Lense<PARENT_STATE=any, CHILD_STATE=any> = {
|
|
|
3
3
|
set: (state: PARENT_STATE, childState: CHILD_STATE) => PARENT_STATE;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
type Filter<
|
|
6
|
+
type Filter<ITEM=any> = (item: ITEM) => boolean
|
|
7
7
|
|
|
8
8
|
type SortFunction<ITEM=any> = (a: ITEM, b: ITEM) => number
|
|
9
9
|
type SortObject<ITEM=any> = {
|
|
@@ -23,13 +23,15 @@ type SwitchableProps<PROPS=any> = {
|
|
|
23
23
|
state?: string | Lense;
|
|
24
24
|
} & Omit<PROPS, 'of' | 'state' | 'current'>;
|
|
25
25
|
|
|
26
|
-
type ClassesType = (string | string[] | { [className: string]: boolean })[]
|
|
26
|
+
type ClassesType = (string | string[] | { [className: string]: boolean | undefined })[]
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
declare module 'sygnal' {
|
|
30
|
+
import { MainDOMSource } from '@cycle/dom';
|
|
31
|
+
import { Stream } from 'xstream';
|
|
30
32
|
export function run(component: any, drivers?: any, options?: any): { hmr: (newComponent: any) => void }
|
|
31
33
|
export function classes(...classes: ClassesType): string;
|
|
32
|
-
export function processForm<FIELDS extends { [field: string]: any }>(target:
|
|
34
|
+
export function processForm<FIELDS extends { [field: string]: any }>(target: MainDOMSource, options?: { events?: string | string[], preventDefault?: boolean }): Stream<FIELDS & { event: Event, eventType: string }>;
|
|
33
35
|
export function Collection<PROPS extends { [prop: string]: any }>(
|
|
34
36
|
props: CollectionProps<PROPS>
|
|
35
37
|
): JSX.Element;
|