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.
- package/.babelrc +31 -30
- package/.eslintrc +17 -17
- package/.github/workflows/deploy_docs.yml +28 -28
- package/.github/workflows/publish.yml +21 -21
- package/LICENSE +21 -21
- package/README.md +67 -67
- package/dist/cjs/calls/dialogs/chaynsDialog.js +0 -2
- package/dist/cjs/calls/dialogs/communication.js +0 -2
- package/dist/cjs/calls/dialogs/confirm.js +0 -1
- package/dist/cjs/calls/dialogs/date.js +0 -50
- package/dist/cjs/calls/dialogs/iFrame.js +1 -1
- package/dist/cjs/calls/index.js +1 -162
- package/dist/cjs/calls/sendMessage.js +0 -12
- package/dist/cjs/calls/visibilityChangeListener.js +0 -7
- package/dist/cjs/components/AppDialogWrapper.js +3 -3
- package/dist/cjs/components/ChaynsContext.js +1 -1
- package/dist/cjs/components/ChaynsProvider.js +6 -10
- package/dist/cjs/components/ErrorBoundary.js +1 -1
- package/dist/cjs/components/WaitUntil.js +0 -2
- package/dist/cjs/components/withCompatMode.js +9 -13
- package/dist/cjs/components/withHydrationBoundary.js +2 -2
- package/dist/cjs/constants/hydrationContext.js +1 -3
- package/dist/cjs/constants/languages.js +1 -1
- package/dist/cjs/handler/DialogHandler.js +0 -4
- package/dist/cjs/hooks/geoLocationListener.js +0 -7
- package/dist/cjs/hooks/scrollListener.js +0 -14
- package/dist/cjs/hooks/useAccessToken.js +0 -4
- package/dist/cjs/hooks/useCurrentPage.js +0 -3
- package/dist/cjs/hooks/useCustomCallbackFunction.js +0 -4
- package/dist/cjs/hooks/useCustomData.js +0 -3
- package/dist/cjs/hooks/useDevice.js +0 -3
- package/dist/cjs/hooks/useDialogState.js +0 -7
- package/dist/cjs/hooks/useEnvironment.js +0 -3
- package/dist/cjs/hooks/useFunctions.js +0 -3
- package/dist/cjs/hooks/useIsAdminMode.js +0 -3
- package/dist/cjs/hooks/useLanguage.js +0 -3
- package/dist/cjs/hooks/usePages.js +0 -6
- package/dist/cjs/hooks/useParameters.js +0 -3
- package/dist/cjs/hooks/useSite.js +0 -3
- package/dist/cjs/hooks/useUser.js +0 -3
- package/dist/cjs/hooks/useValues.js +0 -3
- package/dist/cjs/hooks/windowMetricsListener.js +0 -7
- package/dist/cjs/host/ChaynsHost.js +3 -4
- package/dist/cjs/host/iframe/HostIframe.js +4 -23
- package/dist/cjs/host/module/ModuleHost.js +5 -9
- package/dist/cjs/host/module/utils/loadComponent.js +4 -5
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/types/IChaynsReact.js +39 -46
- package/dist/cjs/util/appCall.js +0 -2
- package/dist/cjs/util/deviceHelper.js +0 -4
- package/dist/cjs/util/heightHelper.js +1 -1
- package/dist/cjs/util/initModuleFederationSharing.js +2 -6
- package/dist/cjs/util/postIframeForm.js +0 -1
- package/dist/cjs/util/transferNestedFunctions.js +0 -3
- package/dist/cjs/wrapper/AppWrapper.js +6 -20
- package/dist/cjs/wrapper/FrameWrapper.js +2 -7
- package/dist/cjs/wrapper/ModuleFederationWrapper.js +1 -3
- package/dist/cjs/wrapper/StaticChaynsApi.js +1 -1
- package/dist/esm/calls/dialogs/chaynsDialog.js +0 -2
- package/dist/esm/calls/dialogs/communication.js +0 -2
- package/dist/esm/calls/dialogs/confirm.js +0 -1
- package/dist/esm/calls/dialogs/date.js +0 -51
- package/dist/esm/calls/dialogs/iFrame.js +1 -1
- package/dist/esm/calls/index.js +1 -162
- package/dist/esm/calls/sendMessage.js +0 -12
- package/dist/esm/calls/visibilityChangeListener.js +0 -7
- package/dist/esm/components/AppDialogWrapper.js +2 -2
- package/dist/esm/components/ChaynsContext.js +1 -1
- package/dist/esm/components/ChaynsProvider.js +5 -10
- package/dist/esm/components/WaitUntil.js +0 -2
- package/dist/esm/components/withCompatMode.js +8 -14
- package/dist/esm/components/withHydrationBoundary.js +2 -2
- package/dist/esm/constants/hydrationContext.js +1 -3
- package/dist/esm/constants/languages.js +1 -1
- package/dist/esm/handler/DialogHandler.js +1 -5
- package/dist/esm/hooks/geoLocationListener.js +0 -7
- package/dist/esm/hooks/scrollListener.js +0 -14
- package/dist/esm/hooks/useAccessToken.js +0 -5
- package/dist/esm/hooks/useCurrentPage.js +0 -4
- package/dist/esm/hooks/useCustomCallbackFunction.js +0 -5
- package/dist/esm/hooks/useCustomData.js +0 -4
- package/dist/esm/hooks/useDevice.js +0 -3
- package/dist/esm/hooks/useDialogState.js +0 -8
- package/dist/esm/hooks/useEnvironment.js +0 -3
- package/dist/esm/hooks/useFunctions.js +0 -4
- package/dist/esm/hooks/useIsAdminMode.js +0 -3
- package/dist/esm/hooks/useLanguage.js +0 -3
- package/dist/esm/hooks/usePages.js +0 -6
- package/dist/esm/hooks/useParameters.js +0 -3
- package/dist/esm/hooks/useSite.js +0 -3
- package/dist/esm/hooks/useUser.js +0 -3
- package/dist/esm/hooks/useValues.js +0 -4
- package/dist/esm/hooks/windowMetricsListener.js +0 -7
- package/dist/esm/host/ChaynsHost.js +2 -3
- package/dist/esm/host/iframe/HostIframe.js +3 -22
- package/dist/esm/host/module/ModuleHost.js +4 -8
- package/dist/esm/host/module/utils/loadComponent.js +3 -4
- package/dist/esm/types/IChaynsReact.js +39 -49
- package/dist/esm/util/appCall.js +0 -2
- package/dist/esm/util/deviceHelper.js +0 -4
- package/dist/esm/util/initModuleFederationSharing.js +1 -5
- package/dist/esm/util/postIframeForm.js +0 -1
- package/dist/esm/util/transferNestedFunctions.js +0 -2
- package/dist/esm/wrapper/AppWrapper.js +6 -20
- package/dist/esm/wrapper/FrameWrapper.js +2 -6
- package/dist/esm/wrapper/ModuleFederationWrapper.js +1 -3
- package/dist/esm/wrapper/SsrWrapper.js +1 -1
- package/dist/esm/wrapper/StaticChaynsApi.js +1 -1
- package/dist/types/calls/dialogs/alert.d.ts +1 -1
- package/dist/types/calls/dialogs/chaynsDialog.d.ts +24 -24
- package/dist/types/calls/dialogs/close.d.ts +1 -1
- package/dist/types/calls/dialogs/communication.d.ts +3 -3
- package/dist/types/calls/dialogs/confirm.d.ts +13 -13
- package/dist/types/calls/dialogs/date.d.ts +96 -96
- package/dist/types/calls/dialogs/dropUpAlert.d.ts +5 -5
- package/dist/types/calls/dialogs/fileSelect.d.ts +16 -16
- package/dist/types/calls/dialogs/iFrame.d.ts +10 -10
- package/dist/types/calls/dialogs/index.d.ts +14 -14
- package/dist/types/calls/dialogs/input.d.ts +15 -15
- package/dist/types/calls/dialogs/mediaSelect.d.ts +8 -8
- package/dist/types/calls/dialogs/open.d.ts +1 -1
- package/dist/types/calls/dialogs/select.d.ts +6 -6
- package/dist/types/calls/dialogs/signature.d.ts +7 -7
- package/dist/types/calls/dialogs/toast.d.ts +1 -1
- package/dist/types/calls/dialogs/utils/callback.d.ts +1 -1
- package/dist/types/calls/dialogs/utils/is.d.ts +4 -4
- package/dist/types/calls/getUserInfo.d.ts +9 -9
- package/dist/types/calls/index.d.ts +255 -255
- package/dist/types/calls/sendMessage.d.ts +13 -13
- package/dist/types/calls/visibilityChangeListener.d.ts +9 -9
- package/dist/types/components/AppDialogWrapper.d.ts +5 -5
- package/dist/types/components/ChaynsContext.d.ts +3 -3
- package/dist/types/components/ChaynsProvider.d.ts +11 -11
- package/dist/types/components/ErrorBoundary.d.ts +13 -13
- package/dist/types/components/WaitUntil.d.ts +7 -7
- package/dist/types/components/moduleWrapper.d.ts +4 -4
- package/dist/types/components/withCompatMode.d.ts +43 -43
- package/dist/types/components/withHydrationBoundary.d.ts +24 -24
- package/dist/types/constants/hydrationContext.d.ts +6 -6
- package/dist/types/constants/index.d.ts +1 -1
- package/dist/types/constants/languages.d.ts +12 -12
- package/dist/types/handler/DialogHandler.d.ts +24 -24
- package/dist/types/helper/apiListenerHelper.d.ts +6 -6
- package/dist/types/hooks/context.d.ts +3 -3
- package/dist/types/hooks/geoLocationListener.d.ts +18 -18
- package/dist/types/hooks/index.d.ts +18 -18
- package/dist/types/hooks/scrollListener.d.ts +28 -28
- package/dist/types/hooks/useAccessToken.d.ts +6 -6
- package/dist/types/hooks/useCurrentPage.d.ts +5 -5
- package/dist/types/hooks/useCustomCallbackFunction.d.ts +5 -5
- package/dist/types/hooks/useCustomData.d.ts +4 -4
- package/dist/types/hooks/useDevice.d.ts +5 -5
- package/dist/types/hooks/useDialogState.d.ts +9 -9
- package/dist/types/hooks/useEnvironment.d.ts +5 -5
- package/dist/types/hooks/useFunctions.d.ts +4 -4
- package/dist/types/hooks/useIsAdminMode.d.ts +4 -4
- package/dist/types/hooks/useLanguage.d.ts +5 -5
- package/dist/types/hooks/usePages.d.ts +18 -18
- package/dist/types/hooks/useParameters.d.ts +5 -5
- package/dist/types/hooks/useSite.d.ts +5 -5
- package/dist/types/hooks/useUser.d.ts +5 -5
- package/dist/types/hooks/useValues.d.ts +4 -4
- package/dist/types/hooks/windowMetricsListener.d.ts +11 -11
- package/dist/types/host/ChaynsHost.d.ts +29 -29
- package/dist/types/host/iframe/HostIframe.d.ts +26 -26
- package/dist/types/host/iframe/utils/useUpdateData.d.ts +3 -3
- package/dist/types/host/module/ModuleHost.d.ts +28 -28
- package/dist/types/host/module/utils/loadComponent.d.ts +3 -3
- package/dist/types/index.d.ts +20 -20
- package/dist/types/types/IChaynsReact.d.ts +898 -899
- package/dist/types/types/dialog.d.ts +41 -41
- package/dist/types/util/appCall.d.ts +2 -2
- package/dist/types/util/bindChaynsApi.d.ts +1 -1
- package/dist/types/util/deviceHelper.d.ts +9 -9
- package/dist/types/util/heightHelper.d.ts +1 -1
- package/dist/types/util/initModuleFederationSharing.d.ts +3 -3
- package/dist/types/util/is.d.ts +5 -5
- package/dist/types/util/postIframeForm.d.ts +1 -1
- package/dist/types/util/transferNestedFunctions.d.ts +1 -1
- package/dist/types/util/url.d.ts +1 -1
- package/dist/types/wrapper/AppWrapper.d.ts +22 -22
- package/dist/types/wrapper/FrameWrapper.d.ts +18 -18
- package/dist/types/wrapper/ModuleFederationWrapper.d.ts +13 -13
- package/dist/types/wrapper/SsrWrapper.d.ts +14 -14
- package/dist/types/wrapper/StaticChaynsApi.d.ts +16 -16
- package/package.json +88 -88
- package/toolkit.config.js +20 -20
- package/tsconfig.json +56 -56
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _defineProperty(
|
|
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,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,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,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,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
|
|
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
|
|
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 (
|
|
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;
|
|
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
|
-
|
|
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
|
|
11
|
+
return React.createElement(React.Suspense, {
|
|
12
12
|
fallback: fallback || ''
|
|
13
|
-
},
|
|
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
|
-
|
|
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
|
-
}),
|
|
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 =
|
|
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
|
|
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] =
|
|
114
|
+
componentMap[scope][module] = React.lazy(() => promise);
|
|
116
115
|
}
|
|
117
116
|
return componentMap[scope][module];
|
|
118
117
|
};
|