@reactables/core 1.3.0-beta.0 → 2.0.0-beta.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.
@@ -1,17 +1,14 @@
1
- import { Observable } from 'rxjs';
2
- import { SliceConfig, Cases } from './createSlice';
3
- import { Reactable, ActionCreatorTypeFromReducer } from '../Models/Reactable';
4
- import { Effect } from '../Models/Effect';
5
- import { Action } from '../Models/Action';
6
- export interface EffectsAndSources {
7
- effects?: Effect<unknown, unknown>[];
8
- sources?: Observable<Action<unknown>>[] | {
9
- [key: string]: Observable<unknown>;
10
- };
11
- }
12
- export interface RxConfig<T, S extends Cases<T>> extends SliceConfig<T, S>, EffectsAndSources {
13
- debug?: boolean;
14
- /**@deprecated Use storeValue modifier instead to add store value behaviour to reactable */
15
- storeValue?: boolean;
16
- }
17
- export declare const RxBuilder: <T, S extends Cases<T>>({ effects, sources, debug, storeValue, ...sliceConfig }: RxConfig<T, S>) => Reactable<T, { [K in keyof S]: ActionCreatorTypeFromReducer<S[K]>; }, { [K_2 in keyof S]: import("../Models/Action").ActionCreator<unknown>; } extends infer T_1 extends Record<string, unknown> ? { [K_1 in keyof T_1 as `${string & K_1}`]: `${string & K_1}`; } : never>;
1
+ import { SliceConfig, Cases } from './createSlice';
2
+ import { Reactable, ActionCreatorTypeFromReducer } from '../Models/Reactable';
3
+ import { Action } from '../Models/Action';
4
+ import { Observable } from 'rxjs';
5
+ export interface DestroyAction {
6
+ destroy: () => void;
7
+ }
8
+ export interface RxConfig<T, S extends Cases<T>> extends SliceConfig<T, S> {
9
+ debug?: boolean;
10
+ sources?: Observable<Action<unknown>>[];
11
+ }
12
+ export declare const RxBuilder: <T, S extends Cases<T>>({ sources, debug, ...sliceConfig }: RxConfig<T, S>) => Reactable<T, { [K in keyof S]: ActionCreatorTypeFromReducer<S[K]>; } & DestroyAction, { [K_2 in keyof S]: ActionCreatorTypeFromReducer<S[K_2]>; } & {
13
+ destroy: () => void;
14
+ } extends infer T_1 extends Record<string, unknown> ? { [K_1 in keyof T_1 as `${string & K_1}`]: `${string & K_1}`; } : never>;
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,4 +1,7 @@
1
- import { Observable, ObservedValueOf } from 'rxjs';
2
- import { Reactable } from '../Models';
3
- import { ActionObservableWithTypes } from '../Models/Reactable';
4
- export declare const combine: <T extends Record<string, Reactable<unknown, unknown, Record<string, string>>>>(sourceReactables: T) => [Observable<{ [K in keyof T]: ObservedValueOf<T[K][0]>; }>, { [K_1 in keyof T]: T[K_1][1]; }, ActionObservableWithTypes<{ [K_4 in ({ [K_3 in keyof T]: T[K_3] extends Reactable<unknown, unknown, infer P extends Record<string, string>> ? { [Pkey in keyof P as `[${K_3 & string}] - ${Pkey & string}`]: `[${K_3 & string}] - ${Pkey & string}`; } : never; } extends infer T_1 ? { [K_2 in keyof T_1]: { [K_3 in keyof T]: T[K_3] extends Reactable<unknown, unknown, infer P extends Record<string, string>> ? { [Pkey in keyof P as `[${K_3 & string}] - ${Pkey & string}`]: `[${K_3 & string}] - ${Pkey & string}`; } : never; }[K_2] extends Record<string, any> ? { [K_3 in keyof T]: T[K_3] extends Reactable<unknown, unknown, infer P extends Record<string, string>> ? { [Pkey in keyof P as `[${K_3 & string}] - ${Pkey & string}`]: `[${K_3 & string}] - ${Pkey & string}`; } : never; }[K_2] : never; } : never)[keyof T] extends infer T_2 ? T_2 extends ({ [K_3 in keyof T]: T[K_3] extends Reactable<unknown, unknown, infer P extends Record<string, string>> ? { [Pkey in keyof P as `[${K_3 & string}] - ${Pkey & string}`]: `[${K_3 & string}] - ${Pkey & string}`; } : never; } extends infer T_1 ? { [K_2 in keyof T_1]: { [K_3 in keyof T]: T[K_3] extends Reactable<unknown, unknown, infer P extends Record<string, string>> ? { [Pkey in keyof P as `[${K_3 & string}] - ${Pkey & string}`]: `[${K_3 & string}] - ${Pkey & string}`; } : never; }[K_2] extends Record<string, any> ? { [K_3 in keyof T]: T[K_3] extends Reactable<unknown, unknown, infer P extends Record<string, string>> ? { [Pkey in keyof P as `[${K_3 & string}] - ${Pkey & string}`]: `[${K_3 & string}] - ${Pkey & string}`; } : never; }[K_2] : never; } : never)[keyof T] ? T_2 extends any ? keyof T_2 : never : never : never]: ({ [K_3 in keyof T]: T[K_3] extends Reactable<unknown, unknown, infer P extends Record<string, string>> ? { [Pkey in keyof P as `[${K_3 & string}] - ${Pkey & string}`]: `[${K_3 & string}] - ${Pkey & string}`; } : never; } extends infer T_1 ? { [K_2 in keyof T_1]: { [K_3 in keyof T]: T[K_3] extends Reactable<unknown, unknown, infer P extends Record<string, string>> ? { [Pkey in keyof P as `[${K_3 & string}] - ${Pkey & string}`]: `[${K_3 & string}] - ${Pkey & string}`; } : never; }[K_2] extends Record<string, any> ? { [K_3 in keyof T]: T[K_3] extends Reactable<unknown, unknown, infer P extends Record<string, string>> ? { [Pkey in keyof P as `[${K_3 & string}] - ${Pkey & string}`]: `[${K_3 & string}] - ${Pkey & string}`; } : never; }[K_2] : never; } : never)[keyof T] extends infer T_3 ? T_3 extends ({ [K_3 in keyof T]: T[K_3] extends Reactable<unknown, unknown, infer P extends Record<string, string>> ? { [Pkey in keyof P as `[${K_3 & string}] - ${Pkey & string}`]: `[${K_3 & string}] - ${Pkey & string}`; } : never; } extends infer T_1 ? { [K_2 in keyof T_1]: { [K_3 in keyof T]: T[K_3] extends Reactable<unknown, unknown, infer P extends Record<string, string>> ? { [Pkey in keyof P as `[${K_3 & string}] - ${Pkey & string}`]: `[${K_3 & string}] - ${Pkey & string}`; } : never; }[K_2] extends Record<string, any> ? { [K_3 in keyof T]: T[K_3] extends Reactable<unknown, unknown, infer P extends Record<string, string>> ? { [Pkey in keyof P as `[${K_3 & string}] - ${Pkey & string}`]: `[${K_3 & string}] - ${Pkey & string}`; } : never; }[K_2] : never; } : never)[keyof T] ? T_3 extends { [k in K_4]?: any; } ? T_3[K_4] : never : never : never; }>];
1
+ import { Observable, ObservedValueOf } from 'rxjs';
2
+ import { Reactable } from '../Models';
3
+ import { DestroyAction } from './RxBuilder';
4
+ import { ActionObservableWithTypes } from '../Models/Reactable';
5
+ export declare const combine: <T extends Record<string, Reactable<unknown, DestroyAction, Record<string, string>>>>(sourceReactables: T) => [Observable<{ [K in keyof T]: ObservedValueOf<T[K][0]>; }>, { [K_1 in keyof T]: T[K_1][1]; } & DestroyAction, ActionObservableWithTypes<({ [K_3 in keyof T]: T[K_3] extends Reactable<unknown, DestroyAction, infer P extends Record<string, string>> ? { [Pkey in keyof P as `[${K_3 & string}] - ${Pkey & string}`]: `[${K_3 & string}] - ${Pkey & string}`; } : never; } extends infer T_1 ? { [K_2 in keyof T_1]: { [K_3 in keyof T]: T[K_3] extends Reactable<unknown, DestroyAction, infer P extends Record<string, string>> ? { [Pkey in keyof P as `[${K_3 & string}] - ${Pkey & string}`]: `[${K_3 & string}] - ${Pkey & string}`; } : never; }[K_2] extends Record<string, any> ? { [K_3 in keyof T]: T[K_3] extends Reactable<unknown, DestroyAction, infer P extends Record<string, string>> ? { [Pkey in keyof P as `[${K_3 & string}] - ${Pkey & string}`]: `[${K_3 & string}] - ${Pkey & string}`; } : never; }[K_2] : never; } : never)[keyof T] & {
6
+ [key: string]: string;
7
+ }>];
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,30 +1,28 @@
1
- import { Reactable } from '../Models';
2
- type ExpandedMap<T extends Record<string, Reactable<unknown, unknown>>> = {
3
- [K in keyof T]: T[K] extends Reactable<unknown, unknown, infer P> ? {
4
- [Pkey in keyof P as `[${K & string}] - ${Pkey & string}`]: `[${K & string}] - ${Pkey & string}`;
5
- } : never;
6
- };
7
- type Merge<U> = {
8
- [K in U extends any ? keyof U : never]: U extends {
9
- [k in K]?: any;
10
- } ? U[K] : never;
11
- };
12
- type FlattenedEntries<T> = Merge<{
13
- [K in keyof T]: T[K] extends Record<string, any> ? T[K] : never;
14
- }[keyof T]>;
15
- type CombinedActionStringMap<T extends Record<string, Reactable<unknown, unknown>>> = FlattenedEntries<ExpandedMap<T>>;
16
- /**
17
- * @description helper method to create an action type string map for a combined reacatable
18
- */
19
- export declare const combineActionTypeStringMaps: <T extends Record<string, Reactable<unknown, unknown, Record<string, string>>>>(sourceReactables: T) => CombinedActionStringMap<T>;
20
- export type ActionTypeString<S extends Record<string, unknown>, Z extends string> = Z extends undefined ? {
21
- [K in keyof S as `${string & K}`]: `${string & K}`;
22
- } : {
23
- [K in keyof S as `[${Z}] - ${string & K}`]: `[${Z}] - ${string & K}`;
24
- };
25
- /**
26
- * @description creates an action type string map from existing string maps or an ActionMap,
27
- * if given a parent key it will append a prefix to the resulting strings
28
- */
29
- export declare const createActionTypeStringMap: <S extends Record<string, unknown>, Z extends string = undefined>(types: S, parentKey?: Z) => ActionTypeString<S, Z>;
30
- export {};
1
+ import { Reactable } from '../Models';
2
+ import { DestroyAction } from './RxBuilder';
3
+ type ExpandedMap<T extends Record<string, Reactable<unknown, unknown & DestroyAction>>> = {
4
+ [K in keyof T]: T[K] extends Reactable<unknown, unknown & DestroyAction, infer P> ? {
5
+ [Pkey in keyof P as `[${K & string}] - ${Pkey & string}`]: `[${K & string}] - ${Pkey & string}`;
6
+ } : never;
7
+ };
8
+ type FlattenedEntries<T> = {
9
+ [K in keyof T]: T[K] extends Record<string, any> ? T[K] : never;
10
+ }[keyof T];
11
+ type CombinedActionStringMap<T extends Record<string, Reactable<unknown, unknown & DestroyAction>>> = FlattenedEntries<ExpandedMap<T>> & {
12
+ [key: string]: string;
13
+ };
14
+ /**
15
+ * @description helper method to create an action type string map for a combined reacatable
16
+ */
17
+ export declare const combineActionTypeStringMaps: <T extends Record<string, Reactable<unknown, DestroyAction, Record<string, string>>>>(sourceReactables: T) => CombinedActionStringMap<T>;
18
+ export type ActionTypeString<S extends Record<string, unknown>, Z extends string> = Z extends undefined ? {
19
+ [K in keyof S as `${string & K}`]: `${string & K}`;
20
+ } : {
21
+ [K in keyof S as `[${Z}] - ${string & K}`]: `[${Z}] - ${string & K}`;
22
+ };
23
+ /**
24
+ * @description creates an action type string map from existing string maps or an ActionMap,
25
+ * if given a parent key it will append a prefix to the resulting strings
26
+ */
27
+ export declare const createActionTypeStringMap: <S extends Record<string, unknown>, Z extends string = undefined>(types: S, parentKey?: Z) => ActionTypeString<S, Z>;
28
+ export {};
@@ -1,25 +1,20 @@
1
- import { Effect } from '../Models/Effect';
2
- import { Action, ActionCreator, ScopedEffects } from '../Models/Action';
3
- import { Reducer } from '../Models/Hub';
4
- export type SingleActionReducer<T, S> = (state: T, action: Action<S>) => T;
5
- export interface Slice<T> {
6
- actions: {
7
- [key: string]: ActionCreator<unknown>;
8
- };
9
- reducer: Reducer<T>;
10
- }
11
- export interface Cases<T> {
12
- [key: string]: SingleActionReducer<T, unknown> | {
13
- reducer: SingleActionReducer<T, unknown>;
14
- effects?: ((payload?: unknown) => ScopedEffects<unknown>) | Effect<unknown, unknown>[];
15
- };
16
- }
17
- export interface SliceConfig<T, S extends Cases<T>> {
18
- initialState: T;
19
- reducers: S;
20
- name?: string;
21
- }
22
- export declare const createSlice: <T, S extends Cases<T>>(config: SliceConfig<T, S>) => {
23
- reducer: Reducer<T>;
24
- actions: { [K in keyof S]: ActionCreator<unknown>; };
25
- };
1
+ import { Effect } from '../Models/Effect';
2
+ import { Action, ActionCreator, ScopedEffects } from '../Models/Action';
3
+ export declare const addEffects: <T>(actionCreator: ActionCreator<T>, scopedEffects: (payload: T) => ScopedEffects<T>) => ActionCreator<T>;
4
+ export type Reducer<T> = (state?: T, action?: Action<unknown>) => T;
5
+ export type SingleActionReducer<T, S> = (state: T, action: Action<S>) => T;
6
+ export interface Cases<T> {
7
+ [key: string]: SingleActionReducer<T, unknown> | {
8
+ reducer: SingleActionReducer<T, unknown>;
9
+ effects?: ((payload?: unknown) => ScopedEffects<unknown>) | Effect<unknown, unknown>[];
10
+ };
11
+ }
12
+ export interface SliceConfig<T, S extends Cases<T>> {
13
+ initialState: T;
14
+ reducers: S;
15
+ name?: string;
16
+ }
17
+ export declare const createSlice: <T, S extends Cases<T>>(config: SliceConfig<T, S>) => {
18
+ reducer: Reducer<T>;
19
+ actionCreators: { [K in keyof S]: ActionCreator<unknown>; };
20
+ };
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,4 +1,3 @@
1
- export { RxBuilder, EffectsAndSources, RxConfig } from './RxBuilder';
2
- export { storeValue, DestroyAction } from './storeValue';
3
- export { Cases } from './createSlice';
4
- export { combine } from './combine';
1
+ export { RxBuilder, RxConfig, DestroyAction } from './RxBuilder';
2
+ export { Cases, Reducer } from './createSlice';
3
+ export { combine } from './combine';
@@ -1,27 +1,27 @@
1
- /**
2
- * Modified from https://github.com/AsyncBanana/microdiff
3
- * v 1.3.2
4
- * @description handles serializable (JSON) objects only
5
- */
6
- export interface DifferenceCreate {
7
- type: 'CREATE';
8
- path: (string | number)[];
9
- value: unknown;
10
- }
11
- export interface DifferenceRemove {
12
- type: 'REMOVE';
13
- path: (string | number)[];
14
- oldValue: unknown;
15
- }
16
- export interface DifferenceChange {
17
- type: 'CHANGE';
18
- path: (string | number)[];
19
- value: unknown;
20
- oldValue: unknown;
21
- }
22
- export type Difference = DifferenceCreate | DifferenceRemove | DifferenceChange;
23
- interface Options {
24
- cyclesFix: boolean;
25
- }
26
- declare const jsonDiff: (obj: Record<string, any> | any[], newObj: Record<string, any> | any[], options?: Partial<Options>, _stack?: Record<string, any>[]) => Difference[];
27
- export default jsonDiff;
1
+ /**
2
+ * Modified from https://github.com/AsyncBanana/microdiff
3
+ * v 1.3.2
4
+ * @description handles serializable (JSON) objects only
5
+ */
6
+ export interface DifferenceCreate {
7
+ type: 'CREATE';
8
+ path: (string | number)[];
9
+ value: unknown;
10
+ }
11
+ export interface DifferenceRemove {
12
+ type: 'REMOVE';
13
+ path: (string | number)[];
14
+ oldValue: unknown;
15
+ }
16
+ export interface DifferenceChange {
17
+ type: 'CHANGE';
18
+ path: (string | number)[];
19
+ value: unknown;
20
+ oldValue: unknown;
21
+ }
22
+ export type Difference = DifferenceCreate | DifferenceRemove | DifferenceChange;
23
+ interface Options {
24
+ cyclesFix: boolean;
25
+ }
26
+ declare const jsonDiff: (obj: Record<string, any> | any[], newObj: Record<string, any> | any[], options?: Partial<Options>, _stack?: Record<string, any>[]) => Difference[];
27
+ export default jsonDiff;
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,11 +1,11 @@
1
- import { Effect } from './Effect';
2
- export interface ScopedEffects<T> {
3
- key?: string | number;
4
- effects: Effect<T, unknown>[];
5
- }
6
- export interface Action<T = undefined> {
7
- type?: string;
8
- scopedEffects?: ScopedEffects<T>;
9
- payload?: T;
10
- }
11
- export type ActionCreator<T> = (payload?: T) => Action<T>;
1
+ import { Effect } from './Effect';
2
+ export interface ScopedEffects<T> {
3
+ key?: string | number;
4
+ effects: Effect<T, unknown>[];
5
+ }
6
+ export interface Action<T = undefined> {
7
+ type?: string;
8
+ scopedEffects?: ScopedEffects<T>;
9
+ payload?: T;
10
+ }
11
+ export type ActionCreator<T> = (payload?: T) => Action<T>;
@@ -1,3 +1,3 @@
1
- import { OperatorFunction } from 'rxjs';
2
- import { Action } from './Action';
3
- export type Effect<T, S> = OperatorFunction<Action<T>, Action<S>>;
1
+ import { OperatorFunction } from 'rxjs';
2
+ import { Action } from './Action';
3
+ export type Effect<T, S> = OperatorFunction<Action<T>, Action<S>>;
@@ -1,15 +1,16 @@
1
- import { Observable } from 'rxjs';
2
- import { Action } from './Action';
3
- export type ActionCreatorTypeFromReducer<T> = T extends (state: any) => unknown ? () => void : T extends (state: any, action: Action<infer P>) => unknown ? (payload: P) => void : T extends {
4
- reducer: (state: any) => unknown;
5
- } ? () => void : T extends {
6
- reducer: (state: any, action: Action<infer P>) => unknown;
7
- } ? (payload: P) => void : never;
8
- export type ActionObservableWithTypes<T extends Record<string, string>> = Observable<Action<unknown>> & {
9
- types?: T;
10
- ofTypes?: (types: Array<keyof T>) => Observable<Action<unknown>>;
11
- };
12
- export type Reactable<T, S = ActionMap, U extends Record<string, string> = Record<string, string>> = [Observable<T>, S, ActionObservableWithTypes<U>?];
13
- export interface ActionMap {
14
- [key: string | number]: (payload?: unknown) => void | ActionMap;
15
- }
1
+ import { Observable } from 'rxjs';
2
+ import { Action } from './Action';
3
+ import { DestroyAction } from '../Helpers';
4
+ export type ActionCreatorTypeFromReducer<T> = T extends (state: any) => unknown ? () => void : T extends (state: any, action: Action<infer P>) => unknown ? (payload: P) => void : T extends {
5
+ reducer: (state: any) => unknown;
6
+ } ? () => void : T extends {
7
+ reducer: (state: any, action: Action<infer P>) => unknown;
8
+ } ? (payload: P) => void : never;
9
+ export type ActionObservableWithTypes<T extends Record<string, string>> = Observable<Action<unknown>> & {
10
+ types?: T;
11
+ ofTypes?: (types: Array<keyof T>) => Observable<Action<unknown>>;
12
+ };
13
+ export type Reactable<T, S extends DestroyAction = ActionMap & DestroyAction, U extends Record<string, string> = Record<string, string>> = [Observable<T>, S, ActionObservableWithTypes<U>?];
14
+ export interface ActionMap {
15
+ [key: string | number]: (payload?: unknown) => void | ActionMap;
16
+ }
@@ -1,4 +1,3 @@
1
- export { Action, ScopedEffects } from './Action';
2
- export { Effect } from './Effect';
3
- export { Hub, Reducer, HubConfig, StoreConfig, Dispatcher } from './Hub';
4
- export { Reactable, ActionMap, ActionObservableWithTypes } from './Reactable';
1
+ export { Action, ScopedEffects } from './Action';
2
+ export { Effect } from './Effect';
3
+ export { Reactable, ActionMap, ActionObservableWithTypes } from './Reactable';
@@ -1 +1 @@
1
- export { ofTypes } from './ofTypes';
1
+ export { ofTypes } from './ofTypes';
@@ -1,3 +1,3 @@
1
- import { OperatorFunction } from 'rxjs';
2
- import { Action } from '../Models/Action';
3
- export declare const ofTypes: (types: string[]) => OperatorFunction<Action<unknown>, Action<unknown>>;
1
+ import { OperatorFunction } from 'rxjs';
2
+ import { Action } from '../Models/Action';
3
+ export declare const ofTypes: (types: string[]) => OperatorFunction<Action<unknown>, Action<unknown>>;