sygnal 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -63,7 +63,7 @@ type DefaultSinks<STATE, PROPS, ACTIONS, DATA> = {
63
63
  type CustomDriverSinks<STATE, PROPS, DRIVERS, ACTIONS, ACTION_ENTRY> = keyof DRIVERS extends never ? {
64
64
  [driver: string]: SinkValue<STATE, PROPS, ACTIONS, any, any>;
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>;
67
67
  }
68
68
 
69
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>>;
@@ -75,7 +75,7 @@ type WithDefaultActions<STATE, ACTIONS> = ACTIONS & {
75
75
  }
76
76
 
77
77
  type ComponentModel<STATE, PROPS, DRIVERS, ACTIONS> = keyof ACTIONS extends never ? {
78
- [action: string]: ModelEntry<STATE, PROPS, DRIVERS, WithDefaultActions<STATE, ACTIONS>, any>;
78
+ [action: string]: ModelEntry<STATE, PROPS, DRIVERS, WithDefaultActions<STATE, { [action: string]: any }>, any>;
79
79
  } : {
80
80
  [ACTION_KEY in keyof WithDefaultActions<STATE, ACTIONS>]?: ModelEntry<STATE, PROPS, DRIVERS, WithDefaultActions<STATE, ACTIONS>, WithDefaultActions<STATE, ACTIONS>[ACTION_KEY]>;
81
81
  };
@@ -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<ARRAY=any[]> = (array: ARRAY) => ARRAY
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 & CALCULATED, PROPS, FixDrivers<DRIVERS>, ACTIONS>;
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=any, CALCULATED=any, CONTEXT=any> = Component<STATE, any, DRIVERS, ACTIONS, CALCULATED, CONTEXT>
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
@@ -152,7 +152,6 @@ const createElementWithModules = (modules) => {
152
152
  }
153
153
  if (fun(sel)) {
154
154
  if (sel.name === 'Fragment') {
155
- console.log('Skipped instantiation');
156
155
  return sel(data || {}, children)
157
156
  }
158
157
  data ||= {};
package/dist/jsx.esm.js CHANGED
@@ -150,7 +150,6 @@ const createElementWithModules = (modules) => {
150
150
  }
151
151
  if (fun(sel)) {
152
152
  if (sel.name === 'Fragment') {
153
- console.log('Skipped instantiation');
154
153
  return sel(data || {}, children)
155
154
  }
156
155
  data ||= {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sygnal",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "An intuitive framework for building fast and small components or applications based on Cycle.js",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "types": "./dist/index.d.ts",
package/src/index.d.ts CHANGED
@@ -63,7 +63,7 @@ type DefaultSinks<STATE, PROPS, ACTIONS, DATA> = {
63
63
  type CustomDriverSinks<STATE, PROPS, DRIVERS, ACTIONS, ACTION_ENTRY> = keyof DRIVERS extends never ? {
64
64
  [driver: string]: SinkValue<STATE, PROPS, ACTIONS, any, any>;
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>;
67
67
  }
68
68
 
69
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>>;
@@ -75,7 +75,7 @@ type WithDefaultActions<STATE, ACTIONS> = ACTIONS & {
75
75
  }
76
76
 
77
77
  type ComponentModel<STATE, PROPS, DRIVERS, ACTIONS> = keyof ACTIONS extends never ? {
78
- [action: string]: ModelEntry<STATE, PROPS, DRIVERS, WithDefaultActions<STATE, ACTIONS>, any>;
78
+ [action: string]: ModelEntry<STATE, PROPS, DRIVERS, WithDefaultActions<STATE, { [action: string]: any }>, any>;
79
79
  } : {
80
80
  [ACTION_KEY in keyof WithDefaultActions<STATE, ACTIONS>]?: ModelEntry<STATE, PROPS, DRIVERS, WithDefaultActions<STATE, ACTIONS>, WithDefaultActions<STATE, ACTIONS>[ACTION_KEY]>;
81
81
  };
@@ -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<ARRAY=any[]> = (array: ARRAY) => ARRAY
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 & CALCULATED, PROPS, FixDrivers<DRIVERS>, ACTIONS>;
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=any, CALCULATED=any, CONTEXT=any> = Component<STATE, any, DRIVERS, ACTIONS, CALCULATED, CONTEXT>
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<ARRAY=any[]> = (array: ARRAY) => ARRAY
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: HTMLFormElement, options: { events: string | string[], preventDefault: boolean }): FIELDS & { event: Event, eventType: string };
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;