chayns-api 2.1.3-3 → 2.1.5

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 (188) hide show
  1. package/.babelrc +31 -30
  2. package/.eslintrc +17 -17
  3. package/.github/workflows/deploy_docs.yml +28 -28
  4. package/.github/workflows/publish.yml +21 -21
  5. package/LICENSE +21 -21
  6. package/README.md +67 -67
  7. package/dist/cjs/calls/dialogs/chaynsDialog.js +0 -2
  8. package/dist/cjs/calls/dialogs/communication.js +0 -2
  9. package/dist/cjs/calls/dialogs/confirm.js +0 -1
  10. package/dist/cjs/calls/dialogs/date.js +0 -50
  11. package/dist/cjs/calls/dialogs/iFrame.js +1 -1
  12. package/dist/cjs/calls/index.js +1 -162
  13. package/dist/cjs/calls/sendMessage.js +0 -12
  14. package/dist/cjs/calls/visibilityChangeListener.js +0 -7
  15. package/dist/cjs/components/AppDialogWrapper.js +3 -3
  16. package/dist/cjs/components/ChaynsContext.js +1 -1
  17. package/dist/cjs/components/ChaynsProvider.js +6 -10
  18. package/dist/cjs/components/ErrorBoundary.js +1 -1
  19. package/dist/cjs/components/WaitUntil.js +0 -2
  20. package/dist/cjs/components/withCompatMode.js +9 -13
  21. package/dist/cjs/components/withHydrationBoundary.js +2 -2
  22. package/dist/cjs/constants/hydrationContext.js +1 -3
  23. package/dist/cjs/constants/languages.js +1 -1
  24. package/dist/cjs/handler/DialogHandler.js +0 -4
  25. package/dist/cjs/hooks/geoLocationListener.js +0 -7
  26. package/dist/cjs/hooks/scrollListener.js +0 -14
  27. package/dist/cjs/hooks/useAccessToken.js +0 -4
  28. package/dist/cjs/hooks/useCurrentPage.js +0 -3
  29. package/dist/cjs/hooks/useCustomCallbackFunction.js +0 -4
  30. package/dist/cjs/hooks/useCustomData.js +0 -3
  31. package/dist/cjs/hooks/useDevice.js +0 -3
  32. package/dist/cjs/hooks/useDialogState.js +0 -7
  33. package/dist/cjs/hooks/useEnvironment.js +0 -3
  34. package/dist/cjs/hooks/useFunctions.js +0 -3
  35. package/dist/cjs/hooks/useIsAdminMode.js +0 -3
  36. package/dist/cjs/hooks/useLanguage.js +0 -3
  37. package/dist/cjs/hooks/usePages.js +0 -6
  38. package/dist/cjs/hooks/useParameters.js +0 -3
  39. package/dist/cjs/hooks/useSite.js +0 -3
  40. package/dist/cjs/hooks/useUser.js +0 -3
  41. package/dist/cjs/hooks/useValues.js +0 -3
  42. package/dist/cjs/hooks/windowMetricsListener.js +0 -7
  43. package/dist/cjs/host/ChaynsHost.js +3 -4
  44. package/dist/cjs/host/iframe/HostIframe.js +4 -23
  45. package/dist/cjs/host/module/ModuleHost.js +5 -9
  46. package/dist/cjs/host/module/utils/loadComponent.js +4 -5
  47. package/dist/cjs/index.js +1 -1
  48. package/dist/cjs/types/IChaynsReact.js +39 -46
  49. package/dist/cjs/util/appCall.js +0 -2
  50. package/dist/cjs/util/deviceHelper.js +0 -4
  51. package/dist/cjs/util/heightHelper.js +1 -1
  52. package/dist/cjs/util/initModuleFederationSharing.js +2 -6
  53. package/dist/cjs/util/postIframeForm.js +0 -1
  54. package/dist/cjs/util/transferNestedFunctions.js +0 -3
  55. package/dist/cjs/wrapper/AppWrapper.js +6 -20
  56. package/dist/cjs/wrapper/FrameWrapper.js +2 -7
  57. package/dist/cjs/wrapper/ModuleFederationWrapper.js +1 -3
  58. package/dist/cjs/wrapper/StaticChaynsApi.js +1 -1
  59. package/dist/esm/calls/dialogs/chaynsDialog.js +0 -2
  60. package/dist/esm/calls/dialogs/communication.js +0 -2
  61. package/dist/esm/calls/dialogs/confirm.js +0 -1
  62. package/dist/esm/calls/dialogs/date.js +0 -51
  63. package/dist/esm/calls/dialogs/iFrame.js +1 -1
  64. package/dist/esm/calls/index.js +1 -162
  65. package/dist/esm/calls/sendMessage.js +0 -12
  66. package/dist/esm/calls/visibilityChangeListener.js +0 -7
  67. package/dist/esm/components/AppDialogWrapper.js +2 -2
  68. package/dist/esm/components/ChaynsContext.js +1 -1
  69. package/dist/esm/components/ChaynsProvider.js +5 -10
  70. package/dist/esm/components/WaitUntil.js +0 -2
  71. package/dist/esm/components/withCompatMode.js +8 -14
  72. package/dist/esm/components/withHydrationBoundary.js +2 -2
  73. package/dist/esm/constants/hydrationContext.js +1 -3
  74. package/dist/esm/constants/languages.js +1 -1
  75. package/dist/esm/handler/DialogHandler.js +1 -5
  76. package/dist/esm/hooks/geoLocationListener.js +0 -7
  77. package/dist/esm/hooks/scrollListener.js +0 -14
  78. package/dist/esm/hooks/useAccessToken.js +0 -5
  79. package/dist/esm/hooks/useCurrentPage.js +0 -4
  80. package/dist/esm/hooks/useCustomCallbackFunction.js +0 -5
  81. package/dist/esm/hooks/useCustomData.js +0 -4
  82. package/dist/esm/hooks/useDevice.js +0 -3
  83. package/dist/esm/hooks/useDialogState.js +0 -8
  84. package/dist/esm/hooks/useEnvironment.js +0 -3
  85. package/dist/esm/hooks/useFunctions.js +0 -4
  86. package/dist/esm/hooks/useIsAdminMode.js +0 -3
  87. package/dist/esm/hooks/useLanguage.js +0 -3
  88. package/dist/esm/hooks/usePages.js +0 -6
  89. package/dist/esm/hooks/useParameters.js +0 -3
  90. package/dist/esm/hooks/useSite.js +0 -3
  91. package/dist/esm/hooks/useUser.js +0 -3
  92. package/dist/esm/hooks/useValues.js +0 -4
  93. package/dist/esm/hooks/windowMetricsListener.js +0 -7
  94. package/dist/esm/host/ChaynsHost.js +2 -3
  95. package/dist/esm/host/iframe/HostIframe.js +3 -22
  96. package/dist/esm/host/module/ModuleHost.js +4 -8
  97. package/dist/esm/host/module/utils/loadComponent.js +3 -4
  98. package/dist/esm/types/IChaynsReact.js +39 -49
  99. package/dist/esm/util/appCall.js +0 -2
  100. package/dist/esm/util/deviceHelper.js +0 -4
  101. package/dist/esm/util/initModuleFederationSharing.js +1 -5
  102. package/dist/esm/util/postIframeForm.js +0 -1
  103. package/dist/esm/util/transferNestedFunctions.js +0 -2
  104. package/dist/esm/wrapper/AppWrapper.js +6 -20
  105. package/dist/esm/wrapper/FrameWrapper.js +2 -6
  106. package/dist/esm/wrapper/ModuleFederationWrapper.js +1 -3
  107. package/dist/esm/wrapper/SsrWrapper.js +1 -1
  108. package/dist/esm/wrapper/StaticChaynsApi.js +1 -1
  109. package/dist/types/calls/dialogs/alert.d.ts +1 -1
  110. package/dist/types/calls/dialogs/chaynsDialog.d.ts +24 -24
  111. package/dist/types/calls/dialogs/close.d.ts +1 -1
  112. package/dist/types/calls/dialogs/communication.d.ts +3 -3
  113. package/dist/types/calls/dialogs/confirm.d.ts +13 -13
  114. package/dist/types/calls/dialogs/date.d.ts +96 -96
  115. package/dist/types/calls/dialogs/dropUpAlert.d.ts +5 -5
  116. package/dist/types/calls/dialogs/fileSelect.d.ts +16 -16
  117. package/dist/types/calls/dialogs/iFrame.d.ts +10 -10
  118. package/dist/types/calls/dialogs/index.d.ts +14 -14
  119. package/dist/types/calls/dialogs/input.d.ts +15 -15
  120. package/dist/types/calls/dialogs/mediaSelect.d.ts +8 -8
  121. package/dist/types/calls/dialogs/open.d.ts +1 -1
  122. package/dist/types/calls/dialogs/select.d.ts +6 -6
  123. package/dist/types/calls/dialogs/signature.d.ts +7 -7
  124. package/dist/types/calls/dialogs/toast.d.ts +1 -1
  125. package/dist/types/calls/dialogs/utils/callback.d.ts +1 -1
  126. package/dist/types/calls/dialogs/utils/is.d.ts +4 -4
  127. package/dist/types/calls/getUserInfo.d.ts +9 -9
  128. package/dist/types/calls/index.d.ts +255 -255
  129. package/dist/types/calls/sendMessage.d.ts +13 -13
  130. package/dist/types/calls/visibilityChangeListener.d.ts +9 -9
  131. package/dist/types/components/AppDialogWrapper.d.ts +5 -5
  132. package/dist/types/components/ChaynsContext.d.ts +3 -3
  133. package/dist/types/components/ChaynsProvider.d.ts +11 -11
  134. package/dist/types/components/ErrorBoundary.d.ts +13 -13
  135. package/dist/types/components/WaitUntil.d.ts +7 -7
  136. package/dist/types/components/moduleWrapper.d.ts +4 -4
  137. package/dist/types/components/withCompatMode.d.ts +43 -43
  138. package/dist/types/components/withHydrationBoundary.d.ts +24 -24
  139. package/dist/types/constants/hydrationContext.d.ts +6 -6
  140. package/dist/types/constants/index.d.ts +1 -1
  141. package/dist/types/constants/languages.d.ts +12 -12
  142. package/dist/types/handler/DialogHandler.d.ts +24 -24
  143. package/dist/types/helper/apiListenerHelper.d.ts +6 -6
  144. package/dist/types/hooks/context.d.ts +3 -3
  145. package/dist/types/hooks/geoLocationListener.d.ts +18 -18
  146. package/dist/types/hooks/index.d.ts +18 -18
  147. package/dist/types/hooks/scrollListener.d.ts +28 -28
  148. package/dist/types/hooks/useAccessToken.d.ts +6 -6
  149. package/dist/types/hooks/useCurrentPage.d.ts +5 -5
  150. package/dist/types/hooks/useCustomCallbackFunction.d.ts +5 -5
  151. package/dist/types/hooks/useCustomData.d.ts +4 -4
  152. package/dist/types/hooks/useDevice.d.ts +5 -5
  153. package/dist/types/hooks/useDialogState.d.ts +9 -9
  154. package/dist/types/hooks/useEnvironment.d.ts +5 -5
  155. package/dist/types/hooks/useFunctions.d.ts +4 -4
  156. package/dist/types/hooks/useIsAdminMode.d.ts +4 -4
  157. package/dist/types/hooks/useLanguage.d.ts +5 -5
  158. package/dist/types/hooks/usePages.d.ts +18 -18
  159. package/dist/types/hooks/useParameters.d.ts +5 -5
  160. package/dist/types/hooks/useSite.d.ts +5 -5
  161. package/dist/types/hooks/useUser.d.ts +5 -5
  162. package/dist/types/hooks/useValues.d.ts +4 -4
  163. package/dist/types/hooks/windowMetricsListener.d.ts +11 -11
  164. package/dist/types/host/ChaynsHost.d.ts +29 -29
  165. package/dist/types/host/iframe/HostIframe.d.ts +26 -26
  166. package/dist/types/host/iframe/utils/useUpdateData.d.ts +3 -3
  167. package/dist/types/host/module/ModuleHost.d.ts +28 -28
  168. package/dist/types/host/module/utils/loadComponent.d.ts +3 -3
  169. package/dist/types/index.d.ts +20 -20
  170. package/dist/types/types/IChaynsReact.d.ts +898 -899
  171. package/dist/types/types/dialog.d.ts +41 -41
  172. package/dist/types/util/appCall.d.ts +2 -2
  173. package/dist/types/util/bindChaynsApi.d.ts +1 -1
  174. package/dist/types/util/deviceHelper.d.ts +9 -9
  175. package/dist/types/util/heightHelper.d.ts +1 -1
  176. package/dist/types/util/initModuleFederationSharing.d.ts +3 -3
  177. package/dist/types/util/is.d.ts +5 -5
  178. package/dist/types/util/postIframeForm.d.ts +1 -1
  179. package/dist/types/util/transferNestedFunctions.d.ts +1 -1
  180. package/dist/types/util/url.d.ts +1 -1
  181. package/dist/types/wrapper/AppWrapper.d.ts +22 -22
  182. package/dist/types/wrapper/FrameWrapper.d.ts +18 -18
  183. package/dist/types/wrapper/ModuleFederationWrapper.d.ts +13 -13
  184. package/dist/types/wrapper/SsrWrapper.d.ts +14 -14
  185. package/dist/types/wrapper/StaticChaynsApi.d.ts +16 -16
  186. package/package.json +88 -88
  187. package/toolkit.config.js +20 -20
  188. package/tsconfig.json +56 -56
