@elliemae/pui-app-sdk 5.9.0 → 5.10.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.
Files changed (65) hide show
  1. package/dist/cjs/communication/http-client/index.js +3 -6
  2. package/dist/cjs/communication/http-client/response-interceptor.js +1 -2
  3. package/dist/cjs/data/appMiddleware.js +1 -2
  4. package/dist/cjs/data/queryMiddleware.js +1 -2
  5. package/dist/cjs/index.js +3 -0
  6. package/dist/cjs/sideeffect/error-toast/index.js +1 -2
  7. package/dist/cjs/sideeffect/wait-message/index.js +2 -4
  8. package/dist/cjs/utils/app-config/index.js +1 -2
  9. package/dist/cjs/utils/custom-hooks/use-state-selector.js +47 -0
  10. package/dist/cjs/utils/micro-frontend/console-logger.js +1 -2
  11. package/dist/cjs/utils/micro-frontend/guest.js +5 -10
  12. package/dist/cjs/utils/micro-frontend/host.js +7 -14
  13. package/dist/cjs/utils/micro-frontend/index.js +4 -8
  14. package/dist/cjs/utils/micro-frontend/ssfguest-adapter.js +1 -2
  15. package/dist/cjs/utils/session.js +2 -3
  16. package/dist/cjs/utils/window.js +3 -6
  17. package/dist/cjs/view/error-toast/index.js +1 -2
  18. package/dist/cjs/view/fields/autocomplete/index.js +2 -4
  19. package/dist/cjs/view/fields/input-mask/index.js +2 -4
  20. package/dist/cjs/view/form/index.js +1 -2
  21. package/dist/cjs/view/login/index.js +2 -4
  22. package/dist/cjs/view/micro-app/app-factory/index.js +8 -16
  23. package/dist/cjs/view/micro-app/resources/manifest.js +1 -2
  24. package/dist/cjs/view/micro-app/resources/script.js +6 -12
  25. package/dist/cjs/view/micro-app/resources/style.js +3 -6
  26. package/dist/cjs/view/micro-app/use-app-will-render.js +6 -11
  27. package/dist/cjs/view/micro-app/utils.js +2 -4
  28. package/dist/cjs/view/micro-iframe-app/use-frame-loaded.js +2 -3
  29. package/dist/cjs/view/session-timeout/index.js +1 -2
  30. package/dist/cjs/view/wait-message/use-html-wait-message.js +1 -2
  31. package/dist/esm/communication/http-client/index.js +3 -6
  32. package/dist/esm/communication/http-client/response-interceptor.js +1 -2
  33. package/dist/esm/data/appMiddleware.js +1 -2
  34. package/dist/esm/data/queryMiddleware.js +1 -2
  35. package/dist/esm/index.js +6 -0
  36. package/dist/esm/sideeffect/error-toast/index.js +1 -2
  37. package/dist/esm/sideeffect/wait-message/index.js +2 -4
  38. package/dist/esm/utils/app-config/index.js +1 -2
  39. package/dist/esm/utils/custom-hooks/use-state-selector.js +27 -0
  40. package/dist/esm/utils/micro-frontend/console-logger.js +1 -2
  41. package/dist/esm/utils/micro-frontend/guest.js +5 -10
  42. package/dist/esm/utils/micro-frontend/host.js +7 -14
  43. package/dist/esm/utils/micro-frontend/index.js +4 -8
  44. package/dist/esm/utils/micro-frontend/ssfguest-adapter.js +1 -2
  45. package/dist/esm/utils/session.js +2 -3
  46. package/dist/esm/utils/window.js +3 -6
  47. package/dist/esm/view/error-toast/index.js +1 -2
  48. package/dist/esm/view/fields/autocomplete/index.js +2 -4
  49. package/dist/esm/view/fields/input-mask/index.js +2 -4
  50. package/dist/esm/view/form/index.js +1 -2
  51. package/dist/esm/view/login/index.js +2 -4
  52. package/dist/esm/view/micro-app/app-factory/index.js +8 -16
  53. package/dist/esm/view/micro-app/resources/manifest.js +1 -2
  54. package/dist/esm/view/micro-app/resources/script.js +6 -12
  55. package/dist/esm/view/micro-app/resources/style.js +3 -6
  56. package/dist/esm/view/micro-app/use-app-will-render.js +6 -11
  57. package/dist/esm/view/micro-app/utils.js +2 -4
  58. package/dist/esm/view/micro-iframe-app/use-frame-loaded.js +2 -3
  59. package/dist/esm/view/session-timeout/index.js +1 -2
  60. package/dist/esm/view/wait-message/use-html-wait-message.js +1 -2
  61. package/dist/types/lib/api/helpers.d.ts +1 -1
  62. package/dist/types/lib/index.d.ts +3 -0
  63. package/dist/types/lib/utils/custom-hooks/use-state-selector.d.ts +40 -0
  64. package/dist/types/lib/view/fields/toggle/index.stories.d.ts +1 -1
  65. package/package.json +32 -32
