@beinformed/ui 1.27.6 → 1.28.0

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/esm/constants/LayoutHintConfig.js +0 -9
  3. package/esm/constants/LayoutHintConfig.js.map +1 -1
  4. package/esm/constants/LayoutHints.js +0 -4
  5. package/esm/constants/LayoutHints.js.map +1 -1
  6. package/esm/constants/Settings.js +0 -4
  7. package/esm/constants/Settings.js.map +1 -1
  8. package/esm/models/attributes/DatetimeAttributeModel.js +3 -29
  9. package/esm/models/attributes/DatetimeAttributeModel.js.map +1 -1
  10. package/esm/react-client/Init.js +2 -2
  11. package/esm/react-client/Init.js.map +1 -1
  12. package/esm/react-client/client.js +80 -52
  13. package/esm/react-client/client.js.map +1 -1
  14. package/esm/redux/store/configureStore.js +4 -4
  15. package/esm/redux/store/configureStore.js.map +1 -1
  16. package/lib/constants/LayoutHintConfig.js +0 -9
  17. package/lib/constants/LayoutHintConfig.js.flow +0 -9
  18. package/lib/constants/LayoutHintConfig.js.map +1 -1
  19. package/lib/constants/LayoutHints.js +2 -7
  20. package/lib/constants/LayoutHints.js.flow +0 -4
  21. package/lib/constants/LayoutHints.js.map +1 -1
  22. package/lib/constants/Settings.js +0 -4
  23. package/lib/constants/Settings.js.flow +0 -6
  24. package/lib/constants/Settings.js.map +1 -1
  25. package/lib/models/attributes/DatetimeAttributeModel.js +3 -29
  26. package/lib/models/attributes/DatetimeAttributeModel.js.flow +7 -41
  27. package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
  28. package/lib/models/attributes/__tests__/DateAttributeModel.spec.js.flow +1 -35
  29. package/lib/models/attributes/__tests__/DatetimeAttributeModel.spec.js.flow +158 -216
  30. package/lib/models/attributes/__tests__/TimestampModel.spec.js.flow +0 -5
  31. package/lib/react-client/Init.js +2 -2
  32. package/lib/react-client/Init.js.flow +3 -3
  33. package/lib/react-client/Init.js.map +1 -1
  34. package/lib/react-client/client.js +83 -53
  35. package/lib/react-client/client.js.flow +106 -67
  36. package/lib/react-client/client.js.map +1 -1
  37. package/lib/redux/store/configureStore.js +4 -4
  38. package/lib/redux/store/configureStore.js.flow +5 -5
  39. package/lib/redux/store/configureStore.js.map +1 -1
  40. package/package.json +17 -19
  41. package/src/constants/LayoutHintConfig.js +0 -9
  42. package/src/constants/LayoutHints.js +0 -4
  43. package/src/constants/Settings.js +0 -6
  44. package/src/models/attributes/DatetimeAttributeModel.js +7 -41
  45. package/src/models/attributes/__tests__/DateAttributeModel.spec.js +1 -35
  46. package/src/models/attributes/__tests__/DatetimeAttributeModel.spec.js +158 -216
  47. package/src/models/attributes/__tests__/TimestampModel.spec.js +0 -5
  48. package/src/react-client/Init.js +3 -3
  49. package/src/react-client/client.js +106 -67
  50. package/src/redux/store/configureStore.js +5 -5
  51. package/types/constants/LayoutHintConfig.d.ts +8 -23
  52. package/types/constants/LayoutHints.d.ts +0 -4
  53. package/types/models/actions/ActionCollection.d.ts +1 -1
  54. package/types/models/attributes/DatetimeAttributeModel.d.ts +8 -2
  55. package/types/redux/_modularui/types.d.ts +4 -0
  56. package/types/redux/types.d.ts +1 -1
@@ -4,10 +4,8 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = void 0;
7
+ exports.setupClient = exports.setUnhandledRejectionEvent = exports.default = exports.addContentLoadedEvent = void 0;
8
8
  var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
9
- var _elementClosest = _interopRequireDefault(require("element-closest"));
10
- require("focus-visible");
11
9
  var _reactDom = require("react-dom");
12
10
  var _objects = require("../utils/helpers/objects");
13
11
  var _setimmediate = _interopRequireDefault(require("setimmediate"));
@@ -25,16 +23,9 @@ var _exceptions = require("../exceptions");
25
23
  var _Init = _interopRequireDefault(require("./Init"));
26
24
  var _beforeRenderHooks = require("../redux/store/beforeRenderHooks");
27
25
  var _jsxRuntime = require("react/jsx-runtime");