@@ -1,4 +1,4 @@
1
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
2
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
3
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
4
  export default class DialogHandler {
@@ -22,11 +22,7 @@ export default class DialogHandler {
22
22
  };
23
23
  this.isOpen = true;
24
24
  this.dialogId = await this._open(this._config, callback);
25
-
26
- // console.log('dialogId', this.dialogId);
27
-
28
25
  this._addDataListener(this.dialogId, data => {
29
- // console.log('[DialogHandler]dataListener', this.dialogId, data);
30
26
  this.listeners.forEach(cb => cb(data));
31
27
  });
32
28
  });
@@ -1,8 +1,5 @@
1
1
  import { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { useFunctionsSelector } from './context';
3
- /**
4
- * @category Hooks
5
- */
6
3
  export const useGeoLocationListener = () => {
7
4
  const addListener = useFunctionsSelector(f => f.addGeoLocationListener);
8
5
  const removeListener = useFunctionsSelector(f => f.removeGeoLocationListener);
@@ -13,12 +10,8 @@ export const useGeoLocationListener = () => {
13
10
  var _promiseRef$current;
14
11
  void ((_promiseRef$current = promiseRef.current) === null || _promiseRef$current === void 0 ? void 0 : _promiseRef$current.then(removeListener));
15
12
  };
16
- // eslint-disable-next-line react-hooks/exhaustive-deps
17
13
  }, []);
