chayns-api 1.0.1 → 1.0.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 (263) hide show
  1. package/.babelrc +30 -30
  2. package/.eslintrc +17 -17
  3. package/.github/workflows/deploy_docs.yml +28 -28
  4. package/.github/workflows/publish.yml +21 -0
  5. package/LICENSE +21 -21
  6. package/README.md +47 -47
  7. package/dist/cjs/calls/dialogs/alert.js +0 -2
  8. package/dist/cjs/calls/dialogs/chaynsDialog.js +2 -8
  9. package/dist/cjs/calls/dialogs/close.js +0 -2
  10. package/dist/cjs/calls/dialogs/communication.js +1 -16
  11. package/dist/cjs/calls/dialogs/confirm.js +0 -4
  12. package/dist/cjs/calls/dialogs/date.js +46 -63
  13. package/dist/cjs/calls/dialogs/dropUpAlert.js +0 -3
  14. package/dist/cjs/calls/dialogs/fileSelect.js +0 -10
  15. package/dist/cjs/calls/dialogs/iFrame.js +0 -8
  16. package/dist/cjs/calls/dialogs/index.js +0 -27
  17. package/dist/cjs/calls/dialogs/input.js +0 -6
  18. package/dist/cjs/calls/dialogs/mediaSelect.js +0 -7
  19. package/dist/cjs/calls/dialogs/open.js +0 -2
  20. package/dist/cjs/calls/dialogs/select.js +0 -9
  21. package/dist/cjs/calls/dialogs/signature.js +0 -5
  22. package/dist/cjs/calls/dialogs/toast.js +0 -3
  23. package/dist/cjs/calls/dialogs/utils/callback.js +0 -2
  24. package/dist/cjs/calls/dialogs/utils/is.js +0 -4
  25. package/dist/cjs/calls/getUserInfo.js +0 -11
  26. package/dist/cjs/calls/index.js +95 -247
  27. package/dist/cjs/calls/sendMessage.js +8 -34
  28. package/dist/cjs/calls/visibilityChangeListener.js +5 -16
  29. package/dist/cjs/components/ChaynsContext.js +2 -4
  30. package/dist/cjs/components/ChaynsProvider.js +6 -28
  31. package/dist/cjs/components/WaitUntil.js +0 -5
  32. package/dist/cjs/components/withCompatMode.js +1 -16
  33. package/dist/cjs/helper/apiListenerHelper.js +0 -9
  34. package/dist/cjs/hooks/geoLocationListener.js +6 -15
  35. package/dist/cjs/hooks/index.js +6 -16
  36. package/dist/cjs/hooks/scrollListener.js +12 -31
  37. package/dist/cjs/hooks/useAccessToken.js +2 -7
  38. package/dist/cjs/hooks/useCurrentPage.js +2 -6
  39. package/dist/cjs/hooks/useCustomData.js +2 -6
  40. package/dist/cjs/hooks/useDevice.js +2 -6
  41. package/dist/cjs/hooks/useEnvironment.js +2 -6
  42. package/dist/cjs/hooks/useFunctions.js +2 -6
  43. package/dist/cjs/hooks/useIsAdminMode.js +2 -7
  44. package/dist/cjs/hooks/useLanguage.js +2 -6
  45. package/dist/cjs/hooks/usePages.js +26 -18
  46. package/dist/cjs/hooks/useParameters.js +2 -6
  47. package/dist/cjs/hooks/useSite.js +2 -6
  48. package/dist/cjs/hooks/useUser.js +2 -7
  49. package/dist/cjs/hooks/useValues.js +2 -6
  50. package/dist/cjs/hooks/windowMetricsListener.js +6 -16
  51. package/dist/cjs/host/ChaynsHost.js +0 -10
  52. package/dist/cjs/host/iframe/HostIframe.js +23 -30
  53. package/dist/cjs/host/iframe/utils/useUpdateData.js +0 -3
  54. package/dist/cjs/host/module/ModuleHost.js +3 -13
  55. package/dist/cjs/host/module/utils/loadComponent.js +1 -18
  56. package/dist/cjs/host/module/utils/useDynamicScript.js +0 -18
  57. package/dist/cjs/index.js +0 -19
  58. package/dist/cjs/types/IChaynsReact.js +27 -48
  59. package/dist/cjs/util/appCall.js +1 -4
  60. package/dist/cjs/util/deviceHelper.js +5 -22
  61. package/dist/cjs/util/heightHelper.js +0 -9
  62. package/dist/cjs/util/postIframeForm.js +0 -5
  63. package/dist/cjs/wrapper/AppWrapper.js +323 -159
  64. package/dist/cjs/wrapper/FrameWrapper.js +219 -248
  65. package/dist/cjs/wrapper/ModuleFederationWrapper.js +2 -27
  66. package/dist/cjs/wrapper/SsrWrapper.js +0 -8
  67. package/dist/esm/calls/dialogs/alert.js +4 -4
  68. package/dist/esm/calls/dialogs/chaynsDialog.js +7 -11
  69. package/dist/esm/calls/dialogs/communication.js +15 -26
  70. package/dist/esm/calls/dialogs/confirm.js +5 -8
  71. package/dist/esm/calls/dialogs/date.js +119 -128
  72. package/dist/esm/calls/dialogs/dropUpAlert.js +1 -1
  73. package/dist/esm/calls/dialogs/fileSelect.js +23 -62
  74. package/dist/esm/calls/dialogs/iFrame.js +7 -10
  75. package/dist/esm/calls/dialogs/input.js +2 -5
  76. package/dist/esm/calls/dialogs/mediaSelect.js +18 -55
  77. package/dist/esm/calls/dialogs/open.js +2 -2
  78. package/dist/esm/calls/dialogs/select.js +5 -9
  79. package/dist/esm/calls/dialogs/signature.js +0 -2
  80. package/dist/esm/calls/dialogs/toast.js +6 -11
  81. package/dist/esm/calls/dialogs/utils/callback.js +3 -5
  82. package/dist/esm/calls/dialogs/utils/is.js +1 -3
  83. package/dist/esm/calls/getUserInfo.js +32 -92
  84. package/dist/esm/calls/index.js +297 -449
  85. package/dist/esm/calls/sendMessage.js +99 -229
  86. package/dist/esm/calls/visibilityChangeListener.js +14 -19
  87. package/dist/esm/components/ChaynsContext.js +3 -3
  88. package/dist/esm/components/ChaynsProvider.js +45 -86
  89. package/dist/esm/components/WaitUntil.js +21 -86
  90. package/dist/esm/components/withCompatMode.js +35 -77
  91. package/dist/esm/helper/apiListenerHelper.js +10 -15
  92. package/dist/esm/hooks/geoLocationListener.js +24 -50
  93. package/dist/esm/hooks/index.js +1 -1
  94. package/dist/esm/hooks/scrollListener.js +58 -94
  95. package/dist/esm/hooks/useAccessToken.js +8 -30
  96. package/dist/esm/hooks/useCurrentPage.js +4 -8
  97. package/dist/esm/hooks/useCustomData.js +4 -8
  98. package/dist/esm/hooks/useDevice.js +3 -8
  99. package/dist/esm/hooks/useEnvironment.js +3 -8
  100. package/dist/esm/hooks/useFunctions.js +4 -7
  101. package/dist/esm/hooks/useIsAdminMode.js +4 -8
  102. package/dist/esm/hooks/useLanguage.js +3 -8
  103. package/dist/esm/hooks/usePages.js +38 -31
  104. package/dist/esm/hooks/useParameters.js +3 -8
  105. package/dist/esm/hooks/useSite.js +3 -8
  106. package/dist/esm/hooks/useUser.js +3 -9
  107. package/dist/esm/hooks/useValues.js +4 -7
  108. package/dist/esm/hooks/windowMetricsListener.js +22 -48
  109. package/dist/esm/host/ChaynsHost.js +22 -29
  110. package/dist/esm/host/iframe/HostIframe.js +86 -142
  111. package/dist/esm/host/iframe/utils/useUpdateData.js +4 -6
  112. package/dist/esm/host/module/ModuleHost.js +42 -49
  113. package/dist/esm/host/module/utils/loadComponent.js +47 -85
  114. package/dist/esm/host/module/utils/useDynamicScript.js +27 -74
  115. package/dist/esm/types/IChaynsReact.js +37 -61
  116. package/dist/esm/util/appCall.js +2 -4
  117. package/dist/esm/util/deviceHelper.js +13 -37
  118. package/dist/esm/util/heightHelper.js +10 -13
  119. package/dist/esm/util/postIframeForm.js +25 -57
  120. package/dist/esm/wrapper/AppWrapper.js +385 -781
  121. package/dist/esm/wrapper/FrameWrapper.js +262 -1509
  122. package/dist/esm/wrapper/ModuleFederationWrapper.js +47 -284
  123. package/dist/esm/wrapper/SsrWrapper.js +19 -65
  124. package/dist/types/calls/dialogs/alert.d.ts +1 -1
  125. package/dist/types/calls/dialogs/chaynsDialog.d.ts +24 -24
  126. package/dist/types/calls/dialogs/close.d.ts +1 -1
  127. package/dist/types/calls/dialogs/communication.d.ts +3 -3
  128. package/dist/types/calls/dialogs/confirm.d.ts +13 -13
  129. package/dist/types/calls/dialogs/date.d.ts +96 -96
  130. package/dist/types/calls/dialogs/dropUpAlert.d.ts +5 -5
  131. package/dist/types/calls/dialogs/fileSelect.d.ts +16 -16
  132. package/dist/types/calls/dialogs/iFrame.d.ts +10 -10
  133. package/dist/types/calls/dialogs/index.d.ts +14 -14
  134. package/dist/types/calls/dialogs/input.d.ts +15 -15
  135. package/dist/types/calls/dialogs/mediaSelect.d.ts +8 -8
  136. package/dist/types/calls/dialogs/open.d.ts +1 -1
  137. package/dist/types/calls/dialogs/select.d.ts +6 -6
  138. package/dist/types/calls/dialogs/signature.d.ts +7 -7
  139. package/dist/types/calls/dialogs/toast.d.ts +1 -1
  140. package/dist/types/calls/dialogs/utils/callback.d.ts +1 -1
  141. package/dist/types/calls/dialogs/utils/is.d.ts +4 -4
  142. package/dist/types/calls/getUserInfo.d.ts +9 -9
  143. package/dist/types/calls/index.d.ts +225 -231
  144. package/dist/types/calls/sendMessage.d.ts +13 -13
  145. package/dist/types/calls/visibilityChangeListener.d.ts +9 -9
  146. package/dist/types/components/ChaynsContext.d.ts +3 -3
  147. package/dist/types/components/ChaynsProvider.d.ts +13 -13
  148. package/dist/types/components/WaitUntil.d.ts +7 -7
  149. package/dist/types/components/withCompatMode.d.ts +13 -13
  150. package/dist/types/helper/apiListenerHelper.d.ts +6 -6
  151. package/dist/types/hooks/geoLocationListener.d.ts +18 -18
  152. package/dist/types/hooks/index.d.ts +16 -16
  153. package/dist/types/hooks/scrollListener.d.ts +28 -28
  154. package/dist/types/hooks/useAccessToken.d.ts +5 -5
  155. package/dist/types/hooks/useCurrentPage.d.ts +4 -4
  156. package/dist/types/hooks/useCustomData.d.ts +4 -4
  157. package/dist/types/hooks/useDevice.d.ts +5 -5
  158. package/dist/types/hooks/useEnvironment.d.ts +5 -5
  159. package/dist/types/hooks/useFunctions.d.ts +5 -5
  160. package/dist/types/hooks/useIsAdminMode.d.ts +4 -4
  161. package/dist/types/hooks/useLanguage.d.ts +5 -5
  162. package/dist/types/hooks/usePages.d.ts +18 -14
  163. package/dist/types/hooks/useParameters.d.ts +5 -5
  164. package/dist/types/hooks/useSite.d.ts +5 -5
  165. package/dist/types/hooks/useUser.d.ts +5 -5
  166. package/dist/types/hooks/useValues.d.ts +5 -5
  167. package/dist/types/hooks/windowMetricsListener.d.ts +11 -11
  168. package/dist/types/host/ChaynsHost.d.ts +28 -28
  169. package/dist/types/host/iframe/HostIframe.d.ts +24 -24
  170. package/dist/types/host/iframe/utils/useUpdateData.d.ts +3 -3
  171. package/dist/types/host/module/ModuleHost.d.ts +23 -23
  172. package/dist/types/host/module/utils/loadComponent.d.ts +1 -1
  173. package/dist/types/host/module/utils/useDynamicScript.d.ts +9 -9
  174. package/dist/types/index.d.ts +16 -16
  175. package/dist/types/types/IChaynsReact.d.ts +622 -590
  176. package/dist/types/types/dialog.d.ts +41 -41
  177. package/dist/types/util/appCall.d.ts +2 -2
  178. package/dist/types/util/deviceHelper.d.ts +7 -7
  179. package/dist/types/util/heightHelper.d.ts +1 -1
  180. package/dist/types/util/postIframeForm.d.ts +1 -1
  181. package/dist/types/wrapper/AppWrapper.d.ts +18 -16
  182. package/dist/types/wrapper/FrameWrapper.d.ts +15 -15
  183. package/dist/types/wrapper/ModuleFederationWrapper.d.ts +10 -10
  184. package/dist/types/wrapper/SsrWrapper.d.ts +11 -11
  185. package/package.json +76 -76
  186. package/toolkit.config.js +52 -52
  187. package/tsconfig.json +56 -56
  188. package/dist/cjs/bootstrap.js +0 -11
  189. package/dist/cjs/calls/abstractApiListener.js +0 -40
  190. package/dist/cjs/calls/apiEventListener.js +0 -40
  191. package/dist/cjs/calls/setVisibilityChangeListener.js +0 -1
  192. package/dist/cjs/calls/windowMetricsListener.js +0 -18
  193. package/dist/cjs/client.js +0 -93
  194. package/dist/cjs/components/App.js +0 -32
  195. package/dist/cjs/components/App.spec.js +0 -16
  196. package/dist/cjs/components/Button.js +0 -32
  197. package/dist/cjs/components/ChaynsModuleProvider.js +0 -457
  198. package/dist/cjs/components/ChaynsProviderExposed.js +0 -16
  199. package/dist/cjs/components/TestProvider.js +0 -236
  200. package/dist/cjs/components/Title.js +0 -162
  201. package/dist/cjs/functions/addApiListener.js +0 -37
  202. package/dist/cjs/functions/addGeoLocationListener.js +0 -26
  203. package/dist/cjs/functions/addScrollListener.js +0 -26
  204. package/dist/cjs/functions/addWindowMetricsListener.js +0 -37
  205. package/dist/cjs/helper/cssLoader.js +0 -28
  206. package/dist/cjs/hooks/addGeoLocationListener.js +0 -26
  207. package/dist/cjs/hooks/addScrollListener.js +0 -26
  208. package/dist/cjs/hooks/addWindowMetricsListener.js +0 -37
  209. package/dist/cjs/hooks/geoLocation.js +0 -48
  210. package/dist/cjs/hooks/useAddGeoLocationListener.js +0 -26
  211. package/dist/cjs/hooks/useAddScrollListener.js +0 -48
  212. package/dist/cjs/hooks/useAddWindowMetricsListener.js +0 -45
  213. package/dist/cjs/hooks/useAdddScrollListener.js +0 -26
  214. package/dist/cjs/hooks/windowMetrics.js +0 -45
  215. package/dist/cjs/host/HostIframe.js +0 -157
  216. package/dist/cjs/host/ModuleHost.js +0 -11
  217. package/dist/cjs/host/module/utils.js +0 -25
  218. package/dist/cjs/index.example.js +0 -7
  219. package/dist/cjs/index2.js +0 -64
  220. package/dist/cjs/types/DynamicApiImport.d.js +0 -5
  221. package/dist/cjs/types/DynamicImport.d.js +0 -5
  222. package/dist/cjs/types/chayns-components.d.js +0 -1
  223. package/dist/cjs/types/chayns-logger.d.js +0 -1
  224. package/dist/cjs/types/chayns.d.js +0 -1
  225. package/dist/cjs/types/tobit-websocket-service-client.d.js +0 -1
  226. package/dist/cjs/types/toolkit-types.d.js +0 -1
  227. package/dist/cjs/util/useFunctionsContext.js +0 -16
  228. package/dist/cjs/util/useIsAdminMode.js +0 -18
  229. package/dist/cjs/util/useUser.js +0 -16
  230. package/dist/esm/bootstrap.js +0 -4
  231. package/dist/esm/client.js +0 -8
  232. package/dist/esm/components/App.js +0 -35
  233. package/dist/esm/components/App.spec.js +0 -9
  234. package/dist/esm/components/Button.js +0 -34
  235. package/dist/esm/components/ChaynsModuleProvider.js +0 -517
  236. package/dist/esm/components/ChaynsProviderExposed.js +0 -3
  237. package/dist/esm/components/TestProvider.js +0 -308
  238. package/dist/esm/components/Title.js +0 -210
  239. package/dist/esm/helper/cssLoader.js +0 -21
  240. package/dist/esm/hooks/useAddGeoLocationListener.js +0 -18
  241. package/dist/esm/hooks/useAddScrollListener.js +0 -18
  242. package/dist/esm/hooks/useAddWindowMetricsListener.js +0 -18
  243. package/dist/esm/host/HostIframe.js +0 -153
  244. package/dist/esm/index.example.js +0 -1
  245. package/dist/esm/index2.js +0 -5
  246. package/dist/esm/types/DynamicApiImport.d.js +0 -1
  247. package/dist/esm/types/DynamicImport.d.js +0 -1
  248. package/dist/esm/types/chayns-components.d.js +0 -0
  249. package/dist/esm/types/chayns-logger.d.js +0 -0
  250. package/dist/esm/types/chayns.d.js +0 -0
  251. package/dist/esm/types/tobit-websocket-service-client.d.js +0 -0
  252. package/dist/esm/types/toolkit-types.d.js +0 -0
  253. package/dist/esm/util/useIsAdminMode.js +0 -9
  254. package/dist/esm/util/useUser.js +0 -7
  255. package/dist/types/bootstrap.d.ts +0 -1
  256. package/dist/types/client.d.ts +0 -7
  257. package/dist/types/components/App.d.ts +0 -5
  258. package/dist/types/components/Button.d.ts +0 -8
  259. package/dist/types/components/ChaynsModuleProvider.d.ts +0 -170
  260. package/dist/types/components/ChaynsProviderExposed.d.ts +0 -13
  261. package/dist/types/components/Title.d.ts +0 -3
  262. package/dist/types/host/HostIframe.d.ts +0 -20
  263. package/dist/types/index.example.d.ts +0 -0
