chayns-api 1.0.68-0 → 1.0.69
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 +30 -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 +54 -54
- package/dist/cjs/calls/dialogs/date.js +34 -34
- package/dist/cjs/calls/index.js +108 -108
- package/dist/cjs/calls/sendMessage.js +8 -8
- package/dist/cjs/calls/visibilityChangeListener.js +4 -4
- package/dist/cjs/components/AppDialogWrapper.js +2 -2
- package/dist/cjs/components/ChaynsProvider.js +1 -1
- package/dist/cjs/components/ErrorBoundary.js +1 -1
- package/dist/cjs/components/withCompatMode.js +2 -2
- package/dist/cjs/hooks/geoLocationListener.js +4 -4
- package/dist/cjs/hooks/scrollListener.js +8 -8
- package/dist/cjs/hooks/useAccessToken.js +3 -3
- package/dist/cjs/hooks/useCurrentPage.js +2 -2
- package/dist/cjs/hooks/useCustomData.js +2 -2
- package/dist/cjs/hooks/useDevice.js +2 -2
- package/dist/cjs/hooks/useDialogState.js +4 -4
- package/dist/cjs/hooks/useEnvironment.js +2 -2
- package/dist/cjs/hooks/useFunctions.js +2 -2
- package/dist/cjs/hooks/useIsAdminMode.js +2 -2
- package/dist/cjs/hooks/useLanguage.js +2 -2
- package/dist/cjs/hooks/usePages.js +4 -4
- package/dist/cjs/hooks/useParameters.js +2 -2
- package/dist/cjs/hooks/useSite.js +2 -2
- package/dist/cjs/hooks/useUser.js +2 -2
- package/dist/cjs/hooks/useValues.js +2 -2
- package/dist/cjs/hooks/windowMetricsListener.js +4 -4
- package/dist/cjs/host/ChaynsHost.js +40 -21
- package/dist/cjs/host/iframe/HostIframe.js +2 -2
- package/dist/cjs/host/module/ModuleHost.js +20 -5
- package/dist/cjs/host/module/utils/loadComponent.js +53 -98
- package/dist/cjs/host/module/utils/useDynamicScript.js +59 -0
- package/dist/cjs/index.js +1 -36
- package/dist/cjs/types/IChaynsReact.js +4 -4
- package/dist/cjs/util/heightHelper.js +1 -1
- package/dist/cjs/util/url.js +1 -1
- package/dist/cjs/wrapper/AppWrapper.js +6 -6
- package/dist/cjs/wrapper/FrameWrapper.js +1 -1
- package/dist/cjs/wrapper/ModuleFederationWrapper.js +1 -1
- package/dist/esm/calls/dialogs/date.js +34 -34
- package/dist/esm/calls/index.js +108 -108
- package/dist/esm/calls/sendMessage.js +8 -8
- package/dist/esm/calls/visibilityChangeListener.js +4 -4
- package/dist/esm/components/AppDialogWrapper.js +1 -1
- package/dist/esm/components/withCompatMode.js +1 -1
- package/dist/esm/handler/DialogHandler.js +1 -1
- package/dist/esm/hooks/geoLocationListener.js +4 -4
- package/dist/esm/hooks/scrollListener.js +8 -8
- package/dist/esm/hooks/useAccessToken.js +3 -3
- package/dist/esm/hooks/useCurrentPage.js +2 -2
- package/dist/esm/hooks/useCustomData.js +2 -2
- package/dist/esm/hooks/useDevice.js +2 -2
- package/dist/esm/hooks/useDialogState.js +4 -4
- package/dist/esm/hooks/useEnvironment.js +2 -2
- package/dist/esm/hooks/useFunctions.js +2 -2
- package/dist/esm/hooks/useIsAdminMode.js +2 -2
- package/dist/esm/hooks/useLanguage.js +2 -2
- package/dist/esm/hooks/usePages.js +4 -4
- package/dist/esm/hooks/useParameters.js +2 -2
- package/dist/esm/hooks/useSite.js +2 -2
- package/dist/esm/hooks/useUser.js +2 -2
- package/dist/esm/hooks/useValues.js +2 -2
- package/dist/esm/hooks/windowMetricsListener.js +4 -4
- package/dist/esm/host/ChaynsHost.js +39 -18
- package/dist/esm/host/iframe/HostIframe.js +1 -1
- package/dist/esm/host/module/ModuleHost.js +19 -4
- package/dist/esm/host/module/utils/loadComponent.js +53 -99
- package/dist/esm/host/module/utils/useDynamicScript.js +50 -0
- package/dist/esm/index.js +0 -3
- package/dist/esm/types/IChaynsReact.js +4 -4
- package/dist/esm/util/url.js +2 -2
- package/dist/esm/wrapper/AppWrapper.js +6 -6
- package/dist/esm/wrapper/FrameWrapper.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 +259 -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 +13 -13
- package/dist/types/constants/languages.d.ts +12 -12
- package/dist/types/handler/DialogHandler.d.ts +18 -18
- package/dist/types/helper/apiListenerHelper.d.ts +6 -6
- package/dist/types/hooks/geoLocationListener.d.ts +18 -18
- package/dist/types/hooks/index.d.ts +17 -17
- 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 +4 -7
- 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 +5 -5
- 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 +5 -5
- package/dist/types/hooks/windowMetricsListener.d.ts +11 -11
- package/dist/types/host/ChaynsHost.d.ts +30 -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 +27 -28
- package/dist/types/host/module/utils/loadComponent.d.ts +1 -3
- package/dist/types/host/module/utils/useDynamicScript.d.ts +9 -0
- package/dist/types/index.d.ts +19 -22
- package/dist/types/types/IChaynsReact.d.ts +820 -820
- package/dist/types/types/dialog.d.ts +41 -41
- package/dist/types/util/appCall.d.ts +2 -2
- package/dist/types/util/deviceHelper.d.ts +7 -7
- package/dist/types/util/heightHelper.d.ts +1 -1
- 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 +15 -15
- package/dist/types/wrapper/ModuleFederationWrapper.d.ts +10 -10
- package/dist/types/wrapper/SsrWrapper.d.ts +11 -11
- package/dist/types/wrapper/StaticChaynsApi.d.ts +16 -16
- package/package.json +78 -86
- package/toolkit.config.js +20 -20
- package/tsconfig.json +56 -56
- package/dist/chayns-api.js +0 -2
- package/dist/chayns-api.js.LICENSE.txt +0 -51
- package/dist/cjs/components/withHydrationBoundary.js +0 -54
- package/dist/cjs/constants/hydrationContext.js +0 -16
- package/dist/cjs/constants/index.js +0 -16
- package/dist/esm/components/withHydrationBoundary.js +0 -47
- package/dist/esm/constants/hydrationContext.js +0 -10
- package/dist/esm/constants/index.js +0 -1
- package/dist/types/components/withHydrationBoundary.d.ts +0 -17
- package/dist/types/constants/hydrationContext.d.ts +0 -9
- package/dist/types/constants/index.d.ts +0 -1
|
@@ -2,8 +2,8 @@ import { useContextSelector } from 'use-context-selector';
|
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { ChaynsFunctionsContext } from '../components/ChaynsContext';
|
|
4
4
|
import { useWindowMetrics } from './windowMetricsListener';
|
|
5
|
-
/**
|
|
6
|
-
* @category Hooks
|
|
5
|
+
/**
|
|
6
|
+
* @category Hooks
|
|
7
7
|
*/
|
|
8
8
|
export const useScrollListener = () => {
|
|
9
9
|
const addListener = useContextSelector(ChaynsFunctionsContext, v => v.addScrollListener);
|
|
@@ -18,8 +18,8 @@ export const useScrollListener = () => {
|
|
|
18
18
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
19
|
}, []);
|
|
20
20
|
};
|
|
21
|
-
/**
|
|
22
|
-
* @category Hooks
|
|
21
|
+
/**
|
|
22
|
+
* @category Hooks
|
|
23
23
|
*/
|
|
24
24
|
export const useScrollPosition = function () {
|
|
25
25
|
let {
|
|
@@ -46,8 +46,8 @@ export const useScrollPosition = function () {
|
|
|
46
46
|
}, [getScrollPosition]);
|
|
47
47
|
return value;
|
|
48
48
|
};
|
|
49
|
-
/**
|
|
50
|
-
* @category Hooks
|
|
49
|
+
/**
|
|
50
|
+
* @category Hooks
|
|
51
51
|
*/
|
|
52
52
|
export const useScrollOffsetTop = function () {
|
|
53
53
|
let {
|
|
@@ -69,8 +69,8 @@ export const useScrollOffsetTop = function () {
|
|
|
69
69
|
}
|
|
70
70
|
return 0;
|
|
71
71
|
};
|
|
72
|
-
/**
|
|
73
|
-
* @category Hooks
|
|
72
|
+
/**
|
|
73
|
+
* @category Hooks
|
|
74
74
|
*/
|
|
75
75
|
export const useScrollOffsetBottom = function () {
|
|
76
76
|
let {
|
|
@@ -2,9 +2,9 @@ import { useEffect, useState } from "react";
|
|
|
2
2
|
import { useContextSelector } from "use-context-selector";
|
|
3
3
|
import { ChaynsFunctionsContext } from "../components/ChaynsContext";
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* @category Hooks
|
|
7
|
-
* @deprecated Use {@link getAccessToken} instead
|
|
5
|
+
/**
|
|
6
|
+
* @category Hooks
|
|
7
|
+
* @deprecated Use {@link getAccessToken} instead
|
|
8
8
|
*/
|
|
9
9
|
export const useAccessToken = accessToken => {
|
|
10
10
|
const [token, setToken] = useState(null);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* @category Hooks
|
|
4
|
+
/**
|
|
5
|
+
* @category Hooks
|
|
6
6
|
*/
|
|
7
7
|
export const useCurrentPage = () => useContextSelector(ChaynsContext, v => v === null || v === void 0 ? void 0 : v.currentPage);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* @category Hooks
|
|
4
|
+
/**
|
|
5
|
+
* @category Hooks
|
|
6
6
|
*/
|
|
7
7
|
export const useCustomData = () => useContextSelector(ChaynsContext, v => v === null || v === void 0 ? void 0 : v.customData);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
/**
|
|
4
|
-
* @category Hooks
|
|
3
|
+
/**
|
|
4
|
+
* @category Hooks
|
|
5
5
|
*/
|
|
6
6
|
export const useDevice = () => useContextSelector(ChaynsContext, v => v === null || v === void 0 ? void 0 : v.device);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext, ChaynsFunctionsContext } from '../components/ChaynsContext';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* @category Hooks
|
|
4
|
+
/**
|
|
5
|
+
* @category Hooks
|
|
6
6
|
*/
|
|
7
7
|
export const useDialogState = () => {
|
|
8
8
|
const setResult = useContextSelector(ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.setDialogResult);
|
|
@@ -20,8 +20,8 @@ export const useDialogState = () => {
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
* @category Hooks
|
|
23
|
+
/**
|
|
24
|
+
* @category Hooks
|
|
25
25
|
*/
|
|
26
26
|
export const useDialogData = () => {
|
|
27
27
|
const inputData = useContextSelector(ChaynsContext, v => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
/**
|
|
4
|
-
* @category Hooks
|
|
3
|
+
/**
|
|
4
|
+
* @category Hooks
|
|
5
5
|
*/
|
|
6
6
|
export const useEnvironment = () => useContextSelector(ChaynsContext, v => v === null || v === void 0 ? void 0 : v.environment);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContextSelector } from "use-context-selector";
|
|
2
2
|
import { ChaynsFunctionsContext } from "../components/ChaynsContext";
|
|
3
|
-
/**
|
|
4
|
-
* @category Hooks
|
|
3
|
+
/**
|
|
4
|
+
* @category Hooks
|
|
5
5
|
*/
|
|
6
6
|
export const useFunctions = () => {
|
|
7
7
|
const t = useContextSelector(ChaynsFunctionsContext, f => f || {});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
/**
|
|
4
|
-
* @category Hooks
|
|
3
|
+
/**
|
|
4
|
+
* @category Hooks
|
|
5
5
|
*/
|
|
6
6
|
export const useLanguage = () => useContextSelector(ChaynsContext, v => v === null || v === void 0 ? void 0 : v.language);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
3
|
import { moduleWrapper } from '../components/moduleWrapper';
|
|
4
|
-
/**
|
|
5
|
-
* @category Hooks
|
|
4
|
+
/**
|
|
5
|
+
* @category Hooks
|
|
6
6
|
*/
|
|
7
7
|
export const usePages = function () {
|
|
8
8
|
let {
|
|
@@ -16,8 +16,8 @@ export const usePages = function () {
|
|
|
16
16
|
}
|
|
17
17
|
return pages;
|
|
18
18
|
};
|
|
19
|
-
/**
|
|
20
|
-
* @category Hooks
|
|
19
|
+
/**
|
|
20
|
+
* @category Hooks
|
|
21
21
|
*/
|
|
22
22
|
export const usePage = _ref => {
|
|
23
23
|
let {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
/**
|
|
4
|
-
* @category Hooks
|
|
3
|
+
/**
|
|
4
|
+
* @category Hooks
|
|
5
5
|
*/
|
|
6
6
|
export const useParameters = () => useContextSelector(ChaynsContext, v => (v === null || v === void 0 ? void 0 : v.parameters) || []);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
/**
|
|
4
|
-
* @category Hooks
|
|
3
|
+
/**
|
|
4
|
+
* @category Hooks
|
|
5
5
|
*/
|
|
6
6
|
export const useSite = () => useContextSelector(ChaynsContext, v => v === null || v === void 0 ? void 0 : v.site);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
/**
|
|
4
|
-
* @category Hooks
|
|
3
|
+
/**
|
|
4
|
+
* @category Hooks
|
|
5
5
|
*/
|
|
6
6
|
export const useUser = () => useContextSelector(ChaynsContext, v => (v === null || v === void 0 ? void 0 : v.user) || {});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
/**
|
|
4
|
-
* @category Hooks
|
|
3
|
+
/**
|
|
4
|
+
* @category Hooks
|
|
5
5
|
*/
|
|
6
6
|
export const useValues = () => {
|
|
7
7
|
const t = useContextSelector(ChaynsContext, v => v || {});
|
|
@@ -2,8 +2,8 @@ import { useContextSelector } from 'use-context-selector';
|
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { ChaynsFunctionsContext } from '../components/ChaynsContext';
|
|
4
4
|
import { ScreenSize } from '../types/IChaynsReact';
|
|
5
|
-
/**
|
|
6
|
-
* @category Hooks
|
|
5
|
+
/**
|
|
6
|
+
* @category Hooks
|
|
7
7
|
*/
|
|
8
8
|
export const useWindowMetricsListener = () => {
|
|
9
9
|
const addListener = useContextSelector(ChaynsFunctionsContext, v => v.addWindowMetricsListener);
|
|
@@ -18,8 +18,8 @@ export const useWindowMetricsListener = () => {
|
|
|
18
18
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
19
|
}, []);
|
|
20
20
|
};
|
|
21
|
-
/**
|
|
22
|
-
* @category Hooks
|
|
21
|
+
/**
|
|
22
|
+
* @category Hooks
|
|
23
23
|
*/
|
|
24
24
|
export const useWindowMetrics = function () {
|
|
25
25
|
let {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import HostIframe from './iframe/HostIframe';
|
|
3
3
|
import ModuleHost from './module/ModuleHost';
|
|
4
4
|
const ChaynsHost = _ref => {
|
|
@@ -9,6 +9,7 @@ const ChaynsHost = _ref => {
|
|
|
9
9
|
src,
|
|
10
10
|
iFrameRef = undefined,
|
|
11
11
|
loadingComponent = undefined,
|
|
12
|
+
children = undefined,
|
|
12
13
|
system,
|
|
13
14
|
// shallow data
|
|
14
15
|
pages,
|
|
@@ -24,23 +25,8 @@ const ChaynsHost = _ref => {
|
|
|
24
25
|
preventStagingReplacement,
|
|
25
26
|
dialog
|
|
26
27
|
} = _ref;
|
|
27
|
-
const [isVisible, setIsVisible] = useState(type !== 'client-module' && (type !== 'server-module' || !!(system !== null && system !== void 0 && system.serverUrl)));
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (isVisible) return;
|
|
30
|
-
if (typeof startTransition === 'function') {
|
|
31
|
-
startTransition(() => {
|
|
32
|
-
setIsVisible(true);
|
|
33
|
-
});
|
|
34
|
-
} else {
|
|
35
|
-
setIsVisible(true);
|
|
36
|
-
}
|
|
37
|
-
}, []);
|
|
38
|
-
if (!isVisible) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
28
|
switch (type) {
|
|
42
29
|
case 'client-iframe':
|
|
43
|
-
case 'server-iframe':
|
|
44
30
|
return /*#__PURE__*/React.createElement(HostIframe, {
|
|
45
31
|
iFrameRef: iFrameRef,
|
|
46
32
|
iFrameProps: iFrameProps,
|
|
@@ -52,7 +38,6 @@ const ChaynsHost = _ref => {
|
|
|
52
38
|
currentPage: currentPage,
|
|
53
39
|
functions: functions,
|
|
54
40
|
src: src,
|
|
55
|
-
postForm: type === 'server-iframe',
|
|
56
41
|
language: language,
|
|
57
42
|
parameters: parameters,
|
|
58
43
|
environment: environment,
|
|
@@ -61,7 +46,6 @@ const ChaynsHost = _ref => {
|
|
|
61
46
|
dialog: dialog
|
|
62
47
|
});
|
|
63
48
|
case 'client-module':
|
|
64
|
-
case 'server-module':
|
|
65
49
|
return /*#__PURE__*/React.createElement(ModuleHost, {
|
|
66
50
|
system: system,
|
|
67
51
|
pages: pages,
|
|
@@ -79,6 +63,43 @@ const ChaynsHost = _ref => {
|
|
|
79
63
|
preventStagingReplacement: preventStagingReplacement,
|
|
80
64
|
dialog: dialog
|
|
81
65
|
});
|
|
66
|
+
case 'server-iframe':
|
|
67
|
+
return /*#__PURE__*/React.createElement(HostIframe, {
|
|
68
|
+
iFrameRef: iFrameRef,
|
|
69
|
+
iFrameProps: iFrameProps,
|
|
70
|
+
pages: pages,
|
|
71
|
+
isAdminModeActive: isAdminModeActive,
|
|
72
|
+
site: site,
|
|
73
|
+
user: user,
|
|
74
|
+
device: device,
|
|
75
|
+
currentPage: currentPage,
|
|
76
|
+
functions: functions,
|
|
77
|
+
src: src,
|
|
78
|
+
postForm: true,
|
|
79
|
+
language: language,
|
|
80
|
+
parameters: parameters,
|
|
81
|
+
environment: environment,
|
|
82
|
+
customData: customData,
|
|
83
|
+
preventStagingReplacement: preventStagingReplacement,
|
|
84
|
+
dialog: dialog
|
|
85
|
+
});
|
|
86
|
+
case 'server-module':
|
|
87
|
+
return /*#__PURE__*/React.createElement(ModuleHost, {
|
|
88
|
+
system: system,
|
|
89
|
+
pages: pages,
|
|
90
|
+
isAdminModeActive: isAdminModeActive,
|
|
91
|
+
site: site,
|
|
92
|
+
user: user,
|
|
93
|
+
device: device,
|
|
94
|
+
currentPage: currentPage,
|
|
95
|
+
functions: functions,
|
|
96
|
+
language: language,
|
|
97
|
+
parameters: parameters,
|
|
98
|
+
customData: customData,
|
|
99
|
+
environment: environment,
|
|
100
|
+
preventStagingReplacement: preventStagingReplacement,
|
|
101
|
+
dialog: dialog
|
|
102
|
+
}, children);
|
|
82
103
|
default:
|
|
83
104
|
return null;
|
|
84
105
|
}
|
|
@@ -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';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
|
+
import useDynamicScript from './utils/useDynamicScript';
|
|
2
3
|
import loadComponent from './utils/loadComponent';
|
|
3
4
|
import { replaceStagingUrl } from "../../util/url";
|
|
4
5
|
const System = _ref => {
|
|
@@ -7,10 +8,25 @@ const System = _ref => {
|
|
|
7
8
|
fallback,
|
|
8
9
|
...props
|
|
9
10
|
} = _ref;
|
|
10
|
-
const
|
|
11
|
-
|
|
11
|
+
const {
|
|
12
|
+
ready,
|
|
13
|
+
failed
|
|
14
|
+
} = useDynamicScript({
|
|
15
|
+
url: system === null || system === void 0 ? void 0 : system.url,
|
|
16
|
+
scope: system === null || system === void 0 ? void 0 : system.scope
|
|
17
|
+
});
|
|
18
|
+
const Component = useMemo(() => {
|
|
19
|
+
// maybe return waitcursor instead
|
|
20
|
+
if (!system || !ready || failed) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return /*#__PURE__*/React.lazy(loadComponent(system.scope, system.module, system.url, undefined, system.preventSingleton));
|
|
24
|
+
|
|
25
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
26
|
+
}, [system === null || system === void 0 ? void 0 : system.scope, ready, system === null || system === void 0 ? void 0 : system.url]);
|
|
27
|
+
return Component ? /*#__PURE__*/React.createElement(React.Suspense, {
|
|
12
28
|
fallback: fallback || ''
|
|
13
|
-
}, /*#__PURE__*/React.createElement(Component, props));
|
|
29
|
+
}, /*#__PURE__*/React.createElement(Component, props)) : fallback;
|
|
14
30
|
};
|
|
15
31
|
const ModuleHost = _ref2 => {
|
|
16
32
|
let {
|
|
@@ -57,7 +73,6 @@ const ModuleHost = _ref2 => {
|
|
|
57
73
|
system: {
|
|
58
74
|
scope: system.scope,
|
|
59
75
|
url: replaceStagingUrl(preventStagingReplacement, system.url, environment.buildEnvironment),
|
|
60
|
-
serverUrl: replaceStagingUrl(preventStagingReplacement, system.serverUrl, environment.buildEnvironment),
|
|
61
76
|
module: system.module,
|
|
62
77
|
preventSingleton: system.preventSingleton
|
|
63
78
|
},
|
|
@@ -1,106 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
3
4
|
import semver from 'semver';
|
|
4
5
|
import React from 'react';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const componentMap = {};
|
|
9
|
-
init({
|
|
10
|
-
// will be set by chayns-toolkit via DefinePlugin
|
|
11
|
-
name: (_process$env$__PACKAG = process.env.__PACKAGE_NAME__) !== null && _process$env$__PACKAG !== void 0 ? _process$env$__PACKAG : '',
|
|
12
|
-
remotes: [],
|
|
13
|
-
shared: {
|
|
14
|
-
react: {
|
|
15
|
-
version: React.version,
|
|
16
|
-
scope: 'default',
|
|
17
|
-
lib: () => React
|
|
18
|
-
},
|
|
19
|
-
'react-dom': {
|
|
20
|
-
version: ReactDOM.version,
|
|
21
|
-
scope: 'default',
|
|
22
|
-
lib: () => ReactDOM
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
export const loadModule = function (scope, module, url) {
|
|
27
|
-
let preventSingleton = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
28
|
-
if (registeredScopes[scope] !== url || preventSingleton) {
|
|
29
|
-
if (scope in registeredScopes) {
|
|
30
|
-
console.error(`[chayns-api] call registerRemote with force for scope ${scope}. url: ${url}`);
|
|
31
|
-
}
|
|
32
|
-
registerRemotes([{
|
|
33
|
-
name: scope,
|
|
34
|
-
entry: url,
|
|
35
|
-
alias: scope
|
|
36
|
-
}], {
|
|
37
|
-
force: scope in registeredScopes || preventSingleton
|
|
38
|
-
});
|
|
39
|
-
registeredScopes[scope] = url;
|
|
40
|
-
moduleMap[scope] = {};
|
|
41
|
-
componentMap[scope] = {};
|
|
42
|
-
}
|
|
43
|
-
if (!(module in moduleMap[scope])) {
|
|
44
|
-
const path = `${scope}/${module.replace(/^\.\//, '')}`;
|
|
45
|
-
const promise = loadRemote(path);
|
|
46
|
-
promise.catch(e => {
|
|
47
|
-
console.error("[chayns-api] Failed to load module", scope, url, e);
|
|
48
|
-
// causes registerRemote with force = true on next attempt to load the component which tries to load the component again
|
|
49
|
-
registeredScopes[scope] = '';
|
|
50
|
-
});
|
|
51
|
-
return promise;
|
|
52
|
-
}
|
|
53
|
-
return moduleMap[scope][module];
|
|
54
|
-
};
|
|
55
|
-
const loadComponent = function (scope, module, url) {
|
|
6
|
+
import { semaphore } from './useDynamicScript';
|
|
7
|
+
let instances = {};
|
|
8
|
+
export default function loadComponent(scope, module, url) {
|
|
56
9
|
let skipCompatMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
57
10
|
let preventSingleton = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
const matchReactVersion = requiredVersion && semver.satisfies(hostVersion, requiredVersion) && !shareScopes.some(_ref => {
|
|
83
|
-
let {
|
|
84
|
-
version,
|
|
85
|
-
from
|
|
86
|
-
} = _ref;
|
|
87
|
-
return semver.gt(version, hostVersion) && semver.satisfies(version, requiredVersion) || scope === from.split('-').join('_');
|
|
88
|
-
});
|
|
89
|
-
if (!matchReactVersion || environment !== 'production' || process.env.NODE_ENV === 'development') {
|
|
90
|
-
return {
|
|
91
|
-
default: Module.default.CompatComponent
|
|
92
|
-
};
|
|
11
|
+
return async () => {
|
|
12
|
+
// Initializes the shared scope. Fills it with known provided modules from this build and all remotes
|
|
13
|
+
await __webpack_init_sharing__('default');
|
|
14
|
+
const {
|
|
15
|
+
container
|
|
16
|
+
} = window[scope + "_list"].find(x => x.url === url); // or get the container somewhere else
|
|
17
|
+
// Initialize the container, it may provide shared modules
|
|
18
|
+
await container.init(__webpack_share_scopes__.default);
|
|
19
|
+
const factory = await container.get(module);
|
|
20
|
+
semaphore[scope].release();
|
|
21
|
+
let ModuleMap = instances[`${scope}__${module}`];
|
|
22
|
+
let Module;
|
|
23
|
+
if (!ModuleMap) {
|
|
24
|
+
ModuleMap = {};
|
|
25
|
+
instances[`${scope}__${module}`] = ModuleMap;
|
|
26
|
+
}
|
|
27
|
+
if (Object.keys(ModuleMap).length > 0) {
|
|
28
|
+
const newModule = factory();
|
|
29
|
+
Module = ModuleMap[`${newModule.default.buildEnv}__${newModule.default.appVersion}`];
|
|
30
|
+
if (!Module) {
|
|
31
|
+
Module = newModule;
|
|
32
|
+
ModuleMap[`${newModule.default.buildEnv}__${newModule.default.appVersion}`] = newModule;
|
|
93
33
|
}
|
|
34
|
+
} else {
|
|
35
|
+
Module = factory();
|
|
36
|
+
ModuleMap[`${Module.default.buildEnv}__${Module.default.appVersion}`] = Module;
|
|
37
|
+
}
|
|
38
|
+
if (preventSingleton) {
|
|
39
|
+
// Intercom :)
|
|
40
|
+
window[scope + "_list"] = null;
|
|
41
|
+
}
|
|
42
|
+
if (skipCompatMode) return Module;
|
|
43
|
+
const hostVersion = semver.minVersion(React.version);
|
|
44
|
+
const {
|
|
45
|
+
requiredVersion,
|
|
46
|
+
environment
|
|
47
|
+
} = Module.default;
|
|
48
|
+
const matchReactVersion = requiredVersion && semver.satisfies(hostVersion, requiredVersion) && !Object.keys(__webpack_share_scopes__.default.react).some(version => {
|
|
49
|
+
return semver.gt(version, hostVersion) && semver.satisfies(version, requiredVersion) || scope === __webpack_share_scopes__.default.react[version].from.split('-').join('_');
|
|
50
|
+
});
|
|
51
|
+
if (!matchReactVersion || environment !== 'production' || process.env.NODE_ENV === 'development') {
|
|
94
52
|
return {
|
|
95
|
-
default: Module.default.
|
|
53
|
+
default: Module.default.CompatComponent
|
|
96
54
|
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
return componentMap[scope][module];
|
|
105
|
-
};
|
|
106
|
-
export default loadComponent;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
default: Module.default.Component
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import Semaphore from 'semaphore-async-await';
|
|
3
|
+
export const semaphore = {};
|
|
4
|
+
const useDynamicScript = args => {
|
|
5
|
+
const [ready, setReady] = React.useState(false);
|
|
6
|
+
const [failed, setFailed] = React.useState(false);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (!args.url) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const element = document.createElement('script');
|
|
12
|
+
element.src = args.url;
|
|
13
|
+
element.type = 'text/javascript';
|
|
14
|
+
element.async = true;
|
|
15
|
+
setReady(false);
|
|
16
|
+
setFailed(false);
|
|
17
|
+
if (!(args.scope in semaphore)) {
|
|
18
|
+
semaphore[args.scope] = new Semaphore(1);
|
|
19
|
+
}
|
|
20
|
+
(async () => {
|
|
21
|
+
await semaphore[args.scope].acquire();
|
|
22
|
+
element.onload = () => {
|
|
23
|
+
setReady(true);
|
|
24
|
+
const listKey = args.scope + "_list";
|
|
25
|
+
if (!window[listKey]) window[listKey] = [];
|
|
26
|
+
window[listKey].push({
|
|
27
|
+
url: args.url,
|
|
28
|
+
container: window[args.scope]
|
|
29
|
+
});
|
|
30
|
+
window[args.scope] = null;
|
|
31
|
+
};
|
|
32
|
+
element.onerror = () => {
|
|
33
|
+
setReady(false);
|
|
34
|
+
setFailed(true);
|
|
35
|
+
};
|
|
36
|
+
document.head.appendChild(element);
|
|
37
|
+
})();
|
|
38
|
+
return () => {
|
|
39
|
+
semaphore[args.scope].release();
|
|
40
|
+
if (document.head.contains(element)) {
|
|
41
|
+
document.head.removeChild(element);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}, [args.url]);
|
|
45
|
+
return {
|
|
46
|
+
ready,
|
|
47
|
+
failed
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export default useDynamicScript;
|
package/dist/esm/index.js
CHANGED
|
@@ -8,10 +8,7 @@ export * from './hooks';
|
|
|
8
8
|
export * from './components/WaitUntil';
|
|
9
9
|
export * from './types/IChaynsReact';
|
|
10
10
|
export * from './components/withCompatMode';
|
|
11
|
-
export * from './constants';
|
|
12
|
-
export { default as withHydrationBoundary } from './components/withHydrationBoundary';
|
|
13
11
|
export { default as StaticChaynsApi } from './wrapper/StaticChaynsApi';
|
|
14
|
-
export { default as loadComponent, loadModule } from './host/module/utils/loadComponent';
|
|
15
12
|
export { default as DialogHandler } from './handler/DialogHandler';
|
|
16
13
|
import * as _dialog from './calls/dialogs/index';
|
|
17
14
|
export { _dialog as dialog };
|
|
@@ -40,12 +40,12 @@ export let ScreenSize = /*#__PURE__*/function (ScreenSize) {
|
|
|
40
40
|
return ScreenSize;
|
|
41
41
|
}({});
|
|
42
42
|
|
|
43
|
-
/**
|
|
44
|
-
* @ignore
|
|
43
|
+
/**
|
|
44
|
+
* @ignore
|
|
45
45
|
*/
|
|
46
46
|
|
|
47
|
-
/**
|
|
48
|
-
* @ignore
|
|
47
|
+
/**
|
|
48
|
+
* @ignore
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
51
|
export let AccessMode = /*#__PURE__*/function (AccessMode) {
|
package/dist/esm/util/url.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Environment } from
|
|
1
|
+
import { Environment } from "../types/IChaynsReact";
|
|
2
2
|
export const replaceStagingUrl = (prevent, url, environment) => {
|
|
3
|
-
if (prevent
|
|
3
|
+
if (prevent) return url;
|
|
4
4
|
let replacedUrl = url;
|
|
5
5
|
if (environment === Environment.Qa || environment === Environment.Development) {
|
|
6
6
|
replacedUrl = replacedUrl.replace('tapp.chayns-static.space', 'tapp-dev.chayns-static.space');
|