@common-stack/client-react 0.6.1-alpha.1 → 0.6.1-alpha.3
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/application/__tests__/react-client.test.d.ts +1 -0
- package/lib/application/__tests__/react-client.test.js +23 -0
- package/lib/application/__tests__/react-client.test.js.map +1 -0
- package/lib/application/base-apollo-client.d.ts +21 -0
- package/lib/application/base-apollo-client.js +161 -0
- package/lib/application/base-apollo-client.js.map +1 -0
- package/lib/application/base-redux-config.d.ts +22 -0
- package/lib/application/base-redux-config.js +58 -0
- package/lib/application/base-redux-config.js.map +1 -0
- package/lib/application/config.d.ts +4 -0
- package/lib/application/config.js +38 -0
- package/lib/application/config.js.map +1 -0
- package/lib/application/react-client.d.ts +7 -0
- package/lib/application/react-client.js +152 -0
- package/lib/application/react-client.js.map +1 -0
- package/lib/connector/base-react-client-feature.js +9 -2
- package/lib/connector/base-react-client-feature.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const react_client_1 = require("../react-client");
|
|
13
|
+
const react_client_feature_1 = require("../../connector/react-client-feature");
|
|
14
|
+
describe('test client', () => {
|
|
15
|
+
it('test onCreate', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const core = new react_client_feature_1.ReactClientFeature({ onAppCreate: react_client_1.onAppCreate });
|
|
17
|
+
const feature1 = new react_client_feature_1.ReactClientFeature({});
|
|
18
|
+
const feature2 = new react_client_feature_1.ReactClientFeature({});
|
|
19
|
+
const mergedFeature = new react_client_feature_1.ReactClientFeature(feature1, feature2, core);
|
|
20
|
+
yield mergedFeature.createApp(module);
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=react-client.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-client.test.js","sourceRoot":"","sources":["../../../src/application/__tests__/react-client.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kDAA8C;AAC9C,+EAA0E;AAE1E,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAEzB,EAAE,CAAC,eAAe,EAAE,GAAS,EAAE;QAC3B,MAAM,IAAI,GAAG,IAAI,yCAAkB,CAAC,EAAE,WAAW,EAAE,0BAAkB,EAAE,CAAC,CAAC;QAEzE,MAAM,QAAQ,GAAG,IAAI,yCAAkB,CAAC,EAAE,CAAC,CAAC;QAC5C,MAAM,QAAQ,GAAG,IAAI,yCAAkB,CAAC,EAAE,CAAC,CAAC;QAE5C,MAAM,aAAa,GAAG,IAAI,yCAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QACvE,MAAM,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC,CAAA,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ApolloClient } from '@apollo/client';
|
|
2
|
+
import { InMemoryCache } from '@apollo/client/cache';
|
|
3
|
+
import { IClientState } from '@common-stack/client-core';
|
|
4
|
+
import { CdmLogger } from '@cdm-logger/core';
|
|
5
|
+
interface IApolloClientParams {
|
|
6
|
+
initialState?: any;
|
|
7
|
+
scope: 'browser' | 'server' | 'native';
|
|
8
|
+
getDataIdFromObject: (x?: any) => string;
|
|
9
|
+
clientState: IClientState;
|
|
10
|
+
isDebug: boolean;
|
|
11
|
+
isDev: boolean;
|
|
12
|
+
isSSR: boolean;
|
|
13
|
+
httpGraphqlURL: string;
|
|
14
|
+
httpLocalGraphqlURL: string;
|
|
15
|
+
logger: CdmLogger.ILogger;
|
|
16
|
+
}
|
|
17
|
+
export declare const createApolloClient: ({ scope, isDev, isDebug, isSSR, getDataIdFromObject, clientState, httpGraphqlURL, httpLocalGraphqlURL, initialState, logger, }: IApolloClientParams) => {
|
|
18
|
+
apolloClient: ApolloClient<any>;
|
|
19
|
+
cache: InMemoryCache;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.createApolloClient = void 0;
|
|
16
|
+
// version 09/18/2021
|
|
17
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
18
|
+
/* eslint-disable no-underscore-dangle */
|
|
19
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
20
|
+
const client_1 = require("@apollo/client");
|
|
21
|
+
const cache_1 = require("@apollo/client/cache");
|
|
22
|
+
const http_1 = require("@apollo/client/link/http");
|
|
23
|
+
const batch_http_1 = require("@apollo/client/link/batch-http");
|
|
24
|
+
const error_1 = require("@apollo/client/link/error");
|
|
25
|
+
const subscriptions_1 = require("@apollo/client/link/subscriptions");
|
|
26
|
+
const graphql_1 = require("graphql");
|
|
27
|
+
const ts_invariant_1 = require("ts-invariant");
|
|
28
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
29
|
+
const lodash_1 = require("lodash");
|
|
30
|
+
const retry_1 = require("@apollo/client/link/retry");
|
|
31
|
+
const graphql_ws_1 = require("graphql-ws");
|
|
32
|
+
const schema = `
|
|
33
|
+
|
|
34
|
+
`;
|
|
35
|
+
const errorLink = (0, error_1.onError)(({ graphQLErrors, networkError }) => {
|
|
36
|
+
if (graphQLErrors) {
|
|
37
|
+
graphQLErrors.map(({ message, locations, path }) =>
|
|
38
|
+
// tslint:disable-next-line
|
|
39
|
+
ts_invariant_1.invariant.warn(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`));
|
|
40
|
+
}
|
|
41
|
+
if (networkError) {
|
|
42
|
+
// tslint:disable-next-line
|
|
43
|
+
ts_invariant_1.invariant.warn(`[Network error]: ${networkError}`);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
let _apolloClient;
|
|
47
|
+
let _memoryCache;
|
|
48
|
+
const createApolloClient = ({ scope, isDev, isDebug, isSSR, getDataIdFromObject, clientState, httpGraphqlURL, httpLocalGraphqlURL, initialState, logger, }) => {
|
|
49
|
+
var _a;
|
|
50
|
+
const isBrowser = scope === 'browser';
|
|
51
|
+
const isServer = scope === 'server';
|
|
52
|
+
let link;
|
|
53
|
+
const cache = new cache_1.InMemoryCache({
|
|
54
|
+
dataIdFromObject: getDataIdFromObject,
|
|
55
|
+
possibleTypes: clientState.possibleTypes,
|
|
56
|
+
});
|
|
57
|
+
const attemptConditions = (count, operation, error) => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
const promises = (clientState.retryLinkAttemptFuncs || []).map((func) => func(count, operation, error));
|
|
59
|
+
try {
|
|
60
|
+
const result = yield promises;
|
|
61
|
+
return !!result.find((item) => item && (0, lodash_1.isBoolean)(item));
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
logger.trace('Error occured in retryLink Attempt condition', e);
|
|
65
|
+
throw e;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const retrylink = new retry_1.RetryLink({
|
|
69
|
+
attempts: attemptConditions,
|
|
70
|
+
});
|
|
71
|
+
if (_apolloClient && _memoryCache) {
|
|
72
|
+
// return quickly if client is already created.
|
|
73
|
+
return {
|
|
74
|
+
apolloClient: _apolloClient,
|
|
75
|
+
cache: _memoryCache,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
_memoryCache = cache;
|
|
79
|
+
if (isBrowser) {
|
|
80
|
+
const connectionParams = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
|
+
const param = {};
|
|
82
|
+
for (const connectionParam of clientState.connectionParams) {
|
|
83
|
+
(0, lodash_1.merge)(param, yield connectionParam);
|
|
84
|
+
}
|
|
85
|
+
return param;
|
|
86
|
+
});
|
|
87
|
+
const wsLink = new subscriptions_1.GraphQLWsLink((0, graphql_ws_1.createClient)({
|
|
88
|
+
url: httpGraphqlURL.replace(/^http/, 'ws'),
|
|
89
|
+
retryAttempts: 10,
|
|
90
|
+
lazy: true,
|
|
91
|
+
connectionParams,
|
|
92
|
+
on: {
|
|
93
|
+
error: (error) => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
logger.error(error, '[WS connectionCallback error] %j');
|
|
95
|
+
const promises = (clientState.connectionCallbackFuncs || []).map((func) => func(wsLink, error, {}));
|
|
96
|
+
try {
|
|
97
|
+
yield promises;
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
logger.trace('Error occurred in connectionCallback condition', err);
|
|
101
|
+
throw err;
|
|
102
|
+
}
|
|
103
|
+
}),
|
|
104
|
+
// connected: (socket, payload) => {}
|
|
105
|
+
},
|
|
106
|
+
// inactivityTimeout: 10000,
|
|
107
|
+
}));
|
|
108
|
+
link = client_1.ApolloLink.split(({ query, operationName }) => {
|
|
109
|
+
if (operationName.endsWith('_WS')) {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
const operationAST = (0, graphql_1.getOperationAST)(query, operationName);
|
|
113
|
+
return !!operationAST && operationAST.operation === 'subscription';
|
|
114
|
+
}, wsLink, new http_1.HttpLink({
|
|
115
|
+
uri: httpGraphqlURL,
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
else if (isServer) {
|
|
119
|
+
link = new batch_http_1.BatchHttpLink({ uri: httpLocalGraphqlURL, fetch: node_fetch_1.default });
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
link = (0, http_1.createHttpLink)({ uri: httpLocalGraphqlURL, fetch: node_fetch_1.default });
|
|
123
|
+
}
|
|
124
|
+
const links = [errorLink, retrylink, ...(clientState.preLinks || []), link];
|
|
125
|
+
// Add apollo logger during development only
|
|
126
|
+
if (isBrowser && (isDev || isDebug)) {
|
|
127
|
+
const apolloLogger = require('apollo-link-logger');
|
|
128
|
+
links.unshift(apolloLogger.default);
|
|
129
|
+
}
|
|
130
|
+
const params = {
|
|
131
|
+
queryDeduplication: true,
|
|
132
|
+
typeDefs: schema.concat(clientState.typeDefs),
|
|
133
|
+
resolvers: clientState.resolvers,
|
|
134
|
+
link: client_1.ApolloLink.from(links),
|
|
135
|
+
cache,
|
|
136
|
+
connectToDevTools: isBrowser && (isDev || isDebug),
|
|
137
|
+
};
|
|
138
|
+
if (isSSR) {
|
|
139
|
+
if (isBrowser) {
|
|
140
|
+
if (initialState) {
|
|
141
|
+
cache.restore(initialState);
|
|
142
|
+
}
|
|
143
|
+
params.ssrForceFetchDelay = 100;
|
|
144
|
+
}
|
|
145
|
+
else if (isServer) {
|
|
146
|
+
params.ssrMode = true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
_apolloClient = new client_1.ApolloClient(params);
|
|
150
|
+
(_a = clientState === null || clientState === void 0 ? void 0 : clientState.defaults) === null || _a === void 0 ? void 0 : _a.forEach((x) => {
|
|
151
|
+
if (x.type === 'query') {
|
|
152
|
+
cache.writeQuery(x);
|
|
153
|
+
}
|
|
154
|
+
else if (x.type === 'fragment') {
|
|
155
|
+
cache.writeFragment(x);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
return { apolloClient: _apolloClient, cache };
|
|
159
|
+
};
|
|
160
|
+
exports.createApolloClient = createApolloClient;
|
|
161
|
+
//# sourceMappingURL=base-apollo-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-apollo-client.js","sourceRoot":"","sources":["../../src/application/base-apollo-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,qBAAqB;AACrB,sDAAsD;AACtD,yCAAyC;AACzC,sEAAsE;AACtE,2CAA+E;AAC/E,gDAAqD;AACrD,mDAAoE;AACpE,+DAA+D;AAC/D,qDAAoD;AACpD,qEAAkE;AAClE,qCAA0C;AAC1C,+CAAyC;AAEzC,4DAA+B;AAC/B,mCAA0C;AAE1C,qDAAsD;AACtD,2CAA0C;AAE1C,MAAM,MAAM,GAAG;;CAEd,CAAC;AAeF,MAAM,SAAS,GAAG,IAAA,eAAO,EAAC,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,EAAE,EAAE;IAC1D,IAAI,aAAa,EAAE;QACf,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE;QAC/C,2BAA2B;QAC3B,wBAAS,CAAC,IAAI,CAAC,6BAA6B,OAAO,eAAe,SAAS,WAAW,IAAI,EAAE,C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ACL,iBAAiB,EAAE,SAAS,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC;KACrD,CAAC;IACF,IAAI,KAAK,EAAE;QACP,IAAI,SAAS,EAAE;YACX,IAAI,YAAY,EAAE;gBACd,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;aAC/B;YACD,MAAM,CAAC,kBAAkB,GAAG,GAAG,CAAC;SACnC;aAAM,IAAI,QAAQ,EAAE;YACjB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;SACzB;KACJ;IACD,aAAa,GAAG,IAAI,qBAAY,CAAM,MAAM,CAAC,CAAC;IAE9C,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,QAAQ,0CAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACjC,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE;YACpB,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;SACvB;aAAM,IAAI,CAAC,CAAC,IAAI,KAAK,UAAU,EAAE;YAC9B,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;SAC1B;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAClD,CAAC,CAAC;AAvIW,QAAA,kBAAkB,sBAuI7B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Middleware, Action, ReducersMapObject, PreloadedState } 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: ReducersMapObject<S>;
|
|
9
|
+
rootEpic?: Epic<Action<S>, Action<any>, void, any>;
|
|
10
|
+
epicMiddleware?: EpicMiddleware<Action<S>, Action<any>>;
|
|
11
|
+
preMiddleware?: Middleware[];
|
|
12
|
+
postMiddleware?: Middleware[];
|
|
13
|
+
middleware?: Middleware[];
|
|
14
|
+
initialState: PreloadedState<S>;
|
|
15
|
+
persistConfig?: PersistConfig<S, any>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Add any reducers required for this app dirctly in to
|
|
19
|
+
* `combineReducers`
|
|
20
|
+
*/
|
|
21
|
+
export declare const createReduxStore: ({ scope, isDebug, isDev, reducers, rootEpic, epicMiddleware, preMiddleware, postMiddleware, middleware, initialState, persistConfig, }: IReduxStore<any>) => import("redux").Store<any, import("redux").AnyAction>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createReduxStore = void 0;
|
|
4
|
+
// version 11/12/2021
|
|
5
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
8
|
+
/* eslint-disable global-require */
|
|
9
|
+
/* eslint-disable no-underscore-dangle */
|
|
10
|
+
const redux_1 = require("redux");
|
|
11
|
+
const redux_persist_1 = require("redux-persist");
|
|
12
|
+
/**
|
|
13
|
+
* Add any reducers required for this app dirctly in to
|
|
14
|
+
* `combineReducers`
|
|
15
|
+
*/
|
|
16
|
+
const createReduxStore = ({ scope, isDebug, isDev, reducers, rootEpic, epicMiddleware, preMiddleware, postMiddleware, middleware, initialState = {}, persistConfig, }) => {
|
|
17
|
+
const isBrowser = scope === 'browser';
|
|
18
|
+
const isElectronMain = scope === 'ElectronMain';
|
|
19
|
+
/**
|
|
20
|
+
* Add middleware that required for this app.
|
|
21
|
+
*/
|
|
22
|
+
const middlewares = [];
|
|
23
|
+
// add epicMiddleware
|
|
24
|
+
if (epicMiddleware) {
|
|
25
|
+
middlewares.push(epicMiddleware);
|
|
26
|
+
}
|
|
27
|
+
if (preMiddleware) {
|
|
28
|
+
middlewares.unshift(...preMiddleware);
|
|
29
|
+
}
|
|
30
|
+
// Add redux logger during development only
|
|
31
|
+
if ((isDev || isDebug) && isBrowser) {
|
|
32
|
+
const { createLogger } = require('redux-logger');
|
|
33
|
+
middlewares.push(createLogger({
|
|
34
|
+
level: 'info',
|
|
35
|
+
collapsed: true,
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
if (middleware) {
|
|
39
|
+
middlewares.push(...middleware);
|
|
40
|
+
}
|
|
41
|
+
if (postMiddleware) {
|
|
42
|
+
middlewares.push(...postMiddleware);
|
|
43
|
+
}
|
|
44
|
+
const enhancers = () => [(0, redux_1.applyMiddleware)(...middlewares)];
|
|
45
|
+
const composeEnhancers = ((isDev || isDebug) && isBrowser && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || redux_1.compose;
|
|
46
|
+
const rootReducer = (0, redux_1.combineReducers)(reducers);
|
|
47
|
+
const persistedReducer = persistConfig ? (0, redux_persist_1.persistReducer)(persistConfig, rootReducer) : rootReducer;
|
|
48
|
+
const store = (0, redux_1.createStore)(persistedReducer, initialState, composeEnhancers(...enhancers()));
|
|
49
|
+
if (isBrowser || isElectronMain) {
|
|
50
|
+
// no SSR for now
|
|
51
|
+
if (epicMiddleware) {
|
|
52
|
+
epicMiddleware.run(rootEpic);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return store;
|
|
56
|
+
};
|
|
57
|
+
exports.createReduxStore = createReduxStore;
|
|
58
|
+
//# sourceMappingURL=base-redux-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-redux-config.js","sourceRoot":"","sources":["../../src/application/base-redux-config.ts"],"names":[],"mappings":";;;AAAA,qBAAqB;AACrB,sEAAsE;AACtE,uDAAuD;AACvD,uDAAuD;AACvD,mCAAmC;AACnC,yCAAyC;AACzC,iCAUe;AAEf,iDAA8D;AAe9D;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,MAAM,gBAAgB,GAAG,aAAa,CAAC,CAAC,CAAC,IAAA,8BAAc,EAAC,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;IAElG,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,CAAC,GAAG,SAAS,EAAE,CAAC,CAAC,CAAC;IAC5F,IAAI,SAAS,IAAI,cAAc,EAAE;QAC7B,iBAAiB;QACjB,IAAI,cAAc,EAAE;YAChB,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;SAChC;KACJ;IAED,OAAO,KAAK,CAAC;AACjB,CAAC,CAAC;AAhEW,QAAA,gBAAgB,oBAgE3B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.config = void 0;
|
|
27
|
+
const envalid = __importStar(require("envalid"));
|
|
28
|
+
const { str, bool, num } = envalid;
|
|
29
|
+
// export const config = envalid.cleanEnv(process.env, {
|
|
30
|
+
// NODE_ENV: str({ default: 'production', choices: ['production', 'staging', 'development', 'test'] }),
|
|
31
|
+
// LOCAL_GRAPHQL_URL: str({ default: __GRAPHQL_URL__ }),
|
|
32
|
+
// GRAPHQL_URL: str({ devDefault: __GRAPHQL_URL__ }),
|
|
33
|
+
// });
|
|
34
|
+
exports.config = {
|
|
35
|
+
LOCAL_GRAPHQL_URL: 'http://localhost',
|
|
36
|
+
GRAPHQL_URL: 'http://localhost',
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/application/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AAEnC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;AAEnC,wDAAwD;AACxD,2GAA2G;AAC3G,4DAA4D;AAC5D,yDAAyD;AACzD,MAAM;AAEO,QAAA,MAAM,GAAG;IAClB,iBAAiB,EAAE,kBAAkB;IACrC,WAAW,EAAE,kBAAkB;CAClC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ReactClientFeature } from '../connector/react-client-feature';
|
|
3
|
+
export declare const getStoreReducer: (history: any, reducers: any) => import("redux").Reducer<import("redux").CombinedState<{
|
|
4
|
+
[x: string]: unknown;
|
|
5
|
+
}>, never>;
|
|
6
|
+
export declare const onAppDispose: (_: any, data: any) => void;
|
|
7
|
+
export declare const onAppCreate: (modules: ReactClientFeature, entryModule: NodeModule | any) => Promise<void>;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.onAppCreate = exports.onAppDispose = exports.getStoreReducer = void 0;
|
|
16
|
+
const redux_observable_1 = require("redux-observable");
|
|
17
|
+
const rxjs_1 = require("rxjs");
|
|
18
|
+
const operators_1 = require("rxjs/operators");
|
|
19
|
+
const client_1 = require("@cdm-logger/client");
|
|
20
|
+
const redux_1 = require("redux");
|
|
21
|
+
const redux_observable_2 = require("redux-observable");
|
|
22
|
+
const storage_1 = __importDefault(require("redux-persist/lib/storage"));
|
|
23
|
+
const redux_thunk_1 = __importDefault(require("redux-thunk"));
|
|
24
|
+
const redux_persist_1 = require("redux-persist");
|
|
25
|
+
const autoMergeLevel2_1 = __importDefault(require("redux-persist/lib/stateReconciler/autoMergeLevel2"));
|
|
26
|
+
const connected_react_router_1 = require("connected-react-router");
|
|
27
|
+
const client_core_1 = require("@common-stack/client-core");
|
|
28
|
+
const base_redux_config_1 = require("./base-redux-config");
|
|
29
|
+
const config_1 = require("./config");
|
|
30
|
+
const base_apollo_client_1 = require("./base-apollo-client");
|
|
31
|
+
const history_1 = require("history");
|
|
32
|
+
class UtilityClass {
|
|
33
|
+
// tslint:disable-next-line:no-shadowed-variable
|
|
34
|
+
constructor(modules) {
|
|
35
|
+
this.modules = modules;
|
|
36
|
+
}
|
|
37
|
+
getCacheKey(storeObj) {
|
|
38
|
+
return this.modules.getDataIdFromObject(storeObj);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const logger = client_1.ClientLogger.create(process.env.APP_NAME || 'Fullstack-Pro', {
|
|
42
|
+
level: process.env.LOG_LEVEL || 'info',
|
|
43
|
+
});
|
|
44
|
+
const getStoreReducer = (history, reducers) => (0, redux_1.combineReducers)(Object.assign({ router: (0, connected_react_router_1.connectRouter)(history) }, reducers));
|
|
45
|
+
exports.getStoreReducer = getStoreReducer;
|
|
46
|
+
const ref = {
|
|
47
|
+
modules: null,
|
|
48
|
+
container: null,
|
|
49
|
+
history: null,
|
|
50
|
+
apolloClient: null,
|
|
51
|
+
reduxStore: null,
|
|
52
|
+
};
|
|
53
|
+
const onAppDispose = (_, data) => {
|
|
54
|
+
data.store = ref.reduxStore;
|
|
55
|
+
data.history = ref.history;
|
|
56
|
+
delete window.__APOLLO_STATE__;
|
|
57
|
+
};
|
|
58
|
+
exports.onAppDispose = onAppDispose;
|
|
59
|
+
const onAppCreate = (modules, entryModule) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
var _a, _b, _c, _d;
|
|
61
|
+
ref.modules = modules;
|
|
62
|
+
// apollo client
|
|
63
|
+
const clientState = modules.getStateParams({ resolverContex: () => ref.modules.createService({}, {}) });
|
|
64
|
+
const { cache, apolloClient } = (0, base_apollo_client_1.createApolloClient)({
|
|
65
|
+
httpGraphqlURL: config_1.config.GRAPHQL_URL,
|
|
66
|
+
httpLocalGraphqlURL: config_1.config.LOCAL_GRAPHQL_URL,
|
|
67
|
+
isDev: process.env.NODE_ENV === 'development',
|
|
68
|
+
isDebug: __DEBUGGING__,
|
|
69
|
+
isSSR: __SSR__,
|
|
70
|
+
scope: __CLIENT__ ? 'browser' : 'server',
|
|
71
|
+
clientState,
|
|
72
|
+
getDataIdFromObject: (result) => ref.modules.getDataIdFromObject(result),
|
|
73
|
+
initialState: null,
|
|
74
|
+
logger,
|
|
75
|
+
});
|
|
76
|
+
const utility = new UtilityClass(ref.modules);
|
|
77
|
+
// additional bindings to container
|
|
78
|
+
const container = ref.modules.container;
|
|
79
|
+
container.bind(client_core_1.ClientTypes.Logger).toConstantValue(logger);
|
|
80
|
+
container.bind(client_core_1.ClientTypes.UtilityClass).toConstantValue(utility);
|
|
81
|
+
// attaching the context to client as a workaround.
|
|
82
|
+
container.bind(client_core_1.ClientTypes.ApolloClient).toConstantValue(apolloClient);
|
|
83
|
+
container.bind(client_core_1.ClientTypes.InMemoryCache).toConstantValue(cache);
|
|
84
|
+
// services
|
|
85
|
+
const services = ref.modules.createService({}, {});
|
|
86
|
+
apolloClient.container = services;
|
|
87
|
+
const epicMiddleware = (0, redux_observable_2.createEpicMiddleware)({
|
|
88
|
+
dependencies: {
|
|
89
|
+
apolloClient,
|
|
90
|
+
routes: ref.modules.getConfiguredRoutes(),
|
|
91
|
+
services,
|
|
92
|
+
container,
|
|
93
|
+
logger,
|
|
94
|
+
config: {
|
|
95
|
+
loadRoot: true,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
const epic$ = new rxjs_1.BehaviorSubject((0, redux_observable_1.combineEpics)(...ref.modules.epics));
|
|
100
|
+
// Since we're using mergeMap, by default any new
|
|
101
|
+
// epic that comes in will be merged into the previous
|
|
102
|
+
// one, unless an EPIC_END action is dispatched first,
|
|
103
|
+
// which would cause the old one(s) to be unsubscribed
|
|
104
|
+
const rootEpic = (action$, ...rest) => epic$.pipe((0, operators_1.mergeMap)((epic) => epic(action$, ...rest).pipe((0, operators_1.takeUntil)(action$.pipe((0, redux_observable_1.ofType)('EPIC_END'))))));
|
|
105
|
+
const persistConfig = {
|
|
106
|
+
key: client_core_1.REDUX_PERSIST_KEY,
|
|
107
|
+
storage: storage_1.default,
|
|
108
|
+
stateReconciler: autoMergeLevel2_1.default,
|
|
109
|
+
transforms: ref.modules.reduxPersistStateTransformers,
|
|
110
|
+
};
|
|
111
|
+
// redux
|
|
112
|
+
if (entryModule.hot && entryModule.hot.data && ((_a = entryModule.hot) === null || _a === void 0 ? void 0 : _a.data.store)) {
|
|
113
|
+
ref.reduxStore = entryModule.hot.data.store;
|
|
114
|
+
(_b = ref.reduxStore) === null || _b === void 0 ? void 0 : _b.replaceReducer((0, redux_persist_1.persistReducer)(persistConfig, (0, exports.getStoreReducer)(((_d = (_c = entryModule === null || entryModule === void 0 ? void 0 : entryModule.hot) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.history) || history, ref.modules.reducers)));
|
|
115
|
+
// entryModule.hot.accept('../config/epic-config', () => {
|
|
116
|
+
// // we may need to reload epic always as we don't
|
|
117
|
+
// // know whether it is updated using our `modules`
|
|
118
|
+
// const nextRootEpic = require('./epic-config').rootEpic;
|
|
119
|
+
// // First kill any running epics
|
|
120
|
+
// ref.reduxStore?.dispatch({ type: 'EPIC_END' });
|
|
121
|
+
// // Now setup the new one
|
|
122
|
+
// epic$.next(nextRootEpic);
|
|
123
|
+
// });
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// If we have preloaded state, save it.
|
|
127
|
+
const initialState = __CLIENT__
|
|
128
|
+
? Object.assign({}, window.__PRELOADED_STATE__) : {};
|
|
129
|
+
// Delete it once we have it stored in a variable
|
|
130
|
+
if (__CLIENT__) {
|
|
131
|
+
delete window.__PRELOADED_STATE__;
|
|
132
|
+
}
|
|
133
|
+
// middleware
|
|
134
|
+
const history = (0, history_1.createBrowserHistory)();
|
|
135
|
+
const router = (0, connected_react_router_1.connectRouter)(history);
|
|
136
|
+
ref.reduxStore = (0, base_redux_config_1.createReduxStore)({
|
|
137
|
+
scope: __CLIENT__ ? 'browser' : 'server',
|
|
138
|
+
isDebug: true,
|
|
139
|
+
isDev: process.env.NODE_ENV === 'development',
|
|
140
|
+
initialState,
|
|
141
|
+
persistConfig,
|
|
142
|
+
middleware: [redux_thunk_1.default, (0, connected_react_router_1.routerMiddleware)(history)],
|
|
143
|
+
epicMiddleware,
|
|
144
|
+
rootEpic: rootEpic,
|
|
145
|
+
reducers: Object.assign({ router }, modules.reducers),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
// this will be not mapped for epics
|
|
149
|
+
container.bind('ReduxStore').toConstantValue(ref.reduxStore);
|
|
150
|
+
});
|
|
151
|
+
exports.onAppCreate = onAppCreate;
|
|
152
|
+
//# sourceMappingURL=react-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-client.js","sourceRoot":"","sources":["../../src/application/react-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAAwD;AACxD,+BAAuC;AACvC,8CAAqD;AAGrD,+CAAkD;AAClD,iCAA+C;AAC/C,uDAAwD;AACxD,wEAAgD;AAEhD,8DAA0C;AAC1C,iDAA+C;AAC/C,wGAAgF;AAChF,mEAAyE;AACzE,2DAA2E;AAE3E,2DAAuD;AACvD,qCAAkC;AAClC,6DAA0D;AAC1D,qCAA+C;AAE/C,MAAM,YAAY;IACd,gDAAgD;IAChD,YAAoB,OAAO;QAAP,YAAO,GAAP,OAAO,CAAA;IAAG,CAAC;IAExB,WAAW,CAAC,QAAQ;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACtD,CAAC;CACJ;AAGD,MAAM,MAAM,GAAG,qBAAY,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,eAAe,EAAE;IACxE,KAAK,EAAG,OAAO,CAAC,GAAG,CAAC,SAAiB,IAAI,MAAM;CAClD,CAAC,CAAC;AAGI,MAAM,eAAe,GAAG,CAAC,OAAY,EAAE,Q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AAC,mBAAmB,CAAC;SACrC;QACD,aAAa;QACb,MAAM,OAAO,GAAG,IAAA,8BAAoB,GAAE,CAAC;QAEvC,MAAM,MAAM,GAAG,IAAA,sCAAa,EAAC,OAAO,CAAC,CAAC;QACtC,GAAG,CAAC,UAAU,GAAG,IAAA,oCAAgB,EAAC;YAC9B,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ;YACxC,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa;YAC7C,YAAY;YACZ,aAAa;YACb,UAAU,EAAE,CAAC,qBAAe,EAAE,IAAA,yCAAgB,EAAC,OAAO,CAAC,CAAC;YACxD,cAAc;YACd,QAAQ,EAAE,QAAe;YACzB,QAAQ,kBAAI,MAAM,IAAK,OAAO,CAAC,QAAQ,CAAE;SAC5C,CAAC,CAAC;KACN;IAED,oCAAoC;IACpC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AACjE,CAAC,CAAA,CAAC;AAxGW,QAAA,WAAW,eAwGtB"}
|
|
@@ -32,6 +32,13 @@ const plugin_area_1 = require("../plugin-area");
|
|
|
32
32
|
class BaseReactClientFeature extends client_core_1.ApolloClientFeature {
|
|
33
33
|
constructor(...modules) {
|
|
34
34
|
super(...modules);
|
|
35
|
+
this.sidebarSegmentsIn = [];
|
|
36
|
+
this.routerFactoryIn = [];
|
|
37
|
+
this.routeConfigIn = [];
|
|
38
|
+
this.stylesIn = [];
|
|
39
|
+
this.scriptsIn = [];
|
|
40
|
+
this.navItemIn = [];
|
|
41
|
+
this.navItemRightIn = [];
|
|
35
42
|
this.sortMenusByPriority = (menus) => {
|
|
36
43
|
return (0, lodash_1.sortBy)(menus, (obj) => parseInt(obj.priority, 10));
|
|
37
44
|
};
|
|
@@ -65,14 +72,14 @@ class BaseReactClientFeature extends client_core_1.ApolloClientFeature {
|
|
|
65
72
|
}
|
|
66
73
|
getDataRoot(root) {
|
|
67
74
|
let nestedRoot = root;
|
|
68
|
-
for (const component of this.dataRootComponentIn) {
|
|
75
|
+
for (const component of this.dataRootComponentIn || []) {
|
|
69
76
|
nestedRoot = React.createElement(component, {}, nestedRoot);
|
|
70
77
|
}
|
|
71
78
|
return nestedRoot;
|
|
72
79
|
}
|
|
73
80
|
getWrappedRoot(root, req) {
|
|
74
81
|
let nestedRoot = root;
|
|
75
|
-
for (const componentFactory of this.rootComponentFactoryIn) {
|
|
82
|
+
for (const componentFactory of this.rootComponentFactoryIn || []) {
|
|
76
83
|
nestedRoot = React.cloneElement(componentFactory(req), {}, nestedRoot);
|
|
77
84
|
}
|
|
78
85
|
return nestedRoot;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-react-client-feature.js","sourceRoot":"","sources":["../../src/connector/base-react-client-feature.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,qDAAyC;AACzC,2DAAgE;AAChE,mCAAgC;AAGhC,gDAAuE;AAEvE,MAAsB,sBAAuB,SAAQ,iCAAmB;IAepE,YAAY,GAAG,OAAmC;QAC9C,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"base-react-client-feature.js","sourceRoot":"","sources":["../../src/connector/base-react-client-feature.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,qDAAyC;AACzC,2DAAgE;AAChE,mCAAgC;AAGhC,gDAAuE;AAEvE,MAAsB,sBAAuB,SAAQ,iCAAmB;IAepE,YAAY,GAAG,OAAmC;QAC9C,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC;QAdb,sBAAiB,GAAW,EAAE,CAAC;QAC/B,oBAAe,GAAW,EAAE,CAAC;QAC7B,kBAAa,GAAkB,EAAE,CAAC;QAClC,aAAQ,GAAc,EAAE,CAAC;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;CAoBJ;AArFD,wDAqFC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/client-react",
|
|
3
|
-
"version": "0.6.1-alpha.
|
|
3
|
+
"version": "0.6.1-alpha.3",
|
|
4
4
|
"description": "browser plugin for git",
|
|
5
5
|
"homepage": "https://github.com/cdmbase/fullstack-pro#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"watch": "npm run build:lib:watch"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@common-stack/client-core": "0.6.1-alpha.
|
|
32
|
-
"@common-stack/core": "0.6.1-alpha.
|
|
31
|
+
"@common-stack/client-core": "0.6.1-alpha.3",
|
|
32
|
+
"@common-stack/core": "0.6.1-alpha.3",
|
|
33
33
|
"@wordpress/hooks": "^2.10.0",
|
|
34
34
|
"browser-bunyan": "^1.6.3",
|
|
35
35
|
"history-with-query": "^4.10.4",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "8c23bfd49fb16286e23bf5d3d2dce2deb724b275",
|
|
52
52
|
"typescript": {
|
|
53
53
|
"definition": "lib/index.d.ts"
|
|
54
54
|
}
|