@@ -1,73 +1,97 @@
1
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
-
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
-
7
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
-
9
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
-
11
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
12
-
13
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
14
-
15
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
16
-
17
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
18
-
19
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
20
-
21
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
-
23
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
24
-
25
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
26
-
27
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ /* eslint-disable */
3
+ // @ts-nocheck
28
4
 
29
- import { Environment, Font, Gender, IconType, RuntimeEnviroment } from '../types/IChaynsReact';
5
+ import { Environment, Font, Gender, IconType, RuntimeEnviroment, TappEvent } from '../types/IChaynsReact';
30
6
  import invokeAppCall from "../util/appCall";
31
- import getDeviceInfo from "../util/deviceHelper";
32
- import { removeVisibilityChangeListener as _removeVisibilityChangeListener } from "../calls/visibilityChangeListener";
33
- import _getUserInfo from "../calls/getUserInfo";
34
- export var AppWrapper = /*#__PURE__*/function () {
35
- function AppWrapper() {
36
- var _this = this;
37
-
38
- _classCallCheck(this, AppWrapper);
39
-
7
+ import getDeviceInfo, { getScreenSize } from "../util/deviceHelper";
8
+ import { removeVisibilityChangeListener } from "../calls/visibilityChangeListener";
9
+ import getUserInfo from "../calls/getUserInfo";
10
+ import { sendMessageToGroup, sendMessageToPage, sendMessageToUser } from "../calls/sendMessage";
11
+ import { addApiListener, dispatchApiEvent } from "../helper/apiListenerHelper";
12
+ export class AppWrapper {
13
+ mapOldApiToNew(retVal) {
14
+ var _window, _window2, _AppInfo$TappSelected;
15
+ const {
16
+ AppInfo,
17
+ AppUser
18
+ } = retVal;
19
+ this.accessToken = AppUser.TobitAccessToken;
20
+ return {
21
+ device: getDeviceInfo(navigator.userAgent, 'image/webp'),
22
+ environment: {
23
+ buildEnvironment: Environment.Production,
24
+ runtimeEnvironment: RuntimeEnviroment.Unknown
25
+ },
26
+ language: {
27
+ site: AppInfo.Language,
28
+ translation: null,
29
+ device: AppInfo.Language,
30
+ active: AppInfo.Language
31
+ },
32
+ // ToDo: Find better way to detect
33
+ site: {
34
+ id: AppInfo.SiteID,
35
+ locationId: AppInfo.LocationID,
36
+ url: (_window = window) === null || _window === void 0 ? void 0 : _window.location.href.split('#')[0],
37
+ layoutDisposition: {
38
+ contentWide: false,
39
+ barOnTop: false,
40
+ barWide: false,
41
+ coverDetached: false,
42
+ coverHidden: false,
43
+ coverWide: false,
44
+ docked: false
45
+ },
46
+ title: AppInfo.Title,
47
+ colorMode: AppInfo.colorMode,
48
+ color: AppInfo.color,
49
+ domain: AppInfo.domain,
50
+ font: {
51
+ id: Font.Roboto,
52
+ headlineFont: Font.Roboto,
53
+ dynamicFontSize: false
54
+ },
55
+ dynamicFontSize: false,
56
+ locationPersonId: AppInfo.LocationPersonId,
57
+ urlHash: (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.location.hash.replace('#', '')
58
+ },
59
+ parameters: [...new URLSearchParams(location.search)],
60
+ user: {
61
+ firstName: AppUser.FirstName,
62
+ lastName: AppUser.LastName,
63
+ gender: Gender.Unknown,
64
+ userId: AppUser.TobitUserID,
65
+ personId: AppUser.PersonID,
66
+ uacGroups: []
67
+ },
68
+ customData: null,
69
+ isAdminModeActive: AppUser.AdminMode,
70
+ currentPage: {
71
+ id: (_AppInfo$TappSelected = AppInfo.TappSelected) === null || _AppInfo$TappSelected === void 0 ? void 0 : _AppInfo$TappSelected.TappID,
72
+ siteId: AppInfo.SiteID
73
+ },
74
+ pages: AppInfo.Tapps.map(x => ({
75
+ id: x.TappID,
76
+ icon: '',
77
+ iconType: IconType.Font,
78
+ customUrl: '',
79
+ isExclusive: x.isExclusiveView,
80
+ isHiddenFromMenu: x.isHiddenFromMenu,
81
+ minAge: null,
82
+ name: x.ShowName,
83
+ sortId: x.SortUID
84
+ }))
85
+ };
86
+ }
87
+ constructor() {
40
88
  _defineProperty(this, "values", null);
41
-
42
89
  _defineProperty(this, "accessToken", "");
43
-
44
90
  _defineProperty(this, "counter", 0);
45
-
46
91
  _defineProperty(this, "functions", {
47
- getAccessToken: function () {
48
- var _getAccessToken = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(accessToken) {
49
- return regeneratorRuntime.wrap(function _callee$(_context) {
50
- while (1) {
51
- switch (_context.prev = _context.next) {
52
- case 0:
53
- return _context.abrupt("return", {
54
- accessToken: _this.accessToken
55
- });
56
-
57
- case 1:
58
- case "end":
59
- return _context.stop();
60
- }
61
- }
62
- }, _callee);
63
- }));
64
-
65
- function getAccessToken(_x) {
66
- return _getAccessToken.apply(this, arguments);
67
- }
68
-
69
- return getAccessToken;
70
- }(),
92
+ getAccessToken: async () => ({
93
+ accessToken: this.accessToken
94
+ }),
71
95
  // addGeoLocationListener: async (value , callback) => {
72
96
  // return invokeAppCall({
73
97
  // 'action': 14,
@@ -80,7 +104,22 @@ export var AppWrapper = /*#__PURE__*/function () {
80
104
  // addScrollListener: async (value, callback) => {
81
105
  //
82
106
  // },
83
- // addVisibilityChangeListener: async (callback) => addVisibilityChangeListener(callback),
107
+ addVisibilityChangeListener: async callback => {
108
+ const {
109
+ id,
110
+ shouldInitialize
111
+ } = addApiListener('windowMetricsListener', callback);
112
+ this.appCall(60, {}, {
113
+ callback: v => {
114
+ console.log("v", v);
115
+ dispatchApiEvent("windowMetricsListener", {
116
+ isVisible: v.tappEvent === TappEvent.OnShow,
117
+ tappEvent: v.tappEvent
118
+ });
119
+ }
120
+ });
121
+ return id;
122
+ },
84
123
  // addWindowMetricsListener: async (callback) => {
85
124
  // const { id, shouldInitialize } = addApiListener('windowMetricsListener', callback);
86
125
  //
@@ -95,730 +134,295 @@ export var AppWrapper = /*#__PURE__*/function () {
95
134
  // }
96
135
  // return id;
97
136
  // },
98
- customCallbackFunction: function () {
99
- var _customCallbackFunction = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(type, data) {
100
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
101
- while (1) {
102
- switch (_context2.prev = _context2.next) {
103
- case 0:
104
- case "end":
105
- return _context2.stop();
106
- }
107
- }
108
- }, _callee2);
109
- }));
110
-
111
- function customCallbackFunction(_x2, _x3) {
112
- return _customCallbackFunction.apply(this, arguments);
113
- }
114
-
115
- return customCallbackFunction;
116
- }(),
117
- // getAvailableSharingServices: async () => {
118
- // },
119
- // getGeoLocation: async (value) => {
120
- // },
121
- getUserInfo: function () {
122
- var _getUserInfo2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(query) {
123
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
124
- while (1) {
125
- switch (_context3.prev = _context3.next) {
126
- case 0:
127
- return _context3.abrupt("return", _getUserInfo(_this, query));
128
-
129
- case 1:
130
- case "end":
131
- return _context3.stop();
132
- }
133
- }
134
- }, _callee3);
135
- }));
136
-
137
- function getUserInfo(_x4) {
138
- return _getUserInfo2.apply(this, arguments);
139
- }
140
-
141
- return getUserInfo;
142
- }(),
143
- // getScrollPosition: async () => {
137
+ customCallbackFunction: async () => {
138
+ this.notImplemented("customCallbackFunction");
139
+ },
140
+ getAvailableSharingServices: async () => {
141
+ const res = await this.appCall(79);
142
+ return {
143
+ availableSharingApps: res.availableSharingApps,
144
+ availableAndroidApps: res.availableAndroidApps
145
+ };
146
+ },
147
+ getGeoLocation: async () => {
148
+ const res = await this.appCall(14);
149
+ return {
150
+ latitude: res.latitude,
151
+ longitude: res.longitude,
152
+ speed: res.speed,
153
+ code: res.code,
154
+ isAccurate: res.isAccurate
155
+ };
156
+ },
157
+ getUserInfo: async query => {
158
+ return getUserInfo(this, query);
159
+ },
160
+ getScrollPosition: async () => {
161
+ return {
162
+ scrollX: window.scrollX,
163
+ scrollY: window.scrollY
164
+ };
165
+ },
166
+ getWindowMetrics: async () => ({
167
+ bottomBarHeight: 0,
168
+ windowHeight: window.innerHeight,
169
+ offsetTop: 0,
170
+ pageHeight: window.innerHeight,
171
+ pageSize: getScreenSize(window.innerWidth),
172
+ pageWidth: window.innerWidth,
173
+ topBarHeight: 0
174
+ }),
175
+ invokeCall: async (value, callback) => {
176
+ return this.appCall(value.action, value.value, {
177
+ callback
178
+ });
179
+ },
180
+ invokeDialogCall: async (value, callback) => {
181
+ const callbackName = `chaynsApiV5Callback_${this.counter++}`;
182
+ window[callbackName] = _ref => {
183
+ let {
184
+ retVal
185
+ } = _ref;
186
+ callback === null || callback === void 0 ? void 0 : callback(retVal);
187
+ delete window[callbackName];
188
+ };
189
+ const callObj = {
190
+ ...value,
191
+ value: {
192
+ ...value.value,
193
+ callback: callbackName
194
+ }
195
+ };
196
+ invokeAppCall(callObj);
197
+ },
198
+ login: async (value, callback, closeCallback) => {
199
+ const res = await this.appCall({}, callback);
200
+ return {
201
+ loginState: res === null || res === void 0 ? void 0 : res.loginState
202
+ };
203
+ },
204
+ logout: async () => {
205
+ this.appCall(56, undefined, {
206
+ awaitResult: false
207
+ });
208
+ },
209
+ navigateBack: async () => {
210
+ this.appCall(20, undefined, {
211
+ awaitResult: false
212
+ });
213
+ },
214
+ openImage: async value => {
215
+ this.appCall(4, {
216
+ items: value.items.map(x => ({
217
+ url: x.url,
218
+ title: x.title,
219
+ description: x.description,
220
+ preventCache: x.preventCache
221
+ })),
222
+ startIndex: value.startIndex
223
+ }, {
224
+ awaitResult: false
225
+ });
226
+ },
227
+ // openUrl: async (value) => {
228
+ //
144
229
  // },