@@ -47,14 +47,11 @@ const getHTTPClient = ({
47
47
  baseURL,
48
48
  headers
49
49
  });
50
- if (client?.defaults?.timeout)
51
- client.defaults.timeout = REQUEST_TIMEOUT;
50
+ if (client?.defaults?.timeout) client.defaults.timeout = REQUEST_TIMEOUT;
52
51
  (0, import_retry.default)(client);
53
52
  const { request, response } = client?.interceptors || {};
54
- if (request)
55
- request.use(import_request_interceptor.requestInterceptor);
56
- if (response)
57
- response.use(import_response_interceptor.handleSuccess, import_response_interceptor.handleFailure);
53
+ if (request) request.use(import_request_interceptor.requestInterceptor);
54
+ if (response) response.use(import_response_interceptor.handleSuccess, import_response_interceptor.handleFailure);
58
55
  return client;
59
56
  };
60
57
  const getAuthHTTPClient = ({
@@ -45,8 +45,7 @@ const handleFailure = (error) => {
45
45
  if (status === HTTP_UNAUTHORIZED && unAuthorizedFailureHandler && typeof unAuthorizedFailureHandler === "function") {
46
46
  return unAuthorizedFailureHandler(error).then((authorizationHeader) => {
47
47
  const { config } = error;
48
- if (!config?.headers)
49
- throw error;
48
+ if (!config?.headers) throw error;
50
49
  config.headers["Authorization"] = authorizationHeader;
51
50
  return new Promise((resolve, reject) => {
52
51
  import_axios.default.request(config).then(resolve).catch(reject);
@@ -39,8 +39,7 @@ const addMiddleware = ({
39
39
  key,
40
40
  middleware
41
41
  }) => {
42
- if (middlewareDispatchFns.has(key) || !store)
43
- return;
42
+ if (middlewareDispatchFns.has(key) || !store) return;
44
43
  middlewareDispatchFns.set(key, middleware(store));
45
44
  };
46
45
  const removeMiddleware = (key) => {
@@ -38,8 +38,7 @@ const addMiddleware = ({
38
38
  reducerPath,
39
39
  middleware
40
40
  }) => {
41
- if (middlewareDispatchFns.has(reducerPath) || !store)
42
- return;
41
+ if (middlewareDispatchFns.has(reducerPath) || !store) return;
43
42
  middlewareDispatchFns.set(reducerPath, middleware(store));
44
43
  };
45
44
  const removeMiddleware = (reducerPath) => {
package/dist/cjs/index.js CHANGED
@@ -140,6 +140,8 @@ __export(lib_exports, {
140
140
  useInjectSaga: () => import_redux_injectors.useInjectSaga,
141
141
  useInjectSideEffect: () => import_react.useInjectSideEffect,
142
142
  useMediaQueryList: () => import_use_media_query_list.useMediaQueryList,
143
+ useStateSelector: () => import_use_state_selector.useStateSelector,
144
+ useStateSelectorShallow: () => import_use_state_selector.useStateSelectorShallow,
143
145
  waitMessageAction: () => import_actions3.waitMessage,
144
146
  withAppDecorator: () => import_decorator.withAppDecorator
145
147
  });
@@ -156,6 +158,7 @@ var import_page = require("./view/page.js");
156
158
  var import_constants = __toESM(require("./utils/constants.js"));
157
159
  var import_redux_injectors = require("redux-injectors");
158
160
  var import_react = require("./data/react.js");
161
+ var import_use_state_selector = require("./utils/custom-hooks/use-state-selector.js");
159
162
  var import_errorMiddleware = require("./data/errorMiddleware.js");
160
163
  var import_listenerMiddleware = require("./data/listenerMiddleware.js");
161
164
  var import_helper = require("./utils/auth/helper.js");
@@ -33,8 +33,7 @@ function* openErrorToast(action) {
33
33
  );
34
34
  const host = yield (0, import_effects.call)(microApp.getHost.bind(microApp));
35
35
  const message = action?.payload?.description || action?.payload?.messageText;
36
- if (host && message)
37
- yield (0, import_effects.call)(host.openErrorBanner.bind(host), message);
36
+ if (host && message) yield (0, import_effects.call)(host.openErrorBanner.bind(host), message);
38
37
  } catch (ex) {
39
38
  (0, import_micro_frontend.getLogger)().error({
40
39
  ...import_log_records.logRecords.ERR_TOAST_OPEN_FAILED,
@@ -32,8 +32,7 @@ function* openWaitMessage() {
32
32
  import_guest.CMicroAppGuest.getInstance.bind(import_guest.CMicroAppGuest)
33
33
  );
34
34
  const host = yield (0, import_effects.call)(microApp.getHost.bind(microApp));
35
- if (host)
36
- yield (0, import_effects.call)(host.openWaitMessage.bind(host));
35
+ if (host) yield (0, import_effects.call)(host.openWaitMessage.bind(host));
37
36
  } catch (ex) {
38
37
  (0, import_micro_frontend.getLogger)().error({
39
38
  ...import_log_records.logRecords.WAIT_MSG_OPEN_FAILED,
@@ -47,8 +46,7 @@ function* closeWaitMessage() {
47
46
  import_guest.CMicroAppGuest.getInstance.bind(import_guest.CMicroAppGuest)
48
47
  );
49
48
  const host = yield (0, import_effects.call)(microApp.getHost.bind(microApp));
50
- if (host)
51
- yield (0, import_effects.call)(host.closeWaitMessage.bind(host));
49
+ if (host) yield (0, import_effects.call)(host.closeWaitMessage.bind(host));
52
50
  } catch (ex) {
53
51
  (0, import_micro_frontend.getLogger)().error({
54
52
  ...import_log_records.logRecords.WAIT_MSG_CLOSE_FAILED,
@@ -41,8 +41,7 @@ var import_config2 = require("./config.js");
41
41
  const parseAppConfig = (data) => {
42
42
  const { activeEnv } = data;
43
43
  const activeEnvConfig = data.env[activeEnv] || {};
44
- if (data.env)
45
- delete data.env;
44
+ if (data.env) delete data.env;
46
45
  (0, import_config.setAppConfig)(import_lodash.default.merge(data, activeEnvConfig));
47
46
  sessionStorage.setItem("envName", activeEnv);
48
47
  (0, import_appdynamics.setAppDynamicsUserData)({ envName: activeEnv });
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var use_state_selector_exports = {};
20
+ __export(use_state_selector_exports, {
21
+ useStateSelector: () => useStateSelector,
22
+ useStateSelectorShallow: () => useStateSelectorShallow
23
+ });
24
+ module.exports = __toCommonJS(use_state_selector_exports);
25
+ var import_react = require("react");
26
+ var import_react_redux = require("react-redux");
27
+ function useStateSelector(selectStateFieldFunc, fieldName = "", {
28
+ defaultValue = void 0,
29
+ equalityFn = void 0
30
+ } = {}) {
31
+ const [finalDefaultValue] = (0, import_react.useState)(
32
+ defaultValue
33
+ );
34
+ return (0, import_react_redux.useSelector)(
35
+ selectStateFieldFunc(fieldName, finalDefaultValue),
36
+ equalityFn
37
+ );
38
+ }
39
+ function useStateSelectorShallow(selectStateFieldFunc, fieldName = "", {
40
+ defaultValue = void 0,
41
+ equalityFn = import_react_redux.shallowEqual
42
+ } = {}) {
43
+ return useStateSelector(selectStateFieldFunc, fieldName, {
44
+ defaultValue,
45
+ equalityFn
46
+ });
47
+ }
@@ -24,8 +24,7 @@ module.exports = __toCommonJS(console_logger_exports);
24
24
  var import_pui_diagnostics = require("@elliemae/pui-diagnostics");
25
25
  var import_config = require("../app-config/config.js");
26
26
  const logger = (() => {
27
- if (!import_pui_diagnostics.logger)
28
- return console;
27
+ if (!import_pui_diagnostics.logger) return console;
29
28
  return (0, import_pui_diagnostics.logger)({
30
29
  transport: (0, import_pui_diagnostics.Console)(),
31
30
  index: "app",
@@ -125,8 +125,7 @@ class CMicroAppGuest {
125
125
  }
126
126
  if (!host) {
127
127
  const ssfAdapter = new import_ssfguest_adapter.SSFGuestAdapter();
128
- if (!await ssfAdapter.init())
129
- return null;
128
+ if (!await ssfAdapter.init()) return null;
130
129
  host = ssfAdapter;
131
130
  }
132
131
  }
@@ -137,8 +136,7 @@ class CMicroAppGuest {
137
136
  this.props.history = options?.history || this.props.history;
138
137
  if (!this.props.host) {
139
138
  const host = await this.getSSFAdapter();
140
- if (host)
141
- this.props.host = host;
139
+ if (host) this.props.host = host;
142
140
  }
143
141
  __webpack_public_path__ = __webpack_public_path__.replace(/\/?$/, "/");
144
142
  return (0, import_app_config.loadAppConfig)().then(() => {
@@ -146,15 +144,13 @@ class CMicroAppGuest {
146
144
  const userId = this.getSessionStorageItem("userId") || "";
147
145
  (0, import_web_analytics.updateBAEventParameters)({ appId: this.appId, instanceId, userId });
148
146
  (0, import_appdynamics.setAppDynamicsUserData)({ appId: this.appId, instanceId, userId });
149
- if (this.onInit)
150
- this.onInit(this.props);
147
+ if (this.onInit) this.onInit(this.props);
151
148
  });
152
149
  }
153
150
  mount(options = { containerId: "app-container" }) {
154
151
  this.containerId = options?.containerId;
155
152
  return Promise.resolve().then(() => {
156
- if (this.onMount)
157
- this.onMount(options);
153
+ if (this.onMount) this.onMount(options);
158
154
  });
159
155
  }
160
156
  unmount(options) {
@@ -167,7 +163,6 @@ class CMicroAppGuest {
167
163
  return this.onGetRef ? this.onGetRef() : null;
168
164
  }
169
165
  navigate(url, state) {
170
- if (url)
171
- this.props.history.push(url, state);
166
+ if (url) this.props.history.push(url, state);
172
167
  }
173
168
  }
@@ -66,8 +66,7 @@ class CMicroAppHost {
66
66
  this.renewSessionTimer = this.renewSessionTimer.bind(this);
67
67
  this.setSystemVersion = this.setSystemVersion.bind(this);
68
68
  (0, import_app_config.loadAppConfig)().then(() => {
69
- if (this.onInit)
70
- this.onInit(this.props);
69
+ if (this.onInit) this.onInit(this.props);
71
70
  }).catch(() => {
72
71
  });
73
72
  (0, import_web_analytics.updateBAEventParameters)({ appId: this.appId });
@@ -113,23 +112,19 @@ class CMicroAppHost {
113
112
  (0, import_pubsub_js.unsubscribe)(token);
114
113
  }
115
114
  navigate(url, state) {
116
- if (url)
117
- this.props.history.push(url, state);
115
+ if (url) this.props.history.push(url, state);
118
116
  }
119
117
  openWaitMessage() {
120
118
  const store = (0, import_store.getStore)();
121
- if (store)
122
- store.dispatch(import_actions.waitMessage.open());
119
+ if (store) store.dispatch(import_actions.waitMessage.open());
123
120
  }
124
121
  closeWaitMessage() {
125
122
  const store = (0, import_store.getStore)();
126
- if (store)
127
- store.dispatch(import_actions.waitMessage.close());
123
+ if (store) store.dispatch(import_actions.waitMessage.close());
128
124
  }
129
125
  openErrorBanner(message) {
130
126
  const store = (0, import_store.getStore)();
131
- if (store)
132
- store.dispatch(import_error.actions.set({ description: message }));
127
+ if (store) store.dispatch(import_error.actions.set({ description: message }));
133
128
  }
134
129
  getAuthToken() {
135
130
  return (0, import_window.getWindow)().sessionStorage.getItem("Authorization");
@@ -139,13 +134,11 @@ class CMicroAppHost {
139
134
  }
140
135
  logout() {
141
136
  const store = (0, import_store.getStore)();
142
- if (store)
143
- store.dispatch(import_actions2.logout.confirm());
137
+ if (store) store.dispatch(import_actions2.logout.confirm());
144
138
  }
145
139
  renewSessionTimer() {
146
140
  (0, import_session.resetUserIdleTime)();
147
- if (this.onRenewSessionTimer)
148
- this.onRenewSessionTimer();
141
+ if (this.onRenewSessionTimer) this.onRenewSessionTimer();
149
142
  }
150
143
  getBreakpoint() {
151
144
  return (0, import_window.getCurrentBreakpoint)();
@@ -45,10 +45,8 @@ const isGuest = () => import_guest.CMicroAppGuest.isInitialized();
45
45
  const isStandAloneGuest = () => isGuest() && window.top === window.self;
46
46
  const getLogger = () => isHost() ? import_host.CMicroAppHost.getInstance().getLogger() : import_guest.CMicroAppGuest.getInstance().getLogger();
47
47
  const isProduction = (mode) => {
48
- if ((0, import_helpers.isCIBuild)())
49
- return true;
50
- if (mode)
51
- return mode === "production";
48
+ if ((0, import_helpers.isCIBuild)()) return true;
49
+ if (mode) return mode === "production";
52
50
  return true;
53
51
  };
54
52
  const getVersionedPath = (path) => {
@@ -69,10 +67,8 @@ const getMicroFrontEndAppConfig = (appInfo) => {
69
67
  );
70
68
  const { mode = "production" } = microFEAppConfig;
71
69
  const envConfig = isProduction(mode) ? microFEAppConfig.production : microFEAppConfig.development;
72
- if (microFEAppConfig.production)
73
- delete microFEAppConfig.production;
74
- if (microFEAppConfig.development)
75
- delete microFEAppConfig.development;
70
+ if (microFEAppConfig.production) delete microFEAppConfig.production;
71
+ if (microFEAppConfig.development) delete microFEAppConfig.development;
76
72
  const microFEConfig = import_lodash.default.merge(
77
73
  appInfo,
78
74
  {
@@ -34,8 +34,7 @@ module.exports = __toCommonJS(ssfguest_adapter_exports);
34
34
  var import_em_ssf_guest = __toESM(require("@elliemae/em-ssf-guest"));
35
35
  class SSFGuestAdapter {
36
36
  async init() {
37
- if (!import_em_ssf_guest.default)
38
- return false;
37
+ if (!import_em_ssf_guest.default) return false;
39
38
  await import_em_ssf_guest.default.connect();
40
39
  return true;
41
40
  }
@@ -117,9 +117,8 @@ const subscribeToResetSession = (onResetListener) => {
117
117
  return removeListeners.bind(null, resetListeners, onResetListener);
118
118
  };
119
119
  const trackActivity = (element, cb) => {
120
- if (!element)
121
- return () => {
122
- };
120
+ if (!element) return () => {
121
+ };
123
122
  const thorttledCb = (0, import_lodash.throttle)(cb, THROTTLING_TIME, { leading: true });
124
123
  userInteractionEvents.forEach(
125
124
  (r) => element.addEventListener(r, thorttledCb)
@@ -47,16 +47,13 @@ const convertBreakpointToNumber = (breakpoint) => Number(breakpoint.replace("px"
47
47
  const getCurrentBreakpoint = () => {
48
48
  const { width } = getViewportSize();
49
49
  const { breakpoints } = (0, import_pui_theme.getDefaultTheme)();
50
- if (width <= convertBreakpointToNumber(breakpoints.small))
51
- return "small";
52
- if (width <= convertBreakpointToNumber(breakpoints.medium))
53
- return "medium";
50
+ if (width <= convertBreakpointToNumber(breakpoints.small)) return "small";
51
+ if (width <= convertBreakpointToNumber(breakpoints.medium)) return "medium";
54
52
  return "large";
55
53
  };
56
54
  const getAssetPath = () => {
57
55
  const assetPath = window?.emui?._ASSET_PATH || "latest/";
58
- if (!window.emui?.version)
59
- return assetPath;
56
+ if (!window.emui?.version) return assetPath;
60
57
  const majorMinorVersion = window.emui?.version.match(/^(?:\d+\.\d+)*/g);
61
58
  return majorMinorVersion && majorMinorVersion[0] ? assetPath.replace("latest/", `${majorMinorVersion[0]}/`) : assetPath;
62
59
  };
@@ -39,8 +39,7 @@ const ErrorToast = (0, import_react.memo)((props) => {
39
39
  ...storeError
40
40
  };
41
41
  const messageText = toastProps.description || toastProps.messageText;
42
- if (messageText)
43
- (0, import_ds_toast.toast)({ messageText, ...toastProps }, {});
42
+ if (messageText) (0, import_ds_toast.toast)({ messageText, ...toastProps }, {});
44
43
  dispatch(import_error.actions.clear());
45
44
  }
46
45
  }, [storeError, props, dispatch]);
@@ -26,8 +26,7 @@ var import_react = require("react");
26
26
  var import_ds_controlled_form = require("@elliemae/ds-controlled-form");
27
27
  var import_react_hook_form = require("react-hook-form");
28
28
  const filterOptions = (allOptions, newFilter) => {
29
- if (!newFilter)
30
- return allOptions;
29
+ if (!newFilter) return allOptions;
31
30
  const filtered = allOptions.filter(
32
31
  (option) => option.type === "section" || option.label.toLowerCase().includes(newFilter?.toLowerCase())
33
32
  );
@@ -38,8 +37,7 @@ const Autocomplete = ({ children, ...rest }) => {
38
37
  const watchedFilter = watch(rest.name);
39
38
  const onSelect = (0, import_react.useCallback)(
40
39
  (newValue, ...otherArgs) => {
41
- if (rest.onSelect)
42
- rest.onSelect(newValue, ...otherArgs);
40
+ if (rest.onSelect) rest.onSelect(newValue, ...otherArgs);
43
41
  else
44
42
  setValue(rest.name, newValue, {
45
43
  shouldValidate: true,
@@ -46,13 +46,11 @@ const InputMask = ({
46
46
  ...props,
47
47
  onChange: (e) => {
48
48
  onChange(e);
49
- if (changeHandler)
50
- changeHandler(e);
49
+ if (changeHandler) changeHandler(e);
51
50
  },
52
51
  onBlur: (e) => {
53
52
  onBlur();
54
- if (onBlurHandler)
55
- onBlurHandler(e);
53
+ if (onBlurHandler) onBlurHandler(e);
56
54
  }
57
55
  }
58
56
  )
@@ -46,8 +46,7 @@ const Form = ({
46
46
  }) => {
47
47
  const methods = (0, import_react_hook_form.useForm)(reactHookFormProps);
48
48
  const formProps = {};
49
- if (onSubmit)
50
- formProps.onSubmit = methods.handleSubmit(onSubmit);
49
+ if (onSubmit) formProps.onSubmit = methods.handleSubmit(onSubmit);
51
50
  const providerProps = Object.assign(methods, {
52
51
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
53
52
  formProps: reactHookFormProps
@@ -36,12 +36,10 @@ const Login = ({
36
36
  const dispatch = (0, import_react2.useAppDispatch)();
37
37
  const ref = (0, import_react.useRef)(false);
38
38
  (0, import_react.useEffect)(() => {
39
- if (ref.current)
40
- return;
39
+ if (ref.current) return;
41
40
  ref.current = true;
42
41
  (0, import_auth.login)({ clientId, scope, responseType }).then(({ authorized }) => {
43
- if (authorized)
44
- setUserAuthorized(true);
42
+ if (authorized) setUserAuthorized(true);
45
43
  dispatch({ type: import_actions.LOGIN_SUCCESS });
46
44
  }).catch(() => {
47
45
  }).finally(() => {
@@ -85,11 +85,9 @@ const mountApp = async ({ id, name }) => {
85
85
  };
86
86
  const unmountApp = async ({ id, name }) => {
87
87
  const app = (window.emui || {})[id];
88
- if (!app)
89
- return null;
88
+ if (!app) return null;
90
89
  const { unmount } = app;
91
- if (!unmount)
92
- return null;
90
+ if (!unmount) return null;
93
91
  if (typeof unmount !== "function")
94
92
  throw new Error(
95
93
  `unmount failed for application ${name} with id ${id}. unmount is not a valid function`
@@ -107,8 +105,7 @@ const addAppToActiveAppList = (id, elementIds) => {
107
105
  const { getRef } = app;
108
106
  activeApps[id] = { elementIds };
109
107
  const host = import_host.CMicroAppHost.getInstance();
110
- if (host)
111
- host.activeGuests[id] = getRef && getRef() || {};
108
+ if (host) host.activeGuests[id] = getRef && getRef() || {};
112
109
  return Promise.resolve();
113
110
  };
114
111
  const waitAndInitApplication = (appConfig, requests) => (
@@ -121,14 +118,12 @@ const waitAndInitApplication = (appConfig, requests) => (
121
118
  );
122
119
  const removeAssetsFromDOM = (id, documentEle = document) => {
123
120
  const host = import_host.CMicroAppHost.getInstance();
124
- if (host)
125
- delete host.activeGuests[id];
121
+ if (host) delete host.activeGuests[id];
126
122
  const { elementIds } = activeApps[id] || {};
127
123
  if (elementIds) {
128
124
  elementIds.forEach((elementId) => {
129
125
  const ele = documentEle.getElementById(elementId);
130
- if (ele)
131
- ele.remove();
126
+ if (ele) ele.remove();
132
127
  });
133
128
  delete activeApps[id];
134
129
  }
@@ -151,17 +146,14 @@ const unloadApp = ({
151
146
  hostUrl,
152
147
  documentEle
153
148
  }) => {
154
- if (!hostUrl)
155
- throw new Error("Unable to unload app. hostUrl is required");
149
+ if (!hostUrl) throw new Error("Unable to unload app. hostUrl is required");
156
150
  (0, import_micro_frontend.getLogger)().info(import_log_records.logRecords.APP_UNLOADING(id));
157
151
  const app = (window.emui || {})[id];
158
- if (!app)
159
- return;
152
+ if (!app) return;
160
153
  removeAssetsFromDOM(id, documentEle);
161
154
  (0, import_script.removeDynamicImportedScripts)(hostUrl, documentEle);
162
155
  (0, import_script.removePrefetchLinks)(hostUrl, documentEle);
163
156
  (0, import_style.removeDynamicImportedStyles)(hostUrl, documentEle);
164
- if (window.emui && window.emui[id])
165
- delete window.emui[id];
157
+ if (window.emui && window.emui[id]) delete window.emui[id];
166
158
  (0, import_micro_frontend.getLogger)().info(import_log_records.logRecords.APP_UNLOADING_COMPLETE(id));
167
159
  };
@@ -63,8 +63,7 @@ const getAppManifest = async ({
63
63
  };
64
64
  const getFullFileNameofAssetsFromManifest = (manifest, assetNames = []) => assetNames.reduce((assets, assetName) => {
65
65
  const fullFileName = manifest[assetName];
66
- if (fullFileName)
67
- assets.push(fullFileName);
66
+ if (fullFileName) assets.push(fullFileName);
68
67
  else {
69
68
  const logRecord = import_log_records.logRecords.ASSET_NOT_FOUND_IN_MANIFEST(assetName);
70
69
  (0, import_micro_frontend.getLogger)().error(logRecord);
@@ -34,24 +34,20 @@ const addScriptToDOM = ({ name, hostUrl, documentEle }, fileName, index) => {
34
34
  throw new Error("Unable to add scripts to DOM. hostUrl is required.");
35
35
  return new Promise((resolve, reject) => {
36
36
  const ele = documentEle.createElement("script");
37
- if (!ele)
38
- reject(new Error("Unable to insert Application scripts."));
37
+ if (!ele) reject(new Error("Unable to insert Application scripts."));
39
38
  ele.id = `${APP_SCRIPT_ID_PREFIX}${name}-${index}`;
40
39
  const url = new URL(fileName, hostUrl);
41
40
  ele.src = (0, import_url.removeDoubleSlash)(url.href);
42
41
  ele.onload = resolve.bind(null, ele.id);
43
42
  ele.onerror = reject.bind(null, ele.id);
44
43
  ele.async = false;
45
- if (isHeadScript(ele.src))
46
- documentEle.head.appendChild(ele);
47
- else
48
- documentEle.body.appendChild(ele);
44
+ if (isHeadScript(ele.src)) documentEle.head.appendChild(ele);
45
+ else documentEle.body.appendChild(ele);
49
46
  });
50
47
  };
51
48
  const removeScriptFromDOM = (elementId = "", documentEle = document) => new Promise((resolve) => {
52
49
  const ele = documentEle.getElementById(elementId);
53
- if (!ele)
54
- console.warn(new Error(`script with id ${elementId} not found`));
50
+ if (!ele) console.warn(new Error(`script with id ${elementId} not found`));
55
51
  ele.remove();
56
52
  resolve();
57
53
  });
@@ -61,8 +57,7 @@ const removeDynamicImportedScripts = (hostUrl, documentEle) => {
61
57
  for (let index = scriptElements.length - 1; index >= 0; index -= 1) {
62
58
  const scriptEle = scriptElements[index];
63
59
  const { src } = scriptEle;
64
- if (hostPattern.test(src))
65
- scriptEle.remove();
60
+ if (hostPattern.test(src)) scriptEle.remove();
66
61
  }
67
62
  };
68
63
  const removePrefetchLinks = (hostUrl, documentEle) => {
@@ -71,7 +66,6 @@ const removePrefetchLinks = (hostUrl, documentEle) => {
71
66
  for (let index = prefetchElements.length - 1; index >= 0; index -= 1) {
72
67
  const ele = prefetchElements[index];
73
68
  const { href } = ele;
74
- if (hostPattern.test(href))
75
- ele.remove();
69
+ if (hostPattern.test(href)) ele.remove();
76
70
  }
77
71
  };
@@ -31,8 +31,7 @@ const addStylesToDOM = ({ name, hostUrl, documentEle }, fileName, index) => {
31
31
  throw new Error("Unable to add styles to DOM. hostUrl is required.");
32
32
  return new Promise((resolve, reject) => {
33
33
  const ele = documentEle.createElement("link");
34
- if (!ele)
35
- reject(new Error("Unable to insert Application styles."));
34
+ if (!ele) reject(new Error("Unable to insert Application styles."));
36
35
  ele.id = `${APP_STYLE_ID_PREFIX}${name}-${index}`;
37
36
  ele.rel = "stylesheet";
38
37
  const url = new URL(fileName, hostUrl);
@@ -43,8 +42,7 @@ const addStylesToDOM = ({ name, hostUrl, documentEle }, fileName, index) => {
43
42
  };
44
43
  const removeStyleFromDOM = (elementId = "", documentEle = document) => new Promise((resolve) => {
45
44
  const ele = documentEle.getElementById(elementId);
46
- if (!ele)
47
- console.warn(new Error(`style with id ${elementId} not found`));
45
+ if (!ele) console.warn(new Error(`style with id ${elementId} not found`));
48
46
  ele.remove();
49
47
  resolve();
50
48
  });
@@ -54,7 +52,6 @@ const removeDynamicImportedStyles = (hostUrl, documentEle) => {
54
52
  for (let index = prefetchElements.length - 1; index >= 0; index -= 1) {
55
53
  const ele = prefetchElements[index];
56
54
  const { href } = ele;
57
- if (hostPattern.test(href))
58
- ele.remove();
55
+ if (hostPattern.test(href)) ele.remove();
59
56
  }
60
57
  };
@@ -48,19 +48,16 @@ const useAppWillRender = ({
48
48
  async (appConfig, loadFailed = false) => {
49
49
  await (0, import_app_factory.unmountApp)(appConfig);
50
50
  (0, import_app_factory.unloadApp)(appConfig);
51
- if (!loadFailed && onUnloadComplete)
52
- onUnloadComplete();
51
+ if (!loadFailed && onUnloadComplete) onUnloadComplete();
53
52
  },
54
53
  // eslint-disable-next-line react-hooks/exhaustive-deps
55
54
  []
56
55
  );
57
56
  const load = (0, import_react.useCallback)(
58
57
  async (appConfig) => {
59
- if (dispatch)
60
- dispatch(import_actions.waitMessage.open());
58
+ if (dispatch) dispatch(import_actions.waitMessage.open());
61
59
  try {
62
- if (ref.current)
63
- await ref.current;
60
+ if (ref.current) await ref.current;
64
61
  await (0, import_app_factory.loadApp)(appConfig);
65
62
  await (0, import_app_factory.mountApp)(appConfig);
66
63
  } catch (ex) {
@@ -71,15 +68,13 @@ const useAppWillRender = ({
71
68
  await unload(appConfig, true);
72
69
  throw ex;
73
70
  }
74
- if (dispatch)
75
- dispatch(import_actions.waitMessage.close());
71
+ if (dispatch) dispatch(import_actions.waitMessage.close());
76
72
  },
77
73
  [dispatch, unload]
78
74
  );
79
75
  (0, import_react.useLayoutEffect)(() => {
80
- if (!documentEle)
81
- return () => {
82
- };
76
+ if (!documentEle) return () => {
77
+ };
83
78
  const appConfig = (0, import_lodash.merge)(getConfig(), {
84
79
  documentEle,
85
80
  history,
@@ -24,12 +24,10 @@ module.exports = __toCommonJS(utils_exports);
24
24
  var import_config = require("../../utils/app-config/config.js");
25
25
  const getNavigationLinks = () => {
26
26
  const microApps = (0, import_config.getAppConfigValue)("microFrontendApps");
27
- if (!microApps)
28
- return [];
27
+ if (!microApps) return [];
29
28
  return Object.keys(microApps).reduce((value, id) => {
30
29
  const { name, homeRoute } = microApps[id] || {};
31
- if (name && homeRoute)
32
- value.push({ id, name, path: homeRoute });
30
+ if (name && homeRoute) value.push({ id, name, path: homeRoute });
33
31
  return value;
34
32
  }, []);
35
33
  };
@@ -43,9 +43,8 @@ const updateContainerId = (id, documentEle) => {
43
43
  };
44
44
  const useFrameLoaded = ({ id, documentEle }) => {
45
45
  (0, import_react.useEffect)(() => {
46
- if (!documentEle)
47
- return () => {
48
- };
46
+ if (!documentEle) return () => {
47
+ };
49
48
  const host = import_host.CMicroAppHost.getInstance();
50
49
  addBaseTag(id, documentEle);
51
50
  updateContainerId(id, documentEle);
@@ -35,8 +35,7 @@ const SessionTimeout = () => {
35
35
  (0, import_session.initSessionMonitoring)();
36
36
  const warningCb = (0, import_session.subscribeToSessionExpiryWarning)(
37
37
  (sessionExpiryWarningNotifiedAt) => {
38
- if (!sessionExpiryWarningNotifiedAt)
39
- return;
38
+ if (!sessionExpiryWarningNotifiedAt) return;
40
39
  setwarningNotifiedAt(sessionExpiryWarningNotifiedAt);
41
40
  setSessionExpiryWarning(true);
42
41
  }