chayns-api 2.6.0-beta.1 → 2.6.0-beta.10

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 (86) 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 +3 -3
  6. package/dist/cjs/components/withCompatMode.js +2 -2
  7. package/dist/cjs/components/withHydrationBoundary.js +1 -2
  8. package/dist/cjs/constants/hydrationContext.js +12 -1
  9. package/dist/cjs/constants/moduleContext.js +12 -1
  10. package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +8 -0
  11. package/dist/cjs/host/ChaynsHost.js +1 -2
  12. package/dist/cjs/host/iframe/HostIframe.js +1 -2
  13. package/dist/cjs/host/module/ModuleHost.js +2 -3
  14. package/dist/cjs/host/module/utils/loadComponent.js +2 -17
  15. package/dist/cjs/index.js +1 -2
  16. package/dist/cjs/plugins/TrustedDomainsPlugins.js +29 -0
  17. package/dist/cjs/plugins/index.js +8 -1
  18. package/dist/cjs/types/IChaynsReact.js +3 -7
  19. package/dist/cjs/types/global.d.js +1 -0
  20. package/dist/cjs/umd.index.js +1 -2
  21. package/dist/cjs/util/collectCssChunks.js +3 -0
  22. package/dist/cjs/util/deviceHelper.js +17 -4
  23. package/dist/cjs/util/initModuleFederationSharing.js +14 -10
  24. package/dist/cjs/util/is.js +9 -4
  25. package/dist/cjs/util/transferNestedFunctions.js +1 -2
  26. package/dist/cjs/wrapper/AppWrapper.js +9 -3
  27. package/dist/cjs/wrapper/FrameWrapper.js +6 -3
  28. package/dist/cjs/wrapper/StaticChaynsApi.js +1 -3
  29. package/dist/esm/calls/dialogs/alert.js +1 -3
  30. package/dist/esm/calls/dialogs/communication.js +3 -6
  31. package/dist/esm/calls/dialogs/confirm.js +1 -4
  32. package/dist/esm/calls/dialogs/date.js +4 -8
  33. package/dist/esm/calls/dialogs/dropUpAlert.js +1 -2
  34. package/dist/esm/calls/dialogs/fileSelect.js +1 -2
  35. package/dist/esm/calls/dialogs/iFrame.js +11 -9
  36. package/dist/esm/calls/dialogs/input.js +1 -2
  37. package/dist/esm/calls/dialogs/mediaSelect.js +1 -2
  38. package/dist/esm/calls/dialogs/toast.js +1 -2
  39. package/dist/esm/calls/dialogs/utils/callback.js +1 -2
  40. package/dist/esm/calls/index.js +53 -156
  41. package/dist/esm/components/ChaynsProvider.js +18 -20
  42. package/dist/esm/components/WaitUntil.js +5 -6
  43. package/dist/esm/components/withCompatMode.js +1 -0
  44. package/dist/esm/components/withHydrationBoundary.js +5 -6
  45. package/dist/esm/constants/hydrationContext.js +12 -1
  46. package/dist/esm/constants/moduleContext.js +12 -1
  47. package/dist/esm/handler/DialogHandler.js +1 -2
  48. package/dist/esm/hooks/geoLocationListener.js +5 -6
  49. package/dist/esm/hooks/scrollListener.js +12 -15
  50. package/dist/esm/hooks/useIsomorphicLayoutEffect.js +2 -0
  51. package/dist/esm/hooks/usePages.js +16 -19
  52. package/dist/esm/hooks/windowMetricsListener.js +3 -4
  53. package/dist/esm/host/ChaynsHost.js +23 -24
  54. package/dist/esm/host/iframe/HostIframe.js +21 -22
  55. package/dist/esm/host/module/ModuleHost.js +25 -27
  56. package/dist/esm/host/module/utils/loadComponent.js +4 -22
  57. package/dist/esm/plugins/TrustedDomainsPlugins.js +25 -0
  58. package/dist/esm/plugins/index.js +2 -1
  59. package/dist/esm/types/IChaynsReact.js +2 -6
  60. package/dist/esm/types/global.d.js +0 -0
  61. package/dist/esm/util/appStorage.js +3 -6
  62. package/dist/esm/util/collectCssChunks.js +3 -0
  63. package/dist/esm/util/deviceHelper.js +20 -8
  64. package/dist/esm/util/initModuleFederationSharing.js +18 -15
  65. package/dist/esm/util/is.js +11 -8
  66. package/dist/esm/util/transferNestedFunctions.js +1 -2
  67. package/dist/esm/wrapper/AppWrapper.js +23 -26
  68. package/dist/esm/wrapper/FrameWrapper.js +14 -21
  69. package/dist/esm/wrapper/ModuleFederationWrapper.js +2 -5
  70. package/dist/esm/wrapper/StaticChaynsApi.js +2 -5
  71. package/dist/types/calls/dialogs/iFrame.d.ts +10 -4
  72. package/dist/types/calls/index.d.ts +2 -0
  73. package/dist/types/hooks/useIsomorphicLayoutEffect.d.ts +2 -0
  74. package/dist/types/host/module/utils/loadComponent.d.ts +2 -1
  75. package/dist/types/plugins/SSRManifestPlugin.d.ts +2 -2
  76. package/dist/types/plugins/SequentialLoadPlugin.d.ts +2 -2
  77. package/dist/types/plugins/TrustedDomainsPlugins.d.ts +2 -0
  78. package/dist/types/plugins/index.d.ts +1 -0
  79. package/dist/types/types/IChaynsReact.d.ts +29 -12
  80. package/dist/types/util/is.d.ts +1 -0
  81. package/dist/types/wrapper/StaticChaynsApi.d.ts +68 -4
  82. package/eslint.config.mjs +3 -0
  83. package/package.json +32 -22
  84. package/{toolkit.config.js → toolkit.config.ts} +6 -3
  85. package/tsconfig.json +1 -0
  86. package/.eslintrc +0 -17