18
14
  };
19
- /**
20
- * @category Hooks
21
- */
22
15
  export const useGeoLocation = function () {
23
16
  let {
24
17
  enabled = true,
@@ -1,9 +1,6 @@
1
1
  import { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { useWindowMetrics } from './windowMetricsListener';
3
3
  import { useFunctionsSelector } from './context';
4
- /**
5
- * @category Hooks
6
- */
7
4
  export const useScrollListener = () => {
8
5
  const addListener = useFunctionsSelector(f => f.addScrollListener);
9
6
  const removeListener = useFunctionsSelector(f => f.removeScrollListener);
@@ -14,12 +11,8 @@ export const useScrollListener = () => {
14
11
  var _promiseRef$current;
15
12
  void ((_promiseRef$current = promiseRef.current) === null || _promiseRef$current === void 0 ? void 0 : _promiseRef$current.then(removeListener));
16
13
  };
17
- // eslint-disable-next-line react-hooks/exhaustive-deps
18
14
  }, []);
19
15
  };
20
- /**
21
- * @category Hooks
22
- */
23
16
  export const useScrollPosition = function () {
24
17
  let {
25
18
  enabled = true,
@@ -38,16 +31,12 @@ export const useScrollPosition = function () {
38
31
  }, setValue);
39
32
  }
40
33
  return undefined;
41
- // eslint-disable-next-line react-hooks/exhaustive-deps
42
34
  }, [enabled, throttle, addListener]);
