@common-stack/mobile-stack-react 6.0.6-alpha.100

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2017 CDMBase LLC.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # React Package
2
+ React components and containers
3
+
4
+ What does it include:
5
+ ---
6
+ 1. exported react pure components
7
+ 2. exported react containers
8
+ 3. Typescript 2.0.0 => ES6
9
+ 4. unit testing with jest
10
+
11
+ Purpose:
12
+ ---
13
+ This package can be installable in front-end webserver
14
+
15
+ Useful commands:
16
+ ---
17
+ npm run build - build the library files
18
+ npm run test - run tests once
19
+ npm run test:watch - run tests in watchmode (Useful for development)
20
+
21
+ Files explained:
22
+ ---
23
+ src - directory is used for typescript code that is part of the project
24
+ index.ts - Index file of the package. Consists of exported components and containers
25
+ index.spec.ts - Tests file for main
26
+ components - All pure components which don't depend on backend data or external state such as redux
27
+ index.ts - References all the exported components
28
+ containers - Components with data to render. Tightly coupled with redux.
29
+ index.ts - References all the exported containers
30
+ package.json - file is used to describe the library and packages that are required added under peer-dependencies section
31
+ tsconfig.json - configuration file for the library compilation
32
+ webpack.config.js - configuration file of the compilation automation process for the library
33
+
34
+
35
+ Tutorials:
36
+ ---
37
+ [react-jest-enzymes test](https://www.youtube.com/watch?v=bMmntkVM4wQ)
38
+
39
+ [testing react with enzyme tutorial](http://codeheaven.io/testing-react-components-with-enzyme/)
40
+
41
+ [react-redux-typescript-guide](https://github.com/piotrwitek/react-redux-typescript-guide)
42
+
43
+ Performance:
44
+ ---
45
+ [Redux FAQ: Connecting multiple components](http://redux.js.org/docs/FAQ.html#react-multiple-components)
46
+
47
+ [React/Redux Links: Performance articles](https://github.com/markerikson/react-redux-links/blob/master/react-performance.md)
48
+
49
+ [React/Redux: Component re-rendering too often?](http://redux.js.org/docs/faq/ReactRedux.html#react-rendering-too-often)
50
+
@@ -0,0 +1,16 @@
1
+ import { InMemoryCache } from '@apollo/client/cache/index.js';
2
+ import { CdmLogger } from '@cdm-logger/core';
3
+ interface CreateCacheParams {
4
+ getDataIdFromObject: (x?: any) => string;
5
+ clientState: any;
6
+ initialState?: any;
7
+ logger: CdmLogger.ILogger;
8
+ }
9
+ export declare const createCache: ({ getDataIdFromObject, clientState }: CreateCacheParams) => InMemoryCache;
10
+ export declare const initializeCache: ({ cache, initialState, clientState, logger, }: {
11
+ cache: InMemoryCache;
12
+ initialState?: any;
13
+ clientState: any;
14
+ logger: CdmLogger.ILogger;
15
+ }) => void;
16
+ export {};
@@ -0,0 +1,35 @@
1
+ import {InMemoryCache}from'@apollo/client/cache/index.js';// cache.ts
2
+ const createCache = ({ getDataIdFromObject, clientState }) => {
3
+ const cache = new InMemoryCache({
4
+ dataIdFromObject: getDataIdFromObject,
5
+ possibleTypes: clientState.possibleTypes,
6
+ typePolicies: clientState.typePolicies,
7
+ });
8
+ return cache;
9
+ };
10
+ const initializeCache = ({ cache, initialState, clientState, logger, }) => {
11
+ if (initialState) {
12
+ try {
13
+ cache.restore(initialState);
14
+ logger.debug('Cache restored with initial state');
15
+ }
16
+ catch (err) {
17
+ logger.error(err, 'Error restoring cache');
18
+ }
19
+ }
20
+ else {
21
+ clientState.defaults?.forEach((x) => {
22
+ try {
23
+ if (x.type === 'query') {
24
+ cache.writeQuery({ query: x.query, data: x.data });
25
+ }
26
+ else if (x.type === 'fragment') {
27
+ cache.writeFragment({ id: x.id, fragment: x.fragment, data: x.data });
28
+ }
29
+ }
30
+ catch (err) {
31
+ logger.error(err, 'Error writing to cache');
32
+ }
33
+ });
34
+ }
35
+ };export{createCache,initializeCache};
@@ -0,0 +1,19 @@
1
+ import { ApolloClient, NormalizedCacheObject, InMemoryCache } from '@apollo/client/index.js';
2
+ import { CdmLogger } from '@cdm-logger/core';
3
+ interface IApolloClientParams {
4
+ initialState?: any;
5
+ scope: 'browser' | 'server' | 'native';
6
+ getDataIdFromObject: (x?: any) => string;
7
+ clientState: any;
8
+ isDebug: boolean;
9
+ isDev: boolean;
10
+ isSSR: boolean;
11
+ httpGraphqlURL: string;
12
+ httpLocalGraphqlURL: string;
13
+ logger: CdmLogger.ILogger;
14
+ }
15
+ export declare const createApolloClient: ({ scope, isDev, isDebug, isSSR, getDataIdFromObject, clientState, httpGraphqlURL, httpLocalGraphqlURL, initialState, logger, }: IApolloClientParams) => {
16
+ apolloClient: ApolloClient<NormalizedCacheObject>;
17
+ cache: InMemoryCache;
18
+ };
19
+ export {};
@@ -0,0 +1,119 @@
1
+ import {isBoolean,merge}from'lodash-es';import {ApolloLink,ApolloClient}from'@apollo/client/index.js';import {HttpLink}from'@apollo/client/link/http/index.js';import {BatchHttpLink}from'@apollo/client/link/batch-http/index.js';import {onError}from'@apollo/client/link/error/index.js';import {GraphQLWsLink}from'@apollo/client/link/subscriptions/index.js';import {getOperationAST}from'graphql';import {invariant}from'ts-invariant';import {RetryLink}from'@apollo/client/link/retry/index.js';import {createClient}from'graphql-ws';import fetch from'cross-fetch';import {createCache,initializeCache}from'./base-apollo-cache.js';// apolloClient.ts
2
+ const schema = `
3
+ # Add your schema here
4
+ `;
5
+ const errorLink = onError(({ graphQLErrors, networkError }) => {
6
+ if (graphQLErrors) {
7
+ graphQLErrors.map(({ message, locations, path }) => invariant.warn(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`));
8
+ }
9
+ if (networkError) {
10
+ invariant.warn(`[Network error]: ${networkError}`);
11
+ }
12
+ });
13
+ const createApolloClient = ({ scope, isDev, isDebug, isSSR, getDataIdFromObject, clientState, httpGraphqlURL, httpLocalGraphqlURL, initialState, logger, }) => {
14
+ logger.debug('Initializing Apollo Client with parameters, {%o}', {
15
+ scope,
16
+ isDev,
17
+ isDebug,
18
+ isSSR,
19
+ httpGraphqlURL,
20
+ httpLocalGraphqlURL,
21
+ });
22
+ const isBrowser = scope === 'browser';
23
+ const isServer = scope === 'server';
24
+ const cache = createCache({ getDataIdFromObject, clientState, logger });
25
+ logger.debug('Created new Apollo memory cache');
26
+ const retryLink = new RetryLink({
27
+ attempts: async (count, operation, error) => {
28
+ logger.debug('Retrying link attempt', { count, operation, error });
29
+ const promises = (clientState.retryLinkAttemptFuncs || []).map((func) => func(count, operation, error));
30
+ try {
31
+ const result = await Promise.all(promises);
32
+ return !!result.find((item) => item && isBoolean(item));
33
+ }
34
+ catch (e) {
35
+ logger.error(e, 'Error occurred in retryLink attempt condition');
36
+ throw e;
37
+ }
38
+ },
39
+ });
40
+ let link;
41
+ if (isBrowser) {
42
+ const connectionParams = async () => {
43
+ logger.debug('Getting WebSocket connection parameters');
44
+ const param = {};
45
+ for (const connectionParam of clientState.connectionParams) {
46
+ const result = await connectionParam();
47
+ merge(param, await result());
48
+ }
49
+ return param;
50
+ };
51
+ const wsLink = new GraphQLWsLink(createClient({
52
+ url: httpGraphqlURL.replace(/^http/, 'ws'),
53
+ retryAttempts: 10,
54
+ lazy: true,
55
+ shouldRetry: () => true,
56
+ keepAlive: 10000,
57
+ connectionParams,
58
+ on: {
59
+ connected: (socket) => logger.debug('WebSocket connected'),
60
+ error: async (error) => {
61
+ logger.error(error, 'WebSocket connection error');
62
+ const promises = (clientState.connectionCallbackFuncs || []).map((func) => func(wsLink, error, {}));
63
+ try {
64
+ await Promise.all(promises);
65
+ }
66
+ catch (err) {
67
+ logger.trace('Error occurred in WebSocket connection callback', err);
68
+ throw err;
69
+ }
70
+ },
71
+ ping: () => logger.trace('Ping server'),
72
+ pong: () => logger.trace('Pong received'),
73
+ },
74
+ }));
75
+ link = ApolloLink.split(({ query, operationName }) => {
76
+ if (operationName.endsWith('_WS')) {
77
+ return true;
78
+ }
79
+ const operationAST = getOperationAST(query, operationName);
80
+ return !!operationAST && operationAST.operation === 'subscription';
81
+ }, wsLink, new HttpLink({ uri: httpGraphqlURL, credentials: 'include', fetch }));
82
+ }
83
+ else if (isServer) {
84
+ logger.debug('Creating BatchHttpLink for server');
85
+ link = new BatchHttpLink({
86
+ uri: httpLocalGraphqlURL,
87
+ fetch,
88
+ batchInterval: 200,
89
+ batchMax: 100,
90
+ credentials: 'include',
91
+ });
92
+ }
93
+ else {
94
+ logger.debug('Creating HttpLink for native');
95
+ link = new HttpLink({ uri: httpLocalGraphqlURL, fetch, credentials: 'include' });
96
+ }
97
+ const links = [errorLink, retryLink, ...(clientState.preLinks || []), link].filter(Boolean);
98
+ const params = {
99
+ queryDeduplication: true,
100
+ typeDefs: schema.concat(clientState.typeDefs || ''),
101
+ resolvers: clientState.resolvers,
102
+ link: ApolloLink.from(links),
103
+ cache,
104
+ credentials: 'include',
105
+ connectToDevTools: isBrowser && (isDev || isDebug),
106
+ };
107
+ if (isSSR) {
108
+ if (isBrowser) {
109
+ params.ssrForceFetchDelay = 100;
110
+ }
111
+ else if (isServer) {
112
+ params.ssrMode = true;
113
+ }
114
+ }
115
+ const apolloClient = new ApolloClient(params);
116
+ logger.debug('Created new Apollo client');
117
+ initializeCache({ cache, initialState, clientState, logger });
118
+ return { apolloClient, cache };
119
+ };export{createApolloClient};
@@ -0,0 +1,24 @@
1
+ import { Middleware, StoreEnhancer } from 'redux';
2
+ import { EpicMiddleware, Epic } from 'redux-observable';
3
+ import { PersistConfig } from 'redux-persist';
4
+ interface IReduxStore<S = any> {
5
+ scope: 'browser' | 'server' | 'native' | 'ElectronMain';
6
+ isDebug: boolean;
7
+ isDev: boolean;
8
+ reducers: any;
9
+ enhancers?: StoreEnhancer[];
10
+ rootEpic: Epic<any, any, any, any>;
11
+ epicMiddleware?: EpicMiddleware<any, any, S, any>;
12
+ preMiddleware?: Middleware[];
13
+ postMiddleware?: Middleware[];
14
+ middleware?: Middleware[];
15
+ initialState?: any;
16
+ persistConfig?: PersistConfig<any>;
17
+ reduxConfig?: any;
18
+ }
19
+ /**
20
+ * Add any reducers required for this app dirctly in to
21
+ * `combineReducers`
22
+ */
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>;
24
+ export {};
@@ -0,0 +1,39 @@
1
+ import {combineReducers,configureStore}from'@reduxjs/toolkit';import {persistReducer}from'redux-persist';// version 11/12/2021
2
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
3
+ /* eslint-disable @typescript-eslint/no-explicit-any */
4
+ /* eslint-disable @typescript-eslint/no-var-requires */
5
+ /* eslint-disable global-require */
6
+ /* eslint-disable no-underscore-dangle */
7
+ /**
8
+ * Add any reducers required for this app dirctly in to
9
+ * `combineReducers`
10
+ */
11
+ const createReduxStore = ({ scope, isDebug, isDev, reducers, rootEpic, enhancers = [], epicMiddleware, preMiddleware = [], postMiddleware = [], middleware = [], initialState, persistConfig, reduxConfig, }) => {
12
+ const isBrowser = scope === 'browser';
13
+ const isElectronMain = scope === 'ElectronMain';
14
+ const rootReducer = combineReducers(reducers);
15
+ const persistedReducer = persistConfig && isBrowser ? persistReducer(persistConfig, rootReducer) : rootReducer;
16
+ /**
17
+ * Add middleware that required for this app.
18
+ */
19
+ // Add redux logger during development only
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: false,
30
+ }).concat(...middlewares),
31
+ devTools: isDev || isDebug,
32
+ preloadedState: initialState,
33
+ enhancers: (getDefaultEnhancers) => getDefaultEnhancers().concat(...enhancers),
34
+ });
35
+ if ((isBrowser || isElectronMain) && epicMiddleware && rootEpic) {
36
+ epicMiddleware.run(rootEpic);
37
+ }
38
+ return store;
39
+ };export{createReduxStore};
@@ -0,0 +1,9 @@
1
+ import 'reflect-metadata';
2
+ import { Container } from 'inversify';
3
+ import { ApolloClient, NormalizedCacheObject } from '@apollo/client/index.js';
4
+ export declare const createClientContainer: (req?: any, res?: any) => {
5
+ container: Container;
6
+ apolloClient: ApolloClient<NormalizedCacheObject>;
7
+ serviceFunc: () => any;
8
+ logger: import("@cdm-logger/core/lib/interface").ILogger;
9
+ };
@@ -0,0 +1,71 @@
1
+ import'reflect-metadata';import {ClientTypes}from'@common-stack/client-core';import {ScopedContainer}from'@common-stack/client-core/lib/connector/ScopedContainer.js';import {merge}from'lodash-es';import features from'../modules.js';import {logger,UtilityClass}from'../utils/index.js';import {createApolloClient}from'./base-apollo-client.js';import {config}from'./mobile-env-config.js';const utility = new UtilityClass(features);
2
+ ScopedContainer.registerGlobalDependencies((container) => {
3
+ container.bind(ClientTypes.Logger).toConstantValue(logger);
4
+ container.bind(ClientTypes.UtilityClass).toConstantValue(utility);
5
+ });
6
+ const createClientContainer = (req, res) => {
7
+ logger.debug('Calling CreateClientContainer');
8
+ // const childContainer = container.createChild();
9
+ const container = features.createContainers({});
10
+ container
11
+ .bind(ClientTypes.ApolloClient)
12
+ .toDynamicValue((context) => new Error('Too early to bind ApolloClient'))
13
+ .inRequestScope();
14
+ container
15
+ .bind(ClientTypes.ApolloClientFactory)
16
+ .toDynamicValue((context) => () => {
17
+ const newClient = container.get(ClientTypes.ApolloClient);
18
+ return newClient;
19
+ });
20
+ const services = merge({ container }, ...features.createServiceFunc.map((serviceFunc) => serviceFunc(container)));
21
+ const clientState = features.getStateParams({
22
+ resolverContex: () => services,
23
+ // container: container,
24
+ requestResponsePair: {
25
+ req,
26
+ res,
27
+ },
28
+ });
29
+ const { apolloClient, cache } = createApolloClient({
30
+ httpGraphqlURL: config.GRAPHQL_URL,
31
+ httpLocalGraphqlURL: config.LOCAL_GRAPHQL_URL,
32
+ isDev: process.env.NODE_ENV === 'development',
33
+ isDebug: false,
34
+ isSSR: true,
35
+ scope: typeof window !== 'undefined' ? 'browser' : 'server',
36
+ clientState,
37
+ getDataIdFromObject: (result) => features.getDataIdFromObject(result),
38
+ initialState: undefined,
39
+ logger,
40
+ });
41
+ if (!container.isBound(ClientTypes.InMemoryCache)) {
42
+ container
43
+ .bind(ClientTypes.InMemoryCache)
44
+ .toDynamicValue((context) => cache)
45
+ .inRequestScope();
46
+ }
47
+ container
48
+ .rebind(ClientTypes.ApolloClient)
49
+ .toDynamicValue((context) => apolloClient)
50
+ .inRequestScope();
51
+ // const services = serviceFunc();
52
+ const serviceFunc = () => services;
53
+ apolloClient.container = services;
54
+ const clientService = {
55
+ container,
56
+ apolloClient,
57
+ serviceFunc,
58
+ logger,
59
+ };
60
+ if (module.hot) {
61
+ module.hot.dispose(() => {
62
+ // Force Apollo to fetch the latest data from the server
63
+ delete window.__APOLLO_STATE__;
64
+ });
65
+ }
66
+ if (typeof window !== 'undefined') {
67
+ //@ts-ignore
68
+ window.__CLIENT_SERVICE__ = clientService;
69
+ }
70
+ return clientService;
71
+ };export{createClientContainer};
@@ -0,0 +1,15 @@
1
+ export declare const config: Readonly<{
2
+ CLIENT_URL: string;
3
+ LAYOUT_SETTINGS: {
4
+ navTheme: string;
5
+ primaryColor: string;
6
+ layout: string;
7
+ contentWidth: string;
8
+ fixedHeader: boolean;
9
+ fixSiderbar: boolean;
10
+ colorWeak: boolean;
11
+ title: string;
12
+ iconfontUrl: string;
13
+ language: string;
14
+ };
15
+ } & import("envalid").CleanedEnvAccessors>;
@@ -0,0 +1,3 @@
1
+ import { BehaviorSubject } from 'rxjs';
2
+ export declare const epic$: BehaviorSubject<import("redux-observable").Epic<unknown, unknown, void, any>>;
3
+ export declare const rootEpic: (action$: any, state$: any, dependencies: any) => import("rxjs").Observable<unknown>;
@@ -0,0 +1,6 @@
1
+ import {combineEpics,ofType}from'redux-observable';import {BehaviorSubject,mergeMap,takeUntil}from'rxjs';import features from'../modules.js';const epic$ = new BehaviorSubject(combineEpics(...features.epics));
2
+ // Since we're using mergeMap, by default any new
3
+ // epic that comes in will be merged into the previous
4
+ // one, unless an EPIC_END action is dispatched first,
5
+ // which would cause the old one(s) to be unsubscribed
6
+ const rootEpic = (action$, state$, dependencies) => epic$.pipe(mergeMap((epic) => epic(action$, state$, dependencies).pipe(takeUntil(action$.pipe(ofType('EPIC_END'))))));export{epic$,rootEpic};
@@ -0,0 +1,2 @@
1
+ export * from './client.service';
2
+ export * from './redux-config';
@@ -0,0 +1,7 @@
1
+ export declare const config: Readonly<{
2
+ GA_ID: string;
3
+ GRAPHQL_URL: string;
4
+ LOCAL_GRAPHQL_URL: string;
5
+ GRAPHQL_SUBSCRIPTION_URL: string;
6
+ LOG_LEVEL: string;
7
+ } & import("envalid").CleanedEnvAccessors>;
@@ -0,0 +1,8 @@
1
+ import {cleanEnv,str}from'envalid';import {getEnvironment}from'@common-stack/core';const env = getEnvironment();
2
+ const config = cleanEnv(env, {
3
+ GA_ID: str({ devDefault: 'G-xxxxxxx' }),
4
+ GRAPHQL_URL: str({ default: env?.GRAPHQL_URL }),
5
+ LOCAL_GRAPHQL_URL: str({ default: env?.GRAPHQL_URL }),
6
+ GRAPHQL_SUBSCRIPTION_URL: str({ default: env?.GRAPHQL_URL?.replace(/^http/, 'ws') }),
7
+ LOG_LEVEL: str({ devDefault: 'debug' }),
8
+ });export{config};
@@ -0,0 +1,20 @@
1
+ import 'reflect-metadata';
2
+ import { EpicMiddleware } from 'redux-observable';
3
+ import { PersistConfig } from 'redux-persist';
4
+ import modules from '../modules';
5
+ import history from './router-history';
6
+ import { logger } from '../utils';
7
+ export { history };
8
+ interface Dependencies {
9
+ apolloClient: any;
10
+ routes: ReturnType<typeof modules.getConfiguredRoutes>;
11
+ services: any;
12
+ container: any;
13
+ logger: typeof logger;
14
+ config?: any;
15
+ }
16
+ export declare const epicMiddlewareFunc: (apolloClient: any, services: any, container: any) => EpicMiddleware<any, any, any, Dependencies>;
17
+ export declare const persistConfig: PersistConfig<any>;
18
+ export declare const createReduxStore: (apolloClient: any, services: any, container: any) => {
19
+ store: any;
20
+ };
@@ -0,0 +1,52 @@
1
+ import'reflect-metadata';import storage from'@react-native-async-storage/async-storage';import autoMergeLevel2 from'redux-persist/lib/stateReconciler/autoMergeLevel2';import {createEpicMiddleware}from'redux-observable';import {REDUX_PERSIST_KEY,ClientTypes}from'@common-stack/client-core';import {createReduxStore as createReduxStore$1}from'./base-redux-config.js';import features from'../modules.js';import {rootEpic}from'./epic-config.js';export{default as history}from'./router-history.js';import {logger}from'../utils/index.js';const epicMiddlewareFunc = (apolloClient, services, container) => createEpicMiddleware({
2
+ dependencies: {
3
+ apolloClient,
4
+ routes: features.getConfiguredRoutes(),
5
+ services,
6
+ container,
7
+ logger,
8
+ config: {
9
+ loadRoot: true,
10
+ isMobile: true,
11
+ },
12
+ },
13
+ });
14
+ const persistConfig = {
15
+ key: REDUX_PERSIST_KEY,
16
+ storage,
17
+ stateReconciler: autoMergeLevel2,
18
+ transforms: features.reduxPersistStateTransformers,
19
+ };
20
+ const createReduxStore = (apolloClient, services, container) => {
21
+ let store;
22
+ let initialState = {};
23
+ let middlewares = [];
24
+ store = createReduxStore$1({
25
+ scope: typeof window !== 'undefined' ? 'browser' : 'server',
26
+ isDebug: true,
27
+ isDev: process.env.NODE_ENV === 'development',
28
+ initialState,
29
+ persistConfig,
30
+ middleware: middlewares,
31
+ epicMiddleware: epicMiddlewareFunc(apolloClient, services, container),
32
+ rootEpic: rootEpic,
33
+ reducers: { ...features.reducers },
34
+ reduxConfig: features.getReduxConfig(),
35
+ });
36
+ logger.debug('Created new Redux store');
37
+ if (container.isBound(ClientTypes.ReduxStore)) {
38
+ container
39
+ .rebind(ClientTypes.ReduxStore)
40
+ .toDynamicValue(() => store)
41
+ .inRequestScope();
42
+ logger.debug('Rebound ReduxStore in container');
43
+ }
44
+ else {
45
+ container
46
+ .bind(ClientTypes.ReduxStore)
47
+ .toDynamicValue(() => store)
48
+ .inRequestScope();
49
+ logger.debug('Bound ReduxStore in container');
50
+ }
51
+ return { store };
52
+ };export{createReduxStore,epicMiddlewareFunc,persistConfig};
@@ -0,0 +1,2 @@
1
+ declare const hist: import("history").MemoryHistory;
2
+ export default hist;
@@ -0,0 +1 @@
1
+ import {createMemoryHistory}from'history';const hist = createMemoryHistory();export{hist as default};
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './config';
2
+ export * from './utils';
3
+ export * from './load-context.mobile';
package/lib/index.js ADDED
@@ -0,0 +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{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: any;
5
+ container: import("inversify").Container;
6
+ apolloClient: import("@apollo/client").ApolloClient<import("@apollo/client").NormalizedCacheObject>;
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';/* 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(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};
@@ -0,0 +1,3 @@
1
+ import { Feature } from '@common-stack/client-react';
2
+ declare const features: Feature;
3
+ export default features;
package/lib/modules.js ADDED
@@ -0,0 +1,2 @@
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({});export{features as default};
@@ -0,0 +1,10 @@
1
+ import modules from '../modules';
2
+ export declare class UtilityClass {
3
+ private modules;
4
+ constructor(modules: any);
5
+ getCacheKey(storeObj: any): any;
6
+ navigate(name: string, params: never): void;
7
+ }
8
+ declare const logger: import("@cdm-logger/core/lib/interface").ILogger;
9
+ export default modules;
10
+ export { logger };
@@ -0,0 +1,19 @@
1
+ import {ClientLogger}from'@cdm-logger/client';export{default}from'../modules.js';import {navigate}from'./navigator.js';/* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /* eslint-disable import/no-cycle */
3
+ /* eslint-disable @typescript-eslint/no-var-requires */
4
+ class UtilityClass {
5
+ modules;
6
+ // tslint:disable-next-line:no-shadowed-variable
7
+ constructor(modules) {
8
+ this.modules = modules;
9
+ }
10
+ getCacheKey(storeObj) {
11
+ return this.modules.getDataIdFromObject(storeObj);
12
+ }
13
+ navigate(name, params) {
14
+ return navigate(name, params);
15
+ }
16
+ }
17
+ const logger = ClientLogger.create(process.env.APP_NAME || 'Fullstack-Pro', {
18
+ level: process.env.LOG_LEVEL || 'info',
19
+ });export{UtilityClass,logger};
@@ -0,0 +1 @@
1
+ export declare function navigate(name: string, params: never): void;
@@ -0,0 +1,5 @@
1
+ import {navigationRef}from'@common-stack/client-react';function navigate(name, params) {
2
+ if (navigationRef.isReady()) {
3
+ navigationRef.navigate(name, params);
4
+ }
5
+ }export{navigate};
package/package.json ADDED
@@ -0,0 +1,154 @@
1
+ {
2
+ "name": "@common-stack/mobile-stack-react",
3
+ "version": "6.0.6-alpha.100",
4
+ "description": "Client Module for mobile app",
5
+ "homepage": "https://github.com/cdmbase/fullstack-pro#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/cdmbase/fullstack-pro/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/cdmbase/fullstack-pro.git"
12
+ },
13
+ "license": "ISC",
14
+ "author": "CDMBase LLC",
15
+ "type": "module",
16
+ "main": "lib/index.js",
17
+ "module": "lib/index.js",
18
+ "typings": "lib/index.d.ts",
19
+ "scripts": {
20
+ "build": "npm run build:clean && npm run build:lib",
21
+ "build:clean": "rimraf lib",
22
+ "build:lib": "rollup -c rollup.config.mjs",
23
+ "build:lib:watch": "npm run build:lib -- --watch",
24
+ "jest": "./node_modules/.bin/jest",
25
+ "prepublish": "npm run build",
26
+ "test": "jest",
27
+ "test:debug": "npm test -- --runInBand",
28
+ "test:watch": "npm test -- --watch",
29
+ "watch": "npm run build:lib:watch"
30
+ },
31
+ "dependencies": {
32
+ "@apollo/client": "^3.9.0",
33
+ "@cdm-logger/client": "^9.0.3",
34
+ "@common-stack/client-core": "6.0.6-alpha.91",
35
+ "@common-stack/client-react": "6.0.6-alpha.91",
36
+ "@common-stack/components-pro": "6.0.6-alpha.91",
37
+ "@common-stack/core": "6.0.6-alpha.91",
38
+ "@expo/vector-icons": "^14.0.2",
39
+ "@react-native-async-storage/async-storage": "~1.23.1",
40
+ "@react-native-community/datetimepicker": "8.2.0",
41
+ "@react-native-community/masked-view": "~0.1.10",
42
+ "@react-native-community/segmented-control": "~2.2.2",
43
+ "@react-navigation/bottom-tabs": "^7.0.0",
44
+ "@react-navigation/drawer": "^7.0.0",
45
+ "@react-navigation/native": "^7.0.0",
46
+ "@react-navigation/native-stack": "^7.0.0",
47
+ "@react-navigation/stack": "~6.3.18",
48
+ "@reduxjs/toolkit": "^2.2.6",
49
+ "apollo-link-debounce": "^3.0.0",
50
+ "apollo-link-logger": "^2.0.0",
51
+ "apollo-server-errors": "^3.3.1",
52
+ "big-integer": "^1.6.51",
53
+ "cross-fetch": "^4.0.0",
54
+ "envalid": "~7.2.2",
55
+ "expo": "~52.0.17",
56
+ "expo-apple-authentication": "~7.1.2",
57
+ "expo-auth-session": "^6.0.0",
58
+ "expo-blur": "~14.0.1",
59
+ "expo-build-properties": "~0.13.1",
60
+ "expo-constants": "~17.0.3",
61
+ "expo-dev-client": "~5.0.5",
62
+ "expo-device": "~7.0.1",
63
+ "expo-font": "~13.0.1",
64
+ "expo-haptics": "~14.0.0",
65
+ "expo-image-picker": "~16.0.3",
66
+ "expo-linking": "~7.0.3",
67
+ "expo-localization": "~16.0.0",
68
+ "expo-notifications": "~0.29.11",
69
+ "expo-random": "~14.0.1",
70
+ "expo-router": "~4.0.11",
71
+ "expo-secure-store": "~14.0.0",
72
+ "expo-splash-screen": "~0.29.15",
73
+ "expo-status-bar": "~2.0.0",
74
+ "expo-symbols": "~0.2.0",
75
+ "expo-system-ui": "~4.0.5",
76
+ "expo-updates": "^0.26.9",
77
+ "expo-web-browser": "~14.0.1",
78
+ "graphql": "^16.0.0",
79
+ "graphql-ws": "^5.11.2",
80
+ "history": "^4.10.1",
81
+ "immutability-helper": "^3.0.1",
82
+ "inversify": "~6.0.2",
83
+ "isomorphic-fetch": "^2.2.1",
84
+ "lodash": "^4.17.15",
85
+ "metro-minify-terser": "^0.56.0",
86
+ "minilog": "^3.1.0",
87
+ "prop-types": "^15.8.1",
88
+ "query-string": "^9.0.0",
89
+ "ramda": "^0.26.1",
90
+ "react": "18.3.1",
91
+ "react-dom": "18.3.1",
92
+ "react-helmet": "^6.1.0",
93
+ "react-native": "~0.76.3",
94
+ "react-native-confirmation-code-field": "7.3.1",
95
+ "react-native-dotenv": "^3.3.1",
96
+ "react-native-gesture-handler": "~2.20.2",
97
+ "react-native-get-random-values": "~1.11.0",
98
+ "react-native-keyboard-aware-scroll-view": "^0.9.3",
99
+ "react-native-keyboard-spacer": "^0.4.1",
100
+ "react-native-maps": "1.18.0",
101
+ "react-native-mime-types": "^2.3.0",
102
+ "react-native-modal": "^11.6.1",
103
+ "react-native-pager-view": "6.5.1",
104
+ "react-native-reanimated": "~3.16.1",
105
+ "react-native-safe-area-context": "4.12.0",
106
+ "react-native-screens": "~4.1.0",
107
+ "react-native-svg": "15.8.0",
108
+ "react-native-tab-view": "^3.5.2",
109
+ "react-native-tags": "2.2.1",
110
+ "react-native-url-polyfill": "^2.0.0",
111
+ "react-native-web": "~0.19.13",
112
+ "react-native-web-maps": "~0.3.0",
113
+ "react-native-webview": "13.12.5",
114
+ "react-redux": "^9.1.1",
115
+ "redux-logger": "^3.0.6",
116
+ "redux-observable": "^3.0.0-rc.2",
117
+ "redux-persist": "^6.0.0",
118
+ "redux-thunk": "^2.3.0",
119
+ "reflect-metadata": "^0.1.13",
120
+ "reselect": "^4.0.0",
121
+ "rxjs": "^7.8.1",
122
+ "sentry-expo": "~7.0.0",
123
+ "subscriptions-transport-ws": "0.9.18",
124
+ "text-encoding-polyfill": "^0.6.7",
125
+ "ts-invariant": "^0.10.3"
126
+ },
127
+ "devDependencies": {
128
+ "@babel/core": "^7.25.2",
129
+ "@types/jest": "^29.5.12",
130
+ "@types/react": "~18.3.12",
131
+ "@types/react-dom": "~18.3.1",
132
+ "@types/react-test-renderer": "^18.3.0",
133
+ "jest": "^29.2.1",
134
+ "jest-expo": "~52.0.2",
135
+ "react-test-renderer": "18.3.1",
136
+ "typescript": "^5.3.3"
137
+ },
138
+ "jest": {
139
+ "preset": "jest-expo"
140
+ },
141
+ "peerDependencies": {
142
+ "@apollo/client": ">=3.0.0",
143
+ "react": ">=18",
144
+ "react-dom": ">=18",
145
+ "redux": ">=5.0.1"
146
+ },
147
+ "publishConfig": {
148
+ "access": "public"
149
+ },
150
+ "typescript": {
151
+ "definition": "lib/index.d.ts"
152
+ },
153
+ "gitHead": "d93a9fecbb65a8da04bf701b18fbb646afc403b1"
154
+ }