@beinformed/ui 1.28.0 → 1.28.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/CHANGELOG.md +6 -0
- package/esm/react-client/client.js +1 -2
- package/esm/react-client/client.js.map +1 -1
- package/esm/react-client/index.js +1 -1
- package/esm/react-client/index.js.map +1 -1
- package/lib/react-client/client.js +2 -3
- package/lib/react-client/client.js.flow +1 -3
- package/lib/react-client/client.js.map +1 -1
- package/lib/react-client/index.js +17 -7
- package/lib/react-client/index.js.flow +1 -2
- package/lib/react-client/index.js.map +1 -1
- package/package.json +1 -1
- package/src/react-client/client.js +1 -3
- package/src/react-client/index.js +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.28.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.28.0...v1.28.1) (2023-02-20)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **export:** make all parts of react-client importable ([11c4465](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/11c446547c576385644fc8519350c33fd517e009))
|
|
10
|
+
|
|
5
11
|
## [1.28.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.27.6...v1.28.0) (2023-02-20)
|
|
6
12
|
|
|
7
13
|
### Features
|
|
@@ -142,7 +142,7 @@ const mountClient = (applicationNode, initComponent) => {
|
|
|
142
142
|
/**
|
|
143
143
|
* Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.
|
|
144
144
|
*/
|
|
145
|
-
const client = _ref => {
|
|
145
|
+
export const client = _ref => {
|
|
146
146
|
let {
|
|
147
147
|
customReducers,
|
|
148
148
|
theme,
|
|
@@ -156,5 +156,4 @@ const client = _ref => {
|
|
|
156
156
|
} = setupClient(customReducers, beforeRenderHooks);
|
|
157
157
|
addContentLoadedEvent(store, routerHistory, theme, render, ErrorFallbackComponent, mountClient);
|
|
158
158
|
};
|
|
159
|
-
export default client;
|
|
160
159
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["hydrate","render","has","setImmediate","Cache","createBrowserHistory","configureStore","rehydrate","getBasePath","setAllContentInDataSetting","setLoginPreferences","showXHRErrorNotification","handleError","loginSuccess","locationChange","JsonParseException","FetchException","Init","handleBeforeRenderHooks","parseDataToJSON","data","JSON","parse","error","getDataFromServer","dataElement","document","querySelector","Error","textContent","setUnhandledRejectionEvent","store","window","onunhandledrejection","event","detail","errorMessage","reason","message","toString","dispatch","setupClient","customReducers","beforeRenderHooks","contextPath","clear","browserHistory","basename","routerHistory","getState","loadOtherBrowserTabs","getItem","response","listen","location","action","body","className","addContentLoadedEvent","theme","ErrorFallbackComponent","mount","addEventListener","applicationNode","mountClient","initComponent","isSSR","client"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\nimport { hydrate, render } from \"react-dom\";\n\nimport { has } from \"../utils/helpers/objects\";\nimport setImmediate from \"setimmediate\";\n\nimport Cache from \"../utils/browser/Cache\";\n\nimport { createBrowserHistory } from \"history\";\nimport configureStore from \"../redux/store/configureStore\";\n\nimport rehydrate from \"./rehydrate\";\nimport { getBasePath } from \"../constants/Settings\";\n\nimport {\n setAllContentInDataSetting,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\nimport { showXHRErrorNotification } from \"../redux/actions/Notification\";\n\nimport { handleError } from \"../redux/actions/Error\";\nimport { loginSuccess } from \"../redux/actions/SignIn\";\n\nimport { locationChange } from \"../redux/_router/RouterActions\";\n\nimport { JsonParseException, FetchException } from \"../exceptions\";\n\nimport Init from \"./Init\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport type {\n ComponentType,\n Element as ReactElement,\n ElementType,\n} from \"react\";\nimport type { Theme } from \"../react-theme/types\";\nimport type { CustomReducers, ReduxStore } from \"../redux/types\";\nimport type { RouterHistory } from \"react-router\";\nimport type { BeforeRenderHook } from \"../redux/store/beforeRenderHooks\";\nimport type { Props as FallbackProps } from \"../react/ErrorBoundaryFallback\";\n\nexport type Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: Function,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n};\n\n/*\n * deserialize serialized data from the server to provide a smooth dehydration.\n */\nconst parseDataToJSON = (data: string) => {\n try {\n return JSON.parse(data);\n } catch (error) {\n throw new JsonParseException(`Error parsing content ${data}`);\n }\n};\n\nconst getDataFromServer = () => {\n const dataElement = document.querySelector(\n 'script[type=\"application/json\"][data-app-state=\"app-json\"]'\n );\n\n if (!dataElement) {\n throw new Error(\"Error loading state, json not found\");\n } else if (dataElement.textContent.trim() === \"\") {\n return {};\n }\n\n return parseDataToJSON(dataElement.textContent);\n};\n\n/**\n */\nexport const setUnhandledRejectionEvent = (store: ReduxStore) => {\n window.onunhandledrejection = (event) => {\n if (event.detail) {\n return setImmediate(() => {\n const errorMessage = event.detail.reason.message.toString();\n\n store.dispatch(showXHRErrorNotification(errorMessage));\n throw event.detail.reason;\n });\n }\n\n return event;\n };\n};\n\n/**\n */\nexport const setupClient = (\n customReducers: CustomReducers = {},\n beforeRenderHooks: ?Array<BeforeRenderHook>\n): { store: ReduxStore, routerHistory: RouterHistory } => {\n if (typeof window.contextPath === \"undefined\") {\n throw new Error(\"Missing contextPath on window object\");\n }\n\n const data = getDataFromServer();\n\n // remove all resources from cache\n Cache.clear(\"^res:\");\n\n // $FlowExpectedError\n const browserHistory: RouterHistory = createBrowserHistory({\n basename: getBasePath(),\n });\n const { routerHistory, store } = configureStore(\n browserHistory,\n customReducers,\n rehydrate(data)\n );\n\n setAllContentInDataSetting(store.getState());\n setLoginPreferences(store.getState());\n\n // load existing cache from other browser tabs\n Cache.loadOtherBrowserTabs(() => {\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n });\n\n if (has(data, \"error.name\")) {\n const error = new FetchException(data?.error?.response);\n store.dispatch(handleError(error));\n }\n\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n\n // listen to history change and update the redux router store\n routerHistory.listen((location, action) => {\n store.dispatch(locationChange(location, action));\n });\n\n setUnhandledRejectionEvent(store);\n\n if (document.body) {\n document.body.className = \"js\";\n }\n\n if (beforeRenderHooks) {\n handleBeforeRenderHooks(beforeRenderHooks, { store });\n }\n\n return { store, routerHistory };\n};\n\n/**\n */\nexport const addContentLoadedEvent = (\n store: ReduxStore,\n routerHistory: RouterHistory,\n theme?: Theme | Array<Theme>,\n render: Function,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n mount: Function\n) => {\n window.addEventListener(\"DOMContentLoaded\", () => {\n const applicationNode = document.querySelector(\"#application\");\n if (!applicationNode) {\n throw new Error(\n \"No DOM element with id application found to attach client to\"\n );\n }\n\n mount(\n applicationNode,\n <Init\n store={store}\n routerHistory={routerHistory}\n contextPath={window.contextPath}\n theme={theme}\n ErrorFallbackComponent={ErrorFallbackComponent}\n >\n {render()}\n </Init>\n );\n });\n};\n\n/**\n */\nconst mountClient = (\n applicationNode: Element,\n initComponent: ReactElement<ElementType>\n) => {\n const isSSR = applicationNode.querySelector(\".application\");\n if (isSSR) {\n hydrate(initComponent, applicationNode);\n } else {\n render(initComponent, applicationNode);\n }\n};\n\n/**\n * Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.\n */\nconst client = ({\n customReducers,\n theme,\n render,\n beforeRenderHooks,\n ErrorFallbackComponent,\n}: Props) => {\n const { store, routerHistory } = setupClient(\n customReducers,\n beforeRenderHooks\n );\n\n addContentLoadedEvent(\n store,\n routerHistory,\n theme,\n render,\n ErrorF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AAK,EAAEhC,KAAM;MACb,aAAa,EAAEiB,aAAc;MAC7B,WAAW,EAAEhB,MAAM,CAACY,WAAY;MAChC,KAAK,EAAEe,KAAM;MACb,sBAAsB,EAAEC,sBAAuB;MAAA,UAE9C3D,MAAM;IAAE,EACJ,CACR;EACH,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA,MAAM+D,WAAW,GAAG,CAClBD,eAAwB,EACxBE,aAAwC,KACrC;EACH,MAAMC,KAAK,GAAGH,eAAe,CAACpC,aAAa,CAAC,cAAc,CAAC;EAC3D,IAAIuC,KAAK,EAAE;IACTlE,OAAO,CAACiE,aAAa,EAAEF,eAAe,CAAC;EACzC,CAAC,MAAM;IACL9D,MAAM,CAACgE,aAAa,EAAEF,eAAe,CAAC;EACxC;AACF,CAAC;;AAED;AACA;AACA;AACA,MAAMI,MAAM,GAAG,QAMF;EAAA,IANG;IACdzB,cAAc;IACdiB,KAAK;IACL1D,MAAM;IACN0C,iBAAiB;IACjBiB;EACK,CAAC;EACN,MAAM;IAAE7B,KAAK;IAAEiB;EAAc,CAAC,GAAGP,WAAW,CAC1CC,cAAc,EACdC,iBAAiB,CAClB;EAEDe,qBAAqB,CACnB3B,KAAK,EACLiB,aAAa,EACbW,KAAK,EACL1D,MAAM,EACN2D,sBAAsB,EACtBI,WAAW,CACZ;AACH,CAAC;AAED,eAAeG,MAAM"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["hydrate","render","has","setImmediate","Cache","createBrowserHistory","configureStore","rehydrate","getBasePath","setAllContentInDataSetting","setLoginPreferences","showXHRErrorNotification","handleError","loginSuccess","locationChange","JsonParseException","FetchException","Init","handleBeforeRenderHooks","parseDataToJSON","data","JSON","parse","error","getDataFromServer","dataElement","document","querySelector","Error","textContent","setUnhandledRejectionEvent","store","window","onunhandledrejection","event","detail","errorMessage","reason","message","toString","dispatch","setupClient","customReducers","beforeRenderHooks","contextPath","clear","browserHistory","basename","routerHistory","getState","loadOtherBrowserTabs","getItem","response","listen","location","action","body","className","addContentLoadedEvent","theme","ErrorFallbackComponent","mount","addEventListener","applicationNode","mountClient","initComponent","isSSR","client"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\nimport { hydrate, render } from \"react-dom\";\n\nimport { has } from \"../utils/helpers/objects\";\nimport setImmediate from \"setimmediate\";\n\nimport Cache from \"../utils/browser/Cache\";\n\nimport { createBrowserHistory } from \"history\";\nimport configureStore from \"../redux/store/configureStore\";\n\nimport rehydrate from \"./rehydrate\";\nimport { getBasePath } from \"../constants/Settings\";\n\nimport {\n setAllContentInDataSetting,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\nimport { showXHRErrorNotification } from \"../redux/actions/Notification\";\n\nimport { handleError } from \"../redux/actions/Error\";\nimport { loginSuccess } from \"../redux/actions/SignIn\";\n\nimport { locationChange } from \"../redux/_router/RouterActions\";\n\nimport { JsonParseException, FetchException } from \"../exceptions\";\n\nimport Init from \"./Init\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport type {\n ComponentType,\n Element as ReactElement,\n ElementType,\n} from \"react\";\nimport type { Theme } from \"../react-theme/types\";\nimport type { CustomReducers, ReduxStore } from \"../redux/types\";\nimport type { RouterHistory } from \"react-router\";\nimport type { BeforeRenderHook } from \"../redux/store/beforeRenderHooks\";\nimport type { Props as FallbackProps } from \"../react/ErrorBoundaryFallback\";\n\nexport type Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: Function,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n};\n\n/*\n * deserialize serialized data from the server to provide a smooth dehydration.\n */\nconst parseDataToJSON = (data: string) => {\n try {\n return JSON.parse(data);\n } catch (error) {\n throw new JsonParseException(`Error parsing content ${data}`);\n }\n};\n\nconst getDataFromServer = () => {\n const dataElement = document.querySelector(\n 'script[type=\"application/json\"][data-app-state=\"app-json\"]'\n );\n\n if (!dataElement) {\n throw new Error(\"Error loading state, json not found\");\n } else if (dataElement.textContent.trim() === \"\") {\n return {};\n }\n\n return parseDataToJSON(dataElement.textContent);\n};\n\n/**\n */\nexport const setUnhandledRejectionEvent = (store: ReduxStore) => {\n window.onunhandledrejection = (event) => {\n if (event.detail) {\n return setImmediate(() => {\n const errorMessage = event.detail.reason.message.toString();\n\n store.dispatch(showXHRErrorNotification(errorMessage));\n throw event.detail.reason;\n });\n }\n\n return event;\n };\n};\n\n/**\n */\nexport const setupClient = (\n customReducers: CustomReducers = {},\n beforeRenderHooks: ?Array<BeforeRenderHook>\n): { store: ReduxStore, routerHistory: RouterHistory } => {\n if (typeof window.contextPath === \"undefined\") {\n throw new Error(\"Missing contextPath on window object\");\n }\n\n const data = getDataFromServer();\n\n // remove all resources from cache\n Cache.clear(\"^res:\");\n\n // $FlowExpectedError\n const browserHistory: RouterHistory = createBrowserHistory({\n basename: getBasePath(),\n });\n const { routerHistory, store } = configureStore(\n browserHistory,\n customReducers,\n rehydrate(data)\n );\n\n setAllContentInDataSetting(store.getState());\n setLoginPreferences(store.getState());\n\n // load existing cache from other browser tabs\n Cache.loadOtherBrowserTabs(() => {\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n });\n\n if (has(data, \"error.name\")) {\n const error = new FetchException(data?.error?.response);\n store.dispatch(handleError(error));\n }\n\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n\n // listen to history change and update the redux router store\n routerHistory.listen((location, action) => {\n store.dispatch(locationChange(location, action));\n });\n\n setUnhandledRejectionEvent(store);\n\n if (document.body) {\n document.body.className = \"js\";\n }\n\n if (beforeRenderHooks) {\n handleBeforeRenderHooks(beforeRenderHooks, { store });\n }\n\n return { store, routerHistory };\n};\n\n/**\n */\nexport const addContentLoadedEvent = (\n store: ReduxStore,\n routerHistory: RouterHistory,\n theme?: Theme | Array<Theme>,\n render: Function,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n mount: Function\n) => {\n window.addEventListener(\"DOMContentLoaded\", () => {\n const applicationNode = document.querySelector(\"#application\");\n if (!applicationNode) {\n throw new Error(\n \"No DOM element with id application found to attach client to\"\n );\n }\n\n mount(\n applicationNode,\n <Init\n store={store}\n routerHistory={routerHistory}\n contextPath={window.contextPath}\n theme={theme}\n ErrorFallbackComponent={ErrorFallbackComponent}\n >\n {render()}\n </Init>\n );\n });\n};\n\n/**\n */\nconst mountClient = (\n applicationNode: Element,\n initComponent: ReactElement<ElementType>\n) => {\n const isSSR = applicationNode.querySelector(\".application\");\n if (isSSR) {\n hydrate(initComponent, applicationNode);\n } else {\n render(initComponent, applicationNode);\n }\n};\n\n/**\n * Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.\n */\nexport const client = ({\n customReducers,\n theme,\n render,\n beforeRenderHooks,\n ErrorFallbackComponent,\n}: Props) => {\n const { store, routerHistory } = setupClient(\n customReducers,\n beforeRenderHooks\n );\n\n addContentLoadedEvent(\n store,\n routerHistory,\n theme,\n render,\n ErrorFallbackComponent,\n mountClient\n );\n};\n"],"mappings":";AACA,SAASA,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAE3C,SAASC,GAAG,QAAQ,0BAA0B;AAC9C,OAAOC,YAAY,MAAM,cAAc;AAEvC,OAAOC,KAAK,MAAM,wBAAwB;AAE1C,SAASC,oBAAoB,QAAQ,SAAS;AAC9C,OAAOC,cAAc,MAAM,+BAA+B;AAE1D,OAAOC,SAAS,MAAM,aAAa;AACnC,SAASC,WAAW,QAAQ,uBAAuB;AAEnD,SACEC,0BAA0B,EAC1BC,mBAAmB,QACd,8BAA8B;AACrC,SAASC,wBAAwB,QAAQ,+BAA+B;AAExE,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,YAAY,QAAQ,yBAAyB;AAEtD,SAASC,cAAc,QAAQ,gCAAgC;AAE/D,SAASC,kBAAkB,EAAEC,cAAc,QAAQ,eAAe;AAElE,OAAOC,IAAI,MAAM,QAAQ;AAEzB,SAAS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iB;IACjBiB;EACK,CAAC;EACN,MAAM;IAAE7B,KAAK;IAAEiB;EAAc,CAAC,GAAGP,WAAW,CAC1CC,cAAc,EACdC,iBAAiB,CAClB;EAEDe,qBAAqB,CACnB3B,KAAK,EACLiB,aAAa,EACbW,KAAK,EACL1D,MAAM,EACN2D,sBAAsB,EACtBI,WAAW,CACZ;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["setCustomErrorResponseHandler","default","Init"
|
|
1
|
+
{"version":3,"file":"index.js","names":["setCustomErrorResponseHandler","default","Init"],"sources":["../../src/react-client/index.js"],"sourcesContent":["// @flow\nexport { setCustomErrorResponseHandler } from \"../redux/actions/Error\";\n\nexport { default as Init } from \"./Init\";\n\nexport * from \"./client\";\n"],"mappings":"AACA,SAASA,6BAA6B,QAAQ,wBAAwB;AAEtE,SAASC,OAAO,IAAIC,IAAI,QAAQ,QAAQ;AAExC,cAAc,UAAU"}
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.setupClient = exports.setUnhandledRejectionEvent = exports.
|
|
7
|
+
exports.setupClient = exports.setUnhandledRejectionEvent = exports.client = exports.addContentLoadedEvent = void 0;
|
|
8
8
|
var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
|
|
9
9
|
var _reactDom = require("react-dom");
|
|
10
10
|
var _objects = require("../utils/helpers/objects");
|
|
@@ -166,6 +166,5 @@ const client = _ref => {
|
|
|
166
166
|
} = setupClient(customReducers, beforeRenderHooks);
|
|
167
167
|
addContentLoadedEvent(store, routerHistory, theme, render, ErrorFallbackComponent, mountClient);
|
|
168
168
|
};
|
|
169
|
-
|
|
170
|
-
exports.default = _default;
|
|
169
|
+
exports.client = client;
|
|
171
170
|
//# sourceMappingURL=client.js.map
|
|
@@ -202,7 +202,7 @@ const mountClient = (
|
|
|
202
202
|
/**
|
|
203
203
|
* Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.
|
|
204
204
|
*/
|
|
205
|
-
const client = ({
|
|
205
|
+
export const client = ({
|
|
206
206
|
customReducers,
|
|
207
207
|
theme,
|
|
208
208
|
render,
|
|
@@ -223,5 +223,3 @@ const client = ({
|
|
|
223
223
|
mountClient
|
|
224
224
|
);
|
|
225
225
|
};
|
|
226
|
-
|
|
227
|
-
export default client;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["parseDataToJSON","data","JSON","parse","error","JsonParseException","getDataFromServer","dataElement","document","querySelector","Error","textContent","setUnhandledRejectionEvent","store","window","onunhandledrejection","event","detail","setImmediate","errorMessage","reason","message","toString","dispatch","showXHRErrorNotification","setupClient","customReducers","beforeRenderHooks","contextPath","Cache","clear","browserHistory","createBrowserHistory","basename","getBasePath","routerHistory","configureStore","rehydrate","setAllContentInDataSetting","getState","setLoginPreferences","loadOtherBrowserTabs","getItem","loginSuccess","has","FetchException","response","handleError","listen","location","action","locationChange","body","className","handleBeforeRenderHooks","addContentLoadedEvent","theme","render","ErrorFallbackComponent","mount","addEventListener","applicationNode","mountClient","initComponent","isSSR","hydrate","client"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\nimport { hydrate, render } from \"react-dom\";\n\nimport { has } from \"../utils/helpers/objects\";\nimport setImmediate from \"setimmediate\";\n\nimport Cache from \"../utils/browser/Cache\";\n\nimport { createBrowserHistory } from \"history\";\nimport configureStore from \"../redux/store/configureStore\";\n\nimport rehydrate from \"./rehydrate\";\nimport { getBasePath } from \"../constants/Settings\";\n\nimport {\n setAllContentInDataSetting,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\nimport { showXHRErrorNotification } from \"../redux/actions/Notification\";\n\nimport { handleError } from \"../redux/actions/Error\";\nimport { loginSuccess } from \"../redux/actions/SignIn\";\n\nimport { locationChange } from \"../redux/_router/RouterActions\";\n\nimport { JsonParseException, FetchException } from \"../exceptions\";\n\nimport Init from \"./Init\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport type {\n ComponentType,\n Element as ReactElement,\n ElementType,\n} from \"react\";\nimport type { Theme } from \"../react-theme/types\";\nimport type { CustomReducers, ReduxStore } from \"../redux/types\";\nimport type { RouterHistory } from \"react-router\";\nimport type { BeforeRenderHook } from \"../redux/store/beforeRenderHooks\";\nimport type { Props as FallbackProps } from \"../react/ErrorBoundaryFallback\";\n\nexport type Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: Function,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n};\n\n/*\n * deserialize serialized data from the server to provide a smooth dehydration.\n */\nconst parseDataToJSON = (data: string) => {\n try {\n return JSON.parse(data);\n } catch (error) {\n throw new JsonParseException(`Error parsing content ${data}`);\n }\n};\n\nconst getDataFromServer = () => {\n const dataElement = document.querySelector(\n 'script[type=\"application/json\"][data-app-state=\"app-json\"]'\n );\n\n if (!dataElement) {\n throw new Error(\"Error loading state, json not found\");\n } else if (dataElement.textContent.trim() === \"\") {\n return {};\n }\n\n return parseDataToJSON(dataElement.textContent);\n};\n\n/**\n */\nexport const setUnhandledRejectionEvent = (store: ReduxStore) => {\n window.onunhandledrejection = (event) => {\n if (event.detail) {\n return setImmediate(() => {\n const errorMessage = event.detail.reason.message.toString();\n\n store.dispatch(showXHRErrorNotification(errorMessage));\n throw event.detail.reason;\n });\n }\n\n return event;\n };\n};\n\n/**\n */\nexport const setupClient = (\n customReducers: CustomReducers = {},\n beforeRenderHooks: ?Array<BeforeRenderHook>\n): { store: ReduxStore, routerHistory: RouterHistory } => {\n if (typeof window.contextPath === \"undefined\") {\n throw new Error(\"Missing contextPath on window object\");\n }\n\n const data = getDataFromServer();\n\n // remove all resources from cache\n Cache.clear(\"^res:\");\n\n // $FlowExpectedError\n const browserHistory: RouterHistory = createBrowserHistory({\n basename: getBasePath(),\n });\n const { routerHistory, store } = configureStore(\n browserHistory,\n customReducers,\n rehydrate(data)\n );\n\n setAllContentInDataSetting(store.getState());\n setLoginPreferences(store.getState());\n\n // load existing cache from other browser tabs\n Cache.loadOtherBrowserTabs(() => {\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n });\n\n if (has(data, \"error.name\")) {\n const error = new FetchException(data?.error?.response);\n store.dispatch(handleError(error));\n }\n\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n\n // listen to history change and update the redux router store\n routerHistory.listen((location, action) => {\n store.dispatch(locationChange(location, action));\n });\n\n setUnhandledRejectionEvent(store);\n\n if (document.body) {\n document.body.className = \"js\";\n }\n\n if (beforeRenderHooks) {\n handleBeforeRenderHooks(beforeRenderHooks, { store });\n }\n\n return { store, routerHistory };\n};\n\n/**\n */\nexport const addContentLoadedEvent = (\n store: ReduxStore,\n routerHistory: RouterHistory,\n theme?: Theme | Array<Theme>,\n render: Function,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n mount: Function\n) => {\n window.addEventListener(\"DOMContentLoaded\", () => {\n const applicationNode = document.querySelector(\"#application\");\n if (!applicationNode) {\n throw new Error(\n \"No DOM element with id application found to attach client to\"\n );\n }\n\n mount(\n applicationNode,\n <Init\n store={store}\n routerHistory={routerHistory}\n contextPath={window.contextPath}\n theme={theme}\n ErrorFallbackComponent={ErrorFallbackComponent}\n >\n {render()}\n </Init>\n );\n });\n};\n\n/**\n */\nconst mountClient = (\n applicationNode: Element,\n initComponent: ReactElement<ElementType>\n) => {\n const isSSR = applicationNode.querySelector(\".application\");\n if (isSSR) {\n hydrate(initComponent, applicationNode);\n } else {\n render(initComponent, applicationNode);\n }\n};\n\n/**\n * Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.\n */\nconst client = ({\n customReducers,\n theme,\n render,\n beforeRenderHooks,\n ErrorFallbackComponent,\n}: Props) => {\n const { store, routerHistory } = setupClient(\n customReducers,\n beforeRenderHooks\n );\n\n addContentLoadedEvent(\n store,\n routerHistory,\n theme,\n render,\n ErrorFallbackComponent,\n mountClient\n );\n};\n\nexport default client;\n"],"mappings":";;;;;;;;AACA;AAEA;AACA;AAEA;AAEA;AACA;AAEA;AACA;AAEA;AAIA;AAEA;AACA;AAEA;AAEA;AAEA;AAEA;AAA2E;AAqB3E;AACA;AACA;AACA,MAAMA,eAAe,GAAIC,IAAY,IAAK;EACxC,IAAI;IACF,OAAOC,IAAI,CAACC,KAAK,CAACF,IAAI,CAAC;EACzB,CAAC,CAAC,OAAOG,KAAK,EAAE;IACd,MAAM,IAAIC,8BAAkB,CAAE,yBAAwBJ,IAAK,EAAC,CAAC;EAC/D;AACF,CAAC;AAED,MAAMK,iBAAiB,GAAG,MAAM;EAAA;EAC9B,MAAMC,WAAW,GAAGC,QAAQ,CAACC,aAAa,CACxC,4DAA4D,CAC7D;EAED,IAAI,CAACF,WAAW,EAAE;IAChB,MAAM,IAAIG,KAAK,CAAC,qCAAqC,CAAC;EACxD,CAAC,MAAM,IAAI,8BAAAH,WAAW,CAACI,WAAW,gBAAO,KAAK,EAAE,EAAE;IAChD,OAAO,CAAC,CAAC;EACX;EAEA,OAAOX,eAAe,CAACO,WAAW,CAACI,WAAW,CAAC;AACjD,CAAC;;AAED;AACA;AACO,MAAMC,0BAA0B,GAAIC,KAAiB,IAAK;EAC/DC,MAAM,CAACC,oBAAoB,GAAIC,KAAK,IAAK;IACvC,IAAIA,KAAK,CAACC,MAAM,EAAE;MAChB,OAAO,IAAAC,qBAAY,EAAC,MAAM;QACxB,MAAMC,YAAY,GAAGH,KAAK,CAACC,MAAM,CAACG,MAAM,CAACC,OAAO,CAACC,QAAQ,EAAE;QAE3DT,KAAK,CAACU,QAAQ,CAAC,IAAAC,sCAAwB,EAACL,YAAY,CAAC,CAAC;QACtD,MAAMH,KAAK,CAACC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aAAwC,KACrC;EACH,MAAMC,KAAK,GAAGH,eAAe,CAACpD,aAAa,CAAC,cAAc,CAAC;EAC3D,IAAIuD,KAAK,EAAE;IACT,IAAAC,iBAAO,EAACF,aAAa,EAAEF,eAAe,CAAC;EACzC,CAAC,MAAM;IACL,IAAAJ,gBAAM,EAACM,aAAa,EAAEF,eAAe,CAAC;EACxC;AACF,CAAC;;AAED;AACA;AACA;AACA,MAAMK,MAAM,GAAG,QAMF;EAAA,IANG;IACdxC,cAAc;IACd8B,KAAK;IACLC,MAAM;IACN9B,iBAAiB;IACjB+B;EACK,CAAC;EACN,MAAM;IAAE7C,KAAK;IAAEsB;EAAc,CAAC,GAAGV,WAAW,CAC1CC,cAAc,EACdC,iBAAiB,CAClB;EAED4B,qBAAqB,CACnB1C,KAAK,EACLsB,aAAa,EACbqB,KAAK,EACLC,MAAM,EACNC,sBAAsB,EACtBI,WAAW,CACZ;AACH,CAAC;AAAC,eAEaI,MAAM;AAAA"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["parseDataToJSON","data","JSON","parse","error","JsonParseException","getDataFromServer","dataElement","document","querySelector","Error","textContent","setUnhandledRejectionEvent","store","window","onunhandledrejection","event","detail","setImmediate","errorMessage","reason","message","toString","dispatch","showXHRErrorNotification","setupClient","customReducers","beforeRenderHooks","contextPath","Cache","clear","browserHistory","createBrowserHistory","basename","getBasePath","routerHistory","configureStore","rehydrate","setAllContentInDataSetting","getState","setLoginPreferences","loadOtherBrowserTabs","getItem","loginSuccess","has","FetchException","response","handleError","listen","location","action","locationChange","body","className","handleBeforeRenderHooks","addContentLoadedEvent","theme","render","ErrorFallbackComponent","mount","addEventListener","applicationNode","mountClient","initComponent","isSSR","hydrate","client"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\nimport { hydrate, render } from \"react-dom\";\n\nimport { has } from \"../utils/helpers/objects\";\nimport setImmediate from \"setimmediate\";\n\nimport Cache from \"../utils/browser/Cache\";\n\nimport { createBrowserHistory } from \"history\";\nimport configureStore from \"../redux/store/configureStore\";\n\nimport rehydrate from \"./rehydrate\";\nimport { getBasePath } from \"../constants/Settings\";\n\nimport {\n setAllContentInDataSetting,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\nimport { showXHRErrorNotification } from \"../redux/actions/Notification\";\n\nimport { handleError } from \"../redux/actions/Error\";\nimport { loginSuccess } from \"../redux/actions/SignIn\";\n\nimport { locationChange } from \"../redux/_router/RouterActions\";\n\nimport { JsonParseException, FetchException } from \"../exceptions\";\n\nimport Init from \"./Init\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport type {\n ComponentType,\n Element as ReactElement,\n ElementType,\n} from \"react\";\nimport type { Theme } from \"../react-theme/types\";\nimport type { CustomReducers, ReduxStore } from \"../redux/types\";\nimport type { RouterHistory } from \"react-router\";\nimport type { BeforeRenderHook } from \"../redux/store/beforeRenderHooks\";\nimport type { Props as FallbackProps } from \"../react/ErrorBoundaryFallback\";\n\nexport type Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: Function,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n};\n\n/*\n * deserialize serialized data from the server to provide a smooth dehydration.\n */\nconst parseDataToJSON = (data: string) => {\n try {\n return JSON.parse(data);\n } catch (error) {\n throw new JsonParseException(`Error parsing content ${data}`);\n }\n};\n\nconst getDataFromServer = () => {\n const dataElement = document.querySelector(\n 'script[type=\"application/json\"][data-app-state=\"app-json\"]'\n );\n\n if (!dataElement) {\n throw new Error(\"Error loading state, json not found\");\n } else if (dataElement.textContent.trim() === \"\") {\n return {};\n }\n\n return parseDataToJSON(dataElement.textContent);\n};\n\n/**\n */\nexport const setUnhandledRejectionEvent = (store: ReduxStore) => {\n window.onunhandledrejection = (event) => {\n if (event.detail) {\n return setImmediate(() => {\n const errorMessage = event.detail.reason.message.toString();\n\n store.dispatch(showXHRErrorNotification(errorMessage));\n throw event.detail.reason;\n });\n }\n\n return event;\n };\n};\n\n/**\n */\nexport const setupClient = (\n customReducers: CustomReducers = {},\n beforeRenderHooks: ?Array<BeforeRenderHook>\n): { store: ReduxStore, routerHistory: RouterHistory } => {\n if (typeof window.contextPath === \"undefined\") {\n throw new Error(\"Missing contextPath on window object\");\n }\n\n const data = getDataFromServer();\n\n // remove all resources from cache\n Cache.clear(\"^res:\");\n\n // $FlowExpectedError\n const browserHistory: RouterHistory = createBrowserHistory({\n basename: getBasePath(),\n });\n const { routerHistory, store } = configureStore(\n browserHistory,\n customReducers,\n rehydrate(data)\n );\n\n setAllContentInDataSetting(store.getState());\n setLoginPreferences(store.getState());\n\n // load existing cache from other browser tabs\n Cache.loadOtherBrowserTabs(() => {\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n });\n\n if (has(data, \"error.name\")) {\n const error = new FetchException(data?.error?.response);\n store.dispatch(handleError(error));\n }\n\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n\n // listen to history change and update the redux router store\n routerHistory.listen((location, action) => {\n store.dispatch(locationChange(location, action));\n });\n\n setUnhandledRejectionEvent(store);\n\n if (document.body) {\n document.body.className = \"js\";\n }\n\n if (beforeRenderHooks) {\n handleBeforeRenderHooks(beforeRenderHooks, { store });\n }\n\n return { store, routerHistory };\n};\n\n/**\n */\nexport const addContentLoadedEvent = (\n store: ReduxStore,\n routerHistory: RouterHistory,\n theme?: Theme | Array<Theme>,\n render: Function,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n mount: Function\n) => {\n window.addEventListener(\"DOMContentLoaded\", () => {\n const applicationNode = document.querySelector(\"#application\");\n if (!applicationNode) {\n throw new Error(\n \"No DOM element with id application found to attach client to\"\n );\n }\n\n mount(\n applicationNode,\n <Init\n store={store}\n routerHistory={routerHistory}\n contextPath={window.contextPath}\n theme={theme}\n ErrorFallbackComponent={ErrorFallbackComponent}\n >\n {render()}\n </Init>\n );\n });\n};\n\n/**\n */\nconst mountClient = (\n applicationNode: Element,\n initComponent: ReactElement<ElementType>\n) => {\n const isSSR = applicationNode.querySelector(\".application\");\n if (isSSR) {\n hydrate(initComponent, applicationNode);\n } else {\n render(initComponent, applicationNode);\n }\n};\n\n/**\n * Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.\n */\nexport const client = ({\n customReducers,\n theme,\n render,\n beforeRenderHooks,\n ErrorFallbackComponent,\n}: Props) => {\n const { store, routerHistory } = setupClient(\n customReducers,\n beforeRenderHooks\n );\n\n addContentLoadedEvent(\n store,\n routerHistory,\n theme,\n render,\n ErrorFallbackComponent,\n mountClient\n );\n};\n"],"mappings":";;;;;;;;AACA;AAEA;AACA;AAEA;AAEA;AACA;AAEA;AACA;AAEA;AAIA;AAEA;AACA;AAEA;AAEA;AAEA;AAEA;AAA2E;AAqB3E;AACA;AACA;AACA,MAAMA,eAAe,GAAIC,IAAY,IAAK;EACxC,IAAI;IACF,OAAOC,IAAI,CAACC,KAAK,CAACF,IAAI,CAAC;EACzB,CAAC,CAAC,OAAOG,KAAK,EAAE;IACd,MAAM,IAAIC,8BAAkB,CAAE,yBAAwBJ,IAAK,EAAC,CAAC;EAC/D;AACF,CAAC;AAED,MAAMK,iBAAiB,GAAG,MAAM;EAAA;EAC9B,MAAMC,WAAW,GAAGC,QAAQ,CAACC,aAAa,CACxC,4DAA4D,CAC7D;EAED,IAAI,CAACF,WAAW,EAAE;IAChB,MAAM,IAAIG,KAAK,CAAC,qCAAqC,CAAC;EACxD,CAAC,MAAM,IAAI,8BAAAH,WAAW,CAACI,WAAW,gBAAO,KAAK,EAAE,EAAE;IAChD,OAAO,CAAC,CAAC;EACX;EAEA,OAAOX,eAAe,CAACO,WAAW,CAACI,WAAW,CAAC;AACjD,CAAC;;AAED;AACA;AACO,MAAMC,0BAA0B,GAAIC,KAAiB,IAAK;EAC/DC,MAAM,CAACC,oBAAoB,GAAIC,KAAK,IAAK;IACvC,IAAIA,KAAK,CAACC,MAA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sB,aAAc;MAC7B,WAAW,EAAErB,MAAM,CAACc,WAAY;MAChC,KAAK,EAAE4B,KAAM;MACb,sBAAsB,EAAEE,sBAAuB;MAAA,UAE9CD,MAAM;IAAE,EACJ,CACR;EACH,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AADA;AAEA,MAAMK,WAAW,GAAG,CAClBD,eAAwB,EACxBE,aAAwC,KACrC;EACH,MAAMC,KAAK,GAAGH,eAAe,CAACpD,aAAa,CAAC,cAAc,CAAC;EAC3D,IAAIuD,KAAK,EAAE;IACT,IAAAC,iBAAO,EAACF,aAAa,EAAEF,eAAe,CAAC;EACzC,CAAC,MAAM;IACL,IAAAJ,gBAAM,EAACM,aAAa,EAAEF,eAAe,CAAC;EACxC;AACF,CAAC;;AAED;AACA;AACA;AACO,MAAMK,MAAM,GAAG,QAMT;EAAA,IANU;IACrBxC,cAAc;IACd8B,KAAK;IACLC,MAAM;IACN9B,iBAAiB;IACjB+B;EACK,CAAC;EACN,MAAM;IAAE7C,KAAK;IAAEsB;EAAc,CAAC,GAAGV,WAAW,CAC1CC,cAAc,EACdC,iBAAiB,CAClB;EAED4B,qBAAqB,CACnB1C,KAAK,EACLsB,aAAa,EACbqB,KAAK,EACLC,MAAM,EACNC,sBAAsB,EACtBI,WAAW,CACZ;AACH,CAAC;AAAC"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
|
3
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
8
|
+
var _exportNames = {
|
|
9
|
+
setCustomErrorResponseHandler: true,
|
|
10
|
+
Init: true
|
|
11
|
+
};
|
|
7
12
|
Object.defineProperty(exports, "Init", {
|
|
8
13
|
enumerable: true,
|
|
9
14
|
get: function () {
|
|
10
15
|
return _Init.default;
|
|
11
16
|
}
|
|
12
17
|
});
|
|
13
|
-
Object.defineProperty(exports, "client", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return _client.default;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
18
|
Object.defineProperty(exports, "setCustomErrorResponseHandler", {
|
|
20
19
|
enumerable: true,
|
|
21
20
|
get: function () {
|
|
@@ -24,5 +23,16 @@ Object.defineProperty(exports, "setCustomErrorResponseHandler", {
|
|
|
24
23
|
});
|
|
25
24
|
var _Error = require("../redux/actions/Error");
|
|
26
25
|
var _Init = _interopRequireDefault(require("./Init"));
|
|
27
|
-
var _client =
|
|
26
|
+
var _client = require("./client");
|
|
27
|
+
_Object$keys(_client).forEach(function (key) {
|
|
28
|
+
if (key === "default" || key === "__esModule") return;
|
|
29
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
30
|
+
if (key in exports && exports[key] === _client[key]) return;
|
|
31
|
+
Object.defineProperty(exports, key, {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () {
|
|
34
|
+
return _client[key];
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
28
38
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/react-client/index.js"],"sourcesContent":["// @flow\nexport { setCustomErrorResponseHandler } from \"../redux/actions/Error\";\n\nexport { default as Init } from \"./Init\";\n\nexport
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/react-client/index.js"],"sourcesContent":["// @flow\nexport { setCustomErrorResponseHandler } from \"../redux/actions/Error\";\n\nexport { default as Init } from \"./Init\";\n\nexport * from \"./client\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;AAEA;AAEA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -202,7 +202,7 @@ const mountClient = (
|
|
|
202
202
|
/**
|
|
203
203
|
* Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.
|
|
204
204
|
*/
|
|
205
|
-
const client = ({
|
|
205
|
+
export const client = ({
|
|
206
206
|
customReducers,
|
|
207
207
|
theme,
|
|
208
208
|
render,
|
|
@@ -223,5 +223,3 @@ const client = ({
|
|
|
223
223
|
mountClient
|
|
224
224
|
);
|
|
225
225
|
};
|
|
226
|
-
|
|
227
|
-
export default client;
|