145
- // getWindowMetrics: async () => {
230
+ openVideo: async value => {
231
+ this.appCall(15, {
232
+ url: value.url
233
+ }, {
234
+ awaitResult: false
235
+ });
236
+ },
237
+ refreshAccessToken: async () => {
238
+ this.appCall(55, undefined, {
239
+ awaitResult: false
240
+ });
241
+ },
242
+ refreshData: async value => {
243
+ this.notImplemented("refreshData");
244
+ },
245
+ // removeGeoLocationListener: async (id) => {
146
246
  // },
147
- invokeCall: function () {
148
- var _invokeCall = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(value, callback) {
149
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
150
- while (1) {
151
- switch (_context4.prev = _context4.next) {
152
- case 0:
153
- case "end":
154
- return _context4.stop();
155
- }
156
- }
157
- }, _callee4);
158
- }));
159
-
160
- function invokeCall(_x5, _x6) {
161
- return _invokeCall.apply(this, arguments);
162
- }
163
-
164
- return invokeCall;
165
- }(),
166
- invokeDialogCall: function () {
167
- var _invokeDialogCall = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(value, callback) {
168
- var callbackName, callObj;
169
- return regeneratorRuntime.wrap(function _callee5$(_context5) {
170
- while (1) {
171
- switch (_context5.prev = _context5.next) {
172
- case 0:
173
- callbackName = "chaynsApiV5Callback_".concat(_this.counter++);
174
-
175
- window[callbackName] = function (_ref) {
176
- var retVal = _ref.retVal;
177
- callback === null || callback === void 0 ? void 0 : callback(retVal);
178
- delete window[callbackName];
179
- };
180
-
181
- callObj = _objectSpread(_objectSpread({}, value), {}, {
182
- value: _objectSpread(_objectSpread({}, value.value), {}, {
183
- callback: callbackName
184
- })
185
- });
186
- invokeAppCall(callObj);
187
-
188
- case 4:
189
- case "end":
190
- return _context5.stop();
191
- }
192
- }
193
- }, _callee5);
194
- }));
195
-
196
- function invokeDialogCall(_x7, _x8) {
197
- return _invokeDialogCall.apply(this, arguments);
198
- }
199
-
200
- return invokeDialogCall;
201
- }(),
202
- // login: async(value, callback, closeCallback) => {
247
+ // removeScrollListener: async (id) => {
203
248
  // },
