chayns-api 1.1.0-9 → 1.1.3
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 +116 -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 +3 -6
- package/dist/cjs/components/ErrorBoundary.js +1 -1
- package/dist/cjs/components/withCompatMode.js +2 -2
- package/dist/cjs/constants/languages.js +19 -0
- package/dist/cjs/handler/DialogHandler.js +1 -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 +1 -1
- package/dist/cjs/host/iframe/HostIframe.js +2 -2
- package/dist/cjs/host/module/ModuleHost.js +20 -23
- package/dist/cjs/host/module/utils/loadComponent.js +54 -57
- package/dist/cjs/host/module/utils/useDynamicScript.js +5 -7
- package/dist/cjs/index.js +5 -21
- package/dist/cjs/types/IChaynsReact.js +5 -4
- package/dist/cjs/util/deviceHelper.js +9 -2
- package/dist/cjs/util/heightHelper.js +1 -1
- package/dist/cjs/util/is.js +30 -0
- package/dist/cjs/util/transferNestedFunctions.js +5 -2
- package/dist/cjs/wrapper/AppWrapper.js +86 -43
- package/dist/cjs/wrapper/FrameWrapper.js +6 -2
- package/dist/cjs/wrapper/ModuleFederationWrapper.js +1 -1
- package/dist/cjs/wrapper/StaticChaynsApi.js +7 -0
- package/dist/esm/calls/dialogs/date.js +34 -34
- package/dist/esm/calls/index.js +114 -109
- 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/ChaynsProvider.js +2 -5
- package/dist/esm/components/withCompatMode.js +1 -1
- package/dist/esm/constants/languages.js +13 -0
- package/dist/esm/handler/DialogHandler.js +2 -3
- 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/iframe/HostIframe.js +1 -1
- package/dist/esm/host/module/ModuleHost.js +19 -22
- package/dist/esm/host/module/utils/loadComponent.js +53 -56
- package/dist/esm/index.js +1 -3
- package/dist/esm/types/IChaynsReact.js +5 -4
- package/dist/esm/util/deviceHelper.js +9 -2
- package/dist/esm/util/is.js +23 -0
- package/dist/esm/util/transferNestedFunctions.js +5 -2
- package/dist/esm/wrapper/AppWrapper.js +90 -45
- package/dist/esm/wrapper/FrameWrapper.js +6 -2
- package/dist/esm/wrapper/StaticChaynsApi.js +8 -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 -251
- 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 -0
- package/dist/types/handler/DialogHandler.d.ts +24 -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 -4
- 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 -30
- 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 -27
- package/dist/types/host/module/utils/loadComponent.d.ts +1 -1
- package/dist/types/host/module/utils/useDynamicScript.d.ts +9 -9
- package/dist/types/index.d.ts +20 -22
- package/dist/types/types/IChaynsReact.d.ts +859 -816
- 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/is.d.ts +5 -0
- 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 +19 -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 -9
- package/package.json +78 -86
- package/toolkit.config.js +20 -20
- package/tsconfig.json +56 -56
- package/dist/cjs/components/withHydrationBoundary.js +0 -58
- package/dist/cjs/constants/hydrationContext.js +0 -16
- package/dist/cjs/constants/index.js +0 -16
- package/dist/esm/components/withHydrationBoundary.js +0 -51
- 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
|
@@ -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
|
-
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,35 +1,32 @@
|
|
|
1
|
-
import { init } from '@module-federation/runtime';
|
|
2
1
|
import React, { useMemo } from 'react';
|
|
3
|
-
import
|
|
2
|
+
import useDynamicScript from './utils/useDynamicScript';
|
|
4
3
|
import loadComponent from './utils/loadComponent';
|
|
5
4
|
import { replaceStagingUrl } from "../../util/url";
|
|
6
|
-
init({
|
|
7
|
-
// @ts-expect-error will be set by chayns-toolkit via DefinePlugin
|
|
8
|
-
name: process.env.__PACKAGE_NAME__,
|
|
9
|
-
remotes: [],
|
|
10
|
-
shared: {
|
|
11
|
-
react: {
|
|
12
|
-
version: React.version,
|
|
13
|
-
scope: 'default',
|
|
14
|
-
lib: () => React
|
|
15
|
-
},
|
|
16
|
-
'react-dom': {
|
|
17
|
-
version: ReactDOM.version,
|
|
18
|
-
scope: 'default',
|
|
19
|
-
lib: () => ReactDOM
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
5
|
const System = _ref => {
|
|
24
6
|
let {
|
|
25
7
|
system,
|
|
26
8
|
fallback,
|
|
27
9
|
...props
|
|
28
10
|
} = _ref;
|
|
29
|
-
const
|
|
30
|
-
|
|
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, {
|
|
31
28
|
fallback: fallback || ''
|
|
32
|
-
}, /*#__PURE__*/React.createElement(Component, props));
|
|
29
|
+
}, /*#__PURE__*/React.createElement(Component, props)) : fallback;
|
|
33
30
|
};
|
|
34
31
|
const ModuleHost = _ref2 => {
|
|
35
32
|
let {
|
|
@@ -1,63 +1,60 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
1
4
|
import semver from 'semver';
|
|
2
5
|
import React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const dynamicMap = {};
|
|
6
|
+
import { semaphore } from './useDynamicScript';
|
|
7
|
+
let instances = {};
|
|
6
8
|
export default function loadComponent(scope, module, url) {
|
|
7
9
|
let skipCompatMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
8
10
|
let preventSingleton = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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;
|
|
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('_');
|
|
19
50
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return Module;
|
|
30
|
-
}
|
|
31
|
-
const hostVersion = semver.minVersion(React.version);
|
|
32
|
-
const {
|
|
33
|
-
requiredVersion,
|
|
34
|
-
environment
|
|
35
|
-
} = Module.default;
|
|
36
|
-
const shareScopes = await new Promise(resolve => {
|
|
37
|
-
loadShareSync('react', {
|
|
38
|
-
resolver: shareOptions => {
|
|
39
|
-
resolve(shareOptions);
|
|
40
|
-
return shareOptions[0];
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
const matchReactVersion = requiredVersion && semver.satisfies(hostVersion, requiredVersion) && !shareScopes.some(t => {
|
|
45
|
-
const {
|
|
46
|
-
version,
|
|
47
|
-
from
|
|
48
|
-
} = t;
|
|
49
|
-
return semver.gt(version, hostVersion) && semver.satisfies(version, requiredVersion) || scope === from.split('-').join('_');
|
|
50
|
-
});
|
|
51
|
-
if (!matchReactVersion || environment !== 'production' || process.env.NODE_ENV === 'development') {
|
|
52
|
-
return {
|
|
53
|
-
default: Module.default.CompatComponent
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
default: Module.default.Component
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
return dynamicMap[scope][module];
|
|
51
|
+
if (!matchReactVersion || environment !== 'production' || process.env.NODE_ENV === 'development') {
|
|
52
|
+
return {
|
|
53
|
+
default: Module.default.CompatComponent
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
default: Module.default.Component
|
|
58
|
+
};
|
|
59
|
+
};
|
|
63
60
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -7,11 +7,9 @@ export * from './calls';
|
|
|
7
7
|
export * from './hooks';
|
|
8
8
|
export * from './components/WaitUntil';
|
|
9
9
|
export * from './types/IChaynsReact';
|
|
10
|
+
export * from './util/is';
|
|
10
11
|
export * from './components/withCompatMode';
|
|
11
|
-
export * from './constants';
|
|
12
|
-
export { default as withHydrationBoundary } from './components/withHydrationBoundary';
|
|
13
12
|
export { default as StaticChaynsApi } from './wrapper/StaticChaynsApi';
|
|
14
|
-
export { default as loadComponent } from './host/module/utils/loadComponent';
|
|
15
13
|
export { default as DialogHandler } from './handler/DialogHandler';
|
|
16
14
|
import * as _dialog from './calls/dialogs/index';
|
|
17
15
|
export { _dialog as dialog };
|
|
@@ -23,6 +23,7 @@ export let DialogSelectType = /*#__PURE__*/function (DialogSelectType) {
|
|
|
23
23
|
DialogSelectType[DialogSelectType["DEFAULT"] = 0] = "DEFAULT";
|
|
24
24
|
DialogSelectType[DialogSelectType["ICON"] = 1] = "ICON";
|
|
25
25
|
DialogSelectType[DialogSelectType["IMAGE"] = 2] = "IMAGE";
|
|
26
|
+
DialogSelectType[DialogSelectType["SIMPLE"] = 3] = "SIMPLE";
|
|
26
27
|
return DialogSelectType;
|
|
27
28
|
}({});
|
|
28
29
|
export let DialogButtonType = /*#__PURE__*/function (DialogButtonType) {
|
|
@@ -40,12 +41,12 @@ export let ScreenSize = /*#__PURE__*/function (ScreenSize) {
|
|
|
40
41
|
return ScreenSize;
|
|
41
42
|
}({});
|
|
42
43
|
|
|
43
|
-
/**
|
|
44
|
-
* @ignore
|
|
44
|
+
/**
|
|
45
|
+
* @ignore
|
|
45
46
|
*/
|
|
46
47
|
|
|
47
|
-
/**
|
|
48
|
-
* @ignore
|
|
48
|
+
/**
|
|
49
|
+
* @ignore
|
|
49
50
|
*/
|
|
50
51
|
|
|
51
52
|
export let AccessMode = /*#__PURE__*/function (AccessMode) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { parseUserAgent } from 'detect-browser';
|
|
2
2
|
import { AppName, ScreenSize } from '../types/IChaynsReact';
|
|
3
3
|
const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
4
|
-
var _match$groups, _match$groups2, _parsedUA$version$spl, _parsedUA$version;
|
|
4
|
+
var _match$groups, _match$groups2, _customMatch$groups, _parsedUA$version$spl, _parsedUA$version;
|
|
5
5
|
const parsedUA = parseUserAgent(userAgent);
|
|
6
6
|
let appName = AppName.Unknown;
|
|
7
7
|
const match = /(?:my)?chayns\/(?<version>\d+).*(?<siteId>\d{5}-\d{5})/i.exec(userAgent);
|
|
8
|
+
const customMatch = /\s(?<name>intercom|sidekick|team)\/(?<version>\d+)/i.exec(userAgent);
|
|
8
9
|
if (/\sintercom\/\d+/i.test(userAgent)) {
|
|
9
10
|
appName = AppName.TobitChat;
|
|
10
11
|
} else if (/\ssidekick\/\d+/i.test(userAgent)) {
|
|
@@ -20,6 +21,10 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
20
21
|
} else if (/dface|h96pp|h96max|jabiru|chaynsterminal|wayter|odroidn2p/i.test(userAgent)) {
|
|
21
22
|
appName = AppName.ChaynsLauncher;
|
|
22
23
|
}
|
|
24
|
+
let appVersion = match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN;
|
|
25
|
+
if (customMatch !== null && customMatch !== void 0 && (_customMatch$groups = customMatch.groups) !== null && _customMatch$groups !== void 0 && _customMatch$groups.version) {
|
|
26
|
+
appVersion = Number.parseInt(customMatch.groups.version, 10);
|
|
27
|
+
}
|
|
23
28
|
const result = {};
|
|
24
29
|
result.browser = {
|
|
25
30
|
name: parsedUA === null || parsedUA === void 0 ? void 0 : parsedUA.name,
|
|
@@ -29,7 +34,9 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
29
34
|
};
|
|
30
35
|
result.app = {
|
|
31
36
|
name: appName,
|
|
32
|
-
version: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
|
|
37
|
+
version: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN,
|
|
38
|
+
appVersion,
|
|
39
|
+
callVersion: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
|
|
33
40
|
};
|
|
34
41
|
result.imei = undefined; // TODO
|
|
35
42
|
result.accessToken = undefined; // TODO
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getDevice } from '../calls';
|
|
2
|
+
import { AppName } from '../types/IChaynsReact';
|
|
3
|
+
export const isApp = () => {
|
|
4
|
+
var _getDevice$app$name, _getDevice$app;
|
|
5
|
+
return ((_getDevice$app$name = (_getDevice$app = getDevice().app) === null || _getDevice$app === void 0 ? void 0 : _getDevice$app.name) !== null && _getDevice$app$name !== void 0 ? _getDevice$app$name : AppName.Unknown) !== AppName.Unknown;
|
|
6
|
+
};
|
|
7
|
+
export const isAppCallSupported = _ref => {
|
|
8
|
+
var _device$app;
|
|
9
|
+
let {
|
|
10
|
+
minAndroidVersion = 1,
|
|
11
|
+
minIOSVersion = 1
|
|
12
|
+
} = _ref;
|
|
13
|
+
if (!isApp()) return false;
|
|
14
|
+
const device = getDevice();
|
|
15
|
+
if (!((_device$app = device.app) !== null && _device$app !== void 0 && _device$app.callVersion) || isNaN(device.app.callVersion)) return false;
|
|
16
|
+
if (device.os && ['iOS', 'Mac OS'].includes(device.os)) {
|
|
17
|
+
return device.app.callVersion >= minIOSVersion;
|
|
18
|
+
}
|
|
19
|
+
if (device.os === 'Android OS') {
|
|
20
|
+
return device.app.callVersion >= minAndroidVersion;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
};
|
|
@@ -24,8 +24,11 @@ Comlink.transferHandlers.set("FUNCTION", {
|
|
|
24
24
|
},
|
|
25
25
|
deserialize(obj) {
|
|
26
26
|
obj._functionKeys.forEach(x => {
|
|
27
|
-
|
|
28
|
-
obj[x]
|
|
27
|
+
// under certain conditions deserialize can be called more than once on same object
|
|
28
|
+
if (obj[x] instanceof MessagePort) {
|
|
29
|
+
obj[x].start();
|
|
30
|
+
obj[x] = Comlink.wrap(obj[x]);
|
|
31
|
+
}
|
|
29
32
|
});
|
|
30
33
|
return obj;
|
|
31
34
|
}
|