chayns-api 1.1.0-2 → 1.1.0-21
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/dist/chayns-api.js +2 -0
- package/dist/chayns-api.js.LICENSE.txt +41 -0
- package/dist/cjs/calls/dialogs/chaynsDialog.js +3 -6
- package/dist/cjs/calls/dialogs/date.js +29 -2
- package/dist/cjs/calls/dialogs/fileSelect.js +1 -2
- package/dist/cjs/calls/dialogs/input.js +2 -3
- package/dist/cjs/calls/dialogs/select.js +2 -3
- package/dist/cjs/calls/getUserInfo.js +1 -2
- package/dist/cjs/calls/index.js +93 -82
- package/dist/cjs/calls/toolbarChangeListener.js +1 -0
- package/dist/cjs/components/AppDialogWrapper.js +7 -7
- package/dist/cjs/components/ChaynsContext.js +2 -4
- package/dist/cjs/components/ChaynsProvider.js +10 -13
- package/dist/cjs/components/ErrorBoundary.js +31 -0
- package/dist/cjs/components/moduleWrapper.js +9 -0
- package/dist/cjs/components/withCompatMode.js +8 -7
- package/dist/cjs/components/withHydrationBoundary.js +54 -0
- package/dist/cjs/constants/hydrationContext.js +16 -0
- package/dist/cjs/constants/index.js +16 -0
- package/dist/cjs/constants/languages.js +19 -0
- package/dist/cjs/handler/DialogHandler.js +4 -2
- package/dist/cjs/hooks/useAccessToken.js +1 -0
- package/dist/cjs/hooks/useDialogState.js +2 -2
- package/dist/cjs/hooks/usePages.js +2 -2
- package/dist/cjs/host/ChaynsHost.js +21 -41
- package/dist/cjs/host/iframe/HostIframe.js +4 -6
- package/dist/cjs/host/iframe/utils/useUpdateData.js +1 -2
- package/dist/cjs/host/module/ModuleHost.js +9 -24
- package/dist/cjs/host/module/Test3.js +141 -0
- package/dist/cjs/host/module/utils/loadComponent.js +94 -49
- package/dist/cjs/index.js +63 -5
- package/dist/cjs/types/IChaynsReact.js +140 -107
- package/dist/cjs/util/appCall.js +3 -4
- package/dist/cjs/util/deviceHelper.js +18 -13
- package/dist/cjs/util/transferNestedFunctions.js +39 -0
- package/dist/cjs/util/url.js +1 -1
- package/dist/cjs/wrapper/AppWrapper.js +79 -16
- package/dist/cjs/wrapper/FrameWrapper.js +16 -5
- package/dist/cjs/wrapper/StaticChaynsApi.js +22 -0
- package/dist/esm/calls/index.js +22 -1
- package/dist/esm/calls/toolbarChangeListener.js +0 -0
- package/dist/esm/components/AppDialogWrapper.js +4 -3
- package/dist/esm/components/ChaynsProvider.js +6 -7
- package/dist/esm/components/ErrorBoundary.js +23 -0
- package/dist/esm/components/moduleWrapper.js +3 -0
- package/dist/esm/components/withCompatMode.js +5 -4
- package/dist/esm/components/withHydrationBoundary.js +47 -0
- package/dist/esm/constants/hydrationContext.js +10 -0
- package/dist/esm/constants/index.js +1 -0
- package/dist/esm/constants/languages.js +13 -0
- package/dist/esm/handler/DialogHandler.js +6 -4
- package/dist/esm/hooks/useAccessToken.js +1 -0
- package/dist/esm/hooks/useDialogState.js +2 -2
- package/dist/esm/hooks/usePages.js +1 -1
- package/dist/esm/host/ChaynsHost.js +18 -39
- package/dist/esm/host/iframe/HostIframe.js +1 -2
- package/dist/esm/host/module/ModuleHost.js +6 -20
- package/dist/esm/host/module/Test3.js +135 -0
- package/dist/esm/host/module/utils/loadComponent.js +95 -49
- package/dist/esm/index.js +7 -1
- package/dist/esm/types/IChaynsReact.js +142 -87
- package/dist/esm/util/appCall.js +2 -2
- package/dist/esm/util/deviceHelper.js +17 -11
- package/dist/esm/util/transferNestedFunctions.js +35 -0
- package/dist/esm/util/url.js +2 -2
- package/dist/esm/wrapper/AppWrapper.js +80 -16
- package/dist/esm/wrapper/FrameWrapper.js +16 -5
- package/dist/esm/wrapper/StaticChaynsApi.js +20 -0
- package/dist/types/calls/index.d.ts +19 -5
- package/dist/types/calls/toolbarChangeListener.d.ts +0 -0
- package/dist/types/components/AppDialogWrapper.d.ts +2 -2
- package/dist/types/components/ChaynsProvider.d.ts +1 -4
- package/dist/types/components/ErrorBoundary.d.ts +13 -0
- package/dist/types/components/moduleWrapper.d.ts +4 -0
- package/dist/types/components/withHydrationBoundary.d.ts +17 -0
- package/dist/types/constants/hydrationContext.d.ts +9 -0
- package/dist/types/constants/index.d.ts +1 -0
- package/dist/types/constants/languages.d.ts +12 -0
- package/dist/types/handler/DialogHandler.d.ts +0 -1
- package/dist/types/hooks/useAccessToken.d.ts +1 -0
- package/dist/types/hooks/useCurrentPage.d.ts +4 -1
- package/dist/types/host/ChaynsHost.d.ts +0 -1
- package/dist/types/host/module/ModuleHost.d.ts +2 -0
- package/dist/types/host/module/Test3.d.ts +8 -0
- package/dist/types/host/module/utils/loadComponent.d.ts +3 -1
- package/dist/types/index.d.ts +7 -1
- package/dist/types/types/IChaynsReact.d.ts +136 -28
- package/dist/types/util/deviceHelper.d.ts +2 -2
- package/dist/types/util/transferNestedFunctions.d.ts +1 -0
- package/dist/types/wrapper/StaticChaynsApi.d.ts +9 -0
- package/package.json +33 -22
- package/toolkit.config.js +20 -0
|
@@ -12,8 +12,9 @@ var _deviceHelper = _interopRequireWildcard(require("../util/deviceHelper"));
|
|
|
12
12
|
var _getUserInfo = _interopRequireDefault(require("../calls/getUserInfo"));
|
|
13
13
|
var _sendMessage = require("../calls/sendMessage");
|
|
14
14
|
var _apiListenerHelper = require("../helper/apiListenerHelper");
|
|
15
|
-
|
|
16
|
-
function
|
|
15
|
+
var _languages = require("../constants/languages");
|
|
16
|
+
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); }
|
|
17
|
+
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; }
|
|
17
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
19
|
/* eslint-disable */
|
|
19
20
|
// @ts-nocheck
|
|
@@ -23,12 +24,33 @@ class AppWrapper {
|
|
|
23
24
|
values = null;
|
|
24
25
|
accessToken = '';
|
|
25
26
|
mapOldApiToNew(retVal) {
|
|
26
|
-
var _window, _window2, _AppInfo$TappSelected;
|
|
27
|
+
var _window, _colorMode, _window2, _AppInfo$TappSelected;
|
|
27
28
|
const {
|
|
28
29
|
AppInfo,
|
|
29
|
-
AppUser
|
|
30
|
+
AppUser,
|
|
31
|
+
Device
|
|
30
32
|
} = retVal;
|
|
31
33
|
this.accessToken = AppUser.TobitAccessToken;
|
|
34
|
+
const urlParams = new URLSearchParams(location.search);
|
|
35
|
+
const urlParamsLowerCase = new URLSearchParams(location.search.toLowerCase());
|
|
36
|
+
let tappId = urlParamsLowerCase.get('tappid');
|
|
37
|
+
let colorMode = urlParamsLowerCase.get('colormode');
|
|
38
|
+
if (colorMode) {
|
|
39
|
+
try {
|
|
40
|
+
colorMode = Number.parseInt(colorMode, 10);
|
|
41
|
+
} catch {}
|
|
42
|
+
}
|
|
43
|
+
if (tappId) {
|
|
44
|
+
try {
|
|
45
|
+
tappId = Number.parseInt(tappId, 10);
|
|
46
|
+
} catch {
|
|
47
|
+
// ignore
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
let language = AppInfo.Language;
|
|
51
|
+
if (!language) {
|
|
52
|
+
language = _languages.DeviceLanguage[Number.parseInt(Device === null || Device === void 0 ? void 0 : Device.LanguageID, 10)] || 'de';
|
|
53
|
+
}
|
|
32
54
|
return {
|
|
33
55
|
device: (0, _deviceHelper.default)(navigator.userAgent, 'image/webp'),
|
|
34
56
|
environment: {
|
|
@@ -36,12 +58,11 @@ class AppWrapper {
|
|
|
36
58
|
runtimeEnvironment: _IChaynsReact.RuntimeEnviroment.Unknown
|
|
37
59
|
},
|
|
38
60
|
language: {
|
|
39
|
-
site:
|
|
61
|
+
site: language,
|
|
40
62
|
translation: null,
|
|
41
|
-
device:
|
|
42
|
-
active:
|
|
63
|
+
device: language,
|
|
64
|
+
active: language
|
|
43
65
|
},
|
|
44
|
-
// ToDo: Find better way to detect
|
|
45
66
|
site: {
|
|
46
67
|
id: AppInfo.SiteID,
|
|
47
68
|
locationId: AppInfo.LocationID,
|
|
@@ -56,7 +77,7 @@ class AppWrapper {
|
|
|
56
77
|
docked: false
|
|
57
78
|
},
|
|
58
79
|
title: AppInfo.Title,
|
|
59
|
-
colorMode: AppInfo.colorMode,
|
|
80
|
+
colorMode: (_colorMode = colorMode) !== null && _colorMode !== void 0 ? _colorMode : AppInfo.colorMode,
|
|
60
81
|
color: AppInfo.color,
|
|
61
82
|
domain: AppInfo.domain,
|
|
62
83
|
font: {
|
|
@@ -68,7 +89,7 @@ class AppWrapper {
|
|
|
68
89
|
locationPersonId: AppInfo.LocationPersonId,
|
|
69
90
|
urlHash: (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.location.hash.replace('#', '')
|
|
70
91
|
},
|
|
71
|
-
parameters: Object.fromEntries(
|
|
92
|
+
parameters: Object.fromEntries(urlParams),
|
|
72
93
|
user: {
|
|
73
94
|
firstName: AppUser.FirstName,
|
|
74
95
|
lastName: AppUser.LastName,
|
|
@@ -80,7 +101,7 @@ class AppWrapper {
|
|
|
80
101
|
customData: null,
|
|
81
102
|
isAdminModeActive: AppUser.AdminMode,
|
|
82
103
|
currentPage: {
|
|
83
|
-
id: (_AppInfo$TappSelected = AppInfo.TappSelected) === null || _AppInfo$TappSelected === void 0 ? void 0 : _AppInfo$TappSelected.TappID,
|
|
104
|
+
id: ((_AppInfo$TappSelected = AppInfo.TappSelected) === null || _AppInfo$TappSelected === void 0 ? void 0 : _AppInfo$TappSelected.TappID) || tappId,
|
|
84
105
|
siteId: AppInfo.SiteID
|
|
85
106
|
},
|
|
86
107
|
pages: AppInfo.Tapps.map(x => ({
|
|
@@ -151,12 +172,13 @@ class AppWrapper {
|
|
|
151
172
|
permanent: true
|
|
152
173
|
}, {
|
|
153
174
|
callback: v => {
|
|
154
|
-
var _v$accuracy, _v$code;
|
|
175
|
+
var _v$accuracy, _v$isAccurate, _v$code;
|
|
155
176
|
(0, _apiListenerHelper.dispatchApiEvent)('geoLocationListener', {
|
|
156
177
|
latitude: v.latitude,
|
|
157
178
|
longitude: v.longitude,
|
|
158
179
|
accuracy: (_v$accuracy = v.accuracy) !== null && _v$accuracy !== void 0 ? _v$accuracy : null,
|
|
159
180
|
speed: v.speed,
|
|
181
|
+
isAccurate: (_v$isAccurate = v.isAccurate) !== null && _v$isAccurate !== void 0 ? _v$isAccurate : null,
|
|
160
182
|
code: (_v$code = v.code) !== null && _v$code !== void 0 ? _v$code : null
|
|
161
183
|
});
|
|
162
184
|
}
|
|
@@ -202,6 +224,23 @@ class AppWrapper {
|
|
|
202
224
|
}
|
|
203
225
|
return id;
|
|
204
226
|
},
|
|
227
|
+
addToolbarChangeListener: async callback => {
|
|
228
|
+
const {
|
|
229
|
+
id,
|
|
230
|
+
shouldInitialize
|
|
231
|
+
} = (0, _apiListenerHelper.addApiListener)('toolbarChangeListener', callback);
|
|
232
|
+
if (shouldInitialize) {
|
|
233
|
+
this.appCall(293, {}, {
|
|
234
|
+
callback: v => {
|
|
235
|
+
(0, _apiListenerHelper.dispatchApiEvent)('toolbarChangeListener', {
|
|
236
|
+
isVisible: v.isVisible,
|
|
237
|
+
toolbarHeight: v.toolbarHeight
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
return id;
|
|
243
|
+
},
|
|
205
244
|
addWindowMetricsListener: async callback => {
|
|
206
245
|
const {
|
|
207
246
|
id,
|
|
@@ -227,13 +266,15 @@ class AppWrapper {
|
|
|
227
266
|
};
|
|
228
267
|
},
|
|
229
268
|
getGeoLocation: async () => {
|
|
269
|
+
var _res$accuracy, _res$isAccurate, _res$code;
|
|
230
270
|
const res = await this.appCall(14);
|
|
231
271
|
return {
|
|
232
272
|
latitude: res.latitude,
|
|
233
273
|
longitude: res.longitude,
|
|
234
274
|
speed: res.speed,
|
|
235
|
-
|
|
236
|
-
isAccurate: res.isAccurate
|
|
275
|
+
accuracy: (_res$accuracy = res.accuracy) !== null && _res$accuracy !== void 0 ? _res$accuracy : null,
|
|
276
|
+
isAccurate: (_res$isAccurate = res.isAccurate) !== null && _res$isAccurate !== void 0 ? _res$isAccurate : null,
|
|
277
|
+
code: (_res$code = res.code) !== null && _res$code !== void 0 ? _res$code : null
|
|
237
278
|
};
|
|
238
279
|
},
|
|
239
280
|
getUserInfo: async query => {
|
|
@@ -264,7 +305,7 @@ class AppWrapper {
|
|
|
264
305
|
window[callbackName] = ({
|
|
265
306
|
retVal
|
|
266
307
|
}) => {
|
|
267
|
-
callback === null || callback === void 0
|
|
308
|
+
callback === null || callback === void 0 || callback(retVal);
|
|
268
309
|
delete window[callbackName];
|
|
269
310
|
};
|
|
270
311
|
const callObj = {
|
|
@@ -294,6 +335,7 @@ class AppWrapper {
|
|
|
294
335
|
},
|
|
295
336
|
openImage: async value => {
|
|
296
337
|
this.appCall(4, {
|
|
338
|
+
urls: value.items.map(x => x.url),
|
|
297
339
|
items: value.items.map(x => ({
|
|
298
340
|
url: x.url,
|
|
299
341
|
title: x.title,
|
|
@@ -348,6 +390,14 @@ class AppWrapper {
|
|
|
348
390
|
// App does not support removal of onActivate callback which makes this a no-op
|
|
349
391
|
}
|
|
350
392
|
},
|
|
393
|
+
removeToolbarChangeListener: async id => {
|
|
394
|
+
const {
|
|
395
|
+
shouldRemove
|
|
396
|
+
} = (0, _apiListenerHelper.removeApiListener)('toolbarChangeListener', id);
|
|
397
|
+
if (shouldRemove) {
|
|
398
|
+
// App does not support removal of onToolbarBarRemove callback which makes this a no-op
|
|
399
|
+
}
|
|
400
|
+
},
|
|
351
401
|
removeWindowMetricsListener: async id => {
|
|
352
402
|
const shouldRemove = (0, _apiListenerHelper.removeApiListener)('windowMetricsListener', id);
|
|
353
403
|
if (shouldRemove) {
|
|
@@ -361,7 +411,7 @@ class AppWrapper {
|
|
|
361
411
|
id: options.id,
|
|
362
412
|
showName: options.showName,
|
|
363
413
|
position: options.position,
|
|
364
|
-
params: options.params
|
|
414
|
+
params: new URLSearchParams(options.params).toString() || undefined
|
|
365
415
|
}, {
|
|
366
416
|
awaitResult: false
|
|
367
417
|
});
|
|
@@ -508,6 +558,19 @@ class AppWrapper {
|
|
|
508
558
|
}
|
|
509
559
|
async init() {
|
|
510
560
|
this.values = this.mapOldApiToNew(await this.appCall(18));
|
|
561
|
+
const callbackName = `chaynsApiV5Callback_${this.counter++}`;
|
|
562
|
+
window.disablev4AccessTokenChangeListener = true;
|
|
563
|
+
window[callbackName] = ({
|
|
564
|
+
retVal: value
|
|
565
|
+
}) => {
|
|
566
|
+
this.mapOldApiToNew(value);
|
|
567
|
+
};
|
|
568
|
+
this.appCall(66, {
|
|
569
|
+
enabled: true,
|
|
570
|
+
callback: callbackName
|
|
571
|
+
}, {
|
|
572
|
+
awaitResult: false
|
|
573
|
+
});
|
|
511
574
|
return undefined;
|
|
512
575
|
}
|
|
513
576
|
getSSRData() {
|
|
@@ -12,8 +12,8 @@ var _getUserInfo = _interopRequireDefault(require("../calls/getUserInfo"));
|
|
|
12
12
|
var _sendMessage = require("../calls/sendMessage");
|
|
13
13
|
var _heightHelper = require("../util/heightHelper");
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
function _getRequireWildcardCache(
|
|
16
|
-
function _interopRequireWildcard(
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
17
17
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
18
18
|
|
|
19
19
|
class FrameWrapper {
|
|
@@ -34,6 +34,10 @@ class FrameWrapper {
|
|
|
34
34
|
return this.exposedFunctions.addScrollListener(value, callback && comlink.proxy(result => callback(result)));
|
|
35
35
|
},
|
|
36
36
|
addVisibilityChangeListener: async callback => (0, _visibilityChangeListener.addVisibilityChangeListener)(callback),
|
|
37
|
+
addToolbarChangeListener: async callback => {
|
|
38
|
+
if (!this.initialized) await this.ready;
|
|
39
|
+
return this.exposedFunctions.addToolbarChangeListener(callback && comlink.proxy(result => callback(result)));
|
|
40
|
+
},
|
|
37
41
|
addWindowMetricsListener: async callback => {
|
|
38
42
|
if (!this.initialized) await this.ready;
|
|
39
43
|
const {
|
|
@@ -105,6 +109,10 @@ class FrameWrapper {
|
|
|
105
109
|
if (!this.initialized) await this.ready;
|
|
106
110
|
return this.exposedFunctions.openImage(value);
|
|
107
111
|
},
|
|
112
|
+
openMedia: async value => {
|
|
113
|
+
if (!this.initialized) await this.ready;
|
|
114
|
+
return this.exposedFunctions.openMedia(value);
|
|
115
|
+
},
|
|
108
116
|
openUrl: async value => {
|
|
109
117
|
if (!this.initialized) await this.ready;
|
|
110
118
|
return this.exposedFunctions.openUrl(value);
|
|
@@ -142,6 +150,10 @@ class FrameWrapper {
|
|
|
142
150
|
this.resizeListener = null;
|
|
143
151
|
}
|
|
144
152
|
},
|
|
153
|
+
removeToolbarChangeListener: async id => {
|
|
154
|
+
if (!this.initialized) await this.ready;
|
|
155
|
+
return this.exposedFunctions.removeToolbarChangeListener(id);
|
|
156
|
+
},
|
|
145
157
|
selectPage: async options => {
|
|
146
158
|
if (!this.initialized) await this.ready;
|
|
147
159
|
await this.exposedFunctions.selectPage(options);
|
|
@@ -246,9 +258,9 @@ class FrameWrapper {
|
|
|
246
258
|
if (!this.initialized) await this.ready;
|
|
247
259
|
return this.exposedFunctions.openDialog(config, comlink.proxy(callback));
|
|
248
260
|
},
|
|
249
|
-
setDialogResult: async result => {
|
|
261
|
+
setDialogResult: async (buttonType, result) => {
|
|
250
262
|
if (!this.initialized) await this.ready;
|
|
251
|
-
return this.exposedFunctions.setDialogResult(result);
|
|
263
|
+
return this.exposedFunctions.setDialogResult(buttonType, result);
|
|
252
264
|
},
|
|
253
265
|
dispatchEventToDialogClient: async (dialogId, data) => {
|
|
254
266
|
if (!this.initialized) await this.ready;
|
|
@@ -303,7 +315,6 @@ class FrameWrapper {
|
|
|
303
315
|
if (this.initialized) {
|
|
304
316
|
this.values[type] = value;
|
|
305
317
|
}
|
|
306
|
-
this.values[type] = value;
|
|
307
318
|
document.dispatchEvent(new CustomEvent('chayns_api_data', {
|
|
308
319
|
detail: {
|
|
309
320
|
type,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _moduleWrapper = require("../components/moduleWrapper");
|
|
8
|
+
var _FrameWrapper = require("./FrameWrapper");
|
|
9
|
+
class StaticChaynsApi {
|
|
10
|
+
constructor() {
|
|
11
|
+
const wrapper = new _FrameWrapper.FrameWrapper();
|
|
12
|
+
_moduleWrapper.moduleWrapper.current = wrapper;
|
|
13
|
+
this._wrapper = wrapper;
|
|
14
|
+
this.ready = wrapper.init();
|
|
15
|
+
this.addDataListener = wrapper.addDataListener;
|
|
16
|
+
Object.entries(wrapper.functions).forEach(([k, v]) => {
|
|
17
|
+
this[k] = v;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
getSite = () => this._wrapper.values.site;
|
|
21
|
+
}
|
|
22
|
+
var _default = exports.default = StaticChaynsApi;
|
package/dist/esm/calls/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { moduleWrapper } from '../components/
|
|
1
|
+
import { moduleWrapper } from '../components/moduleWrapper';
|
|
2
2
|
/**
|
|
3
3
|
* This adds a listener to determine your location.
|
|
4
4
|
* @category Event listener
|
|
@@ -20,6 +20,14 @@ export const addScrollListener = function () {
|
|
|
20
20
|
export const addVisibilityChangeListener = function () {
|
|
21
21
|
return moduleWrapper.current.functions.addVisibilityChangeListener(...arguments);
|
|
22
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* This method will be executed when the toolbar gets displayed or hidden.
|
|
25
|
+
* @category Event listener
|
|
26
|
+
*/
|
|
27
|
+
export const addToolbarChangeListener = function () {
|
|
28
|
+
return moduleWrapper.current.functions.addToolbarChangeListener(...arguments);
|
|
29
|
+
};
|
|
30
|
+
|
|
23
31
|
/**
|
|
24
32
|
* This adds a listener to get the actual height of the page.
|
|
25
33
|
* @category Event listener
|
|
@@ -101,6 +109,12 @@ export const navigateBack = function () {
|
|
|
101
109
|
export const openImage = function () {
|
|
102
110
|
return moduleWrapper.current.functions.openImage(...arguments);
|
|
103
111
|
};
|
|
112
|
+
/**
|
|
113
|
+
* The images and videos specified in the items array is shown in gallery mode.
|
|
114
|
+
*/
|
|
115
|
+
export const openMedia = function () {
|
|
116
|
+
return moduleWrapper.current.functions.openMedia(...arguments);
|
|
117
|
+
};
|
|
104
118
|
/**
|
|
105
119
|
* Opens an URL in the chayns environment.
|
|
106
120
|
*/
|
|
@@ -132,6 +146,13 @@ export const refreshAccessToken = function () {
|
|
|
132
146
|
export const removeGeoLocationListener = function () {
|
|
133
147
|
return moduleWrapper.current.functions.removeGeoLocationListener(...arguments);
|
|
134
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* This removes a listener for changing toolbar visibility
|
|
151
|
+
* @category Event listener
|
|
152
|
+
*/
|
|
153
|
+
export const removeToolbarChangeListener = function () {
|
|
154
|
+
return moduleWrapper.current.functions.removeToolbarChangeListener(...arguments);
|
|
155
|
+
};
|
|
135
156
|
/**
|
|
136
157
|
* Removes scroll listener.
|
|
137
158
|
* @category Event listener
|
|
File without changes
|
|
@@ -2,6 +2,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
2
2
|
import React, { useEffect, useState } from 'react';
|
|
3
3
|
import ChaynsHost from '../host/ChaynsHost';
|
|
4
4
|
import { useFunctions, useValues } from '../hooks';
|
|
5
|
+
import ErrorBoundary from "./ErrorBoundary";
|
|
5
6
|
const AppDialogWrapper = _ref => {
|
|
6
7
|
let {
|
|
7
8
|
dialogEventTarget
|
|
@@ -18,16 +19,16 @@ const AppDialogWrapper = _ref => {
|
|
|
18
19
|
});
|
|
19
20
|
});
|
|
20
21
|
}, []);
|
|
21
|
-
return /*#__PURE__*/React.createElement(ChaynsHost, _extends({
|
|
22
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(ChaynsHost, _extends({
|
|
22
23
|
type: "client-module",
|
|
23
24
|
system: {
|
|
24
25
|
module: './AppWrapper',
|
|
25
|
-
url: 'https://tapp
|
|
26
|
+
url: 'https://tapp.chayns-static.space/api/dialog-v2/v1/remoteEntry.js',
|
|
26
27
|
scope: 'dialog_v2'
|
|
27
28
|
}
|
|
28
29
|
}, data, {
|
|
29
30
|
functions: functions,
|
|
30
31
|
customData: dialogData
|
|
31
|
-
}));
|
|
32
|
+
})));
|
|
32
33
|
};
|
|
33
34
|
export default AppDialogWrapper;
|
|
@@ -7,12 +7,11 @@ import { FrameWrapper } from '../wrapper/FrameWrapper';
|
|
|
7
7
|
import { ModuleFederationWrapper } from '../wrapper/ModuleFederationWrapper';
|
|
8
8
|
import { SsrWrapper } from '../wrapper/SsrWrapper';
|
|
9
9
|
import { ChaynsContext, ChaynsFunctionsContext } from './ChaynsContext';
|
|
10
|
-
import AppDialogWrapper from
|
|
10
|
+
import AppDialogWrapper from './AppDialogWrapper';
|
|
11
|
+
import { moduleWrapper } from './moduleWrapper';
|
|
11
12
|
|
|
12
13
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13
|
-
|
|
14
|
-
current: undefined
|
|
15
|
-
};
|
|
14
|
+
|
|
16
15
|
const isServer = typeof window === 'undefined';
|
|
17
16
|
const InitialDataProvider = /*#__PURE__*/React.memo(_ref => {
|
|
18
17
|
let {
|
|
@@ -58,7 +57,7 @@ const ChaynsProvider = _ref2 => {
|
|
|
58
57
|
var _deviceInfo$app$name, _deviceInfo$app;
|
|
59
58
|
const deviceInfo = getDeviceInfo(navigator.userAgent, '');
|
|
60
59
|
// load framewrapper in Chaynsweb in app (window.self === window.top)
|
|
61
|
-
if ([AppName.Chayns, AppName.ChaynsLauncher].includes((_deviceInfo$app$name = (_deviceInfo$app = deviceInfo.app) === null || _deviceInfo$app === void 0 ? void 0 : _deviceInfo$app.name) !== null && _deviceInfo$app$name !== void 0 ? _deviceInfo$app$name : AppName.Unknown) && window.self === window.top) {
|
|
60
|
+
if ([AppName.Chayns, AppName.ChaynsLauncher, AppName.Sidekick, AppName.TobitChat].includes((_deviceInfo$app$name = (_deviceInfo$app = deviceInfo.app) === null || _deviceInfo$app === void 0 ? void 0 : _deviceInfo$app.name) !== null && _deviceInfo$app$name !== void 0 ? _deviceInfo$app$name : AppName.Unknown) && window.self === window.top) {
|
|
62
61
|
customWrapper.current = new AppWrapper();
|
|
63
62
|
} else {
|
|
64
63
|
customWrapper.current = new FrameWrapper();
|
|
@@ -83,7 +82,7 @@ const ChaynsProvider = _ref2 => {
|
|
|
83
82
|
return undefined;
|
|
84
83
|
});
|
|
85
84
|
});
|
|
86
|
-
if (customWrapper.current.values) {
|
|
85
|
+
if (customWrapper.current.values && !isModule) {
|
|
87
86
|
setState({
|
|
88
87
|
...customWrapper.current.values
|
|
89
88
|
});
|
|
@@ -94,7 +93,7 @@ const ChaynsProvider = _ref2 => {
|
|
|
94
93
|
if (isModule) {
|
|
95
94
|
setState(data);
|
|
96
95
|
if (data) {
|
|
97
|
-
|
|
96
|
+
customWrapper.current.values = data;
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
}, [data, isModule]);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export default class ErrorBoundary extends React.Component {
|
|
3
|
+
constructor(props) {
|
|
4
|
+
super(props);
|
|
5
|
+
this.state = {
|
|
6
|
+
hasError: false
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
static getDerivedStateFromError() {
|
|
10
|
+
return {
|
|
11
|
+
hasError: true
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
componentDidCatch(error, errorInfo) {
|
|
15
|
+
console.error(error, errorInfo);
|
|
16
|
+
}
|
|
17
|
+
render() {
|
|
18
|
+
if (this.state.hasError) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return this.props.children;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -3,6 +3,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
3
3
|
|
|
4
4
|
import React, { PureComponent } from 'react';
|
|
5
5
|
import ReactDOM from 'react-dom';
|
|
6
|
+
import ErrorBoundary from './ErrorBoundary';
|
|
6
7
|
let ReactDOMClient;
|
|
7
8
|
try {
|
|
8
9
|
ReactDOMClient = require('react-dom/client');
|
|
@@ -20,9 +21,9 @@ export const withCompatMode = Component => {
|
|
|
20
21
|
const {
|
|
21
22
|
innerRef
|
|
22
23
|
} = this.props;
|
|
23
|
-
const component = /*#__PURE__*/React.createElement(Component, _extends({}, this.props, {
|
|
24
|
+
const component = /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Component, _extends({}, this.props, {
|
|
24
25
|
ref: innerRef
|
|
25
|
-
}));
|
|
26
|
+
})));
|
|
26
27
|
if (typeof ((_ReactDOMClient = ReactDOMClient) === null || _ReactDOMClient === void 0 ? void 0 : _ReactDOMClient.createRoot) === 'function') {
|
|
27
28
|
this.root = ReactDOMClient.createRoot(this.ref.current);
|
|
28
29
|
this.root.render(component);
|
|
@@ -34,9 +35,9 @@ export const withCompatMode = Component => {
|
|
|
34
35
|
const {
|
|
35
36
|
innerRef
|
|
36
37
|
} = this.props;
|
|
37
|
-
const component = /*#__PURE__*/React.createElement(Component, _extends({}, this.props, {
|
|
38
|
+
const component = /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Component, _extends({}, this.props, {
|
|
38
39
|
ref: innerRef
|
|
39
|
-
}));
|
|
40
|
+
})));
|
|
40
41
|
if (this.root) {
|
|
41
42
|
this.root.render(component);
|
|
42
43
|
} else {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import { HydrationContext } from '../constants';
|
|
3
|
+
const withHydrationBoundary = (Component, initializer, useHydrationId) => {
|
|
4
|
+
return _ref => {
|
|
5
|
+
let {
|
|
6
|
+
id: idProp,
|
|
7
|
+
children
|
|
8
|
+
} = _ref;
|
|
9
|
+
let value;
|
|
10
|
+
if (!globalThis.window) {
|
|
11
|
+
value = useContext(HydrationContext);
|
|
12
|
+
}
|
|
13
|
+
const id = useHydrationId ? useHydrationId() : idProp;
|
|
14
|
+
if (!id) {
|
|
15
|
+
throw new Error('hydration boundary was not given a id which is required');
|
|
16
|
+
}
|
|
17
|
+
const [store] = useState(() => {
|
|
18
|
+
if (!globalThis.window && id in value) {
|
|
19
|
+
return value[id];
|
|
20
|
+
}
|
|
21
|
+
let initialValue = undefined;
|
|
22
|
+
if (globalThis.window) {
|
|
23
|
+
const htmlId = `__INITIAL_DATA_${id}__`;
|
|
24
|
+
const $elem = document.getElementById(htmlId);
|
|
25
|
+
if ($elem) {
|
|
26
|
+
initialValue = JSON.parse($elem.innerHTML);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const s = initializer(initialValue);
|
|
30
|
+
if (!globalThis.window) {
|
|
31
|
+
value[id] = s;
|
|
32
|
+
}
|
|
33
|
+
return s;
|
|
34
|
+
});
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const htmlId = `__INITIAL_DATA_${id}__`;
|
|
37
|
+
const $elem = document.getElementById(htmlId);
|
|
38
|
+
if ($elem) {
|
|
39
|
+
$elem.remove();
|
|
40
|
+
}
|
|
41
|
+
}, []);
|
|
42
|
+
return /*#__PURE__*/React.createElement(Component, {
|
|
43
|
+
value: store
|
|
44
|
+
}, children);
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export default withHydrationBoundary;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
export let HydrationContext;
|
|
3
|
+
|
|
4
|
+
// force single context on server-side (fake sharing)
|
|
5
|
+
if (!globalThis.window && globalThis._hydrationContext) {
|
|
6
|
+
HydrationContext = globalThis._hydrationContext;
|
|
7
|
+
} else {
|
|
8
|
+
HydrationContext = /*#__PURE__*/createContext({});
|
|
9
|
+
globalThis._hydrationContext = HydrationContext;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hydrationContext';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export let DeviceLanguage = /*#__PURE__*/function (DeviceLanguage) {
|
|
2
|
+
DeviceLanguage[DeviceLanguage["de"] = 1] = "de";
|
|
3
|
+
DeviceLanguage[DeviceLanguage["en"] = 2] = "en";
|
|
4
|
+
DeviceLanguage[DeviceLanguage["fr"] = 3] = "fr";
|
|
5
|
+
DeviceLanguage[DeviceLanguage["it"] = 4] = "it";
|
|
6
|
+
DeviceLanguage[DeviceLanguage["nl"] = 5] = "nl";
|
|
7
|
+
DeviceLanguage[DeviceLanguage["es"] = 6] = "es";
|
|
8
|
+
DeviceLanguage[DeviceLanguage["pt"] = 7] = "pt";
|
|
9
|
+
DeviceLanguage[DeviceLanguage["tr"] = 8] = "tr";
|
|
10
|
+
DeviceLanguage[DeviceLanguage["pl"] = 9] = "pl";
|
|
11
|
+
DeviceLanguage[DeviceLanguage["uk"] = 10] = "uk";
|
|
12
|
+
return DeviceLanguage;
|
|
13
|
+
}({});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
function _toPropertyKey(
|
|
3
|
-
function _toPrimitive(
|
|
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
4
|
export default class DialogHandler {
|
|
5
5
|
constructor(config, open, close, dispatchEvent, addDataListener) {
|
|
6
6
|
_defineProperty(this, "isOpen", false);
|
|
@@ -23,9 +23,11 @@ export default class DialogHandler {
|
|
|
23
23
|
};
|
|
24
24
|
this.isOpen = true;
|
|
25
25
|
this.dialogId = await this._open(this._config, callback);
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
// console.log('dialogId', this.dialogId);
|
|
28
|
+
|
|
27
29
|
this._addDataListener(this.dialogId, data => {
|
|
28
|
-
console.log('[DialogHandler]dataListener', this.dialogId, data);
|
|
30
|
+
// console.log('[DialogHandler]dataListener', this.dialogId, data);
|
|
29
31
|
this.listeners.forEach(cb => cb(data));
|
|
30
32
|
});
|
|
31
33
|
});
|
|
@@ -10,7 +10,7 @@ export const useDialogState = () => {
|
|
|
10
10
|
const addDataListener = useContextSelector(ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.addDialogHostEventListener);
|
|
11
11
|
const isClosingRequested = useContextSelector(ChaynsContext, v => {
|
|
12
12
|
var _v$dialog;
|
|
13
|
-
return v === null || v === void 0
|
|
13
|
+
return v === null || v === void 0 || (_v$dialog = v.dialog) === null || _v$dialog === void 0 ? void 0 : _v$dialog.isClosingRequested;
|
|
14
14
|
});
|
|
15
15
|
return {
|
|
16
16
|
setResult,
|
|
@@ -26,7 +26,7 @@ export const useDialogState = () => {
|
|
|
26
26
|
export const useDialogData = () => {
|
|
27
27
|
const inputData = useContextSelector(ChaynsContext, v => {
|
|
28
28
|
var _v$dialog2;
|
|
29
|
-
return v === null || v === void 0
|
|
29
|
+
return v === null || v === void 0 || (_v$dialog2 = v.dialog) === null || _v$dialog2 === void 0 ? void 0 : _v$dialog2.dialogInput;
|
|
30
30
|
});
|
|
31
31
|
return inputData;
|
|
32
32
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
import { moduleWrapper } from
|
|
3
|
+
import { moduleWrapper } from '../components/moduleWrapper';
|
|
4
4
|
/**
|
|
5
5
|
* @category Hooks
|
|
6
6
|
*/
|