@common-stack/frontend-stack-react 4.0.1-alpha.47 → 4.0.1-alpha.62

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,25 +1,21 @@
1
- import "reflect-metadata";
2
- export declare const epicMiddlewareFunc: (apolloClient: any, services: any, container: any) => import("redux-observable").EpicMiddleware<import("redux").Action<any>, import("redux").Action<any>, void, {
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: any;
8
+ routes: ReturnType<typeof modules.getConfiguredRoutes>;
5
9
  services: any;
6
10
  container: any;
7
- logger: import("@cdm-logger/core/lib/interface").ILogger;
11
+ logger: typeof logger;
8
12
  config: {
9
13
  loadRoot: boolean;
10
14
  };
11
- }>;
12
- export declare const persistConfig: {
13
- key: string;
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
- // @ts-ignore
31
- if (import.meta.hot && import.meta.hot.data && import.meta.hot.data.store) {
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 (__CLIENT__ && typeof window !== 'undefined') {
43
- initialState = { ...window.__PRELOADED_STATE__ }; // #952 TODO we need cookie to have id_token for SSR to work properly
44
- delete window.__PRELOADED_STATE__; // Delete it once we have it stored in a variable
45
- // it doesn't work, since __remixRouter is not created yet.
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: __CLIENT__ && typeof window !== 'undefined' ? 'browser' : 'server',
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
- .rebind('ReduxStore')
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
- .bind('ReduxStore')
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-alpha.47",
3
+ "version": "4.0.1-alpha.62",
4
4
  "description": "Client Module for react app",
5
5
  "homepage": "https://github.com/cdmbase/fullstack-pro#readme",
6
6
  "bugs": {
@@ -52,5 +52,5 @@
52
52
  "typescript": {
53
53
  "definition": "lib/index.d.ts"
54
54
  },
55
- "gitHead": "df1b7718e4d36336a468c518b0fd13c3683f248e"
55
+ "gitHead": "3f1e953bc526483d683bd1ffa480348c21f7182a"
56
56
  }