43
35
  useEffect(() => {
44
36
  void getScrollPosition().then(setValue);
45
37
  }, [getScrollPosition]);
46
38
  return value;
47
39
  };
48
- /**
49
- * @category Hooks
50
- */
51
40
  export const useScrollOffsetTop = function () {
52
41
  let {
53
42
  enabled = true,
@@ -68,9 +57,6 @@ export const useScrollOffsetTop = function () {
68
57
  }
69
58
  return 0;
70
59
  };
71
- /**
72
- * @category Hooks
73
- */
74
60
  export const useScrollOffsetBottom = function () {
75
61
  let {
76
62
  enabled = true,
@@ -1,10 +1,5 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import { useFunctionsSelector } from './context';
3
-
4
- /**
5
- * @category Hooks
6
- * @deprecated Use {@link getAccessToken} instead
7
- */
8
3
  export const useAccessToken = accessToken => {
9
4
  const [token, setToken] = useState(null);
10
5
  const [externalToken, setExternalToken] = useState(null);
@@ -1,6 +1,2 @@
1
1
  import { useValuesSelector } from './context';
2
-
3
- /**
4
- * @category Hooks
5
- */
6
2
  export const useCurrentPage = () => useValuesSelector(v => v.currentPage);
@@ -1,7 +1,2 @@
1
1
  import { useFunctionsSelector } from './context';
2
-
3
- /**
4
- * @category Hooks
5
- * Returns customCallbackFunction
6
- */
7
2
  export const useCustomCallbackFunction = () => useFunctionsSelector(f => f.customCallbackFunction);
@@ -1,6 +1,2 @@
1
1
  import { useValuesSelector } from './context';
2
-
3
- /**
4
- * @category Hooks
5
- */
6
2
  export const useCustomData = () => useValuesSelector(v => v.customData);
@@ -1,5 +1,2 @@
1
1
  import { useValuesSelector } from "./context";
2
- /**
3
- * @category Hooks
4
- */
5
2
  export const useDevice = () => useValuesSelector(v => v.device);
@@ -1,8 +1,4 @@
1
1
  import { useFunctionsSelector, useValuesSelector } from './context';
2
-
3
- /**
4
- * @category Hooks
5
- */
6
2
  export const useDialogState = () => {
7
3
  const setResult = useFunctionsSelector(f => f.setDialogResult);
8
4
  const sendData = useFunctionsSelector(f => f.dispatchEventToDialogHost);
@@ -18,10 +14,6 @@ export const useDialogState = () => {
18
14
  isClosingRequested
19
15
  };
20
16
  };
21
-
22
- /**
23
- * @category Hooks
24
- */
25
17
  export const useDialogData = () => {
26
18
  return useValuesSelector(v => {
27
19
  var _v$dialog2;
@@ -1,5 +1,2 @@
1
1
  import { useValuesSelector } from './context';
2
- /**
3
- * @category Hooks
4
- */
5
2
  export const useEnvironment = () => useValuesSelector(v => v.environment);
@@ -1,6 +1,2 @@
1
1
  import { useFunctionsSelector } from './context';
2
-
3
- /**
4
- * @category Hooks
5
- */
6
2
  export const useFunctions = () => useFunctionsSelector(f => f);
@@ -1,7 +1,4 @@
1
1
  import { useValuesSelector } from './context';
2
- /**
3
- * @category Hooks
4
- */
5
2
  export const useIsAdminMode = () => useValuesSelector(v => {
6
3
  var _v$isAdminModeActive;
7
4
  return (_v$isAdminModeActive = v.isAdminModeActive) !== null && _v$isAdminModeActive !== void 0 ? _v$isAdminModeActive : false;
@@ -1,5 +1,2 @@
1
1
  import { useValuesSelector } from './context';
2
- /**
3
- * @category Hooks
4
- */
5
2
  export const useLanguage = () => useValuesSelector(v => v.language);
@@ -1,8 +1,5 @@
1
1
  import { moduleWrapper } from '../components/moduleWrapper';
2
2
  import { useValuesSelector } from './context';
3
- /**
4
- * @category Hooks
5
- */
6
3
  export const usePages = function () {
7
4
  let {
8
5
  siteId
@@ -15,9 +12,6 @@ export const usePages = function () {
15
12
  }
16
13
  return pages;
17
14
  };
18
- /**
19
- * @category Hooks
20
- */
21
15
  export const usePage = _ref => {
22
16
  let {
23
17
  id,
@@ -1,5 +1,2 @@
1
1
  import { useValuesSelector } from './context';
2
- /**
3
- * @category Hooks
4
- */
5
2
  export const useParameters = () => useValuesSelector(v => v.parameters || []);
@@ -1,5 +1,2 @@
1
1
  import { useValuesSelector } from './context';
2
- /**
3
- * @category Hooks
4
- */
5
2
  export const useSite = () => useValuesSelector(v => v.site);
@@ -1,6 +1,3 @@
1
1
  import { useValuesSelector } from './context';
2
2
  const empty = {};
3
- /**
4
- * @category Hooks
5
- */
6
3
  export const useUser = () => useValuesSelector(v => v.user || empty);
@@ -1,6 +1,2 @@
1
1
  import { useValuesSelector } from './context';
2
-
3
- /**
4
- * @category Hooks
5
- */
6
2
  export const useValues = () => useValuesSelector(v => v);
@@ -1,9 +1,6 @@
1
1
  import { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { ScreenSize } from '../types/IChaynsReact';
3
3
  import { useFunctionsSelector } from './context';
4
- /**
5
- * @category Hooks
6
- */
7
4
  export const useWindowMetricsListener = () => {
8
5
  const addListener = useFunctionsSelector(f => f.addWindowMetricsListener);
9
6
  const removeListener = useFunctionsSelector(f => f.removeWindowMetricsListener);
@@ -14,12 +11,8 @@ export const useWindowMetricsListener = () => {
14
11
  var _promiseRef$current;
15
12
  void ((_promiseRef$current = promiseRef.current) === null || _promiseRef$current === void 0 ? void 0 : _promiseRef$current.then(removeListener));
16
13
  };
17
- // eslint-disable-next-line react-hooks/exhaustive-deps
18
14
  }, []);
19
15
  };
20
- /**
21
- * @category Hooks
22
- */
23
16
  export const useWindowMetrics = function () {
24
17
  let {
25
18
  enabled = true
@@ -10,7 +10,6 @@ const ChaynsHost = _ref => {
10
10
  iFrameRef = undefined,
11
11
  loadingComponent = undefined,
12
12
  system,
13
- // shallow data
14
13
  pages,
15
14
  language,
16
15
  isAdminModeActive,
@@ -41,7 +40,7 @@ const ChaynsHost = _ref => {
41
40
  switch (type) {
42
41
  case 'client-iframe':
43
42
  case 'server-iframe':
44
- return /*#__PURE__*/React.createElement(HostIframe, {
43
+ return React.createElement(HostIframe, {
45
44
  iFrameRef: iFrameRef,
46
45
  iFrameProps: iFrameProps,
47
46
  pages: pages,
@@ -62,7 +61,7 @@ const ChaynsHost = _ref => {
62
61
  });
63
62
  case 'client-module':
64
63
  case 'server-module':
65
- return /*#__PURE__*/React.createElement(ModuleHost, {
64
+ return React.createElement(ModuleHost, {
66
65
  system: system,
67
66
  pages: pages,
68
67
  isAdminModeActive: isAdminModeActive,
@@ -1,4 +1,4 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import React, { useEffect, useRef } from 'react';
3
3
  import * as comlink from 'comlink';
4
4
  import postIframeForm from '../../util/postIframeForm';
@@ -10,7 +10,6 @@ const HostIframe = _ref => {
10
10
  src,
11
11
  postForm = false,
12
12
  iFrameRef,
13
- // shallow data
14
13
  pages,
15
14
  isAdminModeActive,
16
15
  site,
@@ -29,15 +28,13 @@ const HostIframe = _ref => {
29
28
  const ref = useRef();
30
29
  const currentDataRef = useRef();
31
30
  if (!eventTarget.current) {
32
- eventTarget.current = global.document ? document.createElement('div') : undefined; // global.EventTarget ? new EventTarget() : undefined
31
+ eventTarget.current = global.document ? document.createElement('div') : undefined;
33
32
  }
34
33
  const setHeight = value => {
35
34
  if (ref.current) {
36
35
  ref.current.style.height = `${value}px`;
37
36
  }
38
37
  };
39
-
40
- // region initialData
41
38
  const initialData = {
42
39
  site,
43
40
  isAdminModeActive,
@@ -51,11 +48,7 @@ const HostIframe = _ref => {
51
48
  customData,
52
49
  dialog
53
50
  };
54
- // endregion
55
-
56
51
  currentDataRef.current = initialData;
57
-
58
- // region postIframeForm
59
52
  useEffect(() => {
60
53
  (async () => {
61
54
  if (postForm) {
@@ -68,11 +61,7 @@ const HostIframe = _ref => {
68
61
  }), 'chayns', iFrameProps.name);
69
62
  }
70
63
  })();
71
- // eslint-disable-next-line react-hooks/exhaustive-deps
72
64
  }, []);
73
- // endregion
74
-
75
- // region expose data and functions to iframe
76
65
  useEffect(() => {
77
66
  var _ref$current;
78
67
  if ((_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.contentWindow) {
@@ -90,17 +79,12 @@ const HostIframe = _ref => {
90
79
  };
91
80
  comlink.expose(obj, comlink.windowEndpoint(ref.current.contentWindow));
92
81
  ref.current.contentWindow.postMessage('chayns-api-host-ready', '*');
93
- // https://github.com/GoogleChromeLabs/comlink/pull/469 might be better approach once released
94
82
  return () => {
95
83
  delete obj[iFrameProps.name];
96
84
  };
97
85
  }
98
86
  return undefined;
99
- // eslint-disable-next-line react-hooks/exhaustive-deps
100
87
  }, []);
101
- // endregion
102
-
103
- // region dispatch data update
104
88
  useUpdateData(eventTarget.current, 'isAdminModeActive', isAdminModeActive);
105
89
  useUpdateData(eventTarget.current, 'user', user);
106
90
  useUpdateData(eventTarget.current, 'site', site);
@@ -110,13 +94,10 @@ const HostIframe = _ref => {
110
94
  useUpdateData(eventTarget.current, 'environment', environment);
111
95
  useUpdateData(eventTarget.current, 'customData', customData);
112
96
  useUpdateData(eventTarget.current, 'dialog', dialog);
113
- // endregion
114
-
115
- return /*#__PURE__*/React.createElement("iframe", _extends({
97
+ return React.createElement("iframe", _extends({
116
98
  ref: r => {
117
99
  ref.current = r;
118
100
  if (iFrameRef) {
119
- // eslint-disable-next-line no-param-reassign
120
101
  iFrameRef.current = r;
121
102
  }
122
103
  },
@@ -8,16 +8,15 @@ const System = _ref => {
8
8
  ...props
9
9
  } = _ref;
10
10
  const Component = useMemo(() => loadComponent(system.scope, system.module, globalThis.window ? system.url : system.serverUrl, undefined, system.preventSingleton), [system.scope, system.module, system.url, system.serverUrl, system.preventSingleton]);
11
- return /*#__PURE__*/React.createElement(React.Suspense, {
11
+ return React.createElement(React.Suspense, {
12
12
  fallback: fallback || ''
13
- }, /*#__PURE__*/React.createElement(Component, props));
13
+ }, React.createElement(Component, props));
14
14
  };
15
15
  const ModuleHost = _ref2 => {
16
16
  let {
17
17
  system,
18
18
  children = null,
19
19
  functions,
20
- // shallow data
21
20
  pages,
22
21
  isAdminModeActive,
23
22
  site,
@@ -31,7 +30,6 @@ const ModuleHost = _ref2 => {
31
30
  environment,
32
31
  preventStagingReplacement
33
32
  } = _ref2;
34
- // region initialData
35
33
  const initialData = {
36
34
  site,
37
35
  isAdminModeActive,
@@ -49,11 +47,9 @@ const ModuleHost = _ref2 => {
49
47
  if (dialog) {
50
48
  initialData.dialog = dialog;
51
49
  }
52
- // endregion
53
-
54
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
50
+ return React.createElement(React.Fragment, null, React.createElement("div", {
55
51
  className: "module-css"
56
- }), /*#__PURE__*/React.createElement(System, {
52
+ }), React.createElement(System, {
57
53
  system: {
58
54
  scope: system.scope,
59
55
  url: replaceStagingUrl(preventStagingReplacement, system.url, environment.buildEnvironment),
@@ -31,7 +31,6 @@ export const loadModule = function (scope, module, url) {
31
31
  const promise = loadRemote(path);
32
32
  promise.catch(e => {
33
33
  console.error("[chayns-api] Failed to load module", scope, url, e);
34
- // causes registerRemote with force = true on next attempt to load the component which tries to load the component again
35
34
  registeredScopes[scope] = '';
36
35
  });
37
36
  return promise;
@@ -83,7 +82,7 @@ const loadComponent = function (scope, module, url) {
83
82
  class CompatComponent extends React.Component {
84
83
  constructor(props) {
85
84
  super(props);
86
- this.ref = /*#__PURE__*/React.createRef();
85
+ this.ref = React.createRef();
87
86
  }
88
87
  componentDidMount() {
89
88
  OriginalCompatComponent.componentDidMount.apply(this);
@@ -95,7 +94,7 @@ const loadComponent = function (scope, module, url) {
95
94
  OriginalCompatComponent.componentWillUnmount.apply(this);
96
95
  }
97
96
  render() {
98
- return /*#__PURE__*/React.createElement('div', {
97
+ return React.createElement('div', {
99
98
  ref: this.ref
100
99
  });
101
100
  }
@@ -112,7 +111,7 @@ const loadComponent = function (scope, module, url) {
112
111
  console.error("[chayns-api] Failed to load component", scope, url, e);
113
112
  delete componentMap[scope][module];
114
113
  });
115
- componentMap[scope][module] = /*#__PURE__*/React.lazy(() => promise);
114
+ componentMap[scope][module] = React.lazy(() => promise);
116
115
  }
117
116
  return componentMap[scope][module];
118
117
  };