204
- logout: function () {
205
- var _logout = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
206
- return regeneratorRuntime.wrap(function _callee6$(_context6) {
207
- while (1) {
208
- switch (_context6.prev = _context6.next) {
209
- case 0:
210
- case "end":
211
- return _context6.stop();
212
- }
213
- }
214
- }, _callee6);
215
- }));
216
-
217
- function logout() {
218
- return _logout.apply(this, arguments);
219
- }
220
-
221
- return logout;
222
- }(),
223
- navigateBack: function () {
224
- var _navigateBack = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {
225
- return regeneratorRuntime.wrap(function _callee7$(_context7) {
226
- while (1) {
227
- switch (_context7.prev = _context7.next) {
228
- case 0:
229
- case "end":
230
- return _context7.stop();
231
- }
232
- }
233
- }, _callee7);
234
- }));
235
-
236
- function navigateBack() {
237
- return _navigateBack.apply(this, arguments);
238
- }
239
-
240
- return navigateBack;
241
- }(),
242
- openImage: function () {
243
- var _openImage = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(value) {
244
- return regeneratorRuntime.wrap(function _callee8$(_context8) {
245
- while (1) {
246
- switch (_context8.prev = _context8.next) {
247
- case 0:
248
- case "end":
249
- return _context8.stop();
250
- }
251
- }
252
- }, _callee8);
253
- }));
254
-
255
- function openImage(_x9) {
256
- return _openImage.apply(this, arguments);
257
- }
258
-
259
- return openImage;
260
- }(),
261
- openUrl: function () {
262
- var _openUrl = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9(value) {
263
- return regeneratorRuntime.wrap(function _callee9$(_context9) {
264
- while (1) {
265
- switch (_context9.prev = _context9.next) {
266
- case 0:
267
- case "end":
268
- return _context9.stop();
269
- }
270
- }
271
- }, _callee9);
272
- }));
273
-
274
- function openUrl(_x10) {
275
- return _openUrl.apply(this, arguments);
276
- }
277
-
278
- return openUrl;
279
- }(),
280
- openVideo: function () {
281
- var _openVideo = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(value) {
282
- return regeneratorRuntime.wrap(function _callee10$(_context10) {
283
- while (1) {
284
- switch (_context10.prev = _context10.next) {
285
- case 0:
286
- case "end":
287
- return _context10.stop();
288
- }
289
- }
290
- }, _callee10);
291
- }));
292
-
293
- function openVideo(_x11) {
294
- return _openVideo.apply(this, arguments);
295
- }
296
-
297
- return openVideo;
298
- }(),
299
- refreshAccessToken: function () {
300
- var _refreshAccessToken = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() {
301
- return regeneratorRuntime.wrap(function _callee11$(_context11) {
302
- while (1) {
303
- switch (_context11.prev = _context11.next) {
304
- case 0:
305
- case "end":
306
- return _context11.stop();
307
- }
308
- }
309
- }, _callee11);
310
- }));
311
-
312
- function refreshAccessToken() {
313
- return _refreshAccessToken.apply(this, arguments);
314
- }
315
-
316
- return refreshAccessToken;
317
- }(),
318
- refreshData: function () {
319
- var _refreshData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12(value) {
320
- return regeneratorRuntime.wrap(function _callee12$(_context12) {
321
- while (1) {
322
- switch (_context12.prev = _context12.next) {
323
- case 0:
324
- case "end":
325
- return _context12.stop();
326
- }
327
- }
328
- }, _callee12);
329
- }));
330
-
331
- function refreshData(_x12) {
332
- return _refreshData.apply(this, arguments);
333
- }
334
-
335
- return refreshData;
336
- }(),
337
- removeGeoLocationListener: function () {
338
- var _removeGeoLocationListener = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13(id) {
339
- return regeneratorRuntime.wrap(function _callee13$(_context13) {
340
- while (1) {
341
- switch (_context13.prev = _context13.next) {
342
- case 0:
343
- case "end":
344
- return _context13.stop();
345
- }
346
- }
347
- }, _callee13);
348
- }));
349
-
350
- function removeGeoLocationListener(_x13) {
351
- return _removeGeoLocationListener.apply(this, arguments);
352
- }
353
-
354
- return removeGeoLocationListener;
355
- }(),
356
- removeScrollListener: function () {
357
- var _removeScrollListener = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14(id) {
358
- return regeneratorRuntime.wrap(function _callee14$(_context14) {
359
- while (1) {
360
- switch (_context14.prev = _context14.next) {
361
- case 0:
362
- case "end":
363
- return _context14.stop();
364
- }
365
- }
366
- }, _callee14);
367
- }));
368
-
369
- function removeScrollListener(_x14) {
370
- return _removeScrollListener.apply(this, arguments);
371
- }
372
-
373
- return removeScrollListener;
374
- }(),
375
- removeVisibilityChangeListener: function removeVisibilityChangeListener(number) {
376
- _removeVisibilityChangeListener(number);
377
-
249
+ removeVisibilityChangeListener(number) {
250
+ removeVisibilityChangeListener(number);
378
251
  return Promise.resolve();
379
252
  },
380
- removeWindowMetricsListener: function () {
381
- var _removeWindowMetricsListener = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15(id) {
382
- return regeneratorRuntime.wrap(function _callee15$(_context15) {
383
- while (1) {
384
- switch (_context15.prev = _context15.next) {
385
- case 0:
386
- case "end":
387
- return _context15.stop();
388
- }
389
- }
390
- }, _callee15);
391
- }));
392
-
393
- function removeWindowMetricsListener(_x15) {
394
- return _removeWindowMetricsListener.apply(this, arguments);
395
- }
396
-
397
- return removeWindowMetricsListener;
398
- }(),
399
- selectPage: function () {
400
- var _selectPage = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16(options) {
401
- return regeneratorRuntime.wrap(function _callee16$(_context16) {
402
- while (1) {
403
- switch (_context16.prev = _context16.next) {
404
- case 0:
405
- case "end":
406
- return _context16.stop();
407
- }
408
- }
409
- }, _callee16);
410
- }));
411
-
412
- function selectPage(_x16) {
413
- return _selectPage.apply(this, arguments);
414
- }
415
-
416
- return selectPage;
417
- }(),
418
- scrollToY: function () {
419
- var _scrollToY = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17(position, duration) {
420
- return regeneratorRuntime.wrap(function _callee17$(_context17) {
421
- while (1) {
422
- switch (_context17.prev = _context17.next) {
423
- case 0:
424
- case "end":
425
- return _context17.stop();
426
- }
427
- }
428
- }, _callee17);
429
- }));
430
-
431
- function scrollToY(_x17, _x18) {
432
- return _scrollToY.apply(this, arguments);
433
- }
434
-
435
- return scrollToY;
436
- }(),
437
- // sendMessageToGroup: async (groupId, message) => {
438
- // },
439
- // sendMessageToPage: async (message) => {
440
- // },
441
- // sendMessageToUser: async (userId, message) => {
442
- // },
443
- setAdminMode: function () {
444
- var _setAdminMode = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18(enabled) {
445
- return regeneratorRuntime.wrap(function _callee18$(_context18) {
446
- while (1) {
447
- switch (_context18.prev = _context18.next) {
448
- case 0:
449
- case "end":
450
- return _context18.stop();
451
- }
452
- }
453
- }, _callee18);
454
- }));
455
-
456
- function setAdminMode(_x19) {
457
- return _setAdminMode.apply(this, arguments);
458
- }
459
-
460
- return setAdminMode;
461
- }(),
462
- // setDisplayTimeout: async (value) => {
463
- // },
464
- setFloatingButton: function () {
465
- var _setFloatingButton = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19(value, callback) {
466
- return regeneratorRuntime.wrap(function _callee19$(_context19) {
467
- while (1) {
468
- switch (_context19.prev = _context19.next) {
469
- case 0:
470
- case "end":
471
- return _context19.stop();
472
- }
473
- }
474
- }, _callee19);
475
- }));
476
-
477
- function setFloatingButton(_x20, _x21) {
478
- return _setFloatingButton.apply(this, arguments);
479
- }
480
-
481
- return setFloatingButton;
482
- }(),
483
- setHeight: function () {
484
- var _setHeight = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee20(value) {
485
- return regeneratorRuntime.wrap(function _callee20$(_context20) {
486
- while (1) {
487
- switch (_context20.prev = _context20.next) {
488
- case 0:
489
- case "end":
490
- return _context20.stop();
491
- }
492
- }
493
- }, _callee20);
494
- }));
495
-
496
- function setHeight(_x22) {
497
- return _setHeight.apply(this, arguments);
498
- }
499
-
500
- return setHeight;
501
- }(),
502
- setOverlay: function () {
503
- var _setOverlay = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee21(value, callback) {
504
- return regeneratorRuntime.wrap(function _callee21$(_context21) {
505
- while (1) {
506
- switch (_context21.prev = _context21.next) {
507
- case 0:
508
- case "end":
509
- return _context21.stop();
510
- }
511
- }
512
- }, _callee21);
513
- }));
514
-
515
- function setOverlay(_x23, _x24) {
516
- return _setOverlay.apply(this, arguments);
517
- }
518
-
519
- return setOverlay;
520
- }(),
521
- setRefreshScrollEnabled: function () {
522
- var _setRefreshScrollEnabled = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee22(isEnabled) {
523
- return regeneratorRuntime.wrap(function _callee22$(_context22) {
524
- while (1) {
525
- switch (_context22.prev = _context22.next) {
526
- case 0:
527
- invokeAppCall({
528
- action: 0,
529
- value: {
530
- enabled: isEnabled
531
- }
532
- });
533
- return _context22.abrupt("return", {
534
- isEnabled: isEnabled
535
- });
536
-
537
- case 2:
538
- case "end":
539
- return _context22.stop();
540
- }
541
- }
542
- }, _callee22);
543
- }));
544
-
545
- function setRefreshScrollEnabled(_x25) {
546
- return _setRefreshScrollEnabled.apply(this, arguments);
547
- }
548
-
549
- return setRefreshScrollEnabled;
550
- }(),
551
- // setScanQrCode: async (value) => {
253
+ // removeWindowMetricsListener: async (id) => {
254
+ //
552
255
  // },
