@beinformed/ui 1.33.0 → 1.34.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 +14 -0
- package/esm/builder/mergeLayoutHintConfigurations.js +29 -28
- package/esm/builder/mergeLayoutHintConfigurations.js.map +1 -1
- package/esm/react-client/client.js +30 -2
- package/esm/react-client/client.js.map +1 -1
- package/lib/builder/__tests__/mergeLayoutHintConfigurations.spec.js.flow +24 -17
- package/lib/builder/mergeLayoutHintConfigurations.js +29 -28
- package/lib/builder/mergeLayoutHintConfigurations.js.flow +33 -37
- package/lib/builder/mergeLayoutHintConfigurations.js.map +1 -1
- package/lib/react-client/client.js +28 -0
- package/lib/react-client/client.js.flow +30 -2
- package/lib/react-client/client.js.map +1 -1
- package/package.json +15 -16
- package/src/builder/__tests__/LayoutHintConfig.json +11 -0
- package/src/builder/__tests__/mergeLayoutHintConfigurations.spec.js +24 -17
- package/src/builder/__tests__/subdir/LayoutHintConfig.json +11 -0
- package/src/builder/mergeLayoutHintConfigurations.js +33 -37
- package/src/react-client/client.js +30 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
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.34.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.34.0...v1.34.1) (2023-09-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **layout-hint-json:** replace glob with node packages ([c25b89f](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/c25b89f811a934cf2ce57254e5d06a574b674561))
|
|
11
|
+
|
|
12
|
+
## [1.34.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.33.0...v1.34.0) (2023-09-13)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **redirectUri:** the redirectURI to a secure page is now handled through the UI library ([cc54f8e](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/cc54f8e5d436d2c14e6f50dd3793ac074a8dcc2f))
|
|
18
|
+
|
|
5
19
|
## [1.33.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.33.0-beta.7...v1.33.0) (2023-08-29)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
2
|
-
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
3
2
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
4
3
|
import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
|
|
5
|
-
|
|
6
|
-
const fs = require("fs");
|
|
4
|
+
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
7
5
|
const path = require("path");
|
|
6
|
+
const {
|
|
7
|
+
readdirSync,
|
|
8
|
+
statSync,
|
|
9
|
+
readFileSync,
|
|
10
|
+
writeFileSync
|
|
11
|
+
} = require("fs");
|
|
8
12
|
const {
|
|
9
13
|
LayoutHintConfiguration
|
|
10
14
|
} = require("../constants/LayoutHintConfig");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const findFiles = dir => {
|
|
16
|
+
const matchedFiles = [];
|
|
17
|
+
const files = readdirSync(dir);
|
|
18
|
+
for (const file of files) {
|
|
19
|
+
const absolute = path.join(dir, file);
|
|
20
|
+
if (statSync(absolute).isDirectory()) {
|
|
21
|
+
const foundFiles = findFiles(absolute);
|
|
22
|
+
matchedFiles.push(...foundFiles);
|
|
23
|
+
} else {
|
|
24
|
+
const filename = path.basename(file);
|
|
25
|
+
if (filename === "LayoutHintConfig.json") {
|
|
26
|
+
matchedFiles.push(absolute);
|
|
18
27
|
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return matchedFiles;
|
|
22
31
|
};
|
|
23
32
|
|
|
24
33
|
/**
|
|
@@ -28,21 +37,13 @@ const readFiles = files => {
|
|
|
28
37
|
*/
|
|
29
38
|
exports.mergeLayoutHintConfigurations = async (srcFolder, outputFolder) => {
|
|
30
39
|
const escapedSrcFolder = srcFolder.replace(/\\/g, "/");
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
readFiles(files).then(jsons => {
|
|
37
|
-
const newConfig = _Object$assign(LayoutHintConfiguration, ...jsons);
|
|
38
|
-
fs.writeFile(path.join(outputFolder, "LayoutHintConfig.json"), _JSON$stringify(newConfig), writeErr => {
|
|
39
|
-
if (writeErr) {
|
|
40
|
-
return reject(writeErr);
|
|
41
|
-
}
|
|
42
|
-
return resolve();
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
|
40
|
+
const files = findFiles(escapedSrcFolder);
|
|
41
|
+
const jsons = _mapInstanceProperty(files).call(files, file => {
|
|
42
|
+
const content = readFileSync(file, "utf-8");
|
|
43
|
+
return JSON.parse(content);
|
|
46
44
|
});
|
|
45
|
+
const newConfig = _Object$assign(LayoutHintConfiguration, ...jsons);
|
|
46
|
+
writeFileSync(path.join(outputFolder, "LayoutHintConfig.json"), _JSON$stringify(newConfig));
|
|
47
|
+
return _Promise.resolve();
|
|
47
48
|
};
|
|
48
49
|
//# sourceMappingURL=mergeLayoutHintConfigurations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeLayoutHintConfigurations.js","names":["
|
|
1
|
+
{"version":3,"file":"mergeLayoutHintConfigurations.js","names":["path","require","readdirSync","statSync","readFileSync","writeFileSync","LayoutHintConfiguration","findFiles","dir","matchedFiles","files","file","absolute","join","isDirectory","foundFiles","push","filename","basename","exports","mergeLayoutHintConfigurations","srcFolder","outputFolder","escapedSrcFolder","replace","jsons","_mapInstanceProperty","call","content","JSON","parse","newConfig","_Object$assign","_JSON$stringify","_Promise","resolve"],"sources":["../../src/builder/mergeLayoutHintConfigurations.js"],"sourcesContent":["// @flow\nconst path = require(\"path\");\nconst { readdirSync, statSync, readFileSync, writeFileSync } = require(\"fs\");\n\nconst { LayoutHintConfiguration } = require(\"../constants/LayoutHintConfig\");\n\nconst findFiles = (dir: string): Array<string> => {\n const matchedFiles = [];\n\n const files = readdirSync(dir);\n\n for (const file of files) {\n const absolute = path.join(dir, file);\n if (statSync(absolute).isDirectory()) {\n const foundFiles = findFiles(absolute);\n matchedFiles.push(...foundFiles);\n } else {\n const filename = path.basename(file);\n if (filename === \"LayoutHintConfig.json\") {\n matchedFiles.push(absolute);\n }\n }\n }\n\n return matchedFiles;\n};\n\n/**\n * Merge all LayoutHintConfig.json files from this library and in the srcFolder\n * together into one config file, and copies it to the outputFolder.<br/>\n * This file is consumed by Be Informed studio to give layout hint information\n */\nexports.mergeLayoutHintConfigurations = async (\n srcFolder: string,\n outputFolder: string,\n): Promise<void> => {\n const escapedSrcFolder = srcFolder.replace(/\\\\/g, \"/\");\n\n const files = findFiles(escapedSrcFolder);\n\n const jsons = files.map((file) => {\n const content = readFileSync(file, \"utf-8\");\n return JSON.parse(content);\n });\n\n const newConfig = Object.assign(LayoutHintConfiguration, ...jsons);\n\n writeFileSync(\n path.join(outputFolder, \"LayoutHintConfig.json\"),\n JSON.stringify(newConfig),\n );\n\n return Promise.resolve();\n};\n"],"mappings":";;;;AACA,MAAMA,IAAI,GAAGC,OAAO,CAAC,MAAM,CAAC;AAC5B,MAAM;EAAEC,WAAW;EAAEC,QAAQ;EAAEC,YAAY;EAAEC;AAAc,CAAC,GAAGJ,OAAO,CAAC,IAAI,CAAC;AAE5E,MAAM;EAAEK;AAAwB,CAA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a,IAAI,CAACS,YAAY,EAAE,uBAAuB,CAAC,EAChDW,eAAA,CAAeF,SAAS,CAC1B,CAAC;EAED,OAAOG,QAAA,CAAQC,OAAO,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import _trimInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/trim";
|
|
2
|
+
import _URLSearchParams from "@babel/runtime-corejs3/core-js-stable/url-search-params";
|
|
2
3
|
// eslint-disable-next-line react/no-deprecated
|
|
3
4
|
import { hydrate, render } from "react-dom";
|
|
4
5
|
import { has } from "../utils/helpers/objects";
|
|
5
6
|
import setImmediate from "setimmediate";
|
|
6
7
|
import Cache from "../utils/browser/Cache";
|
|
8
|
+
import xhr from "../utils/fetch/xhr";
|
|
7
9
|
import { createBrowserHistory } from "history";
|
|
8
10
|
import configureStore from "../redux/store/configureStore";
|
|
9
11
|
import rehydrate from "./rehydrate";
|
|
10
|
-
import { getBasePath } from "../constants/Settings";
|
|
12
|
+
import { getBasePath, getSetting } from "../constants/Settings";
|
|
11
13
|
import { setAllContentInDataSetting, setLoginPreferences } from "../redux/actions/Preferences";
|
|
12
14
|
import { showXHRErrorNotification } from "../redux/actions/Notification";
|
|
13
15
|
import { handleError } from "../redux/actions/Error";
|
|
14
16
|
import { loginSuccess } from "../redux/actions/SignIn";
|
|
15
|
-
import { locationChange } from "../redux/_router/RouterActions";
|
|
17
|
+
import { locationChange, replace } from "../redux/_router/RouterActions";
|
|
16
18
|
import { JsonParseException, FetchException } from "../exceptions";
|
|
17
19
|
import { Init } from "./Init";
|
|
18
20
|
import { handleBeforeRenderHooks } from "../redux/store/beforeRenderHooks";
|
|
21
|
+
import UnauthorizedException from "../exceptions/UnauthorizedException";
|
|
19
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
23
|
/*
|
|
21
24
|
* deserialize serialized data from the server to provide a smooth dehydration.
|
|
@@ -53,6 +56,30 @@ export const setUnhandledRejectionEvent = store => {
|
|
|
53
56
|
};
|
|
54
57
|
};
|
|
55
58
|
|
|
59
|
+
/**
|
|
60
|
+
* The redirectURI querystring parameter is available when the server is redirecting an unauthorized deep link
|
|
61
|
+
* @param store
|
|
62
|
+
*/
|
|
63
|
+
const handleRedirectURI = store => {
|
|
64
|
+
const urlParams = new _URLSearchParams(window.location.search);
|
|
65
|
+
const redirectURI = urlParams.get("redirectURI");
|
|
66
|
+
if (redirectURI) {
|
|
67
|
+
xhr({
|
|
68
|
+
url: `${getBasePath()}${redirectURI}`
|
|
69
|
+
}).catch(e => {
|
|
70
|
+
if (e instanceof UnauthorizedException) {
|
|
71
|
+
const LOGIN_PATH = getSetting("LOGIN_PATH", "/signin");
|
|
72
|
+
store.dispatch(replace(LOGIN_PATH, {
|
|
73
|
+
from: {
|
|
74
|
+
pathname: redirectURI
|
|
75
|
+
},
|
|
76
|
+
modal: false
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
56
83
|
/**
|
|
57
84
|
*/
|
|
58
85
|
export const setupClient = function () {
|
|
@@ -74,6 +101,7 @@ export const setupClient = function () {
|
|
|
74
101
|
routerHistory,
|
|
75
102
|
store
|
|
76
103
|
} = configureStore(browserHistory, customReducers, rehydrate(data));
|
|
104
|
+
handleRedirectURI(store);
|
|
77
105
|
setAllContentInDataSetting(store.getState());
|
|
78
106
|
setLoginPreferences(store.getState());
|
|
79
107
|
|
|
@@ -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","jsx","_jsx","parseDataToJSON","data","JSON","parse","error","getDataFromServer","_context","dataElement","document","querySelector","Error","_trimInstanceProperty","textContent","call","setUnhandledRejectionEvent","store","window","onunhandledrejection","event","detail","errorMessage","reason","message","toString","dispatch","setupClient","customReducers","arguments","length","undefined","beforeRenderHooks","contextPath","clear","browserHistory","basename","routerHistory","getState","loadOtherBrowserTabs","getItem","response","listen","location","action","body","className","addContentLoadedEvent","theme","ErrorFallbackComponent","mount","addEventListener","applicationNode","children","mountClient","element","isSSR","client","_ref"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\n// eslint-disable-next-line react/no-deprecated\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\ntype RenderFunction = () => ReactElement<ElementType>;\ntype MountFunction = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => void;\ntype Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n mount: MountFunction,\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: RenderFunction,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n mount: MountFunction,\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 element: ReactElement<ElementType>,\n) => {\n const isSSR = applicationNode.querySelector(\".application\");\n if (isSSR) {\n hydrate(element, applicationNode);\n } else {\n render(element, 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 mount,\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 mount ?? mountClient,\n );\n};\n"],"mappings":";AACA;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,SAC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,WAAY;MAChCe,KAAK,EAAEA,KAAM;MACbC,sBAAsB,EAAEA,sBAAuB;MAAAI,QAAA,EAE9CvE,MAAM,CAAC;IAAC,CACL,CACR,CAAC;EACH,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA,MAAMwE,WAAW,GAAGA,CAClBF,eAAwB,EACxBG,OAAkC,KAC/B;EACH,MAAMC,KAAK,GAAGJ,eAAe,CAACzC,aAAa,CAAC,cAAc,CAAC;EAC3D,IAAI6C,KAAK,EAAE;IACT3E,OAAO,CAAC0E,OAAO,EAAEH,eAAe,CAAC;EACnC,CAAC,MAAM;IACLtE,MAAM,CAACyE,OAAO,EAAEH,eAAe,CAAC;EAClC;AACF,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMK,MAAM,GAAGC,IAAA,IAOT;EAAA,IAPU;IACrB9B,cAAc;IACdoB,KAAK;IACLlE,MAAM;IACNkD,iBAAiB;IACjBiB,sBAAsB;IACtBC;EACK,CAAC,GAAAQ,IAAA;EACN,MAAM;IAAEzC,KAAK;IAAEoB;EAAc,CAAC,GAAGV,WAAW,CAC1CC,cAAc,EACdI,iBACF,CAAC;EAEDe,qBAAqB,CACnB9B,KAAK,EACLoB,aAAa,EACbW,KAAK,EACLlE,MAAM,EACNmE,sBAAsB,EACtBC,KAAK,IAAII,WACX,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["hydrate","render","has","setImmediate","Cache","xhr","createBrowserHistory","configureStore","rehydrate","getBasePath","getSetting","setAllContentInDataSetting","setLoginPreferences","showXHRErrorNotification","handleError","loginSuccess","locationChange","replace","JsonParseException","FetchException","Init","handleBeforeRenderHooks","UnauthorizedException","jsx","_jsx","parseDataToJSON","data","JSON","parse","error","getDataFromServer","_context","dataElement","document","querySelector","Error","_trimInstanceProperty","textContent","call","setUnhandledRejectionEvent","store","window","onunhandledrejection","event","detail","errorMessage","reason","message","toString","dispatch","handleRedirectURI","urlParams","_URLSearchParams","location","search","redirectURI","get","url","catch","e","LOGIN_PATH","from","pathname","modal","setupClient","customReducers","arguments","length","undefined","beforeRenderHooks","contextPath","clear","browserHistory","basename","routerHistory","getState","loadOtherBrowserTabs","getItem","response","listen","action","body","className","addContentLoadedEvent","theme","ErrorFallbackComponent","mount","addEventListener","applicationNode","children","mountClient","element","isSSR","client","_ref"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\n// eslint-disable-next-line react/no-deprecated\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 xhr from \"../utils/fetch/xhr\";\n\nimport { createBrowserHistory } from \"history\";\nimport configureStore from \"../redux/store/configureStore\";\n\nimport rehydrate from \"./rehydrate\";\nimport { getBasePath, getSetting } 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, replace } from \"../redux/_router/RouterActions\";\n\nimport { JsonParseException, FetchException } from \"../exceptions\";\n\nimport { Init } from \"./Init\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport UnauthorizedException from \"../exceptions/UnauthorizedException\";\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\ntype RenderFunction = () => ReactElement<ElementType>;\ntype MountFunction = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => void;\ntype Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n mount: MountFunction,\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 * The redirectURI querystring parameter is available when the server is redirecting an unauthorized deep link\n * @param store\n */\nconst handleRedirectURI = (store: ReduxStore) => {\n const urlParams = new URLSearchParams(window.location.search);\n const redirectURI = urlParams.get(\"redirectURI\");\n if (redirectURI) {\n xhr({ url: `${getBasePath()}${redirectURI}` }).catch((e) => {\n if (e instanceof UnauthorizedException) {\n const LOGIN_PATH = getSetting(\"LOGIN_PATH\", \"/signin\");\n store.dispatch(\n replace(LOGIN_PATH, {\n from: { pathname: redirectURI },\n modal: false,\n }),\n );\n }\n });\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 handleRedirectURI(store);\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: RenderFunction,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n mount: MountFunction,\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 element: ReactElement<ElementType>,\n) => {\n const isSSR = applicationNode.querySelector(\".application\");\n if (isSSR) {\n hydrate(element, applicationNode);\n } else {\n render(element, 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 mount,\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 mount ?? mountClient,\n );\n};\n"],"mappings":";;AACA;AACA,SAASA,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAE3C,SAASC,GAAG,QAAQ,0BAA0B;AAC9C,OAAOC,YAAY,MAAM,cAAc;AAEvC,OAAOC,KAAK,MAAM,wBAAwB;AAE1C,OAAOC,GAAG,MAAM,oBAAoB;AAEpC,SAASC,oBAAoB,QAAQ,SAAS;AAC9C,OAAOC,cAAc,MAAM,+BAA+B;AAE1D,OAAOC,SAAS,MAAM,aAAa;AACnC,SAASC,WAAW,EAAEC,UAAU,QAAQ,uBAAuB;AAE/D,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,EAAEC,OAAO,QAAQ,gCAAgC;AAExE,SAASC,kBAAkB,EAAEC,cAAc,QAAQ,eAAe;AAElE,SAASC,IAAI,QAAQ,QAAQ;AAE7B,SAASC,uBAAuB,QAAQ,kCAAkC;AAE1E,OAAOC,qBAAqB,MAAM,qCAAqC;AAAC,SAAAC,GAAA,IAAAC,IAAA;AA2BxE;AACA;AACA;AACA,MAAMC,eAAe,GAAIC,IAAY,IAAK;EACxC,IAAI;IACF,OAAOC,IAAI,CAACC,KAAK,CAACF,IAAI,CAAC;EACzB,CAAC,CAAC,OAAOG,KAAK,EAAE;IACd,MAAM,IAAIX,kBAAkB,CAAE,yBAAwBQ,IAAK,EAAC,CAAC;EAC/D;AACF,CAAC;AAED,MAAMI,iBAAiB,GAAGA,CAAA,KAAM;EAAA,IAAAC,QAAA;EAC9B,MAAMC,WAAW,GAAGC,QAAQ,CAACC,aAAa,CACxC,4DACF,C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AAc;MAC7BJ,WAAW,EAAE7B,MAAM,CAAC6B,WAAY;MAChCc,KAAK,EAAEA,KAAM;MACbC,sBAAsB,EAAEA,sBAAuB;MAAAI,QAAA,EAE9CxF,MAAM,CAAC;IAAC,CACL,CACR,CAAC;EACH,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA,MAAMyF,WAAW,GAAGA,CAClBF,eAAwB,EACxBG,OAAkC,KAC/B;EACH,MAAMC,KAAK,GAAGJ,eAAe,CAACtD,aAAa,CAAC,cAAc,CAAC;EAC3D,IAAI0D,KAAK,EAAE;IACT5F,OAAO,CAAC2F,OAAO,EAAEH,eAAe,CAAC;EACnC,CAAC,MAAM;IACLvF,MAAM,CAAC0F,OAAO,EAAEH,eAAe,CAAC;EAClC;AACF,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMK,MAAM,GAAGC,IAAA,IAOT;EAAA,IAPU;IACrB7B,cAAc;IACdmB,KAAK;IACLnF,MAAM;IACNoE,iBAAiB;IACjBgB,sBAAsB;IACtBC;EACK,CAAC,GAAAQ,IAAA;EACN,MAAM;IAAEtD,KAAK;IAAEkC;EAAc,CAAC,GAAGV,WAAW,CAC1CC,cAAc,EACdI,iBACF,CAAC;EAEDc,qBAAqB,CACnB3C,KAAK,EACLkC,aAAa,EACbU,KAAK,EACLnF,MAAM,EACNoF,sBAAsB,EACtBC,KAAK,IAAII,WACX,CAAC;AACH,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { mergeLayoutHintConfigurations } from "../mergeLayoutHintConfigurations";
|
|
2
2
|
import { LayoutHintConfiguration } from "../../constants/LayoutHintConfig";
|
|
3
3
|
const fs = require("fs");
|
|
4
|
-
|
|
5
|
-
const
|
|
4
|
+
//
|
|
5
|
+
const projectJson1 = {
|
|
6
6
|
MOCK: {
|
|
7
7
|
hint: "mock",
|
|
8
8
|
description: {
|
|
@@ -14,31 +14,38 @@ const projectJson = {
|
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
const projectJson2 = {
|
|
18
|
+
MOCK2: {
|
|
19
|
+
hint: "mock2",
|
|
20
|
+
description: {
|
|
21
|
+
NL: "mock2 dutch description",
|
|
22
|
+
EN: "mock2 english description",
|
|
23
|
+
},
|
|
24
|
+
link: "",
|
|
25
|
+
component: ["attribute"],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
17
29
|
jest.mock("fs", () => ({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
),
|
|
21
|
-
writeFile: jest.fn((path, options, callback) => callback(null)),
|
|
30
|
+
...jest.requireActual("fs"),
|
|
31
|
+
writeFileSync: jest.fn(),
|
|
22
32
|
}));
|
|
23
33
|
|
|
24
|
-
jest.mock("glob", () =>
|
|
25
|
-
jest.fn((pattern, options, callback) =>
|
|
26
|
-
callback(null, ["/input/LayoutHintConfig.json"]),
|
|
27
|
-
),
|
|
28
|
-
);
|
|
29
|
-
|
|
30
34
|
describe("mergeLayoutHintConfigurations", () => {
|
|
31
35
|
it("generates layouthint.json", async () => {
|
|
32
36
|
expect.assertions(1);
|
|
33
37
|
|
|
34
|
-
const expectedJson = {
|
|
38
|
+
const expectedJson = {
|
|
39
|
+
...LayoutHintConfiguration,
|
|
40
|
+
...projectJson1,
|
|
41
|
+
...projectJson2,
|
|
42
|
+
};
|
|
35
43
|
|
|
36
|
-
await mergeLayoutHintConfigurations("
|
|
44
|
+
await mergeLayoutHintConfigurations("./src", "/output");
|
|
37
45
|
|
|
38
|
-
expect(fs.
|
|
39
|
-
|
|
46
|
+
expect(fs.writeFileSync).toHaveBeenCalledWith(
|
|
47
|
+
"\\output\\LayoutHintConfig.json",
|
|
40
48
|
JSON.stringify(expectedJson),
|
|
41
|
-
expect.anything(),
|
|
42
49
|
);
|
|
43
50
|
});
|
|
44
51
|
});
|
|
@@ -2,26 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
4
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
5
|
-
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
6
5
|
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
|
|
7
6
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
8
|
-
|
|
9
|
-
const fs = require("fs");
|
|
7
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
10
8
|
const path = require("path");
|
|
9
|
+
const {
|
|
10
|
+
readdirSync,
|
|
11
|
+
statSync,
|
|
12
|
+
readFileSync,
|
|
13
|
+
writeFileSync
|
|
14
|
+
} = require("fs");
|
|
11
15
|
const {
|
|
12
16
|
LayoutHintConfiguration
|
|
13
17
|
} = require("../constants/LayoutHintConfig");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const findFiles = dir => {
|
|
19
|
+
const matchedFiles = [];
|
|
20
|
+
const files = readdirSync(dir);
|
|
21
|
+
for (const file of files) {
|
|
22
|
+
const absolute = path.join(dir, file);
|
|
23
|
+
if (statSync(absolute).isDirectory()) {
|
|
24
|
+
const foundFiles = findFiles(absolute);
|
|
25
|
+
matchedFiles.push(...foundFiles);
|
|
26
|
+
} else {
|
|
27
|
+
const filename = path.basename(file);
|
|
28
|
+
if (filename === "LayoutHintConfig.json") {
|
|
29
|
+
matchedFiles.push(absolute);
|
|
21
30
|
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return matchedFiles;
|
|
25
34
|
};
|
|
26
35
|
|
|
27
36
|
/**
|
|
@@ -31,21 +40,13 @@ const readFiles = files => {
|
|
|
31
40
|
*/
|
|
32
41
|
exports.mergeLayoutHintConfigurations = async (srcFolder, outputFolder) => {
|
|
33
42
|
const escapedSrcFolder = srcFolder.replace(/\\/g, "/");
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
readFiles(files).then(jsons => {
|
|
40
|
-
const newConfig = (0, _assign.default)(LayoutHintConfiguration, ...jsons);
|
|
41
|
-
fs.writeFile(path.join(outputFolder, "LayoutHintConfig.json"), (0, _stringify.default)(newConfig), writeErr => {
|
|
42
|
-
if (writeErr) {
|
|
43
|
-
return reject(writeErr);
|
|
44
|
-
}
|
|
45
|
-
return resolve();
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
});
|
|
43
|
+
const files = findFiles(escapedSrcFolder);
|
|
44
|
+
const jsons = (0, _map.default)(files).call(files, file => {
|
|
45
|
+
const content = readFileSync(file, "utf-8");
|
|
46
|
+
return JSON.parse(content);
|
|
49
47
|
});
|
|
48
|
+
const newConfig = (0, _assign.default)(LayoutHintConfiguration, ...jsons);
|
|
49
|
+
writeFileSync(path.join(outputFolder, "LayoutHintConfig.json"), (0, _stringify.default)(newConfig));
|
|
50
|
+
return _promise.default.resolve();
|
|
50
51
|
};
|
|
51
52
|
//# sourceMappingURL=mergeLayoutHintConfigurations.js.map
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
const glob = require("glob");
|
|
3
|
-
const fs = require("fs");
|
|
4
2
|
const path = require("path");
|
|
3
|
+
const { readdirSync, statSync, readFileSync, writeFileSync } = require("fs");
|
|
5
4
|
|
|
6
5
|
const { LayoutHintConfiguration } = require("../constants/LayoutHintConfig");
|
|
7
6
|
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
fs.readFile(file, "utf-8", (err, data) => {
|
|
13
|
-
if (err) {
|
|
14
|
-
return reject(err);
|
|
15
|
-
} else {
|
|
16
|
-
return resolve(JSON.parse(data));
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}),
|
|
20
|
-
);
|
|
7
|
+
const findFiles = (dir: string): Array<string> => {
|
|
8
|
+
const matchedFiles = [];
|
|
9
|
+
|
|
10
|
+
const files = readdirSync(dir);
|
|
21
11
|
|
|
22
|
-
|
|
12
|
+
for (const file of files) {
|
|
13
|
+
const absolute = path.join(dir, file);
|
|
14
|
+
if (statSync(absolute).isDirectory()) {
|
|
15
|
+
const foundFiles = findFiles(absolute);
|
|
16
|
+
matchedFiles.push(...foundFiles);
|
|
17
|
+
} else {
|
|
18
|
+
const filename = path.basename(file);
|
|
19
|
+
if (filename === "LayoutHintConfig.json") {
|
|
20
|
+
matchedFiles.push(absolute);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return matchedFiles;
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
/**
|
|
@@ -32,27 +35,20 @@ exports.mergeLayoutHintConfigurations = async (
|
|
|
32
35
|
outputFolder: string,
|
|
33
36
|
): Promise<void> => {
|
|
34
37
|
const escapedSrcFolder = srcFolder.replace(/\\/g, "/");
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
glob(escapedSrcFolder + "/**/LayoutHintConfig.json", {}, (err, files) => {
|
|
37
|
-
if (err) {
|
|
38
|
-
return reject(err);
|
|
39
|
-
}
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
(writeErr) => {
|
|
48
|
-
if (writeErr) {
|
|
49
|
-
return reject(writeErr);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return resolve();
|
|
53
|
-
},
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
39
|
+
const files = findFiles(escapedSrcFolder);
|
|
40
|
+
|
|
41
|
+
const jsons = files.map((file) => {
|
|
42
|
+
const content = readFileSync(file, "utf-8");
|
|
43
|
+
return JSON.parse(content);
|
|
57
44
|
});
|
|
45
|
+
|
|
46
|
+
const newConfig = Object.assign(LayoutHintConfiguration, ...jsons);
|
|
47
|
+
|
|
48
|
+
writeFileSync(
|
|
49
|
+
path.join(outputFolder, "LayoutHintConfig.json"),
|
|
50
|
+
JSON.stringify(newConfig),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return Promise.resolve();
|
|
58
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeLayoutHintConfigurations.js","names":["
|
|
1
|
+
{"version":3,"file":"mergeLayoutHintConfigurations.js","names":["path","require","readdirSync","statSync","readFileSync","writeFileSync","LayoutHintConfiguration","findFiles","dir","matchedFiles","files","file","absolute","join","isDirectory","foundFiles","push","filename","basename","exports","mergeLayoutHintConfigurations","srcFolder","outputFolder","escapedSrcFolder","replace","jsons","_map","default","call","content","JSON","parse","newConfig","_assign","_stringify","_promise","resolve"],"sources":["../../src/builder/mergeLayoutHintConfigurations.js"],"sourcesContent":["// @flow\nconst path = require(\"path\");\nconst { readdirSync, statSync, readFileSync, writeFileSync } = require(\"fs\");\n\nconst { LayoutHintConfiguration } = require(\"../constants/LayoutHintConfig\");\n\nconst findFiles = (dir: string): Array<string> => {\n const matchedFiles = [];\n\n const files = readdirSync(dir);\n\n for (const file of files) {\n const absolute = path.join(dir, file);\n if (statSync(absolute).isDirectory()) {\n const foundFiles = findFiles(absolute);\n matchedFiles.push(...foundFiles);\n } else {\n const filename = path.basename(file);\n if (filename === \"LayoutHintConfig.json\") {\n matchedFiles.push(absolute);\n }\n }\n }\n\n return matchedFiles;\n};\n\n/**\n * Merge all LayoutHintConfig.json files from this library and in the srcFolder\n * together into one config file, and copies it to the outputFolder.<br/>\n * This file is consumed by Be Informed studio to give layout hint information\n */\nexports.mergeLayoutHintConfigurations = async (\n srcFolder: string,\n outputFolder: string,\n): Promise<void> => {\n const escapedSrcFolder = srcFolder.replace(/\\\\/g, \"/\");\n\n const files = findFiles(escapedSrcFolder);\n\n const jsons = files.map((file) => {\n const content = readFileSync(file, \"utf-8\");\n return JSON.parse(content);\n });\n\n const newConfig = Object.assign(LayoutHintConfiguration, ...jsons);\n\n writeFileSync(\n path.join(outputFolder, \"LayoutHintConfig.json\"),\n JSON.stringify(newConfig),\n );\n\n return Promise.resolve();\n};\n"],"mappings":";;;;;;;AACA,MAAMA,IAAI,GAAGC,OAAO,CAAC,MAAM,CAAC;AAC5B,MAAM;EAAEC,WAAW;EAAEC,QAAQ;EAAEC,YAAY;EAAEC;AAAc,CAAC,GAAGJ,OAAO,CAAC,IAAI,CAAC;AAE5E,MAAM;EAAEK;AAAwB,CAAC,GAAGL,OAAO,CAAC,+BAA+B,CAAC;AAE5E,MAAMM,SAAS,GAAIC,GAAW,IAAoB;EAChD,MAAMC,YAAY,GAAG,EAAE;EAEvB,MAAMC,KAAK,GAAGR,WAAW,CAACM,GAAG,CAAC;EAE9B,KAAK,MAAMG,IAAI,IAAID,KAAK,EAAE;IACxB,MAAME,QAAQ,GAAGZ,IAAI,CAACa,IAAI,CAACL,GAAG,EAAEG,IAAI,CAAC;IACrC,IAAIR,QAAQ,CAACS,QAAQ,CAAC,CAACE,WAAW,CAAC,CAAC,EAAE;MACpC,MAAMC,UAAU,GAAGR,SAAS,CAACK,QAAQ,CAAC;MACtCH,YAAY,CAACO,IAAI,CAAC,GAAGD,UAAU,CAAC;IAClC,CAAC,MAAM;MACL,MAAME,QAAQ,GAAGjB,IAAI,CAACkB,QAAQ,CAACP,IAAI,CAAC;MACpC,IAAIM,QAAQ,KAAK,uBAAuB,EAAE;QACxCR,YAAY,CAACO,IAAI,CAACJ,QAAQ,CAAC;MAC7B;IACF;EACF;EAEA,OAAOH,YAAY;AACrB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACAU,OAAO,CAACC,6BAA6B,GAAG,OACtCC,SAAiB,EACjBC,YAAoB,KACF;EAClB,MAAMC,gBAAgB,GAAGF,SAAS,CAACG,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;EAEtD,MAAMd,KAAK,GAAGH,SAAS,CAACgB,gBAAgB,CAAC;EAEzC,MAAME,KAAK,GAAG,IAAAC,IAAA,CAAAC,OAAA,EAAAjB,KAAK,EAAAkB,IAAA,CAALlB,KAAK,EAAMC,IAAI,IAAK;IAChC,MAAMkB,OAAO,GAAGzB,YAAY,CAACO,IAAI,EAAE,OAAO,CAAC;IAC3C,OAAOmB,IAAI,CAACC,KAAK,CAACF,OAAO,CAAC;EAC5B,CAAC,CAAC;EAEF,MAAMG,SAAS,GAAG,IAAAC,OAAA,CAAAN,OAAA,EAAcrB,uBAAuB,EAAE,GAAGmB,KAAK,CAAC;EAElEpB,aAAa,CACXL,IAAI,CAACa,IAAI,CAACS,YAAY,EAAE,uBAAuB,CAAC,EAChD,IAAAY,UAAA,CAAAP,OAAA,EAAeK,SAAS,CAC1B,CAAC;EAED,OAAOG,QAAA,CAAAR,OAAA,CAAQS,OAAO,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -6,10 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
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
|
+
var _urlSearchParams = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/url-search-params"));
|
|
9
10
|
var _reactDom = require("react-dom");
|
|
10
11
|
var _objects = require("../utils/helpers/objects");
|
|
11
12
|
var _setimmediate = _interopRequireDefault(require("setimmediate"));
|
|
12
13
|
var _Cache = _interopRequireDefault(require("../utils/browser/Cache"));
|
|
14
|
+
var _xhr = _interopRequireDefault(require("../utils/fetch/xhr"));
|
|
13
15
|
var _history = require("history");
|
|
14
16
|
var _configureStore = _interopRequireDefault(require("../redux/store/configureStore"));
|
|
15
17
|
var _rehydrate = _interopRequireDefault(require("./rehydrate"));
|
|
@@ -22,6 +24,7 @@ var _RouterActions = require("../redux/_router/RouterActions");
|
|
|
22
24
|
var _exceptions = require("../exceptions");
|
|
23
25
|
var _Init = require("./Init");
|
|
24
26
|
var _beforeRenderHooks = require("../redux/store/beforeRenderHooks");
|
|
27
|
+
var _UnauthorizedException = _interopRequireDefault(require("../exceptions/UnauthorizedException"));
|
|
25
28
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
29
|
// eslint-disable-next-line react/no-deprecated
|
|
27
30
|
/*
|
|
@@ -61,8 +64,32 @@ const setUnhandledRejectionEvent = store => {
|
|
|
61
64
|
};
|
|
62
65
|
|
|
63
66
|
/**
|
|
67
|
+
* The redirectURI querystring parameter is available when the server is redirecting an unauthorized deep link
|
|
68
|
+
* @param store
|
|
64
69
|
*/
|
|
65
70
|
exports.setUnhandledRejectionEvent = setUnhandledRejectionEvent;
|
|
71
|
+
const handleRedirectURI = store => {
|
|
72
|
+
const urlParams = new _urlSearchParams.default(window.location.search);
|
|
73
|
+
const redirectURI = urlParams.get("redirectURI");
|
|
74
|
+
if (redirectURI) {
|
|
75
|
+
(0, _xhr.default)({
|
|
76
|
+
url: `${(0, _Settings.getBasePath)()}${redirectURI}`
|
|
77
|
+
}).catch(e => {
|
|
78
|
+
if (e instanceof _UnauthorizedException.default) {
|
|
79
|
+
const LOGIN_PATH = (0, _Settings.getSetting)("LOGIN_PATH", "/signin");
|
|
80
|
+
store.dispatch((0, _RouterActions.replace)(LOGIN_PATH, {
|
|
81
|
+
from: {
|
|
82
|
+
pathname: redirectURI
|
|
83
|
+
},
|
|
84
|
+
modal: false
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
*/
|
|
66
93
|
const setupClient = function () {
|
|
67
94
|
let customReducers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
68
95
|
let beforeRenderHooks = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -82,6 +109,7 @@ const setupClient = function () {
|
|
|
82
109
|
routerHistory,
|
|
83
110
|
store
|
|
84
111
|
} = (0, _configureStore.default)(browserHistory, customReducers, (0, _rehydrate.default)(data));
|
|
112
|
+
handleRedirectURI(store);
|
|
85
113
|
(0, _Preferences.setAllContentInDataSetting)(store.getState());
|
|
86
114
|
(0, _Preferences.setLoginPreferences)(store.getState());
|
|
87
115
|
|
|
@@ -7,11 +7,13 @@ import setImmediate from "setimmediate";
|
|
|
7
7
|
|
|
8
8
|
import Cache from "../utils/browser/Cache";
|
|
9
9
|
|
|
10
|
+
import xhr from "../utils/fetch/xhr";
|
|
11
|
+
|
|
10
12
|
import { createBrowserHistory } from "history";
|
|
11
13
|
import configureStore from "../redux/store/configureStore";
|
|
12
14
|
|
|
13
15
|
import rehydrate from "./rehydrate";
|
|
14
|
-
import { getBasePath } from "../constants/Settings";
|
|
16
|
+
import { getBasePath, getSetting } from "../constants/Settings";
|
|
15
17
|
|
|
16
18
|
import {
|
|
17
19
|
setAllContentInDataSetting,
|
|
@@ -22,7 +24,7 @@ import { showXHRErrorNotification } from "../redux/actions/Notification";
|
|
|
22
24
|
import { handleError } from "../redux/actions/Error";
|
|
23
25
|
import { loginSuccess } from "../redux/actions/SignIn";
|
|
24
26
|
|
|
25
|
-
import { locationChange } from "../redux/_router/RouterActions";
|
|
27
|
+
import { locationChange, replace } from "../redux/_router/RouterActions";
|
|
26
28
|
|
|
27
29
|
import { JsonParseException, FetchException } from "../exceptions";
|
|
28
30
|
|
|
@@ -30,6 +32,8 @@ import { Init } from "./Init";
|
|
|
30
32
|
|
|
31
33
|
import { handleBeforeRenderHooks } from "../redux/store/beforeRenderHooks";
|
|
32
34
|
|
|
35
|
+
import UnauthorizedException from "../exceptions/UnauthorizedException";
|
|
36
|
+
|
|
33
37
|
import type {
|
|
34
38
|
ComponentType,
|
|
35
39
|
Element as ReactElement,
|
|
@@ -97,6 +101,28 @@ export const setUnhandledRejectionEvent = (store: ReduxStore) => {
|
|
|
97
101
|
};
|
|
98
102
|
};
|
|
99
103
|
|
|
104
|
+
/**
|
|
105
|
+
* The redirectURI querystring parameter is available when the server is redirecting an unauthorized deep link
|
|
106
|
+
* @param store
|
|
107
|
+
*/
|
|
108
|
+
const handleRedirectURI = (store: ReduxStore) => {
|
|
109
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
110
|
+
const redirectURI = urlParams.get("redirectURI");
|
|
111
|
+
if (redirectURI) {
|
|
112
|
+
xhr({ url: `${getBasePath()}${redirectURI}` }).catch((e) => {
|
|
113
|
+
if (e instanceof UnauthorizedException) {
|
|
114
|
+
const LOGIN_PATH = getSetting("LOGIN_PATH", "/signin");
|
|
115
|
+
store.dispatch(
|
|
116
|
+
replace(LOGIN_PATH, {
|
|
117
|
+
from: { pathname: redirectURI },
|
|
118
|
+
modal: false,
|
|
119
|
+
}),
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
100
126
|
/**
|
|
101
127
|
*/
|
|
102
128
|
export const setupClient = (
|
|
@@ -122,6 +148,8 @@ export const setupClient = (
|
|
|
122
148
|
rehydrate(data),
|
|
123
149
|
);
|
|
124
150
|
|
|
151
|
+
handleRedirectURI(store);
|
|
152
|
+
|
|
125
153
|
setAllContentInDataSetting(store.getState());
|
|
126
154
|
setLoginPreferences(store.getState());
|
|
127
155
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["_reactDom","require","_objects","_setimmediate","_interopRequireDefault","_Cache","_history","_configureStore","_rehydrate","_Settings","_Preferences","_Notification","_Error","_SignIn","_RouterActions","_exceptions","_Init","_beforeRenderHooks","_jsxRuntime","parseDataToJSON","data","JSON","parse","error","JsonParseException","getDataFromServer","_context","dataElement","document","querySelector","Error","_trim","default","textContent","call","setUnhandledRejectionEvent","store","window","onunhandledrejection","event","detail","setImmediate","errorMessage","reason","message","toString","dispatch","showXHRErrorNotification","exports","setupClient","customReducers","arguments","length","undefined","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","jsx","Init","children","mountClient","element","isSSR","hydrate","client","_ref"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\n// eslint-disable-next-line react/no-deprecated\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\ntype RenderFunction = () => ReactElement<ElementType>;\ntype MountFunction = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => void;\ntype Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n mount: MountFunction,\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: RenderFunction,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n mount: MountFunction,\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 element: ReactElement<ElementType>,\n) => {\n const isSSR = applicationNode.querySelector(\".application\");\n if (isSSR) {\n hydrate(element, applicationNode);\n } else {\n render(element, 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 mount,\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 mount ?? mountClient,\n );\n};\n"],"mappings":";;;;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,G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
1
|
+
{"version":3,"file":"client.js","names":["_reactDom","require","_objects","_setimmediate","_interopRequireDefault","_Cache","_xhr","_history","_configureStore","_rehydrate","_Settings","_Preferences","_Notification","_Error","_SignIn","_RouterActions","_exceptions","_Init","_beforeRenderHooks","_UnauthorizedException","_jsxRuntime","parseDataToJSON","data","JSON","parse","error","JsonParseException","getDataFromServer","_context","dataElement","document","querySelector","Error","_trim","default","textContent","call","setUnhandledRejectionEvent","store","window","onunhandledrejection","event","detail","setImmediate","errorMessage","reason","message","toString","dispatch","showXHRErrorNotification","exports","handleRedirectURI","urlParams","_urlSearchParams","location","search","redirectURI","get","xhr","url","getBasePath","catch","e","UnauthorizedException","LOGIN_PATH","getSetting","replace","from","pathname","modal","setupClient","customReducers","arguments","length","undefined","beforeRenderHooks","contextPath","Cache","clear","browserHistory","createBrowserHistory","basename","routerHistory","configureStore","rehydrate","setAllContentInDataSetting","getState","setLoginPreferences","loadOtherBrowserTabs","getItem","loginSuccess","has","FetchException","response","handleError","listen","action","locationChange","body","className","handleBeforeRenderHooks","addContentLoadedEvent","theme","render","ErrorFallbackComponent","mount","addEventListener","applicationNode","jsx","Init","children","mountClient","element","isSSR","hydrate","client","_ref"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\n// eslint-disable-next-line react/no-deprecated\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 xhr from \"../utils/fetch/xhr\";\n\nimport { createBrowserHistory } from \"history\";\nimport configureStore from \"../redux/store/configureStore\";\n\nimport rehydrate from \"./rehydrate\";\nimport { getBasePath, getSetting } 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, replace } from \"../redux/_router/RouterActions\";\n\nimport { JsonParseException, FetchException } from \"../exceptions\";\n\nimport { Init } from \"./Init\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport UnauthorizedException from \"../exceptions/UnauthorizedException\";\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\ntype RenderFunction = () => ReactElement<ElementType>;\ntype MountFunction = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => void;\ntype Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n mount: MountFunction,\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 * The redirectURI querystring parameter is available when the server is redirecting an unauthorized deep link\n * @param store\n */\nconst handleRedirectURI = (store: ReduxStore) => {\n const urlParams = new URLSearchParams(window.location.search);\n const redirectURI = urlParams.get(\"redirectURI\");\n if (redirectURI) {\n xhr({ url: `${getBasePath()}${redirectURI}` }).catch((e) => {\n if (e instanceof UnauthorizedException) {\n const LOGIN_PATH = getSetting(\"LOGIN_PATH\", \"/signin\");\n store.dispatch(\n replace(LOGIN_PATH, {\n from: { pathname: redirectURI },\n modal: false,\n }),\n );\n }\n });\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 handleRedirectURI(store);\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: RenderFunction,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n mount: MountFunction,\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 element: ReactElement<ElementType>,\n) => {\n const isSSR = applicationNode.querySelector(\".application\");\n if (isSSR) {\n hydrate(element, applicationNode);\n } else {\n render(element, 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 mount,\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 mount ?? mountClient,\n );\n};\n"],"mappings":";;;;;;;;;AAEA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,IAAA,GAAAF,sBAAA,CAAAH,OAAA;AAEA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,eAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAEA,IAAAQ,UAAA,GAAAL,sBAAA,CAAAH,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AAEA,IAAAU,YAAA,GAAAV,OAAA;AAIA,IAAAW,aAAA,GAAAX,OAAA;AAEA,IAAAY,MAAA,GAAAZ,OAAA;AACA,IAAAa,OAAA,GAAAb,OAAA;AAEA,IAAAc,cAAA,GAAAd,OAAA;AAEA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AC;EACnC,CAAC,MAAM;IACL,IAAAJ,gBAAM,EAACS,OAAO,EAAEL,eAAe,CAAC;EAClC;AACF,CAAC;;AAED;AACA;AACA;AACO,MAAMQ,MAAM,GAAGC,IAAA,IAOT;EAAA,IAPU;IACrB7C,cAAc;IACd+B,KAAK;IACLC,MAAM;IACN5B,iBAAiB;IACjB6B,sBAAsB;IACtBC;EACK,CAAC,GAAAW,IAAA;EACN,MAAM;IAAE9E,KAAK;IAAE4C;EAAc,CAAC,GAAGZ,WAAW,CAC1CC,cAAc,EACdI,iBACF,CAAC;EAED0B,qBAAqB,CACnB/D,KAAK,EACL4C,aAAa,EACboB,KAAK,EACLC,MAAM,EACNC,sBAAsB,EACtBC,KAAK,IAAIM,WACX,CAAC;AACH,CAAC;AAAC7D,OAAA,CAAAiE,MAAA,GAAAA,MAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.34.1",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "http://support.beinformed.com",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"styled-components": "^5.0.0"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@babel/runtime-corejs3": "^7.22.
|
|
85
|
+
"@babel/runtime-corejs3": "^7.22.15",
|
|
86
86
|
"big.js": "^6.2.1",
|
|
87
87
|
"date-fns": "^2.30.0",
|
|
88
88
|
"deepmerge": "^4.3.1",
|
|
@@ -98,50 +98,49 @@
|
|
|
98
98
|
"setimmediate": "^1.0.5"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
|
-
"@babel/cli": "^7.22.
|
|
102
|
-
"@babel/core": "^7.22.
|
|
103
|
-
"@babel/eslint-parser": "^7.22.
|
|
101
|
+
"@babel/cli": "^7.22.15",
|
|
102
|
+
"@babel/core": "^7.22.17",
|
|
103
|
+
"@babel/eslint-parser": "^7.22.15",
|
|
104
104
|
"@babel/eslint-plugin": "^7.22.10",
|
|
105
105
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
106
106
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
107
|
-
"@babel/plugin-transform-runtime": "^7.22.
|
|
108
|
-
"@babel/preset-env": "^7.22.
|
|
109
|
-
"@babel/preset-flow": "^7.22.
|
|
110
|
-
"@babel/preset-react": "^7.22.
|
|
107
|
+
"@babel/plugin-transform-runtime": "^7.22.15",
|
|
108
|
+
"@babel/preset-env": "^7.22.15",
|
|
109
|
+
"@babel/preset-flow": "^7.22.15",
|
|
110
|
+
"@babel/preset-react": "^7.22.15",
|
|
111
111
|
"@commitlint/cli": "^17.7.1",
|
|
112
112
|
"@commitlint/config-conventional": "^17.7.0",
|
|
113
113
|
"@testing-library/react": "^14.0.0",
|
|
114
114
|
"auditjs": "^4.0.41",
|
|
115
|
-
"babel-jest": "^29.
|
|
115
|
+
"babel-jest": "^29.7.0",
|
|
116
116
|
"babel-plugin-styled-components": "^2.1.4",
|
|
117
117
|
"cherry-pick": "^0.5.0",
|
|
118
118
|
"commit-and-tag-version": "^11.2.3",
|
|
119
119
|
"cross-env": "^7.0.3",
|
|
120
120
|
"documentation": "^14.0.2",
|
|
121
|
-
"eslint": "^8.
|
|
121
|
+
"eslint": "^8.49.0",
|
|
122
122
|
"eslint-config-prettier": "^9.0.0",
|
|
123
123
|
"eslint-plugin-babel": "^5.3.1",
|
|
124
124
|
"eslint-plugin-ft-flow": "^3.0.0",
|
|
125
125
|
"eslint-plugin-import": "^2.28.1",
|
|
126
126
|
"eslint-plugin-jest": "^27.2.3",
|
|
127
|
-
"eslint-plugin-jsdoc": "^46.
|
|
127
|
+
"eslint-plugin-jsdoc": "^46.6.0",
|
|
128
128
|
"eslint-plugin-react": "^7.33.2",
|
|
129
129
|
"eslint-plugin-react-hooks": "^4.5.0",
|
|
130
130
|
"eslint-plugin-you-dont-need-lodash-underscore": "^6.13.0",
|
|
131
131
|
"flow-bin": "^0.200.1",
|
|
132
132
|
"flow-copy-source": "^2.0.9",
|
|
133
133
|
"flow-typed": "^3.9.0",
|
|
134
|
-
"glob": "^10.3.3",
|
|
135
134
|
"history": "^4.0.0",
|
|
136
135
|
"husky": "^8.0.3",
|
|
137
|
-
"jest": "^29.
|
|
138
|
-
"jest-environment-jsdom": "^29.
|
|
136
|
+
"jest": "^29.7.0",
|
|
137
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
139
138
|
"jest-junit": "^16.0.0",
|
|
140
139
|
"jest-sonar-reporter": "^2.0.0",
|
|
141
140
|
"jscodeshift": "^0.15.0",
|
|
142
141
|
"lint-staged": "^13.2.3",
|
|
143
142
|
"polished": "^4.0.0",
|
|
144
|
-
"prettier": "^3.0.
|
|
143
|
+
"prettier": "^3.0.3",
|
|
145
144
|
"react": "^18.0.0",
|
|
146
145
|
"react-dom": "^18.0.0",
|
|
147
146
|
"react-helmet-async": "^1.0.0",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { mergeLayoutHintConfigurations } from "../mergeLayoutHintConfigurations";
|
|
2
2
|
import { LayoutHintConfiguration } from "../../constants/LayoutHintConfig";
|
|
3
3
|
const fs = require("fs");
|
|
4
|
-
|
|
5
|
-
const
|
|
4
|
+
//
|
|
5
|
+
const projectJson1 = {
|
|
6
6
|
MOCK: {
|
|
7
7
|
hint: "mock",
|
|
8
8
|
description: {
|
|
@@ -14,31 +14,38 @@ const projectJson = {
|
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
const projectJson2 = {
|
|
18
|
+
MOCK2: {
|
|
19
|
+
hint: "mock2",
|
|
20
|
+
description: {
|
|
21
|
+
NL: "mock2 dutch description",
|
|
22
|
+
EN: "mock2 english description",
|
|
23
|
+
},
|
|
24
|
+
link: "",
|
|
25
|
+
component: ["attribute"],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
17
29
|
jest.mock("fs", () => ({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
),
|
|
21
|
-
writeFile: jest.fn((path, options, callback) => callback(null)),
|
|
30
|
+
...jest.requireActual("fs"),
|
|
31
|
+
writeFileSync: jest.fn(),
|
|
22
32
|
}));
|
|
23
33
|
|
|
24
|
-
jest.mock("glob", () =>
|
|
25
|
-
jest.fn((pattern, options, callback) =>
|
|
26
|
-
callback(null, ["/input/LayoutHintConfig.json"]),
|
|
27
|
-
),
|
|
28
|
-
);
|
|
29
|
-
|
|
30
34
|
describe("mergeLayoutHintConfigurations", () => {
|
|
31
35
|
it("generates layouthint.json", async () => {
|
|
32
36
|
expect.assertions(1);
|
|
33
37
|
|
|
34
|
-
const expectedJson = {
|
|
38
|
+
const expectedJson = {
|
|
39
|
+
...LayoutHintConfiguration,
|
|
40
|
+
...projectJson1,
|
|
41
|
+
...projectJson2,
|
|
42
|
+
};
|
|
35
43
|
|
|
36
|
-
await mergeLayoutHintConfigurations("
|
|
44
|
+
await mergeLayoutHintConfigurations("./src", "/output");
|
|
37
45
|
|
|
38
|
-
expect(fs.
|
|
39
|
-
|
|
46
|
+
expect(fs.writeFileSync).toHaveBeenCalledWith(
|
|
47
|
+
"\\output\\LayoutHintConfig.json",
|
|
40
48
|
JSON.stringify(expectedJson),
|
|
41
|
-
expect.anything(),
|
|
42
49
|
);
|
|
43
50
|
});
|
|
44
51
|
});
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
const glob = require("glob");
|
|
3
|
-
const fs = require("fs");
|
|
4
2
|
const path = require("path");
|
|
3
|
+
const { readdirSync, statSync, readFileSync, writeFileSync } = require("fs");
|
|
5
4
|
|
|
6
5
|
const { LayoutHintConfiguration } = require("../constants/LayoutHintConfig");
|
|
7
6
|
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
fs.readFile(file, "utf-8", (err, data) => {
|
|
13
|
-
if (err) {
|
|
14
|
-
return reject(err);
|
|
15
|
-
} else {
|
|
16
|
-
return resolve(JSON.parse(data));
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}),
|
|
20
|
-
);
|
|
7
|
+
const findFiles = (dir: string): Array<string> => {
|
|
8
|
+
const matchedFiles = [];
|
|
9
|
+
|
|
10
|
+
const files = readdirSync(dir);
|
|
21
11
|
|
|
22
|
-
|
|
12
|
+
for (const file of files) {
|
|
13
|
+
const absolute = path.join(dir, file);
|
|
14
|
+
if (statSync(absolute).isDirectory()) {
|
|
15
|
+
const foundFiles = findFiles(absolute);
|
|
16
|
+
matchedFiles.push(...foundFiles);
|
|
17
|
+
} else {
|
|
18
|
+
const filename = path.basename(file);
|
|
19
|
+
if (filename === "LayoutHintConfig.json") {
|
|
20
|
+
matchedFiles.push(absolute);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return matchedFiles;
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
/**
|
|
@@ -32,27 +35,20 @@ exports.mergeLayoutHintConfigurations = async (
|
|
|
32
35
|
outputFolder: string,
|
|
33
36
|
): Promise<void> => {
|
|
34
37
|
const escapedSrcFolder = srcFolder.replace(/\\/g, "/");
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
glob(escapedSrcFolder + "/**/LayoutHintConfig.json", {}, (err, files) => {
|
|
37
|
-
if (err) {
|
|
38
|
-
return reject(err);
|
|
39
|
-
}
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
(writeErr) => {
|
|
48
|
-
if (writeErr) {
|
|
49
|
-
return reject(writeErr);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return resolve();
|
|
53
|
-
},
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
39
|
+
const files = findFiles(escapedSrcFolder);
|
|
40
|
+
|
|
41
|
+
const jsons = files.map((file) => {
|
|
42
|
+
const content = readFileSync(file, "utf-8");
|
|
43
|
+
return JSON.parse(content);
|
|
57
44
|
});
|
|
45
|
+
|
|
46
|
+
const newConfig = Object.assign(LayoutHintConfiguration, ...jsons);
|
|
47
|
+
|
|
48
|
+
writeFileSync(
|
|
49
|
+
path.join(outputFolder, "LayoutHintConfig.json"),
|
|
50
|
+
JSON.stringify(newConfig),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return Promise.resolve();
|
|
58
54
|
};
|
|
@@ -7,11 +7,13 @@ import setImmediate from "setimmediate";
|
|
|
7
7
|
|
|
8
8
|
import Cache from "../utils/browser/Cache";
|
|
9
9
|
|
|
10
|
+
import xhr from "../utils/fetch/xhr";
|
|
11
|
+
|
|
10
12
|
import { createBrowserHistory } from "history";
|
|
11
13
|
import configureStore from "../redux/store/configureStore";
|
|
12
14
|
|
|
13
15
|
import rehydrate from "./rehydrate";
|
|
14
|
-
import { getBasePath } from "../constants/Settings";
|
|
16
|
+
import { getBasePath, getSetting } from "../constants/Settings";
|
|
15
17
|
|
|
16
18
|
import {
|
|
17
19
|
setAllContentInDataSetting,
|
|
@@ -22,7 +24,7 @@ import { showXHRErrorNotification } from "../redux/actions/Notification";
|
|
|
22
24
|
import { handleError } from "../redux/actions/Error";
|
|
23
25
|
import { loginSuccess } from "../redux/actions/SignIn";
|
|
24
26
|
|
|
25
|
-
import { locationChange } from "../redux/_router/RouterActions";
|
|
27
|
+
import { locationChange, replace } from "../redux/_router/RouterActions";
|
|
26
28
|
|
|
27
29
|
import { JsonParseException, FetchException } from "../exceptions";
|
|
28
30
|
|
|
@@ -30,6 +32,8 @@ import { Init } from "./Init";
|
|
|
30
32
|
|
|
31
33
|
import { handleBeforeRenderHooks } from "../redux/store/beforeRenderHooks";
|
|
32
34
|
|
|
35
|
+
import UnauthorizedException from "../exceptions/UnauthorizedException";
|
|
36
|
+
|
|
33
37
|
import type {
|
|
34
38
|
ComponentType,
|
|
35
39
|
Element as ReactElement,
|
|
@@ -97,6 +101,28 @@ export const setUnhandledRejectionEvent = (store: ReduxStore) => {
|
|
|
97
101
|
};
|
|
98
102
|
};
|
|
99
103
|
|
|
104
|
+
/**
|
|
105
|
+
* The redirectURI querystring parameter is available when the server is redirecting an unauthorized deep link
|
|
106
|
+
* @param store
|
|
107
|
+
*/
|
|
108
|
+
const handleRedirectURI = (store: ReduxStore) => {
|
|
109
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
110
|
+
const redirectURI = urlParams.get("redirectURI");
|
|
111
|
+
if (redirectURI) {
|
|
112
|
+
xhr({ url: `${getBasePath()}${redirectURI}` }).catch((e) => {
|
|
113
|
+
if (e instanceof UnauthorizedException) {
|
|
114
|
+
const LOGIN_PATH = getSetting("LOGIN_PATH", "/signin");
|
|
115
|
+
store.dispatch(
|
|
116
|
+
replace(LOGIN_PATH, {
|
|
117
|
+
from: { pathname: redirectURI },
|
|
118
|
+
modal: false,
|
|
119
|
+
}),
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
100
126
|
/**
|
|
101
127
|
*/
|
|
102
128
|
export const setupClient = (
|
|
@@ -122,6 +148,8 @@ export const setupClient = (
|
|
|
122
148
|
rehydrate(data),
|
|
123
149
|
);
|
|
124
150
|
|
|
151
|
+
handleRedirectURI(store);
|
|
152
|
+
|
|
125
153
|
setAllContentInDataSetting(store.getState());
|
|
126
154
|
setLoginPreferences(store.getState());
|
|
127
155
|
|