@common-stack/frontend-stack-react 4.0.2-alpha.9 → 4.0.3-alpha.1
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/redux-config.js +4 -4
- package/lib/entries/antui/components/ErrorBoundary.js +9 -26
- package/lib/entries/antui/entry.server.js +0 -1
- package/lib/entries/antui/root.js +1 -1
- package/lib/entries/chakraui/root.d.ts +1 -0
- package/lib/entries/chakraui/root.js +7 -2
- package/package.json +5 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import'reflect-metadata';import storage from'redux-persist/lib/storage/index.js';import {combineReducers}from'@reduxjs/toolkit';import autoMergeLevel2 from'redux-persist/lib/stateReconciler/autoMergeLevel2.js';import {createEpicMiddleware}from'redux-observable';import {createRouterReducer}from'@common-stack/remix-router-redux';import {persistReducer}from'redux-persist';import {REDUX_PERSIST_KEY}from'@common-stack/client-core';import {createReduxStore as createReduxStore$1}from'./base-redux-config.js';import {logger}from'../utils/index.js';import features from'../modules.js';import {rootEpic}from'./epic-config.js';const epicMiddlewareFunc = (apolloClient, services, container) => createEpicMiddleware({
|
|
1
|
+
import'reflect-metadata';import storage from'redux-persist/lib/storage/index.js';import {combineReducers}from'@reduxjs/toolkit';import autoMergeLevel2 from'redux-persist/lib/stateReconciler/autoMergeLevel2.js';import {createEpicMiddleware}from'redux-observable';import {createRouterReducer}from'@common-stack/remix-router-redux';import {persistReducer}from'redux-persist';import {REDUX_PERSIST_KEY,ClientTypes}from'@common-stack/client-core';import {createReduxStore as createReduxStore$1}from'./base-redux-config.js';import {logger}from'../utils/index.js';import features from'../modules.js';import {rootEpic}from'./epic-config.js';const epicMiddlewareFunc = (apolloClient, services, container) => createEpicMiddleware({
|
|
2
2
|
dependencies: {
|
|
3
3
|
apolloClient,
|
|
4
4
|
routes: features.getConfiguredRoutes(),
|
|
@@ -47,12 +47,12 @@ const createReduxStore = (apolloClient, services, container) => {
|
|
|
47
47
|
});
|
|
48
48
|
logger.debug('Created new Redux store');
|
|
49
49
|
}
|
|
50
|
-
if (container.isBound(
|
|
51
|
-
container.rebind(
|
|
50
|
+
if (container.isBound(ClientTypes.ReduxStore)) {
|
|
51
|
+
container.rebind(ClientTypes.ReduxStore).toDynamicValue(() => store).inRequestScope();
|
|
52
52
|
logger.debug('Rebound ReduxStore in container');
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
|
-
container.bind(
|
|
55
|
+
container.bind(ClientTypes.ReduxStore).toDynamicValue(() => store).inRequestScope();
|
|
56
56
|
logger.debug('Bound ReduxStore in container');
|
|
57
57
|
}
|
|
58
58
|
return { store };
|
|
@@ -1,29 +1,12 @@
|
|
|
1
|
-
import*as React from'react';import {Error500}from'@admin-layout/ant-ui';import {useRouteError,isRouteErrorResponse}from'@remix-run/react';
|
|
1
|
+
import*as React from'react';import {Error500}from'@admin-layout/ant-ui';import {useRouteError,isRouteErrorResponse}from'@remix-run/react';function ErrorBoundary() {
|
|
2
2
|
const error = useRouteError();
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (graphqlError.type === 'ACCOUNT_NOT_FOUND') {
|
|
12
|
-
setHasAccountNotFoundError(true);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
setIsLoading(false);
|
|
17
|
-
}, [error]);
|
|
18
|
-
if (!isLoading) {
|
|
19
|
-
if (isRouteErrorResponse(error)) {
|
|
20
|
-
return hasAccountNotFoundError ? (React.createElement(Navigate, { to: "/verify-user" })) : (React.createElement(Error500, { title: error.statusText, status: error.status, data: error.data }));
|
|
21
|
-
}
|
|
22
|
-
else if (error instanceof Error) {
|
|
23
|
-
return React.createElement(Error500, { title: error.message, status: "500", data: error.stack });
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
return React.createElement(Error500, { title: "Unknown Error", status: "500", data: error });
|
|
27
|
-
}
|
|
3
|
+
if (isRouteErrorResponse(error)) {
|
|
4
|
+
return React.createElement(Error500, { title: `Route Error: ${error.statusText}`, status: error.status, data: error.data });
|
|
5
|
+
}
|
|
6
|
+
else if (error instanceof Error) {
|
|
7
|
+
return React.createElement(Error500, { title: error.message, status: "500", data: error.stack });
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
return React.createElement(Error500, { title: "Unknown Error", status: "500", data: error });
|
|
28
11
|
}
|
|
29
12
|
}export{ErrorBoundary};
|
|
@@ -56,7 +56,6 @@ loadContext) {
|
|
|
56
56
|
defaultNS: config.i18n.defaultNS,
|
|
57
57
|
react: config.i18n.react,
|
|
58
58
|
supportedLngs: config.i18n.supportedLngs,
|
|
59
|
-
// ...config.i18n, // use the same configuration as in your client side.
|
|
60
59
|
lng, // The locale we detected above
|
|
61
60
|
ns, // The namespaces the routes about to render want to use
|
|
62
61
|
backend: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import'reflect-metadata';import*as React from'react';import {Outlet,json,useLoaderData,Meta,Links,ScrollRestoration,Scripts}from'@remix-run/react';import publicEnv from'@src/
|
|
1
|
+
import'reflect-metadata';import*as React from'react';import {Outlet,json,useLoaderData,Meta,Links,ScrollRestoration,Scripts}from'@remix-run/react';import publicEnv from'@src/config/public-config';import {PluginArea}from'@common-stack/client-react';import {subscribeReduxRouter}from'@common-stack/remix-router-redux';import {ApplicationErrorHandler}from'@admin-layout/ant-ui';import {ConfigProvider}from'antd';import clientModules,{plugins}from'@app/frontend-stack-react/modules.js';import {useChangeLanguage}from'remix-i18next/react';import {useTranslation}from'react-i18next';import {i18nextInstance}from'@app/frontend-stack-react/i18n-localization/i18next.server.js';export{ErrorBoundary}from'@app/frontend-stack-react/entries/antui/components/ErrorBoundary';const loader = async ({ request }) => {
|
|
2
2
|
const locale = await i18nextInstance.getLocale(request);
|
|
3
3
|
return json({
|
|
4
4
|
__ENV__: publicEnv,
|
|
@@ -16,7 +16,6 @@ const Document = withEmotionCache(({ children }, emotionCache) => {
|
|
|
16
16
|
});
|
|
17
17
|
// reset cache to reapply global styles
|
|
18
18
|
clientStyleData?.reset();
|
|
19
|
-
subscribeReduxRouter({ store: window.__remixStore, router: window.__remixRouter });
|
|
20
19
|
}, []);
|
|
21
20
|
return (React.createElement(React.Fragment, null,
|
|
22
21
|
React.createElement(Head, null),
|
|
@@ -34,9 +33,15 @@ let loader = async ({ request }) => {
|
|
|
34
33
|
let handle = {
|
|
35
34
|
i18n: 'common',
|
|
36
35
|
};
|
|
36
|
+
function shouldRevalidate(params) {
|
|
37
|
+
return params.defaultShouldRevalidate && params.currentUrl.pathname !== params.nextUrl.pathname;
|
|
38
|
+
}
|
|
37
39
|
function App() {
|
|
38
40
|
let { locale } = useLoaderData();
|
|
39
41
|
useChangeLanguage(locale);
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
subscribeReduxRouter({ store: window.__remixStore, router: window.__remixRouter });
|
|
44
|
+
}, []);
|
|
40
45
|
return (React.createElement(ApplicationErrorHandler, { plugins: plugins },
|
|
41
46
|
React.createElement(Document, null, clientModules.getWrappedRoot(React.createElement(Outlet, null)))));
|
|
42
|
-
}export{Document,Head,App as default,handle,loader};
|
|
47
|
+
}export{Document,Head,App as default,handle,loader,shouldRevalidate};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/frontend-stack-react",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3-alpha.1",
|
|
4
4
|
"description": "Client Module for react app",
|
|
5
5
|
"homepage": "https://github.com/cdmbase/fullstack-pro#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@chakra-ui/react": "^2.8.2",
|
|
33
|
-
"@common-stack/client-react": "
|
|
34
|
-
"@common-stack/core": "
|
|
33
|
+
"@common-stack/client-react": "0.0.1",
|
|
34
|
+
"@common-stack/core": "0.0.1",
|
|
35
|
+
"i18next": "^23.10.1",
|
|
35
36
|
"i18next-browser-languagedetector": "^8.0.0",
|
|
36
37
|
"i18next-fs-backend": "^2.3.1",
|
|
37
38
|
"i18next-http-backend": "^2.5.2",
|
|
@@ -56,5 +57,5 @@
|
|
|
56
57
|
"typescript": {
|
|
57
58
|
"definition": "lib/index.d.ts"
|
|
58
59
|
},
|
|
59
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "6df975115a069d10e3f62967edcf41e8c427fc14"
|
|
60
61
|
}
|