chayns-api 2.6.0-beta.2 → 2.6.0-beta.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/.github/workflows/publish.yml +7 -2
- package/dist/cjs/calls/dialogs/date.js +1 -1
- package/dist/cjs/calls/dialogs/iFrame.js +9 -6
- package/dist/cjs/calls/index.js +3 -1
- package/dist/cjs/components/ChaynsProvider.js +2 -3
- package/dist/cjs/components/withCompatMode.js +2 -2
- package/dist/cjs/components/withHydrationBoundary.js +1 -2
- package/dist/cjs/host/ChaynsHost.js +1 -2
- package/dist/cjs/host/iframe/HostIframe.js +1 -2
- package/dist/cjs/host/module/ModuleHost.js +1 -2
- package/dist/cjs/host/module/utils/loadComponent.js +1 -16
- package/dist/cjs/index.js +1 -2
- package/dist/cjs/plugins/TrustedDomainsPlugins.js +29 -0
- package/dist/cjs/plugins/index.js +8 -1
- package/dist/cjs/types/IChaynsReact.js +3 -7
- package/dist/cjs/types/global.d.js +1 -0
- package/dist/cjs/umd.index.js +1 -2
- package/dist/cjs/util/deviceHelper.js +17 -4
- package/dist/cjs/util/initModuleFederationSharing.js +2 -2
- package/dist/cjs/util/is.js +9 -4
- package/dist/cjs/util/transferNestedFunctions.js +1 -2
- package/dist/cjs/wrapper/AppWrapper.js +9 -3
- package/dist/cjs/wrapper/FrameWrapper.js +6 -3
- package/dist/cjs/wrapper/StaticChaynsApi.js +1 -3
- package/dist/esm/calls/dialogs/alert.js +1 -3
- package/dist/esm/calls/dialogs/communication.js +3 -6
- package/dist/esm/calls/dialogs/confirm.js +1 -4
- package/dist/esm/calls/dialogs/date.js +4 -8
- package/dist/esm/calls/dialogs/dropUpAlert.js +1 -2
- package/dist/esm/calls/dialogs/fileSelect.js +1 -2
- package/dist/esm/calls/dialogs/iFrame.js +11 -9
- package/dist/esm/calls/dialogs/input.js +1 -2
- package/dist/esm/calls/dialogs/mediaSelect.js +1 -2
- package/dist/esm/calls/dialogs/toast.js +1 -2
- package/dist/esm/calls/dialogs/utils/callback.js +1 -2
- package/dist/esm/calls/index.js +53 -156
- package/dist/esm/components/ChaynsProvider.js +18 -21
- package/dist/esm/components/WaitUntil.js +5 -6
- package/dist/esm/components/withCompatMode.js +1 -0
- package/dist/esm/components/withHydrationBoundary.js +5 -6
- package/dist/esm/handler/DialogHandler.js +1 -2
- package/dist/esm/hooks/geoLocationListener.js +5 -6
- package/dist/esm/hooks/scrollListener.js +12 -15
- package/dist/esm/hooks/usePages.js +16 -19
- package/dist/esm/hooks/windowMetricsListener.js +3 -4
- package/dist/esm/host/ChaynsHost.js +23 -24
- package/dist/esm/host/iframe/HostIframe.js +21 -22
- package/dist/esm/host/module/ModuleHost.js +24 -26
- package/dist/esm/host/module/utils/loadComponent.js +3 -21
- package/dist/esm/plugins/TrustedDomainsPlugins.js +25 -0
- package/dist/esm/plugins/index.js +2 -1
- package/dist/esm/types/IChaynsReact.js +2 -6
- package/dist/esm/types/global.d.js +0 -0
- package/dist/esm/util/appStorage.js +3 -6
- package/dist/esm/util/deviceHelper.js +20 -8
- package/dist/esm/util/initModuleFederationSharing.js +6 -7
- package/dist/esm/util/is.js +11 -8
- package/dist/esm/util/transferNestedFunctions.js +1 -2
- package/dist/esm/wrapper/AppWrapper.js +23 -26
- package/dist/esm/wrapper/FrameWrapper.js +14 -21
- package/dist/esm/wrapper/ModuleFederationWrapper.js +2 -5
- package/dist/esm/wrapper/StaticChaynsApi.js +2 -5
- package/dist/types/calls/dialogs/iFrame.d.ts +10 -4
- package/dist/types/calls/index.d.ts +2 -0
- package/dist/types/host/module/utils/loadComponent.d.ts +2 -1
- package/dist/types/plugins/SSRManifestPlugin.d.ts +2 -2
- package/dist/types/plugins/SequentialLoadPlugin.d.ts +2 -2
- package/dist/types/plugins/TrustedDomainsPlugins.d.ts +2 -0
- package/dist/types/plugins/index.d.ts +1 -0
- package/dist/types/types/IChaynsReact.d.ts +29 -12
- package/dist/types/util/is.d.ts +1 -0
- package/dist/types/wrapper/StaticChaynsApi.d.ts +68 -4
- package/eslint.config.mjs +3 -0
- package/package.json +32 -22
- package/{toolkit.config.js → toolkit.config.ts} +6 -3
- package/tsconfig.json +1 -0
- package/.eslintrc +0 -17
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import React, { startTransition, useEffect, useState } from 'react';
|
|
2
2
|
import HostIframe from './iframe/HostIframe';
|
|
3
3
|
import ModuleHost from './module/ModuleHost';
|
|
4
|
-
const ChaynsHost =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} = _ref;
|
|
4
|
+
const ChaynsHost = ({
|
|
5
|
+
type,
|
|
6
|
+
iFrameProps,
|
|
7
|
+
functions,
|
|
8
|
+
customFunctions,
|
|
9
|
+
src,
|
|
10
|
+
iFrameRef = undefined,
|
|
11
|
+
loadingComponent = undefined,
|
|
12
|
+
system,
|
|
13
|
+
pages,
|
|
14
|
+
language,
|
|
15
|
+
isAdminModeActive,
|
|
16
|
+
site,
|
|
17
|
+
user,
|
|
18
|
+
currentPage,
|
|
19
|
+
device,
|
|
20
|
+
parameters,
|
|
21
|
+
customData,
|
|
22
|
+
environment,
|
|
23
|
+
preventStagingReplacement,
|
|
24
|
+
dialog,
|
|
25
|
+
styleSettings
|
|
26
|
+
}) => {
|
|
28
27
|
const [isVisible, setIsVisible] = useState(type !== 'client-module' && (type !== 'server-module' || !!(system !== null && system !== void 0 && system.serverUrl)));
|
|
29
28
|
useEffect(() => {
|
|
30
29
|
if (isVisible) return;
|
|
@@ -4,28 +4,27 @@ import * as comlink from 'comlink';
|
|
|
4
4
|
import postIframeForm from '../../util/postIframeForm';
|
|
5
5
|
import useUpdateData from './utils/useUpdateData';
|
|
6
6
|
import { replaceStagingUrl } from "../../util/url";
|
|
7
|
-
const HostIframe =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} = _ref;
|
|
7
|
+
const HostIframe = ({
|
|
8
|
+
iFrameProps,
|
|
9
|
+
src,
|
|
10
|
+
postForm = false,
|
|
11
|
+
iFrameRef,
|
|
12
|
+
pages,
|
|
13
|
+
isAdminModeActive,
|
|
14
|
+
site,
|
|
15
|
+
user,
|
|
16
|
+
currentPage,
|
|
17
|
+
functions,
|
|
18
|
+
customFunctions,
|
|
19
|
+
device,
|
|
20
|
+
language,
|
|
21
|
+
parameters,
|
|
22
|
+
environment,
|
|
23
|
+
customData,
|
|
24
|
+
preventStagingReplacement,
|
|
25
|
+
dialog,
|
|
26
|
+
styleSettings
|
|
27
|
+
}) => {
|
|
29
28
|
const eventTarget = useRef();
|
|
30
29
|
const ref = useRef();
|
|
31
30
|
const currentDataRef = useRef();
|
|
@@ -2,12 +2,11 @@ import React, { useContext, useMemo } from 'react';
|
|
|
2
2
|
import { ModuleContext } from '../../constants/moduleContext';
|
|
3
3
|
import loadComponent from './utils/loadComponent';
|
|
4
4
|
import { replaceStagingUrl } from "../../util/url";
|
|
5
|
-
const System =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} = _ref;
|
|
5
|
+
const System = ({
|
|
6
|
+
system,
|
|
7
|
+
fallback,
|
|
8
|
+
...props
|
|
9
|
+
}) => {
|
|
11
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]);
|
|
12
11
|
if (!globalThis.window) {
|
|
13
12
|
var _system$scope, _moduleContext$_syste;
|
|
@@ -22,26 +21,25 @@ const System = _ref => {
|
|
|
22
21
|
fallback: fallback || ''
|
|
23
22
|
}, React.createElement(Component, props));
|
|
24
23
|
};
|
|
25
|
-
const ModuleHost =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} = _ref2;
|
|
24
|
+
const ModuleHost = ({
|
|
25
|
+
system,
|
|
26
|
+
children = null,
|
|
27
|
+
functions,
|
|
28
|
+
customFunctions,
|
|
29
|
+
pages,
|
|
30
|
+
isAdminModeActive,
|
|
31
|
+
site,
|
|
32
|
+
user,
|
|
33
|
+
currentPage,
|
|
34
|
+
device,
|
|
35
|
+
language,
|
|
36
|
+
parameters,
|
|
37
|
+
customData,
|
|
38
|
+
dialog,
|
|
39
|
+
environment,
|
|
40
|
+
preventStagingReplacement,
|
|
41
|
+
styleSettings
|
|
42
|
+
}) => {
|
|
45
43
|
const data = useMemo(() => {
|
|
46
44
|
const result = {
|
|
47
45
|
site,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export const loadModule =
|
|
3
|
-
let preventSingleton = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
2
|
+
export const loadModule = (scope, module, url, preventSingleton = false) => {
|
|
4
3
|
if (!globalThis.moduleFederationRuntime || !globalThis.moduleFederationScopes) {
|
|
5
4
|
throw new Error('[chayns-api] moduleFederationSharing has not been initialized. Make sure to call initModuleFederationSharing.');
|
|
6
5
|
}
|
|
@@ -43,9 +42,7 @@ export const loadModule = function (scope, module, url) {
|
|
|
43
42
|
}
|
|
44
43
|
return moduleMap[scope][module];
|
|
45
44
|
};
|
|
46
|
-
const loadComponent =
|
|
47
|
-
let skipCompatMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
48
|
-
let preventSingleton = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
45
|
+
const loadComponent = (scope, module, url, skipCompatMode = false, preventSingleton = false) => {
|
|
49
46
|
if (skipCompatMode) {
|
|
50
47
|
console.warn('[chayns-api] skipCompatMode-option is deprecated and is set automatically now');
|
|
51
48
|
}
|
|
@@ -53,7 +50,6 @@ const loadComponent = function (scope, module, url) {
|
|
|
53
50
|
throw new Error('[chayns-api] moduleFederationSharing has not been initialized. Make sure to call initModuleFederationSharing.');
|
|
54
51
|
}
|
|
55
52
|
const {
|
|
56
|
-
loadShareSync,
|
|
57
53
|
getInstance
|
|
58
54
|
} = globalThis.moduleFederationRuntime;
|
|
59
55
|
const {
|
|
@@ -69,21 +65,7 @@ const loadComponent = function (scope, module, url) {
|
|
|
69
65
|
if (typeof Module.default === 'function') {
|
|
70
66
|
return Module;
|
|
71
67
|
}
|
|
72
|
-
const shareScopes =
|
|
73
|
-
loadShareSync('react', {
|
|
74
|
-
resolver: shareOptions => {
|
|
75
|
-
const optionsMap = shareOptions.reduce((p, e) => {
|
|
76
|
-
p[e.version] = e;
|
|
77
|
-
e.version;
|
|
78
|
-
return p;
|
|
79
|
-
}, {});
|
|
80
|
-
resolve({
|
|
81
|
-
'chayns-api': optionsMap
|
|
82
|
-
});
|
|
83
|
-
return shareOptions[0];
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
68
|
+
const shareScopes = getInstance().shareScopeMap;
|
|
87
69
|
const sharedReact = (_shareScopes$chaynsA = shareScopes['chayns-api'].react) === null || _shareScopes$chaynsA === void 0 ? void 0 : _shareScopes$chaynsA[React.version];
|
|
88
70
|
const matchReactVersion = sharedReact && sharedReact.useIn.includes(scope) && ((_sharedReact$lib = sharedReact.lib) === null || _sharedReact$lib === void 0 ? void 0 : _sharedReact$lib.call(sharedReact)) === React;
|
|
89
71
|
if (!matchReactVersion || Module.default.environment !== 'production' || (Module.default.version || 1) < 2) {
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
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
|
+
class TrustedDomainsError extends Error {
|
|
5
|
+
constructor(entry) {
|
|
6
|
+
super('Remote entry ' + entry + ' is not in trusted domains');
|
|
7
|
+
_defineProperty(this, "name", 'TrustedDomainsError');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export const TrustedDomainsPlugin = (trustedDomains = []) => {
|
|
11
|
+
return {
|
|
12
|
+
name: 'trusted-domains',
|
|
13
|
+
beforeRequest(args) {
|
|
14
|
+
args.options.remotes.forEach(remote => {
|
|
15
|
+
if ('entry' in remote) {
|
|
16
|
+
const parsed = new URL(remote.entry);
|
|
17
|
+
if (!trustedDomains.some(domain => parsed.hostname.endsWith(domain))) {
|
|
18
|
+
throw new TrustedDomainsError(remote.entry);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return args;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { SSRManifestPlugin } from './SSRManifestPlugin';
|
|
1
|
+
export { SSRManifestPlugin } from './SSRManifestPlugin';
|
|
2
|
+
export { TrustedDomainsPlugin } from './TrustedDomainsPlugins';
|
|
@@ -60,6 +60,7 @@ export let ScreenSize = function (ScreenSize) {
|
|
|
60
60
|
export let AppFlavor = function (AppFlavor) {
|
|
61
61
|
AppFlavor["None"] = "none";
|
|
62
62
|
AppFlavor["Chayns"] = "chayns";
|
|
63
|
+
AppFlavor["Electron"] = "electron";
|
|
63
64
|
return AppFlavor;
|
|
64
65
|
}({});
|
|
65
66
|
export let AccessMode = function (AccessMode) {
|
|
@@ -135,12 +136,6 @@ export let DesignSettingsUpdateCoverTypes = function (DesignSettingsUpdateCoverT
|
|
|
135
136
|
DesignSettingsUpdateCoverTypes[DesignSettingsUpdateCoverTypes["None"] = 4] = "None";
|
|
136
137
|
return DesignSettingsUpdateCoverTypes;
|
|
137
138
|
}({});
|
|
138
|
-
export let DesignSettingsUpdateColorSchemeMode = function (DesignSettingsUpdateColorSchemeMode) {
|
|
139
|
-
DesignSettingsUpdateColorSchemeMode[DesignSettingsUpdateColorSchemeMode["Normal"] = 0] = "Normal";
|
|
140
|
-
DesignSettingsUpdateColorSchemeMode[DesignSettingsUpdateColorSchemeMode["Dark"] = 1] = "Dark";
|
|
141
|
-
DesignSettingsUpdateColorSchemeMode[DesignSettingsUpdateColorSchemeMode["Bright"] = 2] = "Bright";
|
|
142
|
-
return DesignSettingsUpdateColorSchemeMode;
|
|
143
|
-
}({});
|
|
144
139
|
export let DesignSettingsUpdateTappViewModes = function (DesignSettingsUpdateTappViewModes) {
|
|
145
140
|
DesignSettingsUpdateTappViewModes[DesignSettingsUpdateTappViewModes["Normal"] = 0] = "Normal";
|
|
146
141
|
DesignSettingsUpdateTappViewModes[DesignSettingsUpdateTappViewModes["Exclusive"] = 1] = "Exclusive";
|
|
@@ -251,6 +246,7 @@ export let AppName = function (AppName) {
|
|
|
251
246
|
AppName[AppName["Team"] = 8] = "Team";
|
|
252
247
|
AppName[AppName["CityApp"] = 9] = "CityApp";
|
|
253
248
|
AppName[AppName["ElectronChayns"] = 10] = "ElectronChayns";
|
|
249
|
+
AppName[AppName["ElectronTeam"] = 11] = "ElectronTeam";
|
|
254
250
|
return AppName;
|
|
255
251
|
}({});
|
|
256
252
|
export let BrowserName = function (BrowserName) {
|
|
File without changes
|
|
@@ -7,8 +7,7 @@ export function isAppStorageAvailable() {
|
|
|
7
7
|
}
|
|
8
8
|
return ((_this$values$device$a2 = this.values.device.app) === null || _this$values$device$a2 === void 0 ? void 0 : _this$values$device$a2.appVersion) >= (['iOS', 'Mac OS'].includes(this.values.device.os) ? 1046 : 1033);
|
|
9
9
|
}
|
|
10
|
-
export function getAppStorageItem(storeName, key) {
|
|
11
|
-
let callbackPrefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'chaynsApiV5Callback';
|
|
10
|
+
export function getAppStorageItem(storeName, key, callbackPrefix = 'chaynsApiV5Callback') {
|
|
12
11
|
const callbackName = `${callbackPrefix}_${this.counter++}`;
|
|
13
12
|
return new Promise(resolve => {
|
|
14
13
|
window[callbackName] = (_key, _storeName, value) => {
|
|
@@ -31,8 +30,7 @@ export function getAppStorageItem(storeName, key) {
|
|
|
31
30
|
}
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
|
-
export function setAppStorageItem(storeName, key, value) {
|
|
35
|
-
let callbackPrefix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'chaynsApiV5Callback';
|
|
33
|
+
export function setAppStorageItem(storeName, key, value, callbackPrefix = 'chaynsApiV5Callback') {
|
|
36
34
|
const callbackName = `${callbackPrefix}_${this.counter++}`;
|
|
37
35
|
return new Promise((resolve, reject) => {
|
|
38
36
|
window[callbackName] = () => {
|
|
@@ -70,8 +68,7 @@ export function clearAppStorage(storeName) {
|
|
|
70
68
|
window.chaynsWebViewStorage.chaynsDataErase(storeName);
|
|
71
69
|
}
|
|
72
70
|
}
|
|
73
|
-
export async function addAppStorageListener(storeName, prefix, callback) {
|
|
74
|
-
let callbackPrefix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'chaynsApiV5Callback';
|
|
71
|
+
export async function addAppStorageListener(storeName, prefix, callback, callbackPrefix = 'chaynsApiV5Callback') {
|
|
75
72
|
const callbackName = `${callbackPrefix}_${this.counter++}`;
|
|
76
73
|
const {
|
|
77
74
|
shouldInitialize
|
|
@@ -1,32 +1,44 @@
|
|
|
1
1
|
import { UAParser } from 'ua-parser-js';
|
|
2
2
|
import { AppFlavor, AppName, ScreenSize } from '../types/IChaynsReact';
|
|
3
|
-
const getDeviceInfo =
|
|
3
|
+
const getDeviceInfo = (userAgent, acceptHeader, {
|
|
4
|
+
imei
|
|
5
|
+
} = {}) => {
|
|
4
6
|
var _match$groups, _match$groups2, _customMatch$groups, _browser$version$spli, _browser$version, _uaParser$getOS, _uaParser$getOS2, _uaParser$getOS3;
|
|
5
|
-
let {
|
|
6
|
-
imei
|
|
7
|
-
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
8
7
|
const uaParser = new UAParser(userAgent);
|
|
9
8
|
let appName = AppName.Unknown;
|
|
10
|
-
|
|
11
|
-
const
|
|
9
|
+
let appFlavor = AppFlavor.None;
|
|
10
|
+
const match = /(?:^|\s)(?:my)?chayns\/(?<version>\d+).*(?<siteId>\d{5}-\d{5})/i.exec(userAgent);
|
|
11
|
+
const customMatch = /\s(?<name>intercom|sidekick|team|cityApp|electron-chayns|electron-d3sc|electron-team)\/(?<version>\d+)/i.exec(userAgent);
|
|
12
12
|
if (/\sintercom\/\d+/i.test(userAgent)) {
|
|
13
13
|
appName = AppName.TobitChat;
|
|
14
|
+
appFlavor = AppFlavor.Chayns;
|
|
14
15
|
} else if (/\ssidekick\/\d+/i.test(userAgent)) {
|
|
15
16
|
appName = AppName.Sidekick;
|
|
17
|
+
appFlavor = AppFlavor.Chayns;
|
|
16
18
|
} else if (/\steam\/\d+/i.test(userAgent)) {
|
|
17
19
|
appName = AppName.Team;
|
|
20
|
+
appFlavor = AppFlavor.Chayns;
|
|
18
21
|
} else if (/\scityApp\/\d+/i.test(userAgent)) {
|
|
19
22
|
appName = AppName.CityApp;
|
|
23
|
+
appFlavor = AppFlavor.Chayns;
|
|
20
24
|
} else if ((match === null || match === void 0 || (_match$groups = match.groups) === null || _match$groups === void 0 ? void 0 : _match$groups.siteId) === '60021-08989') {
|
|
21
25
|
appName = AppName.Chayns;
|
|
26
|
+
appFlavor = AppFlavor.Chayns;
|
|
22
27
|
} else if ((match === null || match === void 0 || (_match$groups2 = match.groups) === null || _match$groups2 === void 0 ? void 0 : _match$groups2.siteId) === '77892-10814') {
|
|
23
28
|
appName = AppName.David;
|
|
29
|
+
appFlavor = AppFlavor.Chayns;
|
|
24
30
|
} else if (match) {
|
|
25
31
|
appName = AppName.Location;
|
|
32
|
+
appFlavor = AppFlavor.Chayns;
|
|
26
33
|
} else if (/dface|h96pp|h96max|jabiru|chaynsterminal|wayter|odroidn2p|chayns-runtime-custom/i.test(userAgent)) {
|
|
27
34
|
appName = AppName.ChaynsLauncher;
|
|
35
|
+
appFlavor = AppFlavor.Chayns;
|
|
28
36
|
} else if (/electron-chayns|electron-d3sc/i.test(userAgent)) {
|
|
29
37
|
appName = AppName.ElectronChayns;
|
|
38
|
+
appFlavor = AppFlavor.Electron;
|
|
39
|
+
} else if (/electron-team/i.test(userAgent)) {
|
|
40
|
+
appName = AppName.ElectronTeam;
|
|
41
|
+
appFlavor = AppFlavor.Electron;
|
|
30
42
|
}
|
|
31
43
|
let appVersion = match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN;
|
|
32
44
|
if (customMatch !== null && customMatch !== void 0 && (_customMatch$groups = customMatch.groups) !== null && _customMatch$groups !== void 0 && _customMatch$groups.version) {
|
|
@@ -42,7 +54,7 @@ const getDeviceInfo = function (userAgent, acceptHeader) {
|
|
|
42
54
|
};
|
|
43
55
|
result.app = {
|
|
44
56
|
name: appName,
|
|
45
|
-
flavor:
|
|
57
|
+
flavor: appFlavor,
|
|
46
58
|
version: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN,
|
|
47
59
|
appVersion,
|
|
48
60
|
callVersion: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
|
|
@@ -56,7 +68,7 @@ const getDeviceInfo = function (userAgent, acceptHeader) {
|
|
|
56
68
|
result.isTouch = getClientDeviceInfo().isTouch;
|
|
57
69
|
} else {
|
|
58
70
|
const screenSizeByUA = /mobi/i.test(userAgent) ? ScreenSize.SM : ScreenSize.XL;
|
|
59
|
-
result.screenSize =
|
|
71
|
+
result.screenSize = appFlavor === AppFlavor.Chayns ? ScreenSize.XS : screenSizeByUA;
|
|
60
72
|
}
|
|
61
73
|
return result;
|
|
62
74
|
};
|
|
@@ -5,11 +5,10 @@ let ReactDOMClient;
|
|
|
5
5
|
try {
|
|
6
6
|
ReactDOMClient = require('react-dom/client');
|
|
7
7
|
} catch (e) {}
|
|
8
|
-
export const initModuleFederationSharing =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} = _ref;
|
|
8
|
+
export const initModuleFederationSharing = ({
|
|
9
|
+
name,
|
|
10
|
+
plugins = []
|
|
11
|
+
}) => {
|
|
13
12
|
if (globalThis.moduleFederationRuntime) {
|
|
14
13
|
return;
|
|
15
14
|
}
|
|
@@ -20,7 +19,7 @@ export const initModuleFederationSharing = _ref => {
|
|
|
20
19
|
componentMap: {}
|
|
21
20
|
};
|
|
22
21
|
const {
|
|
23
|
-
|
|
22
|
+
createInstance
|
|
24
23
|
} = globalThis.moduleFederationRuntime;
|
|
25
24
|
const shared = {
|
|
26
25
|
react: {
|
|
@@ -41,7 +40,7 @@ export const initModuleFederationSharing = _ref => {
|
|
|
41
40
|
lib: () => ReactDOMClient
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
|
-
|
|
43
|
+
createInstance({
|
|
45
44
|
name: name !== null && name !== void 0 ? name : '',
|
|
46
45
|
remotes: [],
|
|
47
46
|
shared,
|
package/dist/esm/util/is.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { getDevice } from '../calls';
|
|
2
|
-
import {
|
|
2
|
+
import { AppFlavor } from '../types/IChaynsReact';
|
|
3
3
|
export const isApp = () => {
|
|
4
|
-
var _getDevice$app
|
|
5
|
-
return ((_getDevice$app
|
|
4
|
+
var _getDevice$app;
|
|
5
|
+
return ((_getDevice$app = getDevice().app) === null || _getDevice$app === void 0 ? void 0 : _getDevice$app.flavor) === AppFlavor.Chayns;
|
|
6
6
|
};
|
|
7
|
-
export const isAppCallSupported =
|
|
7
|
+
export const isAppCallSupported = ({
|
|
8
|
+
minAndroidVersion = 1,
|
|
9
|
+
minIOSVersion = 1
|
|
10
|
+
}) => {
|
|
8
11
|
var _device$app;
|
|
9
|
-
let {
|
|
10
|
-
minAndroidVersion = 1,
|
|
11
|
-
minIOSVersion = 1
|
|
12
|
-
} = _ref;
|
|
13
12
|
if (!isApp()) return false;
|
|
14
13
|
const device = getDevice();
|
|
15
14
|
if (!((_device$app = device.app) !== null && _device$app !== void 0 && _device$app.callVersion) || isNaN(device.app.callVersion)) return false;
|
|
@@ -20,4 +19,8 @@ export const isAppCallSupported = _ref => {
|
|
|
20
19
|
return device.app.callVersion >= minAndroidVersion;
|
|
21
20
|
}
|
|
22
21
|
return false;
|
|
22
|
+
};
|
|
23
|
+
export const isElectron = () => {
|
|
24
|
+
var _getDevice$app2;
|
|
25
|
+
return ((_getDevice$app2 = getDevice().app) === null || _getDevice$app2 === void 0 ? void 0 : _getDevice$app2.flavor) === AppFlavor.Electron;
|
|
23
26
|
};
|
|
@@ -6,8 +6,7 @@ Comlink.transferHandlers.set("FUNCTION", {
|
|
|
6
6
|
serialize(obj) {
|
|
7
7
|
obj._functionKeys = [];
|
|
8
8
|
const ports = [];
|
|
9
|
-
Object.entries(obj).forEach(
|
|
10
|
-
let [k, v] = _ref;
|
|
9
|
+
Object.entries(obj).forEach(([k, v]) => {
|
|
11
10
|
if (typeof v === 'function') {
|
|
12
11
|
const {
|
|
13
12
|
port1,
|
|
@@ -4,6 +4,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
4
4
|
import throttle from 'lodash.throttle';
|
|
5
5
|
import getUserInfo from '../calls/getUserInfo';
|
|
6
6
|
import { sendMessageToGroup, sendMessageToPage, sendMessageToUser } from '../calls/sendMessage';
|
|
7
|
+
import { DefaultLoginDialogOptions } from '../constants';
|
|
7
8
|
import { DeviceLanguage } from '../constants/languages';
|
|
8
9
|
import DialogHandler from '../handler/DialogHandler';
|
|
9
10
|
import { addApiListener, dispatchApiEvent, removeApiListener } from '../helper/apiListenerHelper';
|
|
@@ -12,7 +13,6 @@ import invokeAppCall from '../util/appCall';
|
|
|
12
13
|
import { addAppStorageListener, clearAppStorage, isAppStorageAvailable, setAppStorageItem } from '../util/appStorage';
|
|
13
14
|
import getDeviceInfo, { getScreenSize } from '../util/deviceHelper';
|
|
14
15
|
import { isAppCallSupported } from '../util/is';
|
|
15
|
-
import { DefaultLoginDialogOptions } from '../constants';
|
|
16
16
|
export class AppWrapper {
|
|
17
17
|
async loadStyleSettings(siteId) {
|
|
18
18
|
try {
|
|
@@ -145,7 +145,6 @@ export class AppWrapper {
|
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
147
|
constructor() {
|
|
148
|
-
var _this = this;
|
|
149
148
|
_defineProperty(this, "values", null);
|
|
150
149
|
_defineProperty(this, "accessToken", '');
|
|
151
150
|
_defineProperty(this, "listeners", []);
|
|
@@ -297,12 +296,16 @@ export class AppWrapper {
|
|
|
297
296
|
callback
|
|
298
297
|
});
|
|
299
298
|
},
|
|
299
|
+
invokePaymentCall: async (value, callback) => {
|
|
300
|
+
return this.appCall(value.action, value.value, {
|
|
301
|
+
callback
|
|
302
|
+
});
|
|
303
|
+
},
|
|
300
304
|
invokeDialogCall: async (value, callback) => {
|
|
301
305
|
const callbackName = `chaynsApiV5Callback_${this.counter++}`;
|
|
302
|
-
window[callbackName] =
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
} = _ref;
|
|
306
|
+
window[callbackName] = ({
|
|
307
|
+
retVal
|
|
308
|
+
}) => {
|
|
306
309
|
callback === null || callback === void 0 || callback(retVal);
|
|
307
310
|
delete window[callbackName];
|
|
308
311
|
};
|
|
@@ -315,20 +318,18 @@ export class AppWrapper {
|
|
|
315
318
|
};
|
|
316
319
|
invokeAppCall(callObj);
|
|
317
320
|
},
|
|
318
|
-
login: async
|
|
319
|
-
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
320
|
-
let callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
321
|
-
let closeCallback = arguments.length > 2 ? arguments[2] : undefined;
|
|
321
|
+
login: async (value = {}, callback, closeCallback) => {
|
|
322
322
|
const {
|
|
323
323
|
result,
|
|
324
324
|
buttonType
|
|
325
|
-
} = await
|
|
325
|
+
} = await this.functions.createDialog({
|
|
326
326
|
...DefaultLoginDialogOptions,
|
|
327
327
|
...value
|
|
328
328
|
}).open();
|
|
329
329
|
if (buttonType === DialogButtonType.OK && result.token) {
|
|
330
330
|
const response = {
|
|
331
331
|
loginState: LoginState.SUCCESS,
|
|
332
|
+
buttonType,
|
|
332
333
|
...result
|
|
333
334
|
};
|
|
334
335
|
if (callback) callback(response);
|
|
@@ -336,6 +337,7 @@ export class AppWrapper {
|
|
|
336
337
|
}
|
|
337
338
|
const response = {
|
|
338
339
|
loginState: LoginState.LoginFailed,
|
|
340
|
+
buttonType,
|
|
339
341
|
...result
|
|
340
342
|
};
|
|
341
343
|
if (closeCallback) closeCallback(response);
|
|
@@ -431,8 +433,7 @@ export class AppWrapper {
|
|
|
431
433
|
url.pathname += `/${options.path}`;
|
|
432
434
|
}
|
|
433
435
|
if (options.params) {
|
|
434
|
-
Object.entries(options.params).forEach(
|
|
435
|
-
let [k, v] = _ref2;
|
|
436
|
+
Object.entries(options.params).forEach(([k, v]) => {
|
|
436
437
|
url.searchParams.set(k, v);
|
|
437
438
|
});
|
|
438
439
|
}
|
|
@@ -612,9 +613,8 @@ export class AppWrapper {
|
|
|
612
613
|
});
|
|
613
614
|
return currentDialogId;
|
|
614
615
|
},
|
|
615
|
-
closeDialog:
|
|
616
|
-
|
|
617
|
-
const dialog = _this.dialogs.find(x => x.dialogId === dialogId);
|
|
616
|
+
closeDialog: (dialogId, result, buttonType = -1) => {
|
|
617
|
+
const dialog = this.dialogs.find(x => x.dialogId === dialogId);
|
|
618
618
|
if (dialog) {
|
|
619
619
|
dialog.resolve({
|
|
620
620
|
buttonType,
|
|
@@ -684,12 +684,10 @@ export class AppWrapper {
|
|
|
684
684
|
notImplemented(call) {
|
|
685
685
|
console.warn(`call ${call} not implement in app`);
|
|
686
686
|
}
|
|
687
|
-
appCall(action
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
awaitResult = true
|
|
692
|
-
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
687
|
+
appCall(action, value = {}, {
|
|
688
|
+
callback,
|
|
689
|
+
awaitResult = true
|
|
690
|
+
} = {}) {
|
|
693
691
|
if (!awaitResult) {
|
|
694
692
|
invokeAppCall({
|
|
695
693
|
action,
|
|
@@ -742,10 +740,9 @@ export class AppWrapper {
|
|
|
742
740
|
this.appCall(254, {
|
|
743
741
|
enabled: true
|
|
744
742
|
}, {
|
|
745
|
-
callback:
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
} = _ref3;
|
|
743
|
+
callback: ({
|
|
744
|
+
colorMode
|
|
745
|
+
}) => {
|
|
749
746
|
this.values = {
|
|
750
747
|
...this.values,
|
|
751
748
|
site: {
|
|
@@ -9,7 +9,6 @@ import { sendMessageToGroup, sendMessageToPage, sendMessageToUser } from '../cal
|
|
|
9
9
|
import { setTappHeight } from '../util/heightHelper';
|
|
10
10
|
export class FrameWrapper {
|
|
11
11
|
constructor() {
|
|
12
|
-
var _this = this;
|
|
13
12
|
_defineProperty(this, "resolve", null);
|
|
14
13
|
_defineProperty(this, "exposedFunctions", null);
|
|
15
14
|
_defineProperty(this, "exposedCustomFunctions", {});
|
|
@@ -33,7 +32,7 @@ export class FrameWrapper {
|
|
|
33
32
|
if (!this.initialized) await this.ready;
|
|
34
33
|
try {
|
|
35
34
|
return await this.exposedFunctions.addVisibilityChangeListener(comlink.proxy(result => callback(result)));
|
|
36
|
-
} catch
|
|
35
|
+
} catch {
|
|
37
36
|
return addVisibilityChangeListener(callback);
|
|
38
37
|
}
|
|
39
38
|
},
|
|
@@ -83,6 +82,10 @@ export class FrameWrapper {
|
|
|
83
82
|
if (!this.initialized) await this.ready;
|
|
84
83
|
return this.exposedFunctions.invokeCall(value, callback && comlink.proxy(result => callback(result)));
|
|
85
84
|
},
|
|
85
|
+
invokePaymentCall: async (value, callback) => {
|
|
86
|
+
if (!this.initialized) await this.ready;
|
|
87
|
+
return this.exposedFunctions.invokePaymentCall(value, callback && comlink.proxy(result => callback(result)));
|
|
88
|
+
},
|
|
86
89
|
invokeDialogCall: async (value, callback) => {
|
|
87
90
|
if (!this.initialized) await this.ready;
|
|
88
91
|
return this.exposedFunctions.invokeDialogCall(value, callback && comlink.proxy(result => callback(result)));
|
|
@@ -299,13 +302,10 @@ export class FrameWrapper {
|
|
|
299
302
|
if (p in target) {
|
|
300
303
|
return target[p];
|
|
301
304
|
}
|
|
302
|
-
return target[p] = async
|
|
303
|
-
if (!
|
|
304
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
305
|
-
args[_key] = arguments[_key];
|
|
306
|
-
}
|
|
305
|
+
return target[p] = async (...args) => {
|
|
306
|
+
if (!this.initialized) await this.ready;
|
|
307
307
|
const wrappedArgs = args.map(v => typeof v === 'function' ? comlink.proxy(v) : v);
|
|
308
|
-
return
|
|
308
|
+
return this.exposedCustomFunctions[p](...wrappedArgs);
|
|
309
309
|
};
|
|
310
310
|
}
|
|
311
311
|
}));
|
|
@@ -325,15 +325,13 @@ export class FrameWrapper {
|
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
async init() {
|
|
328
|
-
var _await$exposed$_custo
|
|
329
|
-
_this2 = this;
|
|
328
|
+
var _await$exposed$_custo;
|
|
330
329
|
if (this.initialized) return;
|
|
331
330
|
const exposed = comlink.wrap(comlink.windowEndpoint(window.parent))[window.name];
|
|
332
|
-
const dataListener = () => exposed.addDataListener(comlink.proxy(
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
} = _ref;
|
|
331
|
+
const dataListener = () => exposed.addDataListener(comlink.proxy(({
|
|
332
|
+
type,
|
|
333
|
+
value
|
|
334
|
+
}) => {
|
|
337
335
|
if (this.initialized) {
|
|
338
336
|
this.values = {
|
|
339
337
|
...this.values,
|
|
@@ -361,12 +359,7 @@ export class FrameWrapper {
|
|
|
361
359
|
this.exposedCustomFunctions = exposed.customFunctions;
|
|
362
360
|
this.exposedCustomFunctionNames = (_await$exposed$_custo = await exposed._customFunctionNames) !== null && _await$exposed$_custo !== void 0 ? _await$exposed$_custo : [];
|
|
363
361
|
this.customFunctions = this.exposedCustomFunctionNames.reduce((p, e) => {
|
|
364
|
-
p[e] = function ()
|
|
365
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
366
|
-
args[_key2] = arguments[_key2];
|
|
367
|
-
}
|
|
368
|
-
return _this2.exposedCustomFunctions[e](...args.map(a => typeof a === 'function' ? comlink.proxy(a) : a));
|
|
369
|
-
};
|
|
362
|
+
p[e] = (...args) => this.exposedCustomFunctions[e](...args.map(a => typeof a === 'function' ? comlink.proxy(a) : a));
|
|
370
363
|
return p;
|
|
371
364
|
}, {});
|
|
372
365
|
this.initialized = true;
|