@@ -11,8 +11,7 @@ var _getUserInfo = _interopRequireDefault(require("../calls/getUserInfo"));
11
11
  var _sendMessage = require("../calls/sendMessage");
12
12
  var _heightHelper = require("../util/heightHelper");
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
15
  class FrameWrapper {
17
16
  resolve = null;
18
17
  exposedFunctions = null;
@@ -37,7 +36,7 @@ class FrameWrapper {
37
36
  if (!this.initialized) await this.ready;
38
37
  try {
39
38
  return await this.exposedFunctions.addVisibilityChangeListener(comlink.proxy(result => callback(result)));
40
- } catch (ex) {
39
+ } catch {
41
40
  return (0, _visibilityChangeListener.addVisibilityChangeListener)(callback);
42
41
  }
43
42
  },
@@ -87,6 +86,10 @@ class FrameWrapper {
87
86
  if (!this.initialized) await this.ready;
88
87
  return this.exposedFunctions.invokeCall(value, callback && comlink.proxy(result => callback(result)));
89
88
  },
89
+ invokePaymentCall: async (value, callback) => {
90
+ if (!this.initialized) await this.ready;
91
+ return this.exposedFunctions.invokePaymentCall(value, callback && comlink.proxy(result => callback(result)));
92
+ },
90
93
  invokeDialogCall: async (value, callback) => {
91
94
  if (!this.initialized) await this.ready;
92
95
  return this.exposedFunctions.invokeDialogCall(value, callback && comlink.proxy(result => callback(result)));
@@ -27,9 +27,7 @@ class StaticChaynsApi {
27
27
  this._wrapper = wrapper;
28
28
  this.ready = wrapper.init();
29
29
  this.addDataListener = wrapper.addDataListener;
30
- Object.entries(wrapper.functions).forEach(([k, v]) => {
31
- this[k] = v;
32
- });
30
+ Object.assign(this, wrapper.functions);
33
31
  }
34
32
  getUser = () => this._wrapper.values.user;
35
33
  getSite = () => this._wrapper.values.site;
@@ -1,7 +1,5 @@
1
1
  import { buttonText, buttonType, chaynsDialog } from './chaynsDialog';
2
- export function alert() {
3
- let title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
4
- let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2
+ export function alert(title = '', message = '') {
5
3
  return chaynsDialog({
6
4
  'dialog': {
7
5
  title,
@@ -10,8 +10,7 @@ export function sendData(data, isApiEvent) {
10
10
  }
11
11
  const listeners = [];
12
12
  const apiListeners = [];
13
- function _dialogDataListener() {
14
- let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
13
+ function _dialogDataListener(e = {}) {
15
14
  if (!e.data || !e.data.action && typeof e.data !== 'string') {
16
15
  return;
17
16
  }
@@ -31,8 +30,7 @@ function _dialogDataListener() {
31
30
  }
32
31
  }
33
32
  }
34
- export function addDialogDataListener(callback) {
35
- let getApiEvents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
33
+ export function addDialogDataListener(callback, getApiEvents = false) {
36
34
  if (listeners.length === 0 || apiListeners.length === 0) {
37
35
  window.addEventListener('message', _dialogDataListener);
38
36
  }
@@ -43,8 +41,7 @@ export function addDialogDataListener(callback) {
43
41
  }
44
42
  return true;
45
43
  }
46
- export function removeDialogDataListener(callback) {
47
- let getApiEvents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
44
+ export function removeDialogDataListener(callback, getApiEvents = false) {
48
45
  let index;
49
46
  if (getApiEvents) {
50
47
  index = apiListeners.indexOf(callback);
@@ -1,8 +1,5 @@
1
1
  import { buttonText, buttonType, chaynsDialog } from './chaynsDialog';
2
- export function confirm() {
3
- let title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
4
- let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
5
- let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2
+ export function confirm(title = '', message = '', config = {}) {
6
3
  if (Array.isArray(config)) {
7
4
  config = {
8
5
  'buttons': config
@@ -2,8 +2,7 @@ import { buttonText, buttonType, dialogAction } from './chaynsDialog';
2
2
  import { isDate, isNumber, isObject } from './utils/is';
3
3
  import { open } from './open';
4
4
  import { getDevice } from "../index";
5
- export function date() {
6
- let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5
+ export function date(config = {}) {
7
6
  let {
8
7
  preSelect,
9
8
  minDate,
@@ -45,8 +44,7 @@ export function date() {
45
44
  return Promise.resolve(data.selectedDate);
46
45
  });
47
46
  }
48
- export function advancedDate() {
49
- let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
47
+ export function advancedDate(config = {}) {
50
48
  let {
51
49
  preSelect,
52
50
  minDate,
@@ -143,9 +141,7 @@ function validateValue(value) {
143
141
  }
144
142
  return value;
145
143
  }
146
- function roundInterval() {
147
- let preDate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
148
- let interval = arguments.length > 1 ? arguments[1] : undefined;
144
+ function roundInterval(preDate = new Date(), interval) {
149
145
  if (!isDate(preDate)) {
150
146
  if (isNumber(preDate)) {
151
147
  preDate = new Date(preDate);
@@ -153,7 +149,7 @@ function roundInterval() {
153
149
  return -1;
154
150
  }
155
151
  }
156
- let minutes = preDate.getMinutes();
152
+ const minutes = preDate.getMinutes();
157
153
  preDate.setMinutes(minutes - minutes % interval);
158
154
  preDate.setSeconds(0);
159
155
  return parseInt(preDate.getTime() / 1000 + "", 10);
@@ -1,7 +1,6 @@
1
1
  import { open } from './open';
2
2
  import { dialogAction } from './chaynsDialog';
3
- export function dropUpAlert() {
4
- let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3
+ export function dropUpAlert(dialog = {}) {
5
4
  dialog.callType = dialogAction.DROP_UP_ALERT;
6
5
  return open(dialog);
7
6
  }
@@ -7,8 +7,7 @@ export const fileType = {
7
7
  'AUDIO': 'audio',
8
8
  'DOCUMENT': ['application/x-latex', 'application/x-tex', 'text/', 'application/json', 'application/pdf', 'application/msword', 'application/msexcel', 'application/mspowerpoint', 'application/vnd.ms-word', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument', 'application/vnd.oasis.opendocument']
9
9
  };
10
- export async function fileSelect() {
11
- let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
10
+ export async function fileSelect(dialog = {}) {
12
11
  if (!dialog.buttons || !Array.isArray(dialog.buttons)) {
13
12
  dialog.buttons = [];
14
13
  if (dialog.multiselect || dialog.directory) {
@@ -2,12 +2,16 @@ import { buttonText, buttonType, dialogAction } from './chaynsDialog';
2
2
  import { open } from './open';
3
3
  import { addDialogDataListener, sendData } from './communication';
4
4
  import { getSite, invokeDialogCall } from "../index";
5
- export function iFrame() {
6
- let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
7
- url: ""
5
+ export function iFrame(dialog = {
6
+ url: ""
7
+ }) {
8
+ const config = {
9
+ ...dialog,
10
+ tappIframeName: window.name,
11
+ callType: dialogAction.IFRAME
8
12
  };
9
- if (!dialog.buttons || !Array.isArray(dialog.buttons)) {
10
- dialog.buttons = [{
13
+ if (!config.buttons || !Array.isArray(config.buttons)) {
14
+ config.buttons = [{
11
15
  'text': buttonText.YES,
12
16
  'buttonType': buttonType.POSITIVE
13
17
  }, {
@@ -15,12 +19,10 @@ export function iFrame() {
15
19
  'buttonType': buttonType.NEGATIVE
16
20
  }];
17
21
  }
18
- dialog.tappIframeName = window.name;
19
- dialog.callType = dialogAction.IFRAME;
20
22
  const site = getSite();
21
- dialog.url = `${dialog.url}${dialog.url.indexOf('?') >= 0 ? '&' : '?'}siteId=${site.id}`;
23
+ config.url = `${config.url}${config.url.indexOf('?') >= 0 ? '&' : '?'}siteId=${site.id}`;
22
24
  addDialogDataListener(_chaynsCallResponder, true);
23
- return open(dialog);
25
+ return open(config);
24
26
  }
25
27
  export function _chaynsCallResponder(obj) {
26
28
  if (obj.call.value.callback) {
@@ -1,7 +1,6 @@
1
1
  import { buttonText, buttonType, dialogAction } from './chaynsDialog';
2
2
  import { open } from './open';
3
- export function input() {
4
- let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3
+ export function input(dialog = {}) {
5
4
  if (!dialog.buttons || !Array.isArray(dialog.buttons)) {
6
5
  dialog.buttons = [{
7
6
  'text': buttonText.YES,
@@ -1,8 +1,7 @@
1
1
  import { buttonText, buttonType, dialogAction } from './chaynsDialog';
2
2
  import { open } from './open';
3
3
  import { getAccessToken, getUser, login } from "../index";
4
- export async function mediaSelect() {
5
- let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4
+ export async function mediaSelect(dialog = {}) {
6
5
  if (!dialog.buttons || !Array.isArray(dialog.buttons)) {
7
6
  dialog.buttons = [{
8
7
  'text': buttonText.OK,
@@ -1,7 +1,6 @@
1
1
  import { getCallbackName } from "./utils/callback";
2
2
  import { invokeDialogCall } from "../index";
3
- export function toast() {
4
- let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3
+ export function toast(config = {}) {
5
4
  const callbackName = 'toastCallback';
6
5
  return invokeDialogCall({
7
6
  action: 276,
@@ -1,5 +1,4 @@
1
- export function getCallbackName(fnName) {
2
- let framePrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1
+ export function getCallbackName(fnName, framePrefix = '') {
3
2
  if (framePrefix !== '') {
4
3
  return `window._chaynsCallbacks.${framePrefix}.${fnName}`;
5
4
  }
@@ -1,158 +1,57 @@
1
1
  import { moduleWrapper } from '../components/moduleWrapper';
2
- export const addGeoLocationListener = function () {
3
- return moduleWrapper.current.functions.addGeoLocationListener(...arguments);
4
- };
5
- export const addScrollListener = function () {
6
- return moduleWrapper.current.functions.addScrollListener(...arguments);
7
- };
8
- export const addVisibilityChangeListener = function () {
9
- return moduleWrapper.current.functions.addVisibilityChangeListener(...arguments);
10
- };
11
- export const addToolbarChangeListener = function () {
12
- return moduleWrapper.current.functions.addToolbarChangeListener(...arguments);
13
- };
14
- export const addAccessTokenChangeListener = function () {
15
- return moduleWrapper.current.functions.addAccessTokenChangeListener(...arguments);
16
- };
17
- export const addWindowMetricsListener = function () {
18
- return moduleWrapper.current.functions.addWindowMetricsListener(...arguments);
19
- };
20
- export const customCallbackFunction = function () {
21
- return moduleWrapper.current.functions.customCallbackFunction(...arguments);
22
- };
23
- export const getAccessToken = function () {
24
- return moduleWrapper.current.functions.getAccessToken(...arguments);
25
- };
26
- export const getAvailableSharingServices = function () {
27
- return moduleWrapper.current.functions.getAvailableSharingServices(...arguments);
28
- };
29
- export const getCustomCookie = function () {
30
- return moduleWrapper.current.functions.getCustomCookie(...arguments);
31
- };
32
- export const getGeoLocation = function () {
33
- return moduleWrapper.current.functions.getGeoLocation(...arguments);
34
- };
35
- export const getUserInfo = function () {
36
- return moduleWrapper.current.functions.getUserInfo(...arguments);
37
- };
38
- export const getScrollPosition = function () {
39
- return moduleWrapper.current.functions.getScrollPosition(...arguments);
40
- };
41
- export const getWindowMetrics = function () {
42
- return moduleWrapper.current.functions.getWindowMetrics(...arguments);
43
- };
44
- export const invokeCall = function () {
45
- return moduleWrapper.current.functions.invokeCall(...arguments);
46
- };
47
- export const invokeDialogCall = function () {
48
- return moduleWrapper.current.functions.invokeDialogCall(...arguments);
49
- };
50
- export const login = function () {
51
- return moduleWrapper.current.functions.login(...arguments);
52
- };
53
- export const logout = function () {
54
- return moduleWrapper.current.functions.logout(...arguments);
55
- };
56
- export const navigateBack = function () {
57
- return moduleWrapper.current.functions.navigateBack(...arguments);
58
- };
59
- export const openImage = function () {
60
- return moduleWrapper.current.functions.openImage(...arguments);
61
- };
62
- export const openMedia = function () {
63
- return moduleWrapper.current.functions.openMedia(...arguments);
64
- };
65
- export const openUrl = function () {
66
- return moduleWrapper.current.functions.openUrl(...arguments);
67
- };
68
- export const openVideo = function () {
69
- return moduleWrapper.current.functions.openVideo(...arguments);
70
- };
71
- export const refreshData = function () {
72
- return moduleWrapper.current.functions.refreshData(...arguments);
73
- };
74
- export const refreshAccessToken = function () {
75
- return moduleWrapper.current.functions.refreshAccessToken(...arguments);
76
- };
77
- export const removeGeoLocationListener = function () {
78
- return moduleWrapper.current.functions.removeGeoLocationListener(...arguments);
79
- };
80
- export const removeToolbarChangeListener = function () {
81
- return moduleWrapper.current.functions.removeToolbarChangeListener(...arguments);
82
- };
83
- export const removeAccessTokenChangeListener = function () {
84
- return moduleWrapper.current.functions.removeAccessTokenChangeListener(...arguments);
85
- };
86
- export const removeScrollListener = function () {
87
- return moduleWrapper.current.functions.removeScrollListener(...arguments);
88
- };
89
- export const removeVisibilityChangeListener = function () {
90
- return moduleWrapper.current.functions.removeVisibilityChangeListener(...arguments);
91
- };
92
- export const removeWindowMetricsListener = function () {
93
- return moduleWrapper.current.functions.removeWindowMetricsListener(...arguments);
94
- };
95
- export const selectPage = function () {
96
- return moduleWrapper.current.functions.selectPage(...arguments);
97
- };
98
- export const scrollByY = function () {
99
- return moduleWrapper.current.functions.scrollByY(...arguments);
100
- };
101
- export const scrollToY = function () {
102
- return moduleWrapper.current.functions.scrollToY(...arguments);
103
- };
104
- export const sendMessageToGroup = function () {
105
- return moduleWrapper.current.functions.sendMessageToGroup(...arguments);
106
- };
107
- export const sendMessageToPage = function () {
108
- return moduleWrapper.current.functions.sendMessageToPage(...arguments);
109
- };
110
- export const sendMessageToUser = function () {
111
- return moduleWrapper.current.functions.sendMessageToUser(...arguments);
112
- };
113
- export const setAdminMode = function () {
114
- return moduleWrapper.current.functions.setAdminMode(...arguments);
115
- };
116
- export const setCustomCookie = function () {
117
- return moduleWrapper.current.functions.setCustomCookie(...arguments);
118
- };
119
- export const setDisplayTimeout = function () {
120
- return moduleWrapper.current.functions.setDisplayTimeout(...arguments);
121
- };
122
- export const setFloatingButton = function () {
123
- return moduleWrapper.current.functions.setFloatingButton(...arguments);
124
- };
125
- export const setHeight = function () {
126
- return moduleWrapper.current.functions.setHeight(...arguments);
127
- };
128
- export const setRefreshScrollEnabled = function () {
129
- return moduleWrapper.current.functions.setRefreshScrollEnabled(...arguments);
130
- };
131
- export const setScanQrCode = function () {
132
- return moduleWrapper.current.functions.setScanQrCode(...arguments);
133
- };
134
- export const setTempDesignSettings = function () {
135
- return moduleWrapper.current.functions.setTempDesignSettings(...arguments);
136
- };
137
- export const setWaitCursor = function () {
138
- return moduleWrapper.current.functions.setWaitCursor(...arguments);
139
- };
140
- export const storageGetItem = function () {
141
- return moduleWrapper.current.functions.storageGetItem(...arguments);
142
- };
143
- export const storageRemoveItem = function () {
144
- return moduleWrapper.current.functions.storageRemoveItem(...arguments);
145
- };
146
- export const storageSetItem = function () {
147
- return moduleWrapper.current.functions.storageSetItem(...arguments);
148
- };
149
- export const vibrate = function () {
150
- return moduleWrapper.current.functions.vibrate(...arguments);
151
- };
2
+ export const addGeoLocationListener = (...args) => moduleWrapper.current.functions.addGeoLocationListener(...args);
3
+ export const addScrollListener = (...args) => moduleWrapper.current.functions.addScrollListener(...args);
4
+ export const addVisibilityChangeListener = (...args) => moduleWrapper.current.functions.addVisibilityChangeListener(...args);
5
+ export const addToolbarChangeListener = (...args) => moduleWrapper.current.functions.addToolbarChangeListener(...args);
6
+ export const addAccessTokenChangeListener = (...args) => moduleWrapper.current.functions.addAccessTokenChangeListener(...args);
7
+ export const addWindowMetricsListener = (...args) => moduleWrapper.current.functions.addWindowMetricsListener(...args);
8
+ export const customCallbackFunction = (...args) => moduleWrapper.current.functions.customCallbackFunction(...args);
9
+ export const getAccessToken = (...args) => moduleWrapper.current.functions.getAccessToken(...args);
10
+ export const getAvailableSharingServices = (...args) => moduleWrapper.current.functions.getAvailableSharingServices(...args);
11
+ export const getCustomCookie = (...args) => moduleWrapper.current.functions.getCustomCookie(...args);
12
+ export const getGeoLocation = (...args) => moduleWrapper.current.functions.getGeoLocation(...args);
13
+ export const getUserInfo = (...args) => moduleWrapper.current.functions.getUserInfo(...args);
14
+ export const getScrollPosition = (...args) => moduleWrapper.current.functions.getScrollPosition(...args);
15
+ export const getWindowMetrics = (...args) => moduleWrapper.current.functions.getWindowMetrics(...args);
16
+ export const invokeCall = (...args) => moduleWrapper.current.functions.invokeCall(...args);
17
+ export const invokePaymentCall = (...args) => moduleWrapper.current.functions.invokePaymentCall(...args);
18
+ export const invokeDialogCall = (...args) => moduleWrapper.current.functions.invokeDialogCall(...args);
19
+ export const login = (...args) => moduleWrapper.current.functions.login(...args);
20
+ export const logout = (...args) => moduleWrapper.current.functions.logout(...args);
21
+ export const navigateBack = (...args) => moduleWrapper.current.functions.navigateBack(...args);
22
+ export const openImage = (...args) => moduleWrapper.current.functions.openImage(...args);
23
+ export const openMedia = (...args) => moduleWrapper.current.functions.openMedia(...args);
24
+ export const openUrl = (...args) => moduleWrapper.current.functions.openUrl(...args);
25
+ export const openVideo = (...args) => moduleWrapper.current.functions.openVideo(...args);
26
+ export const refreshData = (...args) => moduleWrapper.current.functions.refreshData(...args);
27
+ export const refreshAccessToken = (...args) => moduleWrapper.current.functions.refreshAccessToken(...args);
28
+ export const removeGeoLocationListener = (...args) => moduleWrapper.current.functions.removeGeoLocationListener(...args);
29
+ export const removeToolbarChangeListener = (...args) => moduleWrapper.current.functions.removeToolbarChangeListener(...args);
30
+ export const removeAccessTokenChangeListener = (...args) => moduleWrapper.current.functions.removeAccessTokenChangeListener(...args);
31
+ export const removeScrollListener = (...args) => moduleWrapper.current.functions.removeScrollListener(...args);
32
+ export const removeVisibilityChangeListener = (...args) => moduleWrapper.current.functions.removeVisibilityChangeListener(...args);
33
+ export const removeWindowMetricsListener = (...args) => moduleWrapper.current.functions.removeWindowMetricsListener(...args);
34
+ export const selectPage = (...args) => moduleWrapper.current.functions.selectPage(...args);
35
+ export const scrollByY = (...args) => moduleWrapper.current.functions.scrollByY(...args);
36
+ export const scrollToY = (...args) => moduleWrapper.current.functions.scrollToY(...args);
37
+ export const sendMessageToGroup = (...args) => moduleWrapper.current.functions.sendMessageToGroup(...args);
38
+ export const sendMessageToPage = (...args) => moduleWrapper.current.functions.sendMessageToPage(...args);
39
+ export const sendMessageToUser = (...args) => moduleWrapper.current.functions.sendMessageToUser(...args);
40
+ export const setAdminMode = (...args) => moduleWrapper.current.functions.setAdminMode(...args);
41
+ export const setCustomCookie = (...args) => moduleWrapper.current.functions.setCustomCookie(...args);
42
+ export const setDisplayTimeout = (...args) => moduleWrapper.current.functions.setDisplayTimeout(...args);
43
+ export const setFloatingButton = (...args) => moduleWrapper.current.functions.setFloatingButton(...args);
44
+ export const setHeight = (...args) => moduleWrapper.current.functions.setHeight(...args);
45
+ export const setRefreshScrollEnabled = (...args) => moduleWrapper.current.functions.setRefreshScrollEnabled(...args);
46
+ export const setScanQrCode = (...args) => moduleWrapper.current.functions.setScanQrCode(...args);
47
+ export const setTempDesignSettings = (...args) => moduleWrapper.current.functions.setTempDesignSettings(...args);
48
+ export const setWaitCursor = (...args) => moduleWrapper.current.functions.setWaitCursor(...args);
49
+ export const storageGetItem = (...args) => moduleWrapper.current.functions.storageGetItem(...args);
50
+ export const storageRemoveItem = (...args) => moduleWrapper.current.functions.storageRemoveItem(...args);
51
+ export const storageSetItem = (...args) => moduleWrapper.current.functions.storageSetItem(...args);
52
+ export const vibrate = (...args) => moduleWrapper.current.functions.vibrate(...args);
152
53
  export const createDialog = config => moduleWrapper.current.functions.createDialog(config);
153
- export const setOverlay = function () {
154
- return moduleWrapper.current.functions.setOverlay(...arguments);
155
- };
54
+ export const setOverlay = (...args) => moduleWrapper.current.functions.setOverlay(...args);
156
55
  export const addAnonymousAccount = () => moduleWrapper.current.functions.addAnonymousAccount();
157
56
  export const getUser = () => moduleWrapper.current.values.user;
158
57
  export const getSite = () => moduleWrapper.current.values.site;
@@ -238,6 +137,4 @@ export const environment = new Proxy({}, {
238
137
  return (_moduleWrapper$curren8 = moduleWrapper.current.values.environment) === null || _moduleWrapper$curren8 === void 0 ? void 0 : _moduleWrapper$curren8[prop];
239
138
  }
240
139
  });
241
- export const redirect = function () {
242
- return moduleWrapper.current.functions.redirect(...arguments);
243
- };
140
+ export const redirect = (...args) => moduleWrapper.current.functions.redirect(...args);
@@ -1,5 +1,6 @@
1
1
  import htmlEscape from 'htmlescape';
2
2
  import React, { useEffect, useRef, useState } from 'react';
3
+ import { useIsomorphicLayoutEffect } from '../hooks/useIsomorphicLayoutEffect';
3
4
  import { AppName } from '../types/IChaynsReact';
4
5
  import getDeviceInfo from '../util/deviceHelper';
5
6
  import { AppWrapper } from '../wrapper/AppWrapper';
@@ -9,11 +10,10 @@ import { SsrWrapper } from '../wrapper/SsrWrapper';
9
10
  import { ChaynsContext } from './ChaynsContext';
10
11
  import { addModuleWrapper, moduleWrapper, removeModuleWrapper } from './moduleWrapper';
11
12
  const isServer = typeof window === 'undefined';
12
- const InitialDataProvider = React.memo(_ref => {
13
- let {
14
- data,
15
- renderedByServer
16
- } = _ref;
13
+ const InitialDataProvider = React.memo(({
14
+ data,
15
+ renderedByServer
16
+ }) => {
17
17
  if (!renderedByServer) {
18
18
  return null;
19
19
  }
@@ -25,16 +25,15 @@ const InitialDataProvider = React.memo(_ref => {
25
25
  }
26
26
  });
27
27
  }, () => true);
28
- const ChaynsProvider = _ref2 => {
28
+ const ChaynsProvider = ({
29
+ children,
30
+ data,
31
+ functions,
32
+ customFunctions,
33
+ renderedByServer,
34
+ isModule
35
+ }) => {
29
36
  var _customWrapper$curren, _customWrapper$curren2;
30
- let {
31
- children,
32
- data,
33
- functions,
34
- customFunctions,
35
- renderedByServer,
36
- isModule
37
- } = _ref2;
38
37
  const customWrapper = useRef(null);
39
38
  if (!customWrapper.current) {
40
39
  if (isModule) {
@@ -64,11 +63,10 @@ const ChaynsProvider = _ref2 => {
64
63
  useEffect(() => {
65
64
  void (async () => {
66
65
  await customWrapper.current.init();
67
- customWrapper.current.addDataListener(_ref3 => {
68
- let {
69
- type,
70
- value
71
- } = _ref3;
66
+ customWrapper.current.addDataListener(({
67
+ type,
68
+ value
69
+ }) => {
72
70
  customWrapper.current.emitChange();
73
71
  });
74
72
  if (!isInitialized) {
@@ -88,7 +86,7 @@ const ChaynsProvider = _ref2 => {
88
86
  customWrapper.current.emitChange();
89
87
  }
90
88
  }, [customFunctions, isModule]);
91
- useEffect(() => {
89
+ useIsomorphicLayoutEffect(() => {
92
90
  addModuleWrapper(customWrapper.current);
93
91
  return () => {
94
92
  removeModuleWrapper(customWrapper.current);
@@ -9,12 +9,11 @@ const handleTasks = async tasks => {
9
9
  }
10
10
  }
11
11
  };
12
- export const WaitUntil = _ref => {
13
- let {
14
- tasks,
15
- children,
16
- loadingComponent
17
- } = _ref;
12
+ export const WaitUntil = ({
13
+ tasks,
14
+ children,
15
+ loadingComponent
16
+ }) => {
18
17
  const [loaded, setLoaded] = useState(() => !tasks.length);
19
18
  useEffect(() => {
20
19
  handleTasks(tasks).finally(() => setLoaded(true));
@@ -43,6 +43,7 @@ export const withCompatMode = Component => {
43
43
  }, 0);
44
44
  }
45
45
  componentWillUnmount() {
46
+ clearTimeout(this.timeout);
46
47
  if (this.root) {
47
48
  this.root.unmount();
48
49
  } else {
@@ -3,12 +3,11 @@ import React, { useContext, useEffect, useState } from 'react';
3
3
  import { HydrationContext } from '../constants';
4
4
  function withHydrationBoundary(Component, initializer, useHydrationId, useProps) {
5
5
  const stores = {};
6
- return _ref => {
7
- let {
8
- id: idProp,
9
- children,
10
- ...rest
11
- } = _ref;
6
+ return ({
7
+ id: idProp,
8
+ children,
9
+ ...rest
10
+ }) => {
12
11
  let value;
13
12
  if (!globalThis.window) {
14
13
  value = useContext(HydrationContext);
@@ -3,6 +3,17 @@ export let HydrationContext;
3
3
  if (!globalThis.window && globalThis._hydrationContext) {
4
4
  HydrationContext = globalThis._hydrationContext;
5
5
  } else {
6
- HydrationContext = createContext({});
6
+ const emptyReadonly = new Proxy({}, {
7
+ set() {
8
+ return true;
9
+ },
10
+ defineProperty() {
11
+ return true;
12
+ },
13
+ deleteProperty() {
14
+ return true;
15
+ }
16
+ });
17
+ HydrationContext = createContext(emptyReadonly);
7
18
  globalThis._hydrationContext = HydrationContext;
8
19
  }
@@ -3,6 +3,17 @@ export let ModuleContext;
3
3
  if (!globalThis.window && globalThis._moduleContext) {
4
4
  ModuleContext = globalThis._moduleContext;
5
5
  } else {
6
- ModuleContext = createContext({});
6
+ const emptyReadonly = new Proxy({}, {
7
+ set() {
8
+ return true;
9
+ },
10
+ defineProperty() {
11
+ return true;
12
+ },
13
+ deleteProperty() {
14
+ return true;
15
+ }
16
+ });
17
+ ModuleContext = createContext(emptyReadonly);
7
18
  globalThis._moduleContext = ModuleContext;
8
19
  }
@@ -28,8 +28,7 @@ export default class DialogHandler {
28
28
  });
29
29
  return this.result = res;
30
30
  }
31
- close(buttonType) {
32
- let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
31
+ close(buttonType, data = undefined) {
33
32
  if (!this.isOpen) {
34
33
  return;
35
34
  }
@@ -12,12 +12,11 @@ export const useGeoLocationListener = () => {
12
12
  };
13
13
  }, []);
14
14
  };
15
- export const useGeoLocation = function () {
16
- let {
17
- enabled = true,
18
- timeout = 0,
19
- silent = false
20
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
15
+ export const useGeoLocation = ({
16
+ enabled = true,
17
+ timeout = 0,
18
+ silent = false
19
+ } = {}) => {
21
20
  const [value, setValue] = useState(null);
22
21
  const addListener = useGeoLocationListener();
23
22
  useEffect(() => {