@tramvai/state 2.40.0 → 2.45.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.
- package/lib/connect/hooks/useSelector.d.ts +13 -13
- package/lib/connect/toProps/types.d.ts +4 -4
- package/lib/connect/types.d.ts +1 -1
- package/lib/dispatcher/childDispatcherContext.d.ts +1 -1
- package/lib/dispatcher/dispatcherContext.d.ts +2 -2
- package/lib/stores/SimpleEmitter.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import shallowEqual from '@tinkoff/utils/is/shallowEqual';
|
|
2
2
|
import type { Reducer } from '../../createReducer/createReducer.h';
|
|
3
3
|
import type { BaseStoreConstructor } from '../../stores/BaseStore';
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
|
|
4
|
+
export type ArrayKeys = keyof any[];
|
|
5
|
+
export type Indices<T> = Exclude<keyof T, ArrayKeys>;
|
|
6
|
+
type OptionalStoreType<S = any, N extends string = string> = {
|
|
7
7
|
store: Reducer<S, N> | string;
|
|
8
8
|
optional: true;
|
|
9
9
|
};
|
|
@@ -25,14 +25,14 @@ export declare function useSelector<T, S extends ReadonlyArray<unknown>>(storesO
|
|
|
25
25
|
[Key in Indices<S> as InferStoreNameFromUnknownStore<S[Key]>]: InferStoreStateFromUnknownStore<S[Key]>;
|
|
26
26
|
}) => T, equalityFn?: typeof shallowEqual): T;
|
|
27
27
|
export declare function useSelector<T, S>(storesOrStore: S, selector: (state: Record<string, any>) => T, equalityFn?: typeof shallowEqual): T;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
type DEFAULT_STORE_NAME = string;
|
|
29
|
+
type DEFAULT_STORE_STATE = any;
|
|
30
|
+
type InferStoreNameFromOptionalStore<Store extends OptionalStoreType> = Store['store'] extends Reducer<any, infer Name> ? Name : DEFAULT_STORE_NAME;
|
|
31
|
+
type InferStoreStateFromOptionalStore<Store extends OptionalStoreType> = Store['store'] extends Reducer<infer State> ? State : DEFAULT_STORE_STATE;
|
|
32
|
+
type InferStoreNameFromUnknownStore<Store> = Store extends string ? Store : Store extends OptionalStoreType ? InferStoreNameFromOptionalStore<Store> : Store extends Reducer<any> ? InferStoreNameFromReducer<Store> : Store extends BaseStoreConstructor<any> ? InferStoreNameFromLegacyStore<Store> : DEFAULT_STORE_NAME;
|
|
33
|
+
type InferStoreNameFromReducer<Store extends Reducer<any>> = Store['storeName'];
|
|
34
|
+
type InferStoreStateFromReducer<Store extends Reducer<any>> = Store extends Reducer<infer State> ? State : DEFAULT_STORE_STATE;
|
|
35
|
+
type InferStoreNameFromLegacyStore<Store extends BaseStoreConstructor<any>> = Store['storeName'];
|
|
36
|
+
type InferStoreStateFromLegacyStore<Store extends BaseStoreConstructor<any>> = Store extends BaseStoreConstructor<infer State> ? State : DEFAULT_STORE_STATE;
|
|
37
|
+
type InferStoreStateFromUnknownStore<Store> = Store extends string ? DEFAULT_STORE_STATE : Store extends OptionalStoreType ? InferStoreStateFromOptionalStore<Store> : Store extends Reducer<any> ? InferStoreStateFromReducer<Store> : Store extends BaseStoreConstructor<any> ? InferStoreStateFromLegacyStore<Store> : DEFAULT_STORE_STATE;
|
|
38
38
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ConsumerContext } from '../types';
|
|
2
|
-
export
|
|
2
|
+
export type DependsOnOwnProps<T> = T & {
|
|
3
3
|
dependsOnOwnProps: boolean;
|
|
4
4
|
};
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
5
|
+
export type MapStateToProps<T = any> = (state: Record<string, any>, ownProps: T) => any;
|
|
6
|
+
export type MapContextToProps<T = any> = ((context: ConsumerContext, ownProps: T) => any) | Record<string, Function>;
|
|
7
|
+
export type MergeProps<P = any, T = any, R = any> = (stateProps: P, contextProps: T, ownProps: R) => any;
|
package/lib/connect/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Action, ConsumerContext } from '@tramvai/types-actions-state-context';
|
|
2
|
-
export
|
|
2
|
+
export type ServerState = any;
|
|
@@ -3,7 +3,7 @@ import type { Dispatcher } from './dispatcher';
|
|
|
3
3
|
import type { StoreClass } from '../typings';
|
|
4
4
|
import type { Middleware } from './dispatcher.h';
|
|
5
5
|
import { DispatcherContext } from './dispatcherContext';
|
|
6
|
-
|
|
6
|
+
type InitialState = {
|
|
7
7
|
stores: Record<string, any>;
|
|
8
8
|
};
|
|
9
9
|
export declare class ChildDispatcherContext<TContext> extends DispatcherContext<TContext> {
|
|
@@ -4,10 +4,10 @@ import type { StoreClass, StoreInstance } from '../typings';
|
|
|
4
4
|
import type { Middleware } from './dispatcher.h';
|
|
5
5
|
import { SimpleEmitter } from '../stores/SimpleEmitter';
|
|
6
6
|
import type { Reducer } from '../createReducer/createReducer.h';
|
|
7
|
-
|
|
7
|
+
type InitialState = {
|
|
8
8
|
stores: Record<string, any>;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type Handlers = Dispatcher['handlers'];
|
|
11
11
|
export declare const convertAction: (actionOrNameEvent: string | Event<any>, payload?: any) => Event<any> | {
|
|
12
12
|
payload: any;
|
|
13
13
|
type: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/state",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.45.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@tinkoff/react-hooks": "0.1.4",
|
|
22
22
|
"@tinkoff/utils": "^2.1.2",
|
|
23
|
-
"@tramvai/types-actions-state-context": "2.
|
|
23
|
+
"@tramvai/types-actions-state-context": "2.45.0",
|
|
24
24
|
"@types/hoist-non-react-statics": "^3.3.1",
|
|
25
25
|
"invariant": "^2.2.4",
|
|
26
26
|
"react-is": ">=17",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@reatom/core": "^1.1.5",
|
|
38
|
-
"@tramvai/core": "2.
|
|
38
|
+
"@tramvai/core": "2.45.0",
|
|
39
39
|
"@types/invariant": "^2.2.31",
|
|
40
40
|
"@types/react-is": "^17.0.0",
|
|
41
41
|
"@types/use-sync-external-store": "^0.0.3",
|