@common-stack/frontend-stack-react 4.0.1-alpha.44 → 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.
@@ -14,10 +14,11 @@ interface IReduxStore<S = any> {
14
14
  middleware?: Middleware[];
15
15
  initialState?: any;
16
16
  persistConfig?: PersistConfig<any>;
17
+ reduxConfig?: any;
17
18
  }
18
19
  /**
19
20
  * Add any reducers required for this app dirctly in to
20
21
  * `combineReducers`
21
22
  */
22
- export declare const createReduxStore: ({ scope, isDebug, isDev, reducers, rootEpic, enhancers, epicMiddleware, preMiddleware, postMiddleware, middleware, initialState, persistConfig, }: IReduxStore<any>) => import("@reduxjs/toolkit").Store<any, import("@reduxjs/toolkit").UnknownAction, unknown>;
23
+ export declare const createReduxStore: ({ scope, isDebug, isDev, reducers, rootEpic, enhancers, epicMiddleware, preMiddleware, postMiddleware, middleware, initialState, persistConfig, reduxConfig, }: IReduxStore<any>) => import("@reduxjs/toolkit").Store<any, import("@reduxjs/toolkit").UnknownAction, unknown>;
23
24
  export {};
@@ -4,12 +4,11 @@ import {combineReducers,configureStore}from'@reduxjs/toolkit';import {persistRed
4
4
  /* eslint-disable @typescript-eslint/no-var-requires */
5
5
  /* eslint-disable global-require */
6
6
  /* eslint-disable no-underscore-dangle */
7
- const REGISTER_CONTRIBUTIONS = 'contribution/REGISTER_CONTRIBUTIONS';
8
7
  /**
9
8
  * Add any reducers required for this app dirctly in to
10
9
  * `combineReducers`
11
10
  */
12
- const createReduxStore = ({ scope, isDebug, isDev, reducers, rootEpic, enhancers = [], epicMiddleware, preMiddleware = [], postMiddleware = [], middleware = [], initialState, persistConfig, }) => {
11
+ const createReduxStore = ({ scope, isDebug, isDev, reducers, rootEpic, enhancers = [], epicMiddleware, preMiddleware = [], postMiddleware = [], middleware = [], initialState, persistConfig, reduxConfig, }) => {
13
12
  const isBrowser = scope === 'browser';
14
13
  const isElectronMain = scope === 'ElectronMain';
15
14
  const rootReducer = combineReducers(reducers);
@@ -28,7 +27,7 @@ const createReduxStore = ({ scope, isDebug, isDev, reducers, rootEpic, enhancers
28
27
  reducer: persistedReducer,
29
28
  middleware: (getDefaultMiddleware) => getDefaultMiddleware({
30
29
  serializableCheck: {
31
- ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER, REGISTER_CONTRIBUTIONS],
30
+ ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER, ...(reduxConfig?.ignoredActions || [])],
32
31
  },
33
32
  }).concat(...middlewares),
34
33
  devTools: isDev || isDebug,
@@ -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,
@@ -55,19 +46,17 @@ const createReduxStore = (apolloClient, services, container) => {
55
46
  epicMiddleware: epicMiddlewareFunc(apolloClient, services, container),
56
47
  rootEpic: rootEpic,
57
48
  reducers,
49
+ reduxConfig: features.getReduxConfig(),
58
50
  });
51
+ logger.debug('Created new Redux store');
59
52
  }
60
53
  if (container.isBound('ReduxStore')) {
61
- container
62
- .rebind('ReduxStore')
63
- .toDynamicValue(() => store)
64
- .inRequestScope();
54
+ container.rebind('ReduxStore').toDynamicValue(() => store).inRequestScope();
55
+ logger.debug('Rebound ReduxStore in container');
65
56
  }
66
57
  else {
67
- container
68
- .bind('ReduxStore')
69
- .toDynamicValue(() => store)
70
- .inRequestScope();
58
+ container.bind('ReduxStore').toDynamicValue(() => store).inRequestScope();
59
+ logger.debug('Bound ReduxStore in container');
71
60
  }
72
61
  return { store };
73
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.44",
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": {
@@ -29,7 +29,7 @@
29
29
  "watch": "npm run build:lib:watch"
30
30
  },
31
31
  "dependencies": {
32
- "@common-stack/client-react": "4.0.1-alpha.44",
32
+ "@common-stack/client-react": "4.0.1-alpha.47",
33
33
  "@common-stack/core": "4.0.1-alpha.31",
34
34
  "i18next-fs-backend": "^2.3.1",
35
35
  "i18next-http-backend": "^2.5.2",
@@ -52,5 +52,5 @@
52
52
  "typescript": {
53
53
  "definition": "lib/index.d.ts"
54
54
  },
55
- "gitHead": "45991179199ddbfdce3aba94060944e3715eadd2"
55
+ "gitHead": "3f1e953bc526483d683bd1ffa480348c21f7182a"
56
56
  }