@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.
@@ -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 declare type ArrayKeys = keyof any[];
5
- export declare type Indices<T> = Exclude<keyof T, ArrayKeys>;
6
- declare type OptionalStoreType<S = any, N extends string = string> = {
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
- declare type DEFAULT_STORE_NAME = string;
29
- declare type DEFAULT_STORE_STATE = any;
30
- declare type InferStoreNameFromOptionalStore<Store extends OptionalStoreType> = Store['store'] extends Reducer<any, infer Name> ? Name : DEFAULT_STORE_NAME;
31
- declare type InferStoreStateFromOptionalStore<Store extends OptionalStoreType> = Store['store'] extends Reducer<infer State> ? State : DEFAULT_STORE_STATE;
32
- declare 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
- declare type InferStoreNameFromReducer<Store extends Reducer<any>> = Store['storeName'];
34
- declare type InferStoreStateFromReducer<Store extends Reducer<any>> = Store extends Reducer<infer State> ? State : DEFAULT_STORE_STATE;
35
- declare type InferStoreNameFromLegacyStore<Store extends BaseStoreConstructor<any>> = Store['storeName'];
36
- declare type InferStoreStateFromLegacyStore<Store extends BaseStoreConstructor<any>> = Store extends BaseStoreConstructor<infer State> ? State : DEFAULT_STORE_STATE;
37
- declare 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;
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 declare type DependsOnOwnProps<T> = T & {
2
+ export type DependsOnOwnProps<T> = T & {
3
3
  dependsOnOwnProps: boolean;
4
4
  };
5
- export declare type MapStateToProps<T = any> = (state: Record<string, any>, ownProps: T) => any;
6
- export declare type MapContextToProps<T = any> = ((context: ConsumerContext, ownProps: T) => any) | Record<string, Function>;
7
- export declare type MergeProps<P = any, T = any, R = any> = (stateProps: P, contextProps: T, ownProps: R) => any;
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;
@@ -1,2 +1,2 @@
1
1
  export { Action, ConsumerContext } from '@tramvai/types-actions-state-context';
2
- export declare type ServerState = any;
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
- declare type InitialState = {
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
- declare type InitialState = {
7
+ type InitialState = {
8
8
  stores: Record<string, any>;
9
9
  };
10
- declare type Handlers = Dispatcher['handlers'];
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;
@@ -1,4 +1,4 @@
1
- declare type Listener = (...args: Array<any>) => void;
1
+ type Listener = (...args: Array<any>) => void;
2
2
  export declare class SimpleEmitter {
3
3
  listeners: Listener[];
4
4
  emit(name?: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/state",
3
- "version": "2.40.0",
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.40.0",
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.40.0",
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",