@common-stack/mobile-stack-react 6.0.6-alpha.8 → 6.0.6-alpha.84
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-apollo-cache.js +35 -0
- package/lib/config/base-apollo-client.d.ts +3 -5
- package/lib/config/base-apollo-client.js +54 -82
- package/lib/config/base-redux-config.d.ts +9 -7
- package/lib/config/base-redux-config.js +21 -33
- package/lib/config/client.service.d.ts +2 -2
- package/lib/config/client.service.js +1 -1
- package/lib/config/mobile-env-config.js +2 -2
- package/lib/config/redux-config.d.ts +14 -20
- package/lib/config/redux-config.js +18 -15
- 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 +44 -44
|
@@ -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};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { ApolloClient } from '@apollo/client';
|
|
2
|
-
import { InMemoryCache } from '@apollo/client/cache';
|
|
3
|
-
import { IClientState } from '@common-stack/client-core';
|
|
1
|
+
import { ApolloClient, NormalizedCacheObject, InMemoryCache } from '@apollo/client/index.js';
|
|
4
2
|
import { CdmLogger } from '@cdm-logger/core';
|
|
5
3
|
interface IApolloClientParams {
|
|
6
4
|
initialState?: any;
|
|
7
5
|
scope: 'browser' | 'server' | 'native';
|
|
8
6
|
getDataIdFromObject: (x?: any) => string;
|
|
9
|
-
clientState:
|
|
7
|
+
clientState: any;
|
|
10
8
|
isDebug: boolean;
|
|
11
9
|
isDev: boolean;
|
|
12
10
|
isSSR: boolean;
|
|
@@ -15,7 +13,7 @@ interface IApolloClientParams {
|
|
|
15
13
|
logger: CdmLogger.ILogger;
|
|
16
14
|
}
|
|
17
15
|
export declare const createApolloClient: ({ scope, isDev, isDebug, isSSR, getDataIdFromObject, clientState, httpGraphqlURL, httpLocalGraphqlURL, initialState, logger, }: IApolloClientParams) => {
|
|
18
|
-
apolloClient: ApolloClient<
|
|
16
|
+
apolloClient: ApolloClient<NormalizedCacheObject>;
|
|
19
17
|
cache: InMemoryCache;
|
|
20
18
|
};
|
|
21
19
|
export {};
|
|
@@ -1,65 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
3
|
-
/* eslint-disable no-underscore-dangle */
|
|
4
|
-
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
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
|
|
5
2
|
const schema = `
|
|
6
|
-
|
|
3
|
+
# Add your schema here
|
|
7
4
|
`;
|
|
8
5
|
const errorLink = onError(({ graphQLErrors, networkError }) => {
|
|
9
6
|
if (graphQLErrors) {
|
|
10
|
-
graphQLErrors.map(({ message, locations, path }) =>
|
|
11
|
-
// tslint:disable-next-line
|
|
12
|
-
invariant.warn(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`));
|
|
7
|
+
graphQLErrors.map(({ message, locations, path }) => invariant.warn(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`));
|
|
13
8
|
}
|
|
14
9
|
if (networkError) {
|
|
15
|
-
// tslint:disable-next-line
|
|
16
10
|
invariant.warn(`[Network error]: ${networkError}`);
|
|
17
11
|
}
|
|
18
12
|
});
|
|
19
|
-
let _apolloClient;
|
|
20
|
-
let _memoryCache;
|
|
21
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
22
|
const isBrowser = scope === 'browser';
|
|
23
23
|
const isServer = scope === 'server';
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
logger.trace('Error occured in retryLink Attempt condition', e);
|
|
40
|
-
throw e;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const retrylink = new RetryLink({
|
|
44
|
-
attempts: attemptConditions,
|
|
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
|
+
},
|
|
45
39
|
});
|
|
46
|
-
|
|
47
|
-
// return quickly if client is already created.
|
|
48
|
-
return {
|
|
49
|
-
apolloClient: _apolloClient,
|
|
50
|
-
cache: _memoryCache,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
_memoryCache = cache;
|
|
40
|
+
let link;
|
|
54
41
|
if (isBrowser) {
|
|
55
42
|
const connectionParams = async () => {
|
|
43
|
+
logger.debug('Getting WebSocket connection parameters');
|
|
56
44
|
const param = {};
|
|
57
45
|
for (const connectionParam of clientState.connectionParams) {
|
|
58
|
-
|
|
46
|
+
const result = await connectionParam();
|
|
47
|
+
merge(param, await result());
|
|
59
48
|
}
|
|
60
49
|
return param;
|
|
61
50
|
};
|
|
62
|
-
let timedOut;
|
|
63
51
|
const wsLink = new GraphQLWsLink(createClient({
|
|
64
52
|
url: httpGraphqlURL.replace(/^http/, 'ws'),
|
|
65
53
|
retryAttempts: 10,
|
|
@@ -68,29 +56,20 @@ const createApolloClient = ({ scope, isDev, isDebug, isSSR, getDataIdFromObject,
|
|
|
68
56
|
keepAlive: 10000,
|
|
69
57
|
connectionParams,
|
|
70
58
|
on: {
|
|
71
|
-
connected: (socket) =>
|
|
72
|
-
},
|
|
59
|
+
connected: (socket) => logger.debug('WebSocket connected'),
|
|
73
60
|
error: async (error) => {
|
|
74
|
-
logger.error(error, '
|
|
61
|
+
logger.error(error, 'WebSocket connection error');
|
|
75
62
|
const promises = (clientState.connectionCallbackFuncs || []).map((func) => func(wsLink, error, {}));
|
|
76
63
|
try {
|
|
77
|
-
await promises;
|
|
64
|
+
await Promise.all(promises);
|
|
78
65
|
}
|
|
79
66
|
catch (err) {
|
|
80
|
-
logger.trace('Error occurred in
|
|
67
|
+
logger.trace('Error occurred in WebSocket connection callback', err);
|
|
81
68
|
throw err;
|
|
82
69
|
}
|
|
83
70
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
logger.trace('Pinged Server');
|
|
87
|
-
},
|
|
88
|
-
pong: (received) => {
|
|
89
|
-
logger.trace('Pong received');
|
|
90
|
-
if (received)
|
|
91
|
-
clearTimeout(timedOut); // pong is received, clear connection close timeout
|
|
92
|
-
},
|
|
93
|
-
// inactivityTimeout: 10000,
|
|
71
|
+
ping: () => logger.trace('Ping server'),
|
|
72
|
+
pong: () => logger.trace('Pong received'),
|
|
94
73
|
},
|
|
95
74
|
}));
|
|
96
75
|
link = ApolloLink.split(({ query, operationName }) => {
|
|
@@ -99,49 +78,42 @@ const createApolloClient = ({ scope, isDev, isDebug, isSSR, getDataIdFromObject,
|
|
|
99
78
|
}
|
|
100
79
|
const operationAST = getOperationAST(query, operationName);
|
|
101
80
|
return !!operationAST && operationAST.operation === 'subscription';
|
|
102
|
-
}, wsLink, new HttpLink({
|
|
103
|
-
uri: httpGraphqlURL,
|
|
104
|
-
}));
|
|
81
|
+
}, wsLink, new HttpLink({ uri: httpGraphqlURL, credentials: 'include', fetch }));
|
|
105
82
|
}
|
|
106
83
|
else if (isServer) {
|
|
107
|
-
|
|
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
|
+
});
|
|
108
92
|
}
|
|
109
93
|
else {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const links = [errorLink, retrylink, ...(clientState.preLinks || []), link];
|
|
113
|
-
// Add apollo logger during development only
|
|
114
|
-
if (isBrowser && (isDev || isDebug)) {
|
|
115
|
-
const apolloLogger = require('apollo-link-logger');
|
|
116
|
-
links.unshift(apolloLogger.default);
|
|
94
|
+
logger.debug('Creating HttpLink for native');
|
|
95
|
+
link = new HttpLink({ uri: httpLocalGraphqlURL, fetch, credentials: 'include' });
|
|
117
96
|
}
|
|
97
|
+
const links = [errorLink, retryLink, ...(clientState.preLinks || []), link].filter(Boolean);
|
|
118
98
|
const params = {
|
|
119
99
|
queryDeduplication: true,
|
|
120
|
-
typeDefs: schema.concat(clientState.typeDefs),
|
|
100
|
+
typeDefs: schema.concat(clientState.typeDefs || ''),
|
|
121
101
|
resolvers: clientState.resolvers,
|
|
122
102
|
link: ApolloLink.from(links),
|
|
123
103
|
cache,
|
|
104
|
+
credentials: 'include',
|
|
124
105
|
connectToDevTools: isBrowser && (isDev || isDebug),
|
|
125
106
|
};
|
|
126
107
|
if (isSSR) {
|
|
127
108
|
if (isBrowser) {
|
|
128
|
-
if (initialState) {
|
|
129
|
-
cache.restore(initialState);
|
|
130
|
-
}
|
|
131
109
|
params.ssrForceFetchDelay = 100;
|
|
132
110
|
}
|
|
133
111
|
else if (isServer) {
|
|
134
112
|
params.ssrMode = true;
|
|
135
113
|
}
|
|
136
114
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
else if (x.type === 'fragment') {
|
|
143
|
-
cache.writeFragment(x);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
return { apolloClient: _apolloClient, cache };
|
|
115
|
+
const apolloClient = new ApolloClient(params);
|
|
116
|
+
logger.debug('Created new Apollo client');
|
|
117
|
+
initializeCache({ cache, initialState, clientState, logger });
|
|
118
|
+
return { apolloClient, cache };
|
|
147
119
|
};export{createApolloClient};
|
|
@@ -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").
|
|
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}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,32 @@ 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
|
-
const store = createStore(persistedReducer, initialState, composeEnhancers(...enhancers()));
|
|
44
|
-
if (isBrowser || isElectronMain) {
|
|
45
|
-
// no SSR for now
|
|
46
|
-
if (epicMiddleware) {
|
|
47
|
-
epicMiddleware.run(rootEpic);
|
|
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: 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);
|
|
49
37
|
}
|
|
50
38
|
return store;
|
|
51
39
|
};export{createReduxStore};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { Container } from 'inversify';
|
|
3
|
-
import { ApolloClient } from '@apollo/client/index.js';
|
|
3
|
+
import { ApolloClient, NormalizedCacheObject } from '@apollo/client/index.js';
|
|
4
4
|
export declare const createClientContainer: (req?: any, res?: any) => {
|
|
5
5
|
container: Container;
|
|
6
|
-
apolloClient: ApolloClient<
|
|
6
|
+
apolloClient: ApolloClient<NormalizedCacheObject>;
|
|
7
7
|
serviceFunc: () => any;
|
|
8
8
|
logger: import("@cdm-logger/core/lib/interface").ILogger;
|
|
9
9
|
};
|
|
@@ -35,7 +35,7 @@ const createClientContainer = (req, res) => {
|
|
|
35
35
|
scope: typeof window !== 'undefined' ? 'browser' : 'server',
|
|
36
36
|
clientState,
|
|
37
37
|
getDataIdFromObject: (result) => features.getDataIdFromObject(result),
|
|
38
|
-
initialState:
|
|
38
|
+
initialState: undefined,
|
|
39
39
|
logger,
|
|
40
40
|
});
|
|
41
41
|
if (!container.isBound(ClientTypes.InMemoryCache)) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {cleanEnv,str}from'envalid';import {getEnvironment}from'@common-stack/core';const env = getEnvironment();
|
|
2
2
|
const config = cleanEnv(env, {
|
|
3
3
|
GA_ID: str({ devDefault: 'G-xxxxxxx' }),
|
|
4
|
-
GRAPHQL_URL: str({}),
|
|
5
|
-
LOCAL_GRAPHQL_URL: str({}),
|
|
4
|
+
GRAPHQL_URL: str({ default: env?.GRAPHQL_URL }),
|
|
5
|
+
LOCAL_GRAPHQL_URL: str({ default: env?.GRAPHQL_URL }),
|
|
6
6
|
GRAPHQL_SUBSCRIPTION_URL: str({ default: env?.GRAPHQL_URL?.replace(/^http/, 'ws') }),
|
|
7
7
|
LOG_LEVEL: str({ devDefault: 'debug' }),
|
|
8
8
|
});export{config};
|
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { EpicMiddleware } from 'redux-observable';
|
|
3
|
+
import { PersistConfig } from 'redux-persist';
|
|
4
|
+
import modules from '../modules';
|
|
2
5
|
import history from './router-history';
|
|
6
|
+
import { logger } from '../utils';
|
|
3
7
|
export { history };
|
|
4
|
-
|
|
8
|
+
interface Dependencies {
|
|
5
9
|
apolloClient: any;
|
|
6
|
-
routes:
|
|
10
|
+
routes: ReturnType<typeof modules.getConfiguredRoutes>;
|
|
7
11
|
services: any;
|
|
8
12
|
container: any;
|
|
9
|
-
logger:
|
|
10
|
-
config
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare const
|
|
15
|
-
|
|
16
|
-
storage: import("@react-native-async-storage/async-storage").AsyncStorageStatic;
|
|
17
|
-
stateReconciler: typeof autoMergeLevel2;
|
|
18
|
-
transforms: any[];
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Add any reducers required for this app dirctly in to
|
|
22
|
-
* `combineReducers`
|
|
23
|
-
*/
|
|
24
|
-
export declare const createReduxStore: (history: any, apolloClient: any, services: any, container: any) => {
|
|
25
|
-
store: import("redux").Store<any, import("redux").AnyAction>;
|
|
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;
|
|
26
20
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
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}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({
|
|
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
2
|
dependencies: {
|
|
3
3
|
apolloClient,
|
|
4
4
|
routes: features.getConfiguredRoutes(),
|
|
@@ -6,6 +6,7 @@ import storage from'@react-native-async-storage/async-storage';import autoMergeL
|
|
|
6
6
|
container,
|
|
7
7
|
logger,
|
|
8
8
|
config: {
|
|
9
|
+
loadRoot: true,
|
|
9
10
|
isMobile: true,
|
|
10
11
|
},
|
|
11
12
|
},
|
|
@@ -16,34 +17,36 @@ const persistConfig = {
|
|
|
16
17
|
stateReconciler: autoMergeLevel2,
|
|
17
18
|
transforms: features.reduxPersistStateTransformers,
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
scope: 'browser',
|
|
27
|
-
isDebug: false,
|
|
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,
|
|
28
27
|
isDev: process.env.NODE_ENV === 'development',
|
|
29
|
-
initialState
|
|
28
|
+
initialState,
|
|
30
29
|
persistConfig,
|
|
31
|
-
middleware:
|
|
30
|
+
middleware: middlewares,
|
|
32
31
|
epicMiddleware: epicMiddlewareFunc(apolloClient, services, container),
|
|
33
32
|
rootEpic: rootEpic,
|
|
34
33
|
reducers: { ...features.reducers },
|
|
34
|
+
reduxConfig: features.getReduxConfig(),
|
|
35
35
|
});
|
|
36
|
-
|
|
36
|
+
logger.debug('Created new Redux store');
|
|
37
|
+
if (container.isBound(ClientTypes.ReduxStore)) {
|
|
37
38
|
container
|
|
38
|
-
.rebind(
|
|
39
|
+
.rebind(ClientTypes.ReduxStore)
|
|
39
40
|
.toDynamicValue(() => store)
|
|
40
41
|
.inRequestScope();
|
|
42
|
+
logger.debug('Rebound ReduxStore in container');
|
|
41
43
|
}
|
|
42
44
|
else {
|
|
43
45
|
container
|
|
44
|
-
.bind(
|
|
46
|
+
.bind(ClientTypes.ReduxStore)
|
|
45
47
|
.toDynamicValue(() => store)
|
|
46
48
|
.inRequestScope();
|
|
49
|
+
logger.debug('Bound ReduxStore in container');
|
|
47
50
|
}
|
|
48
51
|
return { store };
|
|
49
52
|
};export{createReduxStore,epicMiddlewareFunc,persistConfig};
|
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: 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};
|
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.84",
|
|
4
4
|
"description": "Client Module for mobile app",
|
|
5
5
|
"homepage": "https://github.com/cdmbase/fullstack-pro#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@apollo/client": "^3.9.0",
|
|
33
33
|
"@cdm-logger/client": "^9.0.3",
|
|
34
|
-
"@common-stack/client-core": "6.0.6-alpha.
|
|
35
|
-
"@common-stack/client-react": "6.0.6-alpha.
|
|
36
|
-
"@common-stack/components-pro": "6.0.6-alpha.
|
|
37
|
-
"@common-stack/core": "6.0.6-alpha.
|
|
38
|
-
"@expo/vector-icons": "
|
|
39
|
-
"@react-native-async-storage/async-storage": "1.
|
|
40
|
-
"@react-native-community/datetimepicker": "
|
|
34
|
+
"@common-stack/client-core": "6.0.6-alpha.84",
|
|
35
|
+
"@common-stack/client-react": "6.0.6-alpha.84",
|
|
36
|
+
"@common-stack/components-pro": "6.0.6-alpha.50",
|
|
37
|
+
"@common-stack/core": "6.0.6-alpha.84",
|
|
38
|
+
"@expo/vector-icons": "^14.0.3",
|
|
39
|
+
"@react-native-async-storage/async-storage": "1.23.1",
|
|
40
|
+
"@react-native-community/datetimepicker": "8.0.1",
|
|
41
41
|
"@react-native-community/masked-view": "~0.1.10",
|
|
42
42
|
"@react-native-community/segmented-control": "~2.2.2",
|
|
43
43
|
"@react-navigation/bottom-tabs": "~6.5.9",
|
|
@@ -52,25 +52,26 @@
|
|
|
52
52
|
"big-integer": "^1.6.51",
|
|
53
53
|
"cross-fetch": "^4.0.0",
|
|
54
54
|
"envalid": "~7.2.2",
|
|
55
|
-
"expo": "~
|
|
56
|
-
"expo-apple-authentication": "~6.
|
|
57
|
-
"expo-asset": "~
|
|
58
|
-
"expo-auth-session": "~5.
|
|
59
|
-
"expo-build-properties": "~0.
|
|
60
|
-
"expo-constants": "~
|
|
61
|
-
"expo-dev-client": "~
|
|
62
|
-
"expo-device": "~
|
|
63
|
-
"expo-file-system": "~
|
|
64
|
-
"expo-image-picker": "~
|
|
65
|
-
"expo-linking": "~
|
|
66
|
-
"expo-localization": "~
|
|
67
|
-
"expo-notifications": "~0.
|
|
68
|
-
"expo-random": "~
|
|
69
|
-
"expo-secure-store": "~
|
|
70
|
-
"expo-splash-screen": "~0.
|
|
71
|
-
"expo-status-bar": "~1.
|
|
72
|
-
"expo-updates": "~0.
|
|
73
|
-
"expo-web-browser": "~
|
|
55
|
+
"expo": "~51.0.38",
|
|
56
|
+
"expo-apple-authentication": "~6.4.2",
|
|
57
|
+
"expo-asset": "~10.0.10",
|
|
58
|
+
"expo-auth-session": "~5.5.2",
|
|
59
|
+
"expo-build-properties": "~0.12.5",
|
|
60
|
+
"expo-constants": "~16.0.2",
|
|
61
|
+
"expo-dev-client": "~4.0.28",
|
|
62
|
+
"expo-device": "~6.0.2",
|
|
63
|
+
"expo-file-system": "~17.0.1",
|
|
64
|
+
"expo-image-picker": "~15.0.7",
|
|
65
|
+
"expo-linking": "~6.3.1",
|
|
66
|
+
"expo-localization": "~15.0.3",
|
|
67
|
+
"expo-notifications": "~0.28.19",
|
|
68
|
+
"expo-random": "~14.0.1",
|
|
69
|
+
"expo-secure-store": "~13.0.2",
|
|
70
|
+
"expo-splash-screen": "~0.27.6",
|
|
71
|
+
"expo-status-bar": "~1.12.1",
|
|
72
|
+
"expo-updates": "~0.25.27",
|
|
73
|
+
"expo-web-browser": "~13.0.3",
|
|
74
|
+
"graphql": "^16.0.0",
|
|
74
75
|
"graphql-ws": "^5.11.2",
|
|
75
76
|
"history": "^4.10.1",
|
|
76
77
|
"immutability-helper": "^3.0.1",
|
|
@@ -85,45 +86,44 @@
|
|
|
85
86
|
"react": "18.2.0",
|
|
86
87
|
"react-dom": "18.2.0",
|
|
87
88
|
"react-helmet": "^6.1.0",
|
|
88
|
-
"react-native": "0.
|
|
89
|
+
"react-native": "0.74.5",
|
|
89
90
|
"react-native-confirmation-code-field": "7.3.1",
|
|
90
91
|
"react-native-dotenv": "^3.3.1",
|
|
91
|
-
"react-native-gesture-handler": "~2.
|
|
92
|
-
"react-native-get-random-values": "~1.
|
|
92
|
+
"react-native-gesture-handler": "~2.16.1",
|
|
93
|
+
"react-native-get-random-values": "~1.11.0",
|
|
93
94
|
"react-native-keyboard-aware-scroll-view": "^0.9.3",
|
|
94
95
|
"react-native-keyboard-spacer": "^0.4.1",
|
|
95
|
-
"react-native-maps": "1.
|
|
96
|
+
"react-native-maps": "1.14.0",
|
|
96
97
|
"react-native-mime-types": "^2.3.0",
|
|
97
98
|
"react-native-modal": "^11.6.1",
|
|
98
|
-
"react-native-pager-view": "6.
|
|
99
|
-
"react-native-reanimated": "~3.
|
|
100
|
-
"react-native-safe-area-context": "4.
|
|
101
|
-
"react-native-screens": "
|
|
102
|
-
"react-native-svg": "
|
|
99
|
+
"react-native-pager-view": "6.3.0",
|
|
100
|
+
"react-native-reanimated": "~3.10.1",
|
|
101
|
+
"react-native-safe-area-context": "4.10.5",
|
|
102
|
+
"react-native-screens": "3.31.1",
|
|
103
|
+
"react-native-svg": "15.2.0",
|
|
103
104
|
"react-native-tab-view": "^3.5.2",
|
|
104
105
|
"react-native-tags": "2.2.1",
|
|
105
106
|
"react-native-url-polyfill": "^2.0.0",
|
|
106
107
|
"react-native-web": "~0.19.6",
|
|
107
108
|
"react-native-web-maps": "~0.3.0",
|
|
108
109
|
"react-redux": "^9.1.1",
|
|
109
|
-
"redux": "^4.0.5",
|
|
110
110
|
"redux-logger": "^3.0.6",
|
|
111
111
|
"redux-observable": "^1.2.0",
|
|
112
112
|
"redux-persist": "^6.0.0",
|
|
113
113
|
"redux-thunk": "^2.3.0",
|
|
114
114
|
"reflect-metadata": "^0.1.13",
|
|
115
115
|
"reselect": "^4.0.0",
|
|
116
|
-
"rxjs": "^
|
|
117
|
-
"
|
|
118
|
-
"rxjs-hooks": "^0.5.2",
|
|
119
|
-
"sentry-expo": "~7.1.0",
|
|
116
|
+
"rxjs": "^7.8.1",
|
|
117
|
+
"sentry-expo": "~7.0.0",
|
|
120
118
|
"subscriptions-transport-ws": "0.9.18",
|
|
121
|
-
"text-encoding-polyfill": "^0.6.7"
|
|
119
|
+
"text-encoding-polyfill": "^0.6.7",
|
|
120
|
+
"ts-invariant": "^0.10.3"
|
|
122
121
|
},
|
|
123
122
|
"peerDependencies": {
|
|
124
123
|
"@apollo/client": ">=3.0.0",
|
|
125
124
|
"react": ">=18",
|
|
126
|
-
"react-dom": ">=18"
|
|
125
|
+
"react-dom": ">=18",
|
|
126
|
+
"redux": ">=5.0.1"
|
|
127
127
|
},
|
|
128
128
|
"publishConfig": {
|
|
129
129
|
"access": "public"
|
|
@@ -131,5 +131,5 @@
|
|
|
131
131
|
"typescript": {
|
|
132
132
|
"definition": "lib/index.d.ts"
|
|
133
133
|
},
|
|
134
|
-
"gitHead": "
|
|
134
|
+
"gitHead": "9be44348b6a4062bc87d71facd35c055002a5b99"
|
|
135
135
|
}
|