28
- /* polyfills needed for ie11 */
29
- (0, _elementClosest.default)(window);
30
-
31
- /* polyfill for focus-visible */
32
-
33
26
  /*
34
27
  * deserialize serialized data from the server to provide a smooth dehydration.
35
28
  */
36
- /**
37
- */
38
29
  const parseDataToJSON = data => {
39
30
  try {
40
31
  return JSON.parse(data);
@@ -42,22 +33,42 @@ const parseDataToJSON = data => {
42
33
  throw new _exceptions.JsonParseException(`Error parsing content ${data}`);
43
34
  }
44
35
  };
45
-
46
- /**
47
- * Mount the webapplication to the DOM, used client side when JavaScript is enabled.
48
- */
49
- const client = props => {
36
+ const getDataFromServer = () => {
50
37
  var _context;
51
- if (typeof window.contextPath === "undefined") {
52
- throw new Error("Missing contextPath on window object");
53
- }
54
38
  const dataElement = document.querySelector('script[type="application/json"][data-app-state="app-json"]');
55
39
  if (!dataElement) {
56
40
  throw new Error("Error loading state, json not found");
57
41
  } else if ((0, _trim.default)(_context = dataElement.textContent).call(_context) === "") {
58
- return;
42
+ return {};
59
43
  }
60
- const data = parseDataToJSON(dataElement.textContent);
44
+ return parseDataToJSON(dataElement.textContent);
45
+ };
46
+
47
+ /**
48
+ */
49
+ const setUnhandledRejectionEvent = store => {
50
+ window.onunhandledrejection = event => {
51
+ if (event.detail) {
52
+ return (0, _setimmediate.default)(() => {
53
+ const errorMessage = event.detail.reason.message.toString();
54
+ store.dispatch((0, _Notification.showXHRErrorNotification)(errorMessage));
55
+ throw event.detail.reason;
56
+ });
57
+ }
58
+ return event;
59
+ };
60
+ };
61
+
62
+ /**
63
+ */
64
+ exports.setUnhandledRejectionEvent = setUnhandledRejectionEvent;
65
+ const setupClient = function () {
66
+ let customReducers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
67
+ let beforeRenderHooks = arguments.length > 1 ? arguments[1] : undefined;
68
+ if (typeof window.contextPath === "undefined") {
69
+ throw new Error("Missing contextPath on window object");
70
+ }
71
+ const data = getDataFromServer();
61
72
 
62
73
  // remove all resources from cache
63
74
  _Cache.default.clear("^res:");
@@ -67,9 +78,9 @@ const client = props => {
67
78
  basename: (0, _Settings.getBasePath)()
68
79
  });
69
80
  const {
70
- history,
81
+ routerHistory,
71
82
  store
72
- } = (0, _configureStore.default)(browserHistory, props.customReducers ?? {}, (0, _rehydrate.default)(data));
83
+ } = (0, _configureStore.default)(browserHistory, customReducers, (0, _rehydrate.default)(data));
73
84
  (0, _Preferences.setAllContentInDataSetting)(store.getState());
74
85
  (0, _Preferences.setLoginPreferences)(store.getState());
75
86
 
@@ -80,7 +91,7 @@ const client = props => {
80
91
  }
81
92
  });
82
93
  if ((0, _objects.has)(data, "error.name")) {
83
- const error = new _exceptions.FetchException(data.error.response);
94
+ const error = new _exceptions.FetchException(data?.error?.response);
84
95
  store.dispatch((0, _Error.handleError)(error));
85
96
  }
