@common-stack/mobile-stack-react 6.0.6-alpha.15 → 6.0.6-alpha.20
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/config/base-redux-config.d.ts +9 -7
- package/lib/config/base-redux-config.js +31 -33
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -1
- package/lib/load-context.mobile.d.ts +8 -0
- package/lib/load-context.mobile.js +14 -0
- package/lib/modules.d.ts +0 -1
- package/lib/modules.js +1 -2
- package/package.json +3 -3
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import { Middleware,
|
|
1
|
+
import { Middleware, StoreEnhancer } from 'redux';
|
|
2
2
|
import { EpicMiddleware, Epic } from 'redux-observable';
|
|
3
3
|
import { PersistConfig } from 'redux-persist';
|
|
4
4
|
interface IReduxStore<S = any> {
|
|
5
5
|
scope: 'browser' | 'server' | 'native' | 'ElectronMain';
|
|
6
6
|
isDebug: boolean;
|
|
7
7
|
isDev: boolean;
|
|
8
|
-
reducers:
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
reducers: any;
|
|
9
|
+
enhancers?: StoreEnhancer[];
|
|
10
|
+
rootEpic: Epic<any, any, any, any>;
|
|
11
|
+
epicMiddleware?: EpicMiddleware<any, any, S, any>;
|
|
11
12
|
preMiddleware?: Middleware[];
|
|
12
13
|
postMiddleware?: Middleware[];
|
|
13
14
|
middleware?: Middleware[];
|
|
14
|
-
initialState
|
|
15
|
-
persistConfig?: PersistConfig<
|
|
15
|
+
initialState?: any;
|
|
16
|
+
persistConfig?: PersistConfig<any>;
|
|
17
|
+
reduxConfig?: any;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Add any reducers required for this app dirctly in to
|
|
19
21
|
* `combineReducers`
|
|
20
22
|
*/
|
|
21
|
-
export declare const createReduxStore: ({ scope, isDebug, isDev, reducers, rootEpic, epicMiddleware, preMiddleware, postMiddleware, middleware, initialState, persistConfig, }: IReduxStore<any>) => import("redux").Store<any, import("redux").UnknownAction, unknown>;
|
|
23
|
+
export declare const createReduxStore: ({ scope, isDebug, isDev, reducers, rootEpic, enhancers, epicMiddleware, preMiddleware, postMiddleware, middleware, initialState, persistConfig, reduxConfig, }: IReduxStore<any>) => import("redux").Store<any, import("redux").UnknownAction, unknown>;
|
|
22
24
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {combineReducers,
|
|
1
|
+
import {combineReducers,configureStore}from'@reduxjs/toolkit';import {persistReducer,FLUSH,REHYDRATE,PAUSE,PERSIST,PURGE,REGISTER}from'redux-persist';// version 11/12/2021
|
|
2
2
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
@@ -8,44 +8,42 @@ import {combineReducers,createStore,applyMiddleware,compose}from'redux';import {
|
|
|
8
8
|
* Add any reducers required for this app dirctly in to
|
|
9
9
|
* `combineReducers`
|
|
10
10
|
*/
|
|
11
|
-
const createReduxStore = ({ scope, isDebug, isDev, reducers, rootEpic, epicMiddleware, preMiddleware, postMiddleware, middleware
|
|
11
|
+
const createReduxStore = ({ scope, isDebug, isDev, reducers, rootEpic, enhancers = [], epicMiddleware, preMiddleware = [], postMiddleware = [], middleware = [], initialState, persistConfig, reduxConfig, }) => {
|
|
12
12
|
const isBrowser = scope === 'browser';
|
|
13
13
|
const isElectronMain = scope === 'ElectronMain';
|
|
14
|
+
const rootReducer = combineReducers(reducers);
|
|
15
|
+
const persistedReducer = persistConfig && isBrowser ? persistReducer(persistConfig, rootReducer) : rootReducer;
|
|
14
16
|
/**
|
|
15
17
|
* Add middleware that required for this app.
|
|
16
18
|
*/
|
|
17
|
-
const middlewares = [thunkMiddleware];
|
|
18
|
-
// add epicMiddleware
|
|
19
|
-
if (epicMiddleware) {
|
|
20
|
-
middlewares.push(epicMiddleware);
|
|
21
|
-
}
|
|
22
|
-
if (preMiddleware) {
|
|
23
|
-
middlewares.unshift(...preMiddleware);
|
|
24
|
-
}
|
|
25
19
|
// Add redux logger during development only
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
20
|
+
const middlewares = [
|
|
21
|
+
...preMiddleware,
|
|
22
|
+
...(epicMiddleware ? [epicMiddleware] : []),
|
|
23
|
+
...middleware,
|
|
24
|
+
...postMiddleware,
|
|
25
|
+
];
|
|
26
|
+
const store = configureStore({
|
|
27
|
+
reducer: persistedReducer,
|
|
28
|
+
middleware: (getDefaultMiddleware) => getDefaultMiddleware({
|
|
29
|
+
serializableCheck: {
|
|
30
|
+
ignoredActions: [
|
|
31
|
+
FLUSH,
|
|
32
|
+
REHYDRATE,
|
|
33
|
+
PAUSE,
|
|
34
|
+
PERSIST,
|
|
35
|
+
PURGE,
|
|
36
|
+
REGISTER,
|
|
37
|
+
...(reduxConfig?.ignoredActions || []),
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
}).concat(...middlewares),
|
|
41
|
+
devTools: isDev || isDebug,
|
|
42
|
+
preloadedState: initialState,
|
|
43
|
+
enhancers: (getDefaultEnhancers) => getDefaultEnhancers().concat(...enhancers),
|
|
44
|
+
});
|
|
45
|
+
if ((isBrowser || isElectronMain) && epicMiddleware && rootEpic) {
|
|
46
|
+
epicMiddleware.run(rootEpic);
|
|
49
47
|
}
|
|
50
48
|
return store;
|
|
51
49
|
};export{createReduxStore};
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{createClientContainer}from'./config/client.service.js';export{createReduxStore,epicMiddlewareFunc,persistConfig}from'./config/redux-config.js';export{UtilityClass,logger}from'./utils/index.js';export{default as history}from'./config/router-history.js';
|
|
1
|
+
export{createClientContainer}from'./config/client.service.js';export{createReduxStore,epicMiddlewareFunc,persistConfig}from'./config/redux-config.js';export{UtilityClass,logger}from'./utils/index.js';export{loadContext}from'./load-context.mobile.js';export{default as history}from'./config/router-history.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
export declare const loadContext: () => {
|
|
3
|
+
modules: import("packages/common-client-react/lib").Feature;
|
|
4
|
+
store: import("redux").Store<any, import("redux").UnknownAction, unknown>;
|
|
5
|
+
container: import("inversify").Container;
|
|
6
|
+
apolloClient: import("@apollo/client").ApolloClient<any>;
|
|
7
|
+
persistor: import("redux-persist").Persistor;
|
|
8
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import'reflect-metadata';import {persistStore}from'redux-persist';import features from'./modules.js';import {createReduxStore}from'./config/redux-config.js';import {createClientContainer}from'./config/client.service.js';import hist from'./config/router-history.js';/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
3
|
+
const loadContext = () => {
|
|
4
|
+
const { apolloClient: client, container, serviceFunc } = createClientContainer();
|
|
5
|
+
const { store } = createReduxStore(hist, client, serviceFunc(), container);
|
|
6
|
+
const persistor = persistStore(store);
|
|
7
|
+
return {
|
|
8
|
+
modules: features,
|
|
9
|
+
store,
|
|
10
|
+
container,
|
|
11
|
+
apolloClient: client,
|
|
12
|
+
persistor,
|
|
13
|
+
};
|
|
14
|
+
};export{loadContext};
|
package/lib/modules.d.ts
CHANGED
package/lib/modules.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import {Feature}from'@common-stack/client-react';// This is a sample `module.ts` that will be replaced during run time.
|
|
2
|
-
const features = new Feature({});
|
|
3
|
-
features.getComponentFillPlugins();export{features as default};
|
|
2
|
+
const features = new Feature({});export{features as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/mobile-stack-react",
|
|
3
|
-
"version": "6.0.6-alpha.
|
|
3
|
+
"version": "6.0.6-alpha.20",
|
|
4
4
|
"description": "Client Module for mobile app",
|
|
5
5
|
"homepage": "https://github.com/cdmbase/fullstack-pro#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@apollo/client": "^3.9.0",
|
|
33
33
|
"@cdm-logger/client": "^9.0.3",
|
|
34
34
|
"@common-stack/client-core": "6.0.6-alpha.5",
|
|
35
|
-
"@common-stack/client-react": "6.0.6-alpha.
|
|
35
|
+
"@common-stack/client-react": "6.0.6-alpha.17",
|
|
36
36
|
"@common-stack/components-pro": "6.0.6-alpha.5",
|
|
37
37
|
"@common-stack/core": "6.0.6-alpha.5",
|
|
38
38
|
"@expo/vector-icons": "~13.0.0",
|
|
@@ -131,5 +131,5 @@
|
|
|
131
131
|
"typescript": {
|
|
132
132
|
"definition": "lib/index.d.ts"
|
|
133
133
|
},
|
|
134
|
-
"gitHead": "
|
|
134
|
+
"gitHead": "b0f998476a168a494f5d9ec4a91f6648cfbe4c3c"
|
|
135
135
|
}
|