553
- setTempDesignSettings: function () {
554
- var _setTempDesignSettings = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee23(value) {
555
- return regeneratorRuntime.wrap(function _callee23$(_context23) {
556
- while (1) {
557
- switch (_context23.prev = _context23.next) {
558
- case 0:
559
- case "end":
560
- return _context23.stop();
561
- }
562
- }
563
- }, _callee23);
564
- }));
565
-
566
- function setTempDesignSettings(_x26) {
567
- return _setTempDesignSettings.apply(this, arguments);
568
- }
569
-
570
- return setTempDesignSettings;
571
- }(),
572
- setWaitCursor: function () {
573
- var _setWaitCursor = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee24(value) {
574
- return regeneratorRuntime.wrap(function _callee24$(_context24) {
575
- while (1) {
576
- switch (_context24.prev = _context24.next) {
577
- case 0:
578
- case "end":
579
- return _context24.stop();
580
- }
581
- }
582
- }, _callee24);
583
- }));
584
-
585
- function setWaitCursor(_x27) {
586
- return _setWaitCursor.apply(this, arguments);
587
- }
588
-
589
- return setWaitCursor;
590
- }(),
591
- storageGetItem: function () {
592
- var _storageGetItem = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee25(key, accessMode) {
593
- return regeneratorRuntime.wrap(function _callee25$(_context25) {
594
- while (1) {
595
- switch (_context25.prev = _context25.next) {
596
- case 0:
597
- case "end":
598
- return _context25.stop();
599
- }
600
- }
601
- }, _callee25);
602
- }));
603
-
604
- function storageGetItem(_x28, _x29) {
605
- return _storageGetItem.apply(this, arguments);
606
- }
607
-
608
- return storageGetItem;
609
- }(),
610
- storageRemoveItem: function () {
611
- var _storageRemoveItem = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee26(key, accessMode) {
612
- return regeneratorRuntime.wrap(function _callee26$(_context26) {
613
- while (1) {
614
- switch (_context26.prev = _context26.next) {
615
- case 0:
616
- case "end":
617
- return _context26.stop();
618
- }
619
- }
620
- }, _callee26);
621
- }));
622
-
623
- function storageRemoveItem(_x30, _x31) {
624
- return _storageRemoveItem.apply(this, arguments);
625
- }
626
-
627
- return storageRemoveItem;
628
- }(),
629
- storageSetItem: function () {
630
- var _storageSetItem = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee27(key, value, accessMode, tappIds) {
631
- return regeneratorRuntime.wrap(function _callee27$(_context27) {
632
- while (1) {
633
- switch (_context27.prev = _context27.next) {
634
- case 0:
635
- case "end":
636
- return _context27.stop();
637
- }
638
- }
639
- }, _callee27);
640
- }));
641
-
642
- function storageSetItem(_x32, _x33, _x34, _x35) {
643
- return _storageSetItem.apply(this, arguments);
644
- }
645
-
646
- return storageSetItem;
647
- }(),
648
- vibrate: function () {
649
- var _vibrate = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee28(value) {
650
- return regeneratorRuntime.wrap(function _callee28$(_context28) {
651
- while (1) {
652
- switch (_context28.prev = _context28.next) {
653
- case 0:
654
- case "end":
655
- return _context28.stop();
656
- }
657
- }
658
- }, _callee28);
659
- }));
660
-
661
- function vibrate(_x36) {
662
- return _vibrate.apply(this, arguments);
663
- }
664
-
665
- return vibrate;
666
- }()
256
+ selectPage: async options => {
257
+ void this.appCall(2, {
258
+ id: options.id,
259
+ showName: options.showName,
260
+ position: options.position,
261
+ params: options.params
262
+ }, {
263
+ awaitResult: false
264
+ });
265
+ },
266
+ scrollToY: async position => {
267
+ window.scrollTo({
268
+ top: position
269
+ });
270
+ },
271
+ sendMessageToGroup: async (groupId, message) => {
272
+ return sendMessageToGroup(this, message, groupId);
273
+ },
274
+ sendMessageToPage: async message => {
275
+ return sendMessageToPage(this, message);
276
+ },
277
+ sendMessageToUser: async (userId, message) => {
278
+ return sendMessageToUser(this, message, userId);
279
+ },
280
+ setAdminMode: async () => {
281
+ this.notImplemented("setAdminMode");
282
+ },
283
+ setDisplayTimeout: async enabled => {
284
+ this.appCall(94, {
285
+ enabled
286
+ }, {
287
+ awaitResult: false
288
+ });
289
+ return {
290
+ isEnabled: enabled
291
+ };
292
+ },
293
+ setFloatingButton: async (value, callback) => {
294
+ void (await this.appCall(72, {
295
+ text: value.text,
296
+ textSize: value.textSize,
297
+ badge: value.badge,
298
+ color: value.color,
299
+ colorText: value.colorText,
300
+ icon: value.icon,
301
+ enabled: value.isEnabled,
302
+ position: value.position
303
+ }, callback));
304
+ },
305
+ setHeight: async () => {
306
+ this.notImplemented("setOverlay");
307
+ },
308
+ setOverlay: async () => {
309
+ this.notImplemented("setOverlay");
310
+ },
311
+ setRefreshScrollEnabled: async isEnabled => {
312
+ this.appCall(0, {
313
+ enabled: isEnabled
314
+ }, {
315
+ awaitResult: false
316
+ });
317
+ return {
318
+ isEnabled
319
+ };
320
+ },
321
+ setScanQrCode: async value => {
322
+ return await this.appCall(34, value);
323
+ },
324
+ setTempDesignSettings: async () => {
325
+ this.notImplemented("setTempDesignSettings");
326
+ },
327
+ setWaitCursor: async value => {
328
+ void this.appCall(1, {
329
+ enabled: value.isEnabled,
330
+ text: value.text,
331
+ timeout: value.timeout,
332
+ progress: value.progress,
333
+ progressText: value.progressText,
334
+ disappearTimeout: value.disappearTimeout
335
+ }, {
336
+ awaitResult: false
337
+ });
338
+ },
339
+ storageGetItem: async (key, accessMode) => {
340
+ const result = await this.appCall(74, {
341
+ key,
342
+ accessMode
343
+ });
344
+ return result === null || result === void 0 ? void 0 : result.object;
345
+ },
346
+ storageRemoveItem: async (key, accessMode) => {
347
+ this.appCall(73, {
348
+ key,
349
+ accessMode
350
+ }, {
351
+ awaitResult: false
352
+ });
353
+ },
354
+ storageSetItem: async (key, value, accessMode, tappIds) => {
355
+ this.appCall(73, {
356
+ key,
357
+ object: value,
358
+ accessMode,
359
+ tappIDs: tappIds
360
+ }, {
361
+ awaitResult: false
362
+ });
363
+ },
364
+ vibrate: async value => {
365
+ void this.appCall(19, value, {
366
+ awaitResult: false
367
+ });
368
+ },
369
+ scrollByY: (value, duration) => {
370
+ window.scrollBy({
371
+ top: value
372
+ });
373
+ }
667
374
  });