86
97
  if (_Cache.default.getItem("auth")) {
@@ -88,54 +99,73 @@ const client = props => {
88
99
  }
89
100
 
90
101
  // listen to history change and update the redux router store
91
- history.listen((location, action) => {
102
+ routerHistory.listen((location, action) => {
92
103
  store.dispatch((0, _RouterActions.locationChange)(location, action));
93
104
  });
94
-
95
- /**
96
- */
97
- window.onunhandledrejection = event => {
98
- if (event.detail) {
99
- return (0, _setimmediate.default)(() => {
100
- const errorMessage = event.detail.reason.message.toString();
101
- store.dispatch((0, _Notification.showXHRErrorNotification)(errorMessage));
102
- throw event.detail.reason;
103
- });
104
- }
105
- return event;
106
- };
105
+ setUnhandledRejectionEvent(store);
107
106
  if (document.body) {
108
107
  document.body.className = "js";
109
108
  }
110
- if (props.beforeRenderHooks) {
111
- (0, _beforeRenderHooks.handleBeforeRenderHooks)(props.beforeRenderHooks, {
109
+ if (beforeRenderHooks) {
110
+ (0, _beforeRenderHooks.handleBeforeRenderHooks)(beforeRenderHooks, {
112
111
  store
113
112
  });
114
113
  }
115
- addContentLoadedEvent(store, history, props.theme, props.render, props.ErrorFallbackComponent);
114
+ return {
115
+ store,
116
+ routerHistory
117
+ };
116
118
  };
117
119
 
118
120
  /**
119
121
  */
120
- const addContentLoadedEvent = (store, history, theme, render, ErrorFallbackComponent) => {
122
+ exports.setupClient = setupClient;
123
+ const addContentLoadedEvent = (store, routerHistory, theme, render, ErrorFallbackComponent, mount) => {
121
124
  window.addEventListener("DOMContentLoaded", () => {
122
125
  const applicationNode = document.querySelector("#application");
123
- if (applicationNode) {
124
- const isSSR = applicationNode.querySelector(".application");
125
- const mount = isSSR ? _reactDom.hydrate : _reactDom.render;
126
- mount( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Init.default, {
127
- store: store,
128
- history: history,
129
- contextPath: window.contextPath,
130
- theme: theme,
131
- ErrorFallbackComponent: ErrorFallbackComponent,
132
- children: render()
133
- }), applicationNode);
134
- } else {
126
+ if (!applicationNode) {
135
127
  throw new Error("No DOM element with id application found to attach client to");
136
128
  }
129
+ mount(applicationNode, /*#__PURE__*/(0, _jsxRuntime.jsx)(_Init.default, {
130
+ store: store,
131
+ routerHistory: routerHistory,
132
+ contextPath: window.contextPath,
133
+ theme: theme,
134
+ ErrorFallbackComponent: ErrorFallbackComponent,
135
+ children: render()
136
+ }));
137
137
  });
138
138
  };
139
+
140
+ /**
141
+ */
142
+ exports.addContentLoadedEvent = addContentLoadedEvent;
143
+ const mountClient = (applicationNode, initComponent) => {
144
+ const isSSR = applicationNode.querySelector(".application");
145
+ if (isSSR) {
146
+ (0, _reactDom.hydrate)(initComponent, applicationNode);
147
+ } else {
148
+ (0, _reactDom.render)(initComponent, applicationNode);
149
+ }
150
+ };
151
+
152
+ /**
153
+ * Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.
154
+ */
155
+ const client = _ref => {
156
+ let {
157
+ customReducers,
158
+ theme,
159
+ render,
160
+ beforeRenderHooks,
161
+ ErrorFallbackComponent
162
+ } = _ref;
163
+ const {
164
+ store,
165
+ routerHistory
166
+ } = setupClient(customReducers, beforeRenderHooks);
167
+ addContentLoadedEvent(store, routerHistory, theme, render, ErrorFallbackComponent, mountClient);
168
+ };
139
169
  var _default = client;
140
170
  exports.default = _default;
141
171
  //# sourceMappingURL=client.js.map
@@ -1,12 +1,5 @@
1
1
  // @flow
2
- /* polyfills needed for ie11 */
3
- import elementClosest from "element-closest";
4
- elementClosest(window);
5
-
6
- /* polyfill for focus-visible */
7
- import "focus-visible";
8
-
9
- import { hydrate, render as reactRender } from "react-dom";
2
+ import { hydrate, render } from "react-dom";
10
3
 
11
4
  import { has } from "../utils/helpers/objects";
12
5
  import setImmediate from "setimmediate";
@@ -36,12 +29,17 @@ import Init from "./Init";
36
29
 
37
30
  import { handleBeforeRenderHooks } from "../redux/store/beforeRenderHooks";
38
31
 
39
- import type { ComponentType } from "react";
32
+ import type {
33
+ ComponentType,
34
+ Element as ReactElement,
35
+ ElementType,
36
+ } from "react";
40
37
  import type { Theme } from "../react-theme/types";
41
38
  import type { CustomReducers, ReduxStore } from "../redux/types";
42
39
  import type { RouterHistory } from "react-router";
43
40
  import type { BeforeRenderHook } from "../redux/store/beforeRenderHooks";
44
41
  import type { Props as FallbackProps } from "../react/ErrorBoundaryFallback";
42
+
45
43
  export type Props = {
46
44
  customReducers?: CustomReducers,
47
45
  theme?: Theme | Array<Theme>,
@@ -53,8 +51,6 @@ export type Props = {
53
51
  /*
54
52
  * deserialize serialized data from the server to provide a smooth dehydration.
55
53
  */
56
- /**
57
- */
58
54
  const parseDataToJSON = (data: string) => {
59
55
  try {
60
56
  return JSON.parse(data);
@@ -63,24 +59,48 @@ const parseDataToJSON = (data: string) => {
63
59
  }
64
60
  };
65
61
 
66
- /**
67
- * Mount the webapplication to the DOM, used client side when JavaScript is enabled.
68
- */
69
- const client = (props: Props) => {
70
- if (typeof window.contextPath === "undefined") {
71
- throw new Error("Missing contextPath on window object");
72
- }
73
-
62
+ const getDataFromServer = () => {
74
63
  const dataElement = document.querySelector(
75
64
  'script[type="application/json"][data-app-state="app-json"]'
76
65
  );
66
+
77
67
  if (!dataElement) {
78
68
  throw new Error("Error loading state, json not found");
79
69
  } else if (dataElement.textContent.trim() === "") {
80
- return;
70
+ return {};
81
71
  }
82
72
 
83
- const data = parseDataToJSON(dataElement.textContent);
73
+ return parseDataToJSON(dataElement.textContent);
74
+ };
75
+
76
+ /**
77
+ */
78
+ export const setUnhandledRejectionEvent = (store: ReduxStore) => {
79
+ window.onunhandledrejection = (event) => {
80
+ if (event.detail) {
81
+ return setImmediate(() => {
82
+ const errorMessage = event.detail.reason.message.toString();
83
+
84
+ store.dispatch(showXHRErrorNotification(errorMessage));
85
+ throw event.detail.reason;
86
+ });
87
+ }
88
+
89
+ return event;
90
+ };
91
+ };
92
+
93
+ /**
94
+ */
95
+ export const setupClient = (
96
+ customReducers: CustomReducers = {},
97
+ beforeRenderHooks: ?Array<BeforeRenderHook>
98
+ ): { store: ReduxStore, routerHistory: RouterHistory } => {
99
+ if (typeof window.contextPath === "undefined") {
100
+ throw new Error("Missing contextPath on window object");
101
+ }
102
+
103
+ const data = getDataFromServer();
84
104
 
85
105
  // remove all resources from cache
86
106
  Cache.clear("^res:");
@@ -89,9 +109,9 @@ const client = (props: Props) => {
89
109
  const browserHistory: RouterHistory = createBrowserHistory({
90
110
  basename: getBasePath(),
91
111
  });
92
- const { history, store } = configureStore(
112
+ const { routerHistory, store } = configureStore(
93
113
  browserHistory,
94
- props.customReducers ?? {},
114
+ customReducers,
95
115
  rehydrate(data)
96
116
  );
97
117
 
@@ -106,7 +126,7 @@ const client = (props: Props) => {
106
126
  });
107
127
 
108
128
  if (has(data, "error.name")) {
109
- const error = new FetchException(data.error.response);
129
+ const error = new FetchException(data?.error?.response);
110
130
  store.dispatch(handleError(error));
111
131
  }
112
132
 
@@ -115,74 +135,93 @@ const client = (props: Props) => {
115
135
  }
116
136
 
117
137
  // listen to history change and update the redux router store
118
- history.listen((location, action) => {
138
+ routerHistory.listen((location, action) => {
119
139
  store.dispatch(locationChange(location, action));
120
140
  });
121
141
 
122
- /**
123
- */
124
- window.onunhandledrejection = (event) => {
125
- if (event.detail) {
126
- return setImmediate(() => {
127
- const errorMessage = event.detail.reason.message.toString();
128
-
129
- store.dispatch(showXHRErrorNotification(errorMessage));
130
- throw event.detail.reason;
131
- });
132
- }
133
-
134
- return event;
135
- };
142
+ setUnhandledRejectionEvent(store);
136
143
 
137
144
  if (document.body) {
138
145
  document.body.className = "js";
139
146
  }
140
147
 
141
- if (props.beforeRenderHooks) {
142
- handleBeforeRenderHooks(props.beforeRenderHooks, { store });
148
+ if (beforeRenderHooks) {
149
+ handleBeforeRenderHooks(beforeRenderHooks, { store });
143
150
  }
144
151
 
145
- addContentLoadedEvent(
146
- store,
147
- history,
148
- props.theme,
149
- props.render,
150
- props.ErrorFallbackComponent
151
- );
152
+ return { store, routerHistory };
152
153
  };
153
154
 
154
155
  /**
155
156
  */
156
- const addContentLoadedEvent = (
157
+ export const addContentLoadedEvent = (
157
158
  store: ReduxStore,
158
- history: RouterHistory,
159
+ routerHistory: RouterHistory,
159
160
  theme?: Theme | Array<Theme>,
160
161
  render: Function,
161
- ErrorFallbackComponent?: ComponentType<FallbackProps>
162
+ ErrorFallbackComponent?: ComponentType<FallbackProps>,
163
+ mount: Function
162
164
  ) => {
163
165
  window.addEventListener("DOMContentLoaded", () => {
164
166
  const applicationNode = document.querySelector("#application");
165
- if (applicationNode) {
166
- const isSSR = applicationNode.querySelector(".application");
167
- const mount = isSSR ? hydrate : reactRender;
168
- mount(
169
- <Init
170
- store={store}
171
- history={history}
172
- contextPath={window.contextPath}
173
- theme={theme}
174
- ErrorFallbackComponent={ErrorFallbackComponent}
175
- >
176
- {render()}
177
- </Init>,
178
- applicationNode
179
- );
180
- } else {
167
+ if (!applicationNode) {
181
168
  throw new Error(
182
169
  "No DOM element with id application found to attach client to"
183
170
  );
184
171
  }
172
+
173
+ mount(
174
+ applicationNode,
175
+ <Init
176
+ store={store}
177
+ routerHistory={routerHistory}
178
+ contextPath={window.contextPath}
179
+ theme={theme}
180
+ ErrorFallbackComponent={ErrorFallbackComponent}
181
+ >
182
+ {render()}
183
+ </Init>
184
+ );
185
185
  });
186
186
  };
187
187
 
188
+ /**
189
+ */
190
+ const mountClient = (
191
+ applicationNode: Element,
192
+ initComponent: ReactElement<ElementType>
193
+ ) => {
194
+ const isSSR = applicationNode.querySelector(".application");
195
+ if (isSSR) {
196
+ hydrate(initComponent, applicationNode);
197
+ } else {
198
+ render(initComponent, applicationNode);
199
+ }
200
+ };
201
+
202
+ /**
203
+ * Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.
204
+ */
205
+ const client = ({
206
+ customReducers,
207
+ theme,
208
+ render,
209
+ beforeRenderHooks,
210
+ ErrorFallbackComponent,
211
+ }: Props) => {
212
+ const { store, routerHistory } = setupClient(
213
+ customReducers,
214
+ beforeRenderHooks
215
+ );
216
+
217
+ addContentLoadedEvent(
218
+ store,
219
+ routerHistory,
220
+ theme,
221
+ render,
222
+ ErrorFallbackComponent,
223
+ mountClient
224
+ );
225
+ };
226
+
188
227
  export default client;
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":["elementClosest","window","parseDataToJSON","data","JSON","parse","error","JsonParseException","client","props","contextPath","Error","dataElement","document","querySelector","textContent","Cache","clear","browserHistory","createBrowserHistory","basename","getBasePath","history","store","configureStore","customReducers","rehydrate","setAllContentInDataSetting","getState","setLoginPreferences","loadOtherBrowserTabs","getItem","dispatch","loginSuccess","has","FetchException","response","handleError","listen","location","action","locationChange","onunhandledrejection","event","detail","setImmediate","errorMessage","reason","message","toString","showXHRErrorNotification","body","className","beforeRenderHooks","handleBeforeRenderHooks","addContentLoadedEvent","theme","render","ErrorFallbackComponent","addEventListener","applicationNode","isSSR","mount","hydrate","reactRender"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\n/* polyfills needed for ie11 */\nimport elementClosest from \"element-closest\";\nelementClosest(window);\n\n/* polyfill for focus-visible */\nimport \"focus-visible\";\n\nimport { hydrate, render as reactRender } 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 { ComponentType } 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\";\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 */\n/**\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\n/**\n * Mount the webapplication to the DOM, used client side when JavaScript is enabled.\n */\nconst client = (props: Props) => {\n if (typeof window.contextPath === \"undefined\") {\n throw new Error(\"Missing contextPath on window object\");\n }\n\n const dataElement = document.querySelector(\n 'script[type=\"application/json\"][data-app-state=\"app-json\"]'\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 const data = parseDataToJSON(dataElement.textContent);\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 { history, store } = configureStore(\n browserHistory,\n props.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 history.listen((location, action) => {\n store.dispatch(locationChange(location, action));\n });\n\n /**\n */\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 if (document.body) {\n document.body.className = \"js\";\n }\n\n if (props.beforeRenderHooks) {\n handleBeforeRenderHooks(props.beforeRenderHooks, { store });\n }\n\n addContentLoadedEvent(\n store,\n history,\n props.theme,\n props.render,\n props.ErrorFallbackComponent\n );\n};\n\n/**\n */\nconst addContentLoadedEvent = (\n store: ReduxStore,\n history: RouterHistory,\n theme?: Theme | Array<Theme>,\n render: Function,\n ErrorFallbackComponent?: ComponentType<FallbackProps>\n) => {\n window.addEventListener(\"DOMContentLoaded\", () => {\n const applicationNode = document.querySelector(\"#application\");\n if (applicationNode) {\n const isSSR = applicationNode.querySelector(\".application\");\n const mount = isSSR ? hydrate : reactRender;\n mount(\n <Init\n store={store}\n history={history}\n contextPath={window.contextPath}\n theme={theme}\n ErrorFallbackComponent={ErrorFallbackComponent}\n >\n {render()}\n </Init>,\n applicationNode\n );\n } else {\n throw new Error(\n \"No DOM element with id application found to attach client to\"\n );\n }\n });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,IAAI9B,QAAQ,CAACsC,IAAI,EAAE;IACjBtC,QAAQ,CAACsC,IAAI,CAACC,SAAS,GAAG,IAAI;EAChC;EAEA,IAAI3C,KAAK,CAAC4C,iBAAiB,EAAE;IAC3B,IAAAC,0CAAuB,EAAC7C,KAAK,CAAC4C,iBAAiB,EAAE;MAAE9B;IAAM,CAAC,CAAC;EAC7D;EAEAgC,qBAAqB,CACnBhC,KAAK,EACLD,OAAO,EACPb,KAAK,CAAC+C,KAAK,EACX/C,KAAK,CAACgD,MAAM,EACZhD,KAAK,CAACiD,sBAAsB,CAC7B;AACH,CAAC;;AAED;AACA;AACA,MAAMH,qBAAqB,GAAG,CAC5BhC,KAAiB,EACjBD,OAAsB,EACtBkC,KAA4B,EAC5BC,MAAgB,EAChBC,sBAAqD,KAClD;EACHzD,MAAM,CAAC0D,gBAAgB,CAAC,kBAAkB,EAAE,MAAM;IAChD,MAAMC,eAAe,GAAG/C,QAAQ,CAACC,aAAa,CAAC,cAAc,CAAC;IAC9D,IAAI8C,eAAe,EAAE;MACnB,MAAMC,KAAK,GAAGD,eAAe,CAAC9C,aAAa,CAAC,cAAc,CAAC;MAC3D,MAAMgD,KAAK,GAAGD,KAAK,GAAGE,iBAAO,GAAGC,gBAAW;MAC3CF,KAAK,eACH,qBAAC,aAAI;QACH,KAAK,EAAEvC,KAAM;QACb,OAAO,EAAED,OAAQ;QACjB,WAAW,EAAErB,MAAM,CAACS,WAAY;QAChC,KAAK,EAAE8C,KAAM;QACb,sBAAsB,EAAEE,sBAAuB;QAAA,UAE9CD,MAAM;MAAE,EACJ,EACPG,eAAe,CAChB;IACH,CAAC,MAAM;MACL,MAAM,IAAIjD,KAAK,CACb,8DAA8D,CAC/D;IACH;EACF,CAAC,CAAC;AACJ,CAAC;AAAC,eAEaH,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 */\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,yB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,CACnB1C,KAAK,EACLsB,aAAa,EACbqB,KAAK,EACLC,MAAM,EACNC,sBAAsB,EACtBI,WAAW,CACZ;AACH,CAAC;AAAC,eAEaI,MAAM;AAAA"}
@@ -13,7 +13,7 @@ var _createReducer = require("../reducers/createReducer");
13
13
  var _RouterActions = require("../_router/RouterActions");
14
14
  /**
15
15
  */
16
- const configureStore = (history, customReducers, initialState) => {
16
+ const configureStore = (routerHistory, customReducers, initialState) => {
17
17
  let composeEnhancers = _redux.compose;
18
18
  if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
19
19
  composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || _redux.compose;
@@ -22,14 +22,14 @@ const configureStore = (history, customReducers, initialState) => {
22
22
  ...customReducers,
23
23
  ...(0, _createReducer.createReducer)()
24
24
  });
25
- const middleware = (0, _redux.applyMiddleware)(_ModularUIMiddleware.modularUIMiddleware, (0, _RouterMiddleware.routerMiddleware)(history), _reduxThunk.default);
25
+ const middleware = (0, _redux.applyMiddleware)(_ModularUIMiddleware.modularUIMiddleware, (0, _RouterMiddleware.routerMiddleware)(routerHistory), _reduxThunk.default);
26
26
  const enhancers = composeEnhancers(middleware);
27
27
  const store = (0, _redux.createStore)(combinedReducers, initialState, enhancers);
28
28
  if (!initialState?.router) {
29
- store.dispatch((0, _RouterActions.locationChange)(history.location, "PUSH"));
29
+ store.dispatch((0, _RouterActions.locationChange)(routerHistory.location, "PUSH"));
30
30
  }
31
31
  return {
32
- history,
32
+ routerHistory,
33
33
  store
34
34
  };
35
35
  };
@@ -20,10 +20,10 @@ import type { Reducer } from "redux";
20
20
  /**
21
21
  */
22
22
  const configureStore = (
23
- history: RouterHistory,
23
+ routerHistory: RouterHistory,
24
24
  customReducers?: Object,
25
25
  initialState?: $Shape<ReduxState>
26
- ): { history: RouterHistory, store: ReduxStore } => {
26
+ ): { routerHistory: RouterHistory, store: ReduxStore } => {
27
27
  let composeEnhancers = compose;
28
28
 
29
29
  if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
@@ -37,7 +37,7 @@ const configureStore = (
37
37
 
38
38
  const middleware = applyMiddleware(
39
39
  modularUIMiddleware,
40
- routerMiddleware(history),
40
+ routerMiddleware(routerHistory),
41
41
  thunk
42
42
  );
43
43
 
@@ -50,9 +50,9 @@ const configureStore = (
50
50
  );
51
51
 
52
52
  if (!initialState?.router) {
53
- store.dispatch(locationChange(history.location, "PUSH"));
53
+ store.dispatch(locationChange(routerHistory.location, "PUSH"));
54
54
  }
55
- return { history, store };
55
+ return { routerHistory, store };
56
56
  };
57
57
 
58
58
  export default configureStore;
@@ -1 +1 @@
1
- {"version":3,"file":"configureStore.js","names":["configureStore","history","customReducers","initialState","composeEnhancers","compose","process","env","NODE_ENV","window","__REDUX_DEVTOOLS_EXTENSION_COMPOSE__","combinedReducers","combineReducers","createReducer","middleware","applyMiddleware","modularUIMiddleware","routerMiddleware","thunk","enhancers","store","createReduxStore","router","dispatch","locationChange","location"],"sources":["../../../src/redux/store/configureStore.js"],"sourcesContent":["// @flow\nimport {\n applyMiddleware,\n compose,\n combineReducers,\n createStore as createReduxStore,\n} from \"redux\";\nimport thunk from \"redux-thunk\";\n\nimport { routerMiddleware } from \"../_router/RouterMiddleware\";\nimport { modularUIMiddleware } from \"../_modularui/ModularUIMiddleware\";\n\nimport { createReducer } from \"../reducers/createReducer\";\nimport { locationChange } from \"../_router/RouterActions\";\n\nimport type { RouterHistory } from \"react-router\";\nimport type { ReduxAction, ReduxState, ReduxStore } from \"../types\";\nimport type { Reducer } from \"redux\";\n\n/**\n */\nconst configureStore = (\n history: RouterHistory,\n customReducers?: Object,\n initialState?: $Shape<ReduxState>\n): { history: RouterHistory, store: ReduxStore } => {\n let composeEnhancers = compose;\n\n if (process.env.NODE_ENV !== \"production\" && typeof window !== \"undefined\") {\n composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;\n }\n\n const combinedReducers: Reducer<ReduxState, ReduxAction> = combineReducers({\n ...customReducers,\n ...createReducer(),\n });\n\n const middleware = applyMiddleware(\n modularUIMiddleware,\n routerMiddleware(history),\n thunk\n );\n\n const enhancers = composeEnhancers(middleware);\n\n const store: ReduxStore = createReduxStore(\n combinedReducers,\n initialState,\n enhancers\n );\n\n if (!initialState?.router) {\n store.dispatch(locationChange(history.location, \"PUSH\"));\n }\n return { history, store };\n};\n\nexport default configureStore;\n"],"mappings":";;;;;;;AACA;AAMA;AAEA;AACA;AAEA;AACA;AAMA;AACA;AACA,MAAMA,cAAc,GAAG,CACrBC,OAAsB,EACtBC,cAAuB,EACvBC,YAAiC,KACiB;EAClD,IAAIC,gBAAgB,GAAGC,cAAO;EAE9B,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IAC1EL,gBAAgB,GAAGK,MAAM,CAACC,oCAAoC,IAAIL,cAAO;EAC3E;EAEA,MAAMM,gBAAkD,GAAG,IAAAC,sBAAe,EAAC;IACzE,GAAGV,cAAc;IACjB,GAAG,IAAAW,4BAAa;EAClB,CAAC,CAAC;EAEF,MAAMC,UAAU,GAAG,IAAAC,sBAAe,EAChCC,wCAAmB,EACnB,IAAAC,kCAAgB,EAAChB,OAAO,CAAC,EACzBiB,mBAAK,CACN;EAED,MAAMC,SAAS,GAAGf,gBAAgB,CAACU,UAAU,CAAC;EAE9C,MAAMM,KAAiB,GAAG,IAAAC,kBAAgB,EACxCV,gBAAgB,EAChBR,YAAY,EACZgB,SAAS,CACV;EAED,IAAI,CAAChB,YAAY,EAAEmB,MAAM,EAAE;IACzBF,KAAK,CAACG,QAAQ,CAAC,IAAAC,6BAAc,EAACvB,OAAO,CAACwB,QAAQ,EAAE,MAAM,CAAC,CAAC;EAC1D;EACA,OAAO;IAAExB,OAAO;IAAEmB;EAAM,CAAC;AAC3B,CAAC;AAAC,eAEapB,cAAc;AAAA"}
1
+ {"version":3,"file":"configureStore.js","names":["configureStore","routerHistory","customReducers","initialState","composeEnhancers","compose","process","env","NODE_ENV","window","__REDUX_DEVTOOLS_EXTENSION_COMPOSE__","combinedReducers","combineReducers","createReducer","middleware","applyMiddleware","modularUIMiddleware","routerMiddleware","thunk","enhancers","store","createReduxStore","router","dispatch","locationChange","location"],"sources":["../../../src/redux/store/configureStore.js"],"sourcesContent":["// @flow\nimport {\n applyMiddleware,\n compose,\n combineReducers,\n createStore as createReduxStore,\n} from \"redux\";\nimport thunk from \"redux-thunk\";\n\nimport { routerMiddleware } from \"../_router/RouterMiddleware\";\nimport { modularUIMiddleware } from \"../_modularui/ModularUIMiddleware\";\n\nimport { createReducer } from \"../reducers/createReducer\";\nimport { locationChange } from \"../_router/RouterActions\";\n\nimport type { RouterHistory } from \"react-router\";\nimport type { ReduxAction, ReduxState, ReduxStore } from \"../types\";\nimport type { Reducer } from \"redux\";\n\n/**\n */\nconst configureStore = (\n routerHistory: RouterHistory,\n customReducers?: Object,\n initialState?: $Shape<ReduxState>\n): { routerHistory: RouterHistory, store: ReduxStore } => {\n let composeEnhancers = compose;\n\n if (process.env.NODE_ENV !== \"production\" && typeof window !== \"undefined\") {\n composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;\n }\n\n const combinedReducers: Reducer<ReduxState, ReduxAction> = combineReducers({\n ...customReducers,\n ...createReducer(),\n });\n\n const middleware = applyMiddleware(\n modularUIMiddleware,\n routerMiddleware(routerHistory),\n thunk\n );\n\n const enhancers = composeEnhancers(middleware);\n\n const store: ReduxStore = createReduxStore(\n combinedReducers,\n initialState,\n enhancers\n );\n\n if (!initialState?.router) {\n store.dispatch(locationChange(routerHistory.location, \"PUSH\"));\n }\n return { routerHistory, store };\n};\n\nexport default configureStore;\n"],"mappings":";;;;;;;AACA;AAMA;AAEA;AACA;AAEA;AACA;AAMA;AACA;AACA,MAAMA,cAAc,GAAG,CACrBC,aAA4B,EAC5BC,cAAuB,EACvBC,YAAiC,KACuB;EACxD,IAAIC,gBAAgB,GAAGC,cAAO;EAE9B,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IAC1EL,gBAAgB,GAAGK,MAAM,CAACC,oCAAoC,IAAIL,cAAO;EAC3E;EAEA,MAAMM,gBAAkD,GAAG,IAAAC,sBAAe,EAAC;IACzE,GAAGV,cAAc;IACjB,GAAG,IAAAW,4BAAa;EAClB,CAAC,CAAC;EAEF,MAAMC,UAAU,GAAG,IAAAC,sBAAe,EAChCC,wCAAmB,EACnB,IAAAC,kCAAgB,EAAChB,aAAa,CAAC,EAC/BiB,mBAAK,CACN;EAED,MAAMC,SAAS,GAAGf,gBAAgB,CAACU,UAAU,CAAC;EAE9C,MAAMM,KAAiB,GAAG,IAAAC,kBAAgB,EACxCV,gBAAgB,EAChBR,YAAY,EACZgB,SAAS,CACV;EAED,IAAI,CAAChB,YAAY,EAAEmB,MAAM,EAAE;IACzBF,KAAK,CAACG,QAAQ,CAAC,IAAAC,6BAAc,EAACvB,aAAa,CAACwB,QAAQ,EAAE,MAAM,CAAC,CAAC;EAChE;EACA,OAAO;IAAExB,aAAa;IAAEmB;EAAM,CAAC;AACjC,CAAC;AAAC,eAEapB,cAAc;AAAA"}