@lomray/react-mobx-manager 2.1.2-beta.1 → 2.1.2-beta.3

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/context.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import React from 'react';
3
3
  import { FC, ReactElement } from "react";
4
4
  import Manager from "./manager.js";
5
- import { TStores } from "./types-01f82098.js";
5
+ import { TStores } from "./types-a4b71460.js";
6
6
  interface IStoreManagerProvider {
7
7
  storeManager: Manager;
8
8
  shouldInit?: boolean;
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from "./types-01f82098.js";
1
+ export * from "./types-a4b71460.js";
2
2
  export * from "./context.js";
3
3
  export { default as Manager } from "./manager.js";
4
4
  export { default as onChangeListener } from "./on-change-listener.js";
package/lib/manager.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import StoreStatus from "./store-status.js";
2
- import { IConstructableStore, IManagerOptions, IManagerParams, IStorage, IStore, IStoreParams, IStorePersisted, TInitStore, TStoreDefinition, TStores } from "./types-01f82098.js";
2
+ import { IConstructableStore, IManagerOptions, IManagerParams, IStorage, IStoreParams, TAnyStore, TInitStore, TStoreDefinition, TStores } from "./types-a4b71460.js";
3
3
  /**
4
4
  * Mobx stores manager
5
5
  */
@@ -11,7 +11,7 @@ declare class Manager {
11
11
  /**
12
12
  * Created stores
13
13
  */
14
- protected readonly stores: Map<string, TInitStore<IStore>>;
14
+ protected readonly stores: Map<string, TInitStore<import("./types-a4b71460.js").IStore>>;
15
15
  /**
16
16
  * Relations between stores
17
17
  * @protected
@@ -116,21 +116,21 @@ declare class Manager {
116
116
  * Get store identity
117
117
  * @protected
118
118
  */
119
- protected getStoreId<T extends IStore>(store: IConstructableStore<T> | TInitStore, params?: IStoreParams): string;
119
+ protected getStoreId<T extends TAnyStore>(store: IConstructableStore<T> | TInitStore, params?: IStoreParams): string;
120
120
  /**
121
121
  * Get exist store
122
122
  */
123
123
  /**
124
124
  * Get exist store
125
125
  */
126
- getStore<T extends IStore>(store: IConstructableStore<T>, params?: IStoreParams): T | undefined;
126
+ getStore<T>(store: IConstructableStore<T>, params?: IStoreParams): T | undefined;
127
127
  /**
128
128
  * Lookup store
129
129
  */
130
130
  /**
131
131
  * Lookup store
132
132
  */
133
- protected lookupStore<T extends IStore>(id: string, params: IStoreParams): TInitStore<T> | undefined;
133
+ protected lookupStore(id: string, params: IStoreParams): TInitStore<TAnyStore> | undefined;
134
134
  /**
135
135
  * Create new store instance
136
136
  * @protected
@@ -139,7 +139,7 @@ declare class Manager {
139
139
  * Create new store instance
140
140
  * @protected
141
141
  */
142
- protected createStore<T extends IStore>(store: IConstructableStore<T>, params: Omit<Required<IStoreParams>, 'key'>): T;
142
+ protected createStore<T>(store: IConstructableStore<T>, params: Omit<Required<IStoreParams>, 'key'>): T;
143
143
  /**
144
144
  * Create stores for component
145
145
  */
@@ -198,19 +198,17 @@ declare class Manager {
198
198
  toPersistedJSON(): Record<string, any>;
199
199
  /**
200
200
  * Get observable store props (fields)
201
- * @private
202
201
  */
203
202
  /**
204
203
  * Get observable store props (fields)
205
- * @private
206
204
  */
207
- static getObservableProps(store: IStore): Record<string, any>;
205
+ static getObservableProps(store: TAnyStore): Record<string, any>;
208
206
  /**
209
207
  * Persist store
210
208
  */
211
209
  /**
212
210
  * Persist store
213
211
  */
214
- static persistStore<TSt extends IStore | IStorePersisted>(store: IConstructableStore<TSt>, id: string): IConstructableStore<TSt>;
212
+ static persistStore<TSt>(store: IConstructableStore<TSt>, id: string): IConstructableStore<TSt>;
215
213
  }
216
214
  export { Manager as default };
@@ -1,4 +1,4 @@
1
- import { IStorePersisted } from "./types-01f82098.js";
1
+ import { IStorePersisted } from "./types-a4b71460.js";
2
2
  /**
3
3
  * Listen persist store changes
4
4
  */
@@ -1,4 +1,4 @@
1
- import { IStorage } from "../types-01f82098.js";
1
+ import { IStorage } from "../types-a4b71460.js";
2
2
  interface IAsyncStorage {
3
3
  getItem: (key: string) => Promise<string | null>;
4
4
  setItem: (key: string, value: string) => Promise<void>;
@@ -1,4 +1,4 @@
1
- import { IStorage } from "../types-01f82098.js";
1
+ import { IStorage } from "../types-a4b71460.js";
2
2
  /**
3
3
  * Local storage for mobx store manager
4
4
  */
@@ -1,4 +1,4 @@
1
- import { TInitStore } from "./types-01f82098.js";
1
+ import { TInitStore } from "./types-a4b71460.js";
2
2
  interface IPromise<TReturn> extends Promise<TReturn> {
3
3
  status?: 'fulfilled' | 'pending' | 'rejected';
4
4
  value?: TReturn;
@@ -12,7 +12,7 @@ declare global {
12
12
  }
13
13
  interface IConstructorParams<TProps = Record<string, any>> {
14
14
  storeManager: Manager;
15
- getStore: <T extends IStore>(store: IConstructableStore<T>, params?: Partial<IStoreParams>) => T | undefined;
15
+ getStore: <T>(store: IConstructableStore<T>, params?: Partial<IStoreParams>) => T | undefined;
16
16
  componentProps: TProps;
17
17
  }
18
18
  interface IStoreLifecycle {
@@ -34,15 +34,15 @@ interface IStorePersisted extends IStore {
34
34
  addOnChangeListener?: (store: IStorePersisted, manager: Manager) => (() => void) | undefined;
35
35
  wakeup?: TWakeup;
36
36
  }
37
- type TInitStore<TSto extends IStore | IStorePersisted = IStore> = TSto & (IStorePersisted | IStore);
38
- type IConstructableStore<TSto extends IStore = IStore> = (new (props: IConstructorParams) => TInitStore<TSto>) & Partial<IStorePersisted>;
37
+ type TInitStore<TSto = IStore> = TSto & TAnyStore;
38
+ type IConstructableStore<TSto = IStore> = (new (props: IConstructorParams) => TInitStore<TSto>) & Partial<IStorePersisted>;
39
39
  /**
40
40
  * Store params
41
41
  */
42
42
  type IStoreConfig = {
43
43
  id?: string;
44
44
  };
45
- type TStoreDefinition<TSto extends IStore | IStorePersisted = any> = IConstructableStore<TSto> | ({
45
+ type TStoreDefinition<TSto = TAnyStore> = IConstructableStore<TSto> | ({
46
46
  store: IConstructableStore<TSto>;
47
47
  } & IStoreConfig);
48
48
  type TMapStores = Record<string, TStoreDefinition>;
@@ -70,8 +70,9 @@ interface IManagerOptions {
70
70
  unused?: number;
71
71
  };
72
72
  }
73
+ type TAnyStore = IStore | IStorePersisted;
73
74
  type TStores = {
74
- [storeKey: string]: IStore | IStorePersisted;
75
+ [storeKey: string]: TAnyStore;
75
76
  };
76
77
  /**
77
78
  * Convert class type to class constructor
@@ -102,13 +103,13 @@ interface IMobxManagerEvents {
102
103
  store: IConstructableStore;
103
104
  };
104
105
  [Events.MOUNT_STORE]: {
105
- store: IStorePersisted | IStore;
106
+ store: TAnyStore;
106
107
  };
107
108
  [Events.UNMOUNT_STORE]: {
108
- store: IStorePersisted | IStore;
109
+ store: TAnyStore;
109
110
  };
110
111
  [Events.DELETE_STORE]: {
111
- store: IStorePersisted | IStore;
112
+ store: TAnyStore;
112
113
  };
113
114
  }
114
- export { IWindowManager, IConstructorParams, IStoreLifecycle, IStore, IStorePersisted, TInitStore, IConstructableStore, IStoreConfig, TStoreDefinition, TMapStores, IManagerParams, TWakeup, IStorage, IManagerOptions, TStores, ClassReturnType, StoresType, IStoreParams, IWithStoreOptions, IMobxManagerEvents };
115
+ export { IWindowManager, IConstructorParams, IStoreLifecycle, IStore, IStorePersisted, TInitStore, IConstructableStore, IStoreConfig, TStoreDefinition, TMapStores, IManagerParams, TWakeup, IStorage, IManagerOptions, TAnyStore, TStores, ClassReturnType, StoresType, IStoreParams, IWithStoreOptions, IMobxManagerEvents };
package/lib/wakeup.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { TStores, TWakeup } from "./types-01f82098.js";
1
+ import { TStores, TWakeup } from "./types-a4b71460.js";
2
2
  /**
3
3
  * Restore persisted store state
4
4
  */
@@ -1,5 +1,5 @@
1
1
  import { FC } from 'react';
2
- import { TMapStores, IWithStoreOptions } from "./types-01f82098.js";
2
+ import { TMapStores, IWithStoreOptions } from "./types-a4b71460.js";
3
3
  /**
4
4
  * Make component observable and pass stores as props
5
5
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lomray/react-mobx-manager",
3
- "version": "2.1.2-beta.1",
3
+ "version": "2.1.2-beta.3",
4
4
  "description": "This package provides Mobx stores manager for react.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",