@common-stack/frontend-stack-react 4.0.1-alpha.47 → 4.0.1
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/redux-config.d.ts +12 -16
- package/lib/config/redux-config.js +12 -24
- package/package.json +4 -4
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { EpicMiddleware } from 'redux-observable';
|
|
3
|
+
import { PersistConfig } from 'redux-persist';
|
|
4
|
+
import { logger } from '../utils';
|
|
5
|
+
import modules from '../modules';
|
|
6
|
+
interface Dependencies {
|
|
3
7
|
apolloClient: any;
|
|
4
|
-
routes:
|
|
8
|
+
routes: ReturnType<typeof modules.getConfiguredRoutes>;
|
|
5
9
|
services: any;
|
|
6
10
|
container: any;
|
|
7
|
-
logger:
|
|
11
|
+
logger: typeof logger;
|
|
8
12
|
config: {
|
|
9
13
|
loadRoot: boolean;
|
|
10
14
|
};
|
|
11
|
-
}
|
|
12
|
-
export declare const
|
|
13
|
-
|
|
14
|
-
storage: any;
|
|
15
|
-
stateReconciler: any;
|
|
16
|
-
transforms: any[];
|
|
17
|
-
blacklist: string[];
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Add any reducers required for this app dirctly in to
|
|
21
|
-
* `combineReducers`
|
|
22
|
-
*/
|
|
15
|
+
}
|
|
16
|
+
export declare const epicMiddlewareFunc: (apolloClient: any, services: any, container: any) => EpicMiddleware<any, any, any, Dependencies>;
|
|
17
|
+
export declare const persistConfig: PersistConfig<any>;
|
|
23
18
|
export declare const createReduxStore: (apolloClient: any, services: any, container: any) => {
|
|
24
19
|
store: any;
|
|
25
20
|
};
|
|
21
|
+
export {};
|
|
@@ -17,36 +17,27 @@ const persistConfig = {
|
|
|
17
17
|
transforms: features.reduxPersistStateTransformers,
|
|
18
18
|
blacklist: ['router']
|
|
19
19
|
};
|
|
20
|
-
/**
|
|
21
|
-
* Add any reducers required for this app dirctly in to
|
|
22
|
-
* `combineReducers`
|
|
23
|
-
*/
|
|
24
20
|
const createReduxStore = (apolloClient, services, container) => {
|
|
25
21
|
const reducers = {
|
|
26
22
|
router: createRouterReducer({}),
|
|
27
23
|
...features.reducers,
|
|
28
24
|
};
|
|
29
25
|
let store;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// console.log('Restoring Redux store:', JSON.stringify(import.meta.hot.data.store.getState()));
|
|
33
|
-
// @ts-ignore
|
|
26
|
+
if (import.meta.hot?.data?.store) {
|
|
27
|
+
logger.debug('Restoring Redux store from hot reload data');
|
|
34
28
|
store = import.meta.hot.data.store;
|
|
35
|
-
// replace the reducers always as we don't have ablity to find
|
|
36
|
-
// new reducer added through our `modules`
|
|
37
29
|
store.replaceReducer(persistReducer(persistConfig, combineReducers(reducers)));
|
|
38
30
|
}
|
|
39
31
|
else {
|
|
40
32
|
let initialState = {};
|
|
41
33
|
let middlewares = [];
|
|
42
|
-
if (
|
|
43
|
-
initialState = { ...window.__PRELOADED_STATE__ };
|
|
44
|
-
delete window.__PRELOADED_STATE__;
|
|
45
|
-
|
|
46
|
-
// middlewares = [createRouterMiddleware({ router: window.__remixRouter } as any)];
|
|
34
|
+
if (typeof window !== 'undefined') {
|
|
35
|
+
initialState = { ...window.__PRELOADED_STATE__ };
|
|
36
|
+
delete window.__PRELOADED_STATE__;
|
|
37
|
+
logger.debug('Loaded initial state from window.__PRELOADED_STATE__');
|
|
47
38
|
}
|
|
48
39
|
store = createReduxStore$1({
|
|
49
|
-
scope:
|
|
40
|
+
scope: typeof window !== 'undefined' ? 'browser' : 'server',
|
|
50
41
|
isDebug: true,
|
|
51
42
|
isDev: process.env.NODE_ENV === 'development',
|
|
52
43
|
initialState,
|
|
@@ -57,18 +48,15 @@ const createReduxStore = (apolloClient, services, container) => {
|
|
|
57
48
|
reducers,
|
|
58
49
|
reduxConfig: features.getReduxConfig(),
|
|
59
50
|
});
|
|
51
|
+
logger.debug('Created new Redux store');
|
|
60
52
|
}
|
|
61
53
|
if (container.isBound('ReduxStore')) {
|
|
62
|
-
container
|
|
63
|
-
|
|
64
|
-
.toDynamicValue(() => store)
|
|
65
|
-
.inRequestScope();
|
|
54
|
+
container.rebind('ReduxStore').toDynamicValue(() => store).inRequestScope();
|
|
55
|
+
logger.debug('Rebound ReduxStore in container');
|
|
66
56
|
}
|
|
67
57
|
else {
|
|
68
|
-
container
|
|
69
|
-
|
|
70
|
-
.toDynamicValue(() => store)
|
|
71
|
-
.inRequestScope();
|
|
58
|
+
container.bind('ReduxStore').toDynamicValue(() => store).inRequestScope();
|
|
59
|
+
logger.debug('Bound ReduxStore in container');
|
|
72
60
|
}
|
|
73
61
|
return { store };
|
|
74
62
|
};export{createReduxStore,epicMiddlewareFunc,persistConfig};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/frontend-stack-react",
|
|
3
|
-
"version": "4.0.1
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Client Module for react app",
|
|
5
5
|
"homepage": "https://github.com/cdmbase/fullstack-pro#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"watch": "npm run build:lib:watch"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@common-stack/client-react": "4.0.1
|
|
33
|
-
"@common-stack/core": "4.0.1
|
|
32
|
+
"@common-stack/client-react": "^4.0.1",
|
|
33
|
+
"@common-stack/core": "^4.0.1",
|
|
34
34
|
"i18next-fs-backend": "^2.3.1",
|
|
35
35
|
"i18next-http-backend": "^2.5.2",
|
|
36
36
|
"react-i18next": "^14.1.0",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"typescript": {
|
|
53
53
|
"definition": "lib/index.d.ts"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "464d04059d3b1f3565e539d1c8023f60d05c1257"
|
|
56
56
|
}
|