668
375
  }
669
-
670
- _createClass(AppWrapper, [{
671
- key: "mapOldApiToNew",
672
- value: function mapOldApiToNew(_ref2) {
673
- var _window, _window2, _AppInfo$TappSelected;
674
-
675
- var retVal = _ref2.retVal;
676
- var AppInfo = retVal.AppInfo,
677
- AppUser = retVal.AppUser;
678
- this.accessToken = AppUser.TobitAccessToken;
679
- return {
680
- device: getDeviceInfo(navigator.userAgent, 'image/webp'),
681
- environment: {
682
- buildEnvironment: Environment.Production,
683
- runtimeEnvironment: RuntimeEnviroment.Unknown
684
- },
685
- language: {
686
- site: AppInfo.Language,
687
- translation: null,
688
- device: AppInfo.Language,
689
- active: AppInfo.Language
690
- },
691
- // ToDo: Find better way to detect
692
- site: {
693
- id: AppInfo.SiteID,
694
- locationId: AppInfo.LocationID,
695
- url: (_window = window) === null || _window === void 0 ? void 0 : _window.location.href.split('#')[0],
696
- layoutDisposition: {
697
- contentWide: false,
698
- barOnTop: false,
699
- barWide: false,
700
- coverDetached: false,
701
- coverHidden: false,
702
- coverWide: false,
703
- docked: false
704
- },
705
- title: AppInfo.Title,
706
- colorMode: AppInfo.colorMode,
707
- color: AppInfo.color,
708
- domain: AppInfo.domain,
709
- font: {
710
- id: Font.Roboto,
711
- headlineFont: Font.Roboto,
712
- dynamicFontSize: false
713
- },
714
- dynamicFontSize: false,
715
- locationPersonId: AppInfo.LocationPersonId,
716
- urlHash: (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.location.hash.replace('#', '')
717
- },
718
- parameters: _toConsumableArray(new URLSearchParams(location.search)),
719
- user: {
720
- firstName: AppUser.FirstName,
721
- lastName: AppUser.LastName,
722
- gender: Gender.Unknown,
723
- userId: AppUser.TobitUserID,
724
- personId: AppUser.PersonID,
725
- uacGroups: []
726
- },
727
- customData: null,
728
- isAdminModeActive: AppUser.AdminMode,
729
- currentPage: {
730
- id: (_AppInfo$TappSelected = AppInfo.TappSelected) === null || _AppInfo$TappSelected === void 0 ? void 0 : _AppInfo$TappSelected.TappID,
731
- siteId: AppInfo.SiteID
732
- },
733
- pages: AppInfo.Tapps.map(function (x) {
734
- return {
735
- id: x.TappID,
736
- icon: '',
737
- iconType: IconType.Font,
738
- customUrl: '',
739
- isExclusive: x.isExclusiveView,
740
- isHiddenFromMenu: x.isHiddenFromMenu,
741
- minAge: null,
742
- name: x.ShowName,
743
- sortId: x.SortUID
744
- };
745
- })
746
- };
747
- }
748
- }, {
749
- key: "appCall",
750
- value: function appCall(call) {
751
- // generate uuid just in case multiple AppWrapper in one window
752
- call.value.callback = "window.chaynsApiV5Callback_" + this.counter++;
753
- invokeAppCall(call);
754
- } // @ts-ignore
755
-
756
- }, {
757
- key: "init",
758
- value: function () {
759
- var _init = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee29() {
760
- var _this2 = this;
761
-
762
- return regeneratorRuntime.wrap(function _callee29$(_context29) {
763
- while (1) {
764
- switch (_context29.prev = _context29.next) {
765
- case 0:
766
- _context29.next = 2;
767
- return new Promise(function (resolve) {
768
- // @ts-ignore
769
- window.globalDataCallback = function (data) {
770
- _this2.values = _this2.mapOldApiToNew(data);
771
- resolve(data);
772
- };
773
-
774
- invokeAppCall({
775
- action: 18,
776
- value: {
777
- callback: 'window.globalDataCallback'
778
- }
779
- });
780
- });
781
-
782
- case 2:
783
- return _context29.abrupt("return", undefined);
784
-
785
- case 3:
786
- case "end":
787
- return _context29.stop();
788
- }
789
- }
790
- }, _callee29);
791
- }));
792
-
793
- function init() {
794
- return _init.apply(this, arguments);
795
- }
796
-
797
- return init;
798
- }()
799
- }, {
800
- key: "getSSRData",
801
- value: function getSSRData() {
802
- return null;
376
+ notImplemented(call) {
377
+ console.warn(`call ${call} not implement in app`);
378
+ }
379
+ appCall(action) {
380
+ let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
381
+ let {
382
+ callback,
383
+ awaitResult = true
384
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
385
+ if (!awaitResult) {
386
+ invokeAppCall({
387
+ action,
388
+ value
389
+ });
390
+ return;
803
391
  }
804
- }, {
805
- key: "addDataListener",
806
- value: function addDataListener(cb) {
807
- var listener = function listener(ev) {
808
- return ev.detail && cb(ev.detail);
809
- };
810
-
811
- document.addEventListener('chayns_api_data', listener);
812
- return function () {
813
- document.removeEventListener('chayns_api_data', listener);
392
+ return new Promise(resolve => {
393
+ const callbackName = `chaynsApiV5Callback_${this.counter++}`;
394
+ window[callbackName] = v => {
395
+ var _v$retVal2;
396
+ if (callback) {
397
+ var _v$retVal;
398
+ callback((_v$retVal = v === null || v === void 0 ? void 0 : v.retVal) !== null && _v$retVal !== void 0 ? _v$retVal : v);
399
+ } else {
400
+ delete window[callbackName];
401
+ }
402
+ resolve((_v$retVal2 = v === null || v === void 0 ? void 0 : v.retVal) !== null && _v$retVal2 !== void 0 ? _v$retVal2 : v);
814
403
  };
815
- }
816
- }, {
817
- key: "getInitialData",
818
- value: function getInitialData() {
819
- return this.values;
820
- }
821
- }]);
822
-
823
- return AppWrapper;
824
- }();
404
+ value.callback = "window." + callbackName;
405
+ invokeAppCall({
406
+ action,
407
+ value
408
+ });
409
+ });
410
+ }
411
+ async init() {
412
+ this.values = this.mapOldApiToNew(await this.appCall(18));
413
+ return undefined;
414
+ }
415
+ getSSRData() {
416
+ return null;
417
+ }
418
+ addDataListener(cb) {
419
+ const listener = ev => ev.detail && cb(ev.detail);
420
+ document.addEventListener('chayns_api_data', listener);
421
+ return () => {
422
+ document.removeEventListener('chayns_api_data', listener);
423
+ };
424
+ }
425
+ getInitialData() {
426
+ return this.values;
427
+ }
428
+ }