chayns-api 2.6.0-beta.1 → 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.
Files changed (79) hide show
  1. package/.github/workflows/publish.yml +7 -2
  2. package/dist/cjs/calls/dialogs/date.js +1 -1
  3. package/dist/cjs/calls/dialogs/iFrame.js +9 -6
  4. package/dist/cjs/calls/index.js +3 -1
  5. package/dist/cjs/components/ChaynsProvider.js +2 -3
  6. package/dist/cjs/components/withCompatMode.js +2 -2
  7. package/dist/cjs/components/withHydrationBoundary.js +1 -2
  8. package/dist/cjs/host/ChaynsHost.js +1 -2
  9. package/dist/cjs/host/iframe/HostIframe.js +1 -2
  10. package/dist/cjs/host/module/ModuleHost.js +2 -3
  11. package/dist/cjs/host/module/utils/loadComponent.js +2 -17
  12. package/dist/cjs/index.js +1 -2
  13. package/dist/cjs/plugins/TrustedDomainsPlugins.js +29 -0
  14. package/dist/cjs/plugins/index.js +8 -1
  15. package/dist/cjs/types/IChaynsReact.js +3 -7
  16. package/dist/cjs/types/global.d.js +1 -0
  17. package/dist/cjs/umd.index.js +1 -2
  18. package/dist/cjs/util/collectCssChunks.js +3 -0
  19. package/dist/cjs/util/deviceHelper.js +17 -4
  20. package/dist/cjs/util/initModuleFederationSharing.js +2 -2
  21. package/dist/cjs/util/is.js +9 -4
  22. package/dist/cjs/util/transferNestedFunctions.js +1 -2
  23. package/dist/cjs/wrapper/AppWrapper.js +9 -3
  24. package/dist/cjs/wrapper/FrameWrapper.js +6 -3
  25. package/dist/cjs/wrapper/StaticChaynsApi.js +1 -3
  26. package/dist/esm/calls/dialogs/alert.js +1 -3
  27. package/dist/esm/calls/dialogs/communication.js +3 -6
  28. package/dist/esm/calls/dialogs/confirm.js +1 -4
  29. package/dist/esm/calls/dialogs/date.js +4 -8
  30. package/dist/esm/calls/dialogs/dropUpAlert.js +1 -2
  31. package/dist/esm/calls/dialogs/fileSelect.js +1 -2
  32. package/dist/esm/calls/dialogs/iFrame.js +11 -9
  33. package/dist/esm/calls/dialogs/input.js +1 -2
  34. package/dist/esm/calls/dialogs/mediaSelect.js +1 -2
  35. package/dist/esm/calls/dialogs/toast.js +1 -2
  36. package/dist/esm/calls/dialogs/utils/callback.js +1 -2
  37. package/dist/esm/calls/index.js +53 -156
  38. package/dist/esm/components/ChaynsProvider.js +18 -21
  39. package/dist/esm/components/WaitUntil.js +5 -6
  40. package/dist/esm/components/withCompatMode.js +1 -0
  41. package/dist/esm/components/withHydrationBoundary.js +5 -6
  42. package/dist/esm/handler/DialogHandler.js +1 -2
  43. package/dist/esm/hooks/geoLocationListener.js +5 -6
  44. package/dist/esm/hooks/scrollListener.js +12 -15
  45. package/dist/esm/hooks/usePages.js +16 -19
  46. package/dist/esm/hooks/windowMetricsListener.js +3 -4
  47. package/dist/esm/host/ChaynsHost.js +23 -24
  48. package/dist/esm/host/iframe/HostIframe.js +21 -22
  49. package/dist/esm/host/module/ModuleHost.js +25 -27
  50. package/dist/esm/host/module/utils/loadComponent.js +4 -22
  51. package/dist/esm/plugins/TrustedDomainsPlugins.js +25 -0
  52. package/dist/esm/plugins/index.js +2 -1
  53. package/dist/esm/types/IChaynsReact.js +2 -6
  54. package/dist/esm/types/global.d.js +0 -0
  55. package/dist/esm/util/appStorage.js +3 -6
  56. package/dist/esm/util/collectCssChunks.js +3 -0
  57. package/dist/esm/util/deviceHelper.js +20 -8
  58. package/dist/esm/util/initModuleFederationSharing.js +6 -7
  59. package/dist/esm/util/is.js +11 -8
  60. package/dist/esm/util/transferNestedFunctions.js +1 -2
  61. package/dist/esm/wrapper/AppWrapper.js +23 -26
  62. package/dist/esm/wrapper/FrameWrapper.js +14 -21
  63. package/dist/esm/wrapper/ModuleFederationWrapper.js +2 -5
  64. package/dist/esm/wrapper/StaticChaynsApi.js +2 -5
  65. package/dist/types/calls/dialogs/iFrame.d.ts +10 -4
  66. package/dist/types/calls/index.d.ts +2 -0
  67. package/dist/types/host/module/utils/loadComponent.d.ts +2 -1
  68. package/dist/types/plugins/SSRManifestPlugin.d.ts +2 -2
  69. package/dist/types/plugins/SequentialLoadPlugin.d.ts +2 -2
  70. package/dist/types/plugins/TrustedDomainsPlugins.d.ts +2 -0
  71. package/dist/types/plugins/index.d.ts +1 -0
  72. package/dist/types/types/IChaynsReact.d.ts +29 -12
  73. package/dist/types/util/is.d.ts +1 -0
  74. package/dist/types/wrapper/StaticChaynsApi.d.ts +68 -4
  75. package/eslint.config.mjs +3 -0
  76. package/package.json +32 -22
  77. package/{toolkit.config.js → toolkit.config.ts} +6 -3
  78. package/tsconfig.json +1 -0
  79. 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 = _ref => {
5
- let {
6
- type,
7
- iFrameProps,
8
- functions,
9
- customFunctions,
10
- src,
11
- iFrameRef = undefined,
12
- loadingComponent = undefined,
13
- system,
14
- pages,
15
- language,
16
- isAdminModeActive,
17
- site,
18
- user,
19
- currentPage,
20
- device,
21
- parameters,
22
- customData,
23
- environment,
24
- preventStagingReplacement,
25
- dialog,
26
- styleSettings
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 = _ref => {
8
- let {
9
- iFrameProps,
10
- src,
11
- postForm = false,
12
- iFrameRef,
13
- pages,
14
- isAdminModeActive,
15
- site,
16
- user,
17
- currentPage,
18
- functions,
19
- customFunctions,
20
- device,
21
- language,
22
- parameters,
23
- environment,
24
- customData,
25
- preventStagingReplacement,
26
- dialog,
27
- styleSettings
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,18 +2,17 @@ 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 = _ref => {
6
- let {
7
- system,
8
- fallback,
9
- ...props
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;
14
13
  const moduleContext = useContext(ModuleContext);
15
14
  (_moduleContext$_syste = moduleContext[_system$scope = system.scope]) !== null && _moduleContext$_syste !== void 0 ? _moduleContext$_syste : moduleContext[_system$scope] = {
16
- url: new URL('mf-manifest.json', system.url).toString(),
15
+ url: system.url,
17
16
  modules: new Set()
18
17
  };
19
18
  moduleContext[system.scope].modules.add(system.module);
@@ -22,26 +21,25 @@ const System = _ref => {
22
21
  fallback: fallback || ''
23
22
  }, React.createElement(Component, props));
24
23
  };
25
- const ModuleHost = _ref2 => {
26
- let {
27
- system,
28
- children = null,
29
- functions,
30
- customFunctions,
31
- pages,
32
- isAdminModeActive,
33
- site,
34
- user,
35
- currentPage,
36
- device,
37
- language,
38
- parameters,
39
- customData,
40
- dialog,
41
- environment,
42
- preventStagingReplacement,
43
- styleSettings
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 = function (scope, module, url) {
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
  }
@@ -21,7 +20,7 @@ export const loadModule = function (scope, module, url) {
21
20
  console.error(`[chayns-api] call registerRemote with force for scope ${scope}. url: ${url}`);
22
21
  }
23
22
  registerRemotes([{
24
- shareScope: url.endsWith('v2.remoteEntry.js') ? 'chayns-api' : 'default',
23
+ shareScope: url.endsWith('v2.remoteEntry.js') || url.endsWith('mf-manifest.json') ? 'chayns-api' : 'default',
25
24
  name: scope,
26
25
  entry: url,
27
26
  alias: scope
@@ -43,9 +42,7 @@ export const loadModule = function (scope, module, url) {
43
42
  }
44
43
  return moduleMap[scope][module];
45
44
  };
46
- const loadComponent = function (scope, module, url) {
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 = typeof getInstance === 'function' ? getInstance().shareScopeMap : await new Promise(resolve => {
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,5 +1,8 @@
1
1
  const remoteInfoCache = {};
2
2
  const loadRemoteInfo = async url => {
3
+ if (!url.endsWith('/mf-manifest.json')) {
4
+ return null;
5
+ }
3
6
  if (remoteInfoCache[url]) {
4
7
  return remoteInfoCache[url];
5
8
  }
@@ -1,32 +1,44 @@
1
1
  import { UAParser } from 'ua-parser-js';
2
2
  import { AppFlavor, AppName, ScreenSize } from '../types/IChaynsReact';
3
- const getDeviceInfo = function (userAgent, acceptHeader) {
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
- const match = /(?: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)\/(?<version>\d+)/i.exec(userAgent);
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: appName === AppName.Unknown || appName === AppName.ElectronChayns ? AppFlavor.None : AppFlavor.Chayns,
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 = appName !== AppName.Unknown && appName !== AppName.ElectronChayns ? ScreenSize.XS : screenSizeByUA;
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 = _ref => {
9
- let {
10
- name,
11
- plugins = []
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
- init
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
- init({
43
+ createInstance({
45
44
  name: name !== null && name !== void 0 ? name : '',
46
45
  remotes: [],
47
46
  shared,
@@ -1,15 +1,14 @@
1
1
  import { getDevice } from '../calls';
2
- import { AppName } from '../types/IChaynsReact';
2
+ import { AppFlavor } from '../types/IChaynsReact';
3
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;
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 = _ref => {
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(_ref => {
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] = _ref => {
303
- let {
304
- retVal
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 function () {
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 _this.functions.createDialog({
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(_ref2 => {
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: function (dialogId, result) {
616
- let buttonType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
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
- let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
689
- let {
690
- callback,
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: _ref3 => {
746
- let {
747
- colorMode
748
- } = _ref3;
743
+ callback: ({
744
+ colorMode
745
+ }) => {
749
746
  this.values = {
750
747
  ...this.values,
751
748
  site: {