chayns-api 1.2.0-1 → 1.2.0-2

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.
@@ -0,0 +1,51 @@
1
+ /*
2
+ object-assign
3
+ (c) Sindre Sorhus
4
+ @license MIT
5
+ */
6
+
7
+ /**
8
+ * @license React
9
+ * scheduler.production.min.js
10
+ *
11
+ * Copyright (c) Facebook, Inc. and its affiliates.
12
+ *
13
+ * This source code is licensed under the MIT license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+
17
+ /** @license React v0.20.2
18
+ * scheduler.production.min.js
19
+ *
20
+ * Copyright (c) Facebook, Inc. and its affiliates.
21
+ *
22
+ * This source code is licensed under the MIT license found in the
23
+ * LICENSE file in the root directory of this source tree.
24
+ */
25
+
26
+ /** @license React v17.0.2
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */
34
+
35
+ /** @license React v17.0.2
36
+ * react-jsx-runtime.production.min.js
37
+ *
38
+ * Copyright (c) Facebook, Inc. and its affiliates.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE file in the root directory of this source tree.
42
+ */
43
+
44
+ /** @license React v17.0.2
45
+ * react.production.min.js
46
+ *
47
+ * Copyright (c) Facebook, Inc. and its affiliates.
48
+ *
49
+ * This source code is licensed under the MIT license found in the
50
+ * LICENSE file in the root directory of this source tree.
51
+ */
@@ -45,11 +45,14 @@ const withCompatMode = Component => {
45
45
  const component = /*#__PURE__*/_react.default.createElement(_ErrorBoundary.default, null, /*#__PURE__*/_react.default.createElement(Component, _extends({}, this.props, {
46
46
  ref: innerRef
47
47
  })));
48
- if (this.root) {
49
- this.root.render(component);
50
- } else {
51
- _reactDom.default.render(component, this.ref.current);
52
- }
48
+ clearTimeout(this.timeout);
49
+ this.timeout = setTimeout(() => {
50
+ if (this.root) {
51
+ this.root.render(component);
52
+ } else {
53
+ _reactDom.default.render(component, this.ref.current);
54
+ }
55
+ }, 0);
53
56
  }
54
57
  componentWillUnmount() {
55
58
  if (this.root) {
@@ -7,35 +7,48 @@ exports.loadModule = exports.default = void 0;
7
7
  var _reactDom = _interopRequireDefault(require("react-dom"));
8
8
  var _semver = _interopRequireDefault(require("semver"));
9
9
  var _react = _interopRequireDefault(require("react"));
10
- var _runtime = require("@module-federation/runtime");
11
- var _process$env$__PACKAG;
12
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ // forces single instance of module federation runtime
12
+ if (!globalThis.moduleFederationRuntime) {
13
+ var _process$env$__PACKAG;
14
+ globalThis.moduleFederationRuntime = require('@module-federation/runtime');
15
+ const {
16
+ init
17
+ } = globalThis.moduleFederationRuntime;
18
+
19
+ // init also should only be called once
20
+ init({
21
+ // will be set by chayns-toolkit via DefinePlugin
22
+ name: (_process$env$__PACKAG = process.env.__PACKAGE_NAME__) !== null && _process$env$__PACKAG !== void 0 ? _process$env$__PACKAG : '',
23
+ remotes: [],
24
+ shared: {
25
+ react: {
26
+ version: _react.default.version,
27
+ scope: 'default',
28
+ lib: () => _react.default
29
+ },
30
+ 'react-dom': {
31
+ version: _reactDom.default.version,
32
+ scope: 'default',
33
+ lib: () => _reactDom.default
34
+ }
35
+ }
36
+ });
37
+ }
38
+ const {
39
+ loadRemote,
40
+ registerRemotes,
41
+ loadShareSync
42
+ } = globalThis.moduleFederationRuntime;
13
43
  const registeredScopes = {};
14
44
  const moduleMap = {};
15
45
  const componentMap = {};
16
- (0, _runtime.init)({
17
- // will be set by chayns-toolkit via DefinePlugin
18
- name: (_process$env$__PACKAG = process.env.__PACKAGE_NAME__) !== null && _process$env$__PACKAG !== void 0 ? _process$env$__PACKAG : '',
19
- remotes: [],
20
- shared: {
21
- react: {
22
- version: _react.default.version,
23
- scope: 'default',
24
- lib: () => _react.default
25
- },
26
- 'react-dom': {
27
- version: _reactDom.default.version,
28
- scope: 'default',
29
- lib: () => _reactDom.default
30
- }
31
- }
32
- });
33
46
  const loadModule = (scope, module, url, preventSingleton = false) => {
34
47
  if (registeredScopes[scope] !== url || preventSingleton) {
35
48
  if (scope in registeredScopes) {
36
49
  console.error(`[chayns-api] call registerRemote with force for scope ${scope}. url: ${url}`);
37
50
  }
38
- (0, _runtime.registerRemotes)([{
51
+ registerRemotes([{
39
52
  name: scope,
40
53
  entry: url,
41
54
  alias: scope
@@ -48,7 +61,7 @@ const loadModule = (scope, module, url, preventSingleton = false) => {
48
61
  }
49
62
  if (!(module in moduleMap[scope])) {
50
63
  const path = `${scope}/${module.replace(/^\.\//, '')}`;
51
- const promise = (0, _runtime.loadRemote)(path);
64
+ const promise = loadRemote(path);
52
65
  promise.catch(e => {
53
66
  console.error("[chayns-api] Failed to load module", scope, url, e);
54
67
  // causes registerRemote with force = true on next attempt to load the component which tries to load the component again
@@ -77,7 +90,7 @@ const loadComponent = (scope, module, url, skipCompatMode = false, preventSingle
77
90
  environment
78
91
  } = Module.default;
79
92
  const shareScopes = await new Promise(resolve => {
80
- (0, _runtime.loadShareSync)('react', {
93
+ loadShareSync('react', {
81
94
  resolver: shareOptions => {
82
95
  resolve(shareOptions);
83
96
  return shareOptions[0];
@@ -7,10 +7,9 @@ exports.semaphore = exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _semaphoreAsyncAwait = _interopRequireDefault(require("semaphore-async-await"));
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
- const semaphore = {};
13
- exports.semaphore = semaphore;
10
+ 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); }
11
+ 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; }
12
+ const semaphore = exports.semaphore = {};
14
13
  const useDynamicScript = args => {
15
14
  const [ready, setReady] = _react.default.useState(false);
16
15
  const [failed, setFailed] = _react.default.useState(false);
@@ -57,5 +56,4 @@ const useDynamicScript = args => {
57
56
  failed
58
57
  };
59
58
  };
60
- var _default = useDynamicScript;
61
- exports.default = _default;
59
+ var _default = exports.default = useDynamicScript;
@@ -3,13 +3,23 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.ToastType = exports.TappEvent = exports.SharingApp = exports.ScreenSize = exports.ScanQrCodeCodeType = exports.ScanQrCodeCameraTypes = exports.RuntimeEnviroment = exports.MediaType = exports.Language = exports.IconType = exports.Gender = exports.Font = exports.FloatingButtonPosition = exports.Environment = exports.DialogType = exports.DialogSelectType = exports.DialogInputType = exports.DialogIconType = exports.DialogButtonType = exports.DialogAnimation = exports.DeviceOs = exports.DateType = exports.ColorMode = exports.BrowserName = exports.AppName = exports.AccessMode = void 0;
6
+ exports.WeekDayType = exports.ToastType = exports.TappEvent = exports.SharingApp = exports.ScreenSize = exports.ScanQrCodeCodeType = exports.ScanQrCodeCameraTypes = exports.RuntimeEnviroment = exports.MediaType = exports.Language = exports.IconType = exports.Gender = exports.Font = exports.FloatingButtonPosition = exports.Environment = exports.DialogType = exports.DialogSelectType = exports.DialogInputType = exports.DialogIconType = exports.DialogButtonType = exports.DialogAnimation = exports.DeviceOs = exports.DateType = exports.ColorMode = exports.BrowserName = exports.AppName = exports.AccessMode = void 0;
7
7
  let DateType = exports.DateType = /*#__PURE__*/function (DateType) {
8
8
  DateType[DateType["DATE"] = 0] = "DATE";
9
9
  DateType[DateType["TIME"] = 1] = "TIME";
10
10
  DateType[DateType["DATE_TIME"] = 2] = "DATE_TIME";
11
11
  return DateType;
12
12
  }({});
13
+ let WeekDayType = exports.WeekDayType = /*#__PURE__*/function (WeekDayType) {
14
+ WeekDayType[WeekDayType["SUNDAY"] = 0] = "SUNDAY";
15
+ WeekDayType[WeekDayType["MONDAY"] = 1] = "MONDAY";
16
+ WeekDayType[WeekDayType["TUESDAY"] = 2] = "TUESDAY";
17
+ WeekDayType[WeekDayType["WEDNESDAY"] = 3] = "WEDNESDAY";
18
+ WeekDayType[WeekDayType["THURSDAY"] = 4] = "THURSDAY";
19
+ WeekDayType[WeekDayType["FRIDAY"] = 5] = "FRIDAY";
20
+ WeekDayType[WeekDayType["SATURDAY"] = 6] = "SATURDAY";
21
+ return WeekDayType;
22
+ }({});
13
23
  let ToastType = exports.ToastType = /*#__PURE__*/function (ToastType) {
14
24
  ToastType[ToastType["NEUTRAL"] = 1] = "NEUTRAL";
15
25
  ToastType[ToastType["SUCCESS"] = 2] = "SUCCESS";
@@ -211,6 +221,7 @@ let RuntimeEnviroment = exports.RuntimeEnviroment = /*#__PURE__*/function (Runti
211
221
  RuntimeEnviroment[RuntimeEnviroment["ChaynsRuntime"] = 3] = "ChaynsRuntime";
212
222
  RuntimeEnviroment[RuntimeEnviroment["IntercomPlugin"] = 4] = "IntercomPlugin";
213
223
  RuntimeEnviroment[RuntimeEnviroment["PagemakerPlugin"] = 5] = "PagemakerPlugin";
224
+ RuntimeEnviroment[RuntimeEnviroment["Dialog"] = 6] = "Dialog";
214
225
  return RuntimeEnviroment;
215
226
  }({});
216
227
  let DeviceOs = exports.DeviceOs = /*#__PURE__*/function (DeviceOs) {
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getScreenSize = exports.getClientDeviceInfo = exports.default = void 0;
7
7
  var _uaParserJs = require("ua-parser-js");
8
8
  var _IChaynsReact = require("../types/IChaynsReact");
9
- const getDeviceInfo = (userAgent, acceptHeader) => {
10
- var _match$groups, _match$groups2, _customMatch$groups, _browser$version$spli, _browser$version, _uaParser$getOS, _uaParser$getOS2;
9
+ const getDeviceInfo = (userAgent, acceptHeader, {
10
+ imei
11
+ } = {}) => {
12
+ var _match$groups, _match$groups2, _customMatch$groups, _browser$version$spli, _browser$version, _uaParser$getOS, _uaParser$getOS2, _uaParser$getOS3;
11
13
  const uaParser = new _uaParserJs.UAParser(userAgent);
12
14
  let appName = _IChaynsReact.AppName.Unknown;
13
15
  const match = /(?:my)?chayns\/(?<version>\d+).*(?<siteId>\d{5}-\d{5})/i.exec(userAgent);
@@ -45,9 +47,11 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
45
47
  appVersion,
46
48
  callVersion: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
47
49
  };
48
- result.imei = undefined; // TODO
50
+ result.imei = imei;
49
51
  result.engine = uaParser.getEngine();
52
+ // TODO: breaking change on next minor and use object with name and version
50
53
  result.os = ((_uaParser$getOS = uaParser.getOS()) === null || _uaParser$getOS === void 0 ? void 0 : _uaParser$getOS.name) === 'Android' ? 'Android OS' : (_uaParser$getOS2 = uaParser.getOS()) === null || _uaParser$getOS2 === void 0 ? void 0 : _uaParser$getOS2.name;
54
+ result.osVersion = (_uaParser$getOS3 = uaParser.getOS()) === null || _uaParser$getOS3 === void 0 ? void 0 : _uaParser$getOS3.version;
51
55
  if (typeof window !== 'undefined') {
52
56
  result.screenSize = getScreenSize(window.innerWidth);
53
57
  result.isTouch = getClientDeviceInfo().isTouch;
@@ -68,7 +68,9 @@ class AppWrapper {
68
68
  }
69
69
  }
70
70
  return {
71
- device: (0, _deviceHelper.default)(navigator.userAgent, 'image/webp'),
71
+ device: (0, _deviceHelper.default)(navigator.userAgent, 'image/webp', {
72
+ imei: Device.IMEI
73
+ }),
72
74
  environment: {
73
75
  buildEnvironment: _IChaynsReact.Environment.Production,
74
76
  runtimeEnvironment: _IChaynsReact.RuntimeEnviroment.Unknown
@@ -446,14 +448,16 @@ class AppWrapper {
446
448
  awaitResult: false
447
449
  });
448
450
  },
449
- scrollToY: async position => {
451
+ scrollToY: async (position, duration) => {
450
452
  window.scrollTo({
451
- top: position
453
+ top: position,
454
+ behavior: duration ? 'smooth' : 'auto'
452
455
  });
453
456
  },
454
457
  scrollByY: (value, duration) => {
455
458
  window.scrollBy({
456
- top: value
459
+ top: value,
460
+ behavior: duration ? 'smooth' : 'auto'
457
461
  });
458
462
  },
459
463
  sendMessageToGroup: async (groupId, message) => {
@@ -5,10 +5,21 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _moduleWrapper = require("../components/moduleWrapper");
8
+ var _IChaynsReact = require("../types/IChaynsReact");
9
+ var _deviceHelper = _interopRequireDefault(require("../util/deviceHelper"));
10
+ var _AppWrapper = require("./AppWrapper");
8
11
  var _FrameWrapper = require("./FrameWrapper");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
13
  class StaticChaynsApi {
10
14
  constructor() {
11
- const wrapper = new _FrameWrapper.FrameWrapper();
15
+ var _deviceInfo$app$name, _deviceInfo$app;
16
+ let wrapper;
17
+ const deviceInfo = (0, _deviceHelper.default)(navigator.userAgent, '');
18
+ if ([_IChaynsReact.AppName.Chayns, _IChaynsReact.AppName.ChaynsLauncher, _IChaynsReact.AppName.Sidekick, _IChaynsReact.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 : _IChaynsReact.AppName.Unknown) && window.self === window.top) {
19
+ wrapper = new _AppWrapper.AppWrapper();
20
+ } else {
21
+ wrapper = new _FrameWrapper.FrameWrapper();
22
+ }
12
23
  _moduleWrapper.moduleWrapper.current = wrapper;
13
24
  this._wrapper = wrapper;
14
25
  this.ready = wrapper.init();
@@ -38,11 +38,14 @@ export const withCompatMode = Component => {
38
38
  const component = /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Component, _extends({}, this.props, {
39
39
  ref: innerRef
40
40
  })));
41
- if (this.root) {
42
- this.root.render(component);
43
- } else {
44
- ReactDOM.render(component, this.ref.current);
45
- }
41
+ clearTimeout(this.timeout);
42
+ this.timeout = setTimeout(() => {
43
+ if (this.root) {
44
+ this.root.render(component);
45
+ } else {
46
+ ReactDOM.render(component, this.ref.current);
47
+ }
48
+ }, 0);
46
49
  }
47
50
  componentWillUnmount() {
48
51
  if (this.root) {
@@ -1,28 +1,42 @@
1
- var _process$env$__PACKAG;
2
1
  import ReactDOM from 'react-dom';
3
2
  import semver from 'semver';
4
3
  import React from 'react';
5
- import { loadRemote, registerRemotes, loadShareSync, init } from '@module-federation/runtime';
4
+
5
+ // forces single instance of module federation runtime
6
+ if (!globalThis.moduleFederationRuntime) {
7
+ var _process$env$__PACKAG;
8
+ globalThis.moduleFederationRuntime = require('@module-federation/runtime');
9
+ const {
10
+ init
11
+ } = globalThis.moduleFederationRuntime;
12
+
13
+ // init also should only be called once
14
+ init({
15
+ // will be set by chayns-toolkit via DefinePlugin
16
+ name: (_process$env$__PACKAG = process.env.__PACKAGE_NAME__) !== null && _process$env$__PACKAG !== void 0 ? _process$env$__PACKAG : '',
17
+ remotes: [],
18
+ shared: {
19
+ react: {
20
+ version: React.version,
21
+ scope: 'default',
22
+ lib: () => React
23
+ },
24
+ 'react-dom': {
25
+ version: ReactDOM.version,
26
+ scope: 'default',
27
+ lib: () => ReactDOM
28
+ }
29
+ }
30
+ });
31
+ }
32
+ const {
33
+ loadRemote,
34
+ registerRemotes,
35
+ loadShareSync
36
+ } = globalThis.moduleFederationRuntime;
6
37
  const registeredScopes = {};
7
38
  const moduleMap = {};
8
39
  const componentMap = {};
9
- init({
10
- // will be set by chayns-toolkit via DefinePlugin
11
- name: (_process$env$__PACKAG = process.env.__PACKAGE_NAME__) !== null && _process$env$__PACKAG !== void 0 ? _process$env$__PACKAG : '',
12
- remotes: [],
13
- shared: {
14
- react: {
15
- version: React.version,
16
- scope: 'default',
17
- lib: () => React
18
- },
19
- 'react-dom': {
20
- version: ReactDOM.version,
21
- scope: 'default',
22
- lib: () => ReactDOM
23
- }
24
- }
25
- });
26
40
  export const loadModule = function (scope, module, url) {
27
41
  let preventSingleton = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
28
42
  if (registeredScopes[scope] !== url || preventSingleton) {
@@ -4,6 +4,16 @@ export let DateType = /*#__PURE__*/function (DateType) {
4
4
  DateType[DateType["DATE_TIME"] = 2] = "DATE_TIME";
5
5
  return DateType;
6
6
  }({});
7
+ export let WeekDayType = /*#__PURE__*/function (WeekDayType) {
8
+ WeekDayType[WeekDayType["SUNDAY"] = 0] = "SUNDAY";
9
+ WeekDayType[WeekDayType["MONDAY"] = 1] = "MONDAY";
10
+ WeekDayType[WeekDayType["TUESDAY"] = 2] = "TUESDAY";
11
+ WeekDayType[WeekDayType["WEDNESDAY"] = 3] = "WEDNESDAY";
12
+ WeekDayType[WeekDayType["THURSDAY"] = 4] = "THURSDAY";
13
+ WeekDayType[WeekDayType["FRIDAY"] = 5] = "FRIDAY";
14
+ WeekDayType[WeekDayType["SATURDAY"] = 6] = "SATURDAY";
15
+ return WeekDayType;
16
+ }({});
7
17
  export let ToastType = /*#__PURE__*/function (ToastType) {
8
18
  ToastType[ToastType["NEUTRAL"] = 1] = "NEUTRAL";
9
19
  ToastType[ToastType["SUCCESS"] = 2] = "SUCCESS";
@@ -208,6 +218,7 @@ export let RuntimeEnviroment = /*#__PURE__*/function (RuntimeEnviroment) {
208
218
  RuntimeEnviroment[RuntimeEnviroment["ChaynsRuntime"] = 3] = "ChaynsRuntime";
209
219
  RuntimeEnviroment[RuntimeEnviroment["IntercomPlugin"] = 4] = "IntercomPlugin";
210
220
  RuntimeEnviroment[RuntimeEnviroment["PagemakerPlugin"] = 5] = "PagemakerPlugin";
221
+ RuntimeEnviroment[RuntimeEnviroment["Dialog"] = 6] = "Dialog";
211
222
  return RuntimeEnviroment;
212
223
  }({});
213
224
  export let DeviceOs = /*#__PURE__*/function (DeviceOs) {
@@ -1,7 +1,10 @@
1
1
  import { UAParser } from 'ua-parser-js';
2
2
  import { AppName, ScreenSize } from '../types/IChaynsReact';
3
- const getDeviceInfo = (userAgent, acceptHeader) => {
4
- var _match$groups, _match$groups2, _customMatch$groups, _browser$version$spli, _browser$version, _uaParser$getOS, _uaParser$getOS2;
3
+ const getDeviceInfo = function (userAgent, acceptHeader) {
4
+ var _match$groups, _match$groups2, _customMatch$groups, _browser$version$spli, _browser$version, _uaParser$getOS, _uaParser$getOS2, _uaParser$getOS3;
5
+ let {
6
+ imei
7
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5
8
  const uaParser = new UAParser(userAgent);
6
9
  let appName = AppName.Unknown;
7
10
  const match = /(?:my)?chayns\/(?<version>\d+).*(?<siteId>\d{5}-\d{5})/i.exec(userAgent);
@@ -39,9 +42,11 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
39
42
  appVersion,
40
43
  callVersion: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
41
44
  };
42
- result.imei = undefined; // TODO
45
+ result.imei = imei;
43
46
  result.engine = uaParser.getEngine();
47
+ // TODO: breaking change on next minor and use object with name and version
44
48
  result.os = ((_uaParser$getOS = uaParser.getOS()) === null || _uaParser$getOS === void 0 ? void 0 : _uaParser$getOS.name) === 'Android' ? 'Android OS' : (_uaParser$getOS2 = uaParser.getOS()) === null || _uaParser$getOS2 === void 0 ? void 0 : _uaParser$getOS2.name;
49
+ result.osVersion = (_uaParser$getOS3 = uaParser.getOS()) === null || _uaParser$getOS3 === void 0 ? void 0 : _uaParser$getOS3.version;
45
50
  if (typeof window !== 'undefined') {
46
51
  result.screenSize = getScreenSize(window.innerWidth);
47
52
  result.isTouch = getClientDeviceInfo().isTouch;
@@ -60,7 +60,9 @@ export class AppWrapper {
60
60
  }
61
61
  }
62
62
  return {
63
- device: getDeviceInfo(navigator.userAgent, 'image/webp'),
63
+ device: getDeviceInfo(navigator.userAgent, 'image/webp', {
64
+ imei: Device.IMEI
65
+ }),
64
66
  environment: {
65
67
  buildEnvironment: Environment.Production,
66
68
  runtimeEnvironment: RuntimeEnviroment.Unknown
@@ -410,14 +412,16 @@ export class AppWrapper {
410
412
  awaitResult: false
411
413
  });
412
414
  },
413
- scrollToY: async position => {
415
+ scrollToY: async (position, duration) => {
414
416
  window.scrollTo({
415
- top: position
417
+ top: position,
418
+ behavior: duration ? 'smooth' : 'auto'
416
419
  });
417
420
  },
418
421
  scrollByY: (value, duration) => {
419
422
  window.scrollBy({
420
- top: value
423
+ top: value,
424
+ behavior: duration ? 'smooth' : 'auto'
421
425
  });
422
426
  },
423
427
  sendMessageToGroup: async (groupId, message) => {
@@ -2,9 +2,13 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
2
2
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
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
  import { moduleWrapper } from '../components/moduleWrapper';
5
+ import { AppName } from '../types/IChaynsReact';
6
+ import getDeviceInfo from '../util/deviceHelper';
7
+ import { AppWrapper } from './AppWrapper';
5
8
  import { FrameWrapper } from './FrameWrapper';
6
9
  class StaticChaynsApi {
7
10
  constructor() {
11
+ var _deviceInfo$app$name, _deviceInfo$app;
8
12
  _defineProperty(this, "getUser", () => this._wrapper.values.user);
9
13
  _defineProperty(this, "getSite", () => this._wrapper.values.site);
10
14
  _defineProperty(this, "getCurrentPage", () => this._wrapper.values.currentPage);
@@ -13,7 +17,13 @@ class StaticChaynsApi {
13
17
  _defineProperty(this, "getParameters", () => this._wrapper.values.parameters);
14
18
  _defineProperty(this, "getPages", () => this._wrapper.values.pages);
15
19
  _defineProperty(this, "getEnvironment", () => this._wrapper.values.environment);
16
- const wrapper = new FrameWrapper();
20
+ let wrapper;
21
+ const deviceInfo = getDeviceInfo(navigator.userAgent, '');
22
+ 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) {
23
+ wrapper = new AppWrapper();
24
+ } else {
25
+ wrapper = new FrameWrapper();
26
+ }
17
27
  moduleWrapper.current = wrapper;
18
28
  this._wrapper = wrapper;
19
29
  this.ready = wrapper.init();
@@ -21,6 +21,28 @@ export interface DialogDate {
21
21
  multiselect?: boolean;
22
22
  monthSelect?: boolean;
23
23
  yearSelect?: boolean;
24
+ interval?: boolean;
25
+ disabledDates?: Date[];
26
+ disabledIntervals?: {
27
+ start: Date;
28
+ end: Date;
29
+ }[];
30
+ disabledWeekDayIntervals?: {
31
+ weekDay: WeekDayType;
32
+ interval?: {
33
+ start: Date;
34
+ end: Date;
35
+ };
36
+ }[];
37
+ }
38
+ export declare enum WeekDayType {
39
+ SUNDAY = 0,
40
+ MONDAY = 1,
41
+ TUESDAY = 2,
42
+ WEDNESDAY = 3,
43
+ THURSDAY = 4,
44
+ FRIDAY = 5,
45
+ SATURDAY = 6
24
46
  }
25
47
  export declare enum ToastType {
26
48
  NEUTRAL = 1,
@@ -133,6 +155,7 @@ export declare enum DialogButtonType {
133
155
  export type ChaynsApiUser = {
134
156
  firstName?: string;
135
157
  lastName?: string;
158
+ nickName?: string;
136
159
  gender?: Gender;
137
160
  uacGroups?: UacGroup[];
138
161
  userId?: number;
@@ -158,10 +181,15 @@ export type ChaynsApiSite = {
158
181
  originSiteId?: string;
159
182
  };
160
183
  export declare enum ScreenSize {
184
+ /** screen width smaller than or equal 556px */
161
185
  XS = 0,
186
+ /** screen width between 557px and 769px */
162
187
  SM = 1,
188
+ /** screen width between 770px and 993px */
163
189
  MD = 2,
190
+ /** screen width between 994px and 1200px */
164
191
  LG = 3,
192
+ /** screen width larger than 1200px */
165
193
  XL = 4
166
194
  }
167
195
  export type ChaynsApiDevice = {
@@ -185,6 +213,7 @@ export type ChaynsApiDevice = {
185
213
  imei?: string;
186
214
  accessToken?: string;
187
215
  os?: 'AIX' | 'Amiga OS' | 'Android OS' | 'Arch' | 'Bada' | 'BeOS' | 'BlackBerry' | 'CentOS' | 'Chromium OS' | 'Contiki' | 'Fedora' | 'Firefox OS' | 'FreeBSD' | 'Debian' | 'DragonFly' | 'Gentoo' | 'GNU' | 'Haiku' | 'Hurd' | 'iOS' | 'Joli' | 'Linpus' | 'Linux' | 'Mac OS' | 'Mageia' | 'Mandriva' | 'MeeGo' | 'Minix' | 'Mint' | 'Morph OS' | 'NetBSD' | 'Nintendo' | 'OpenBSD' | 'OpenVMS' | 'OS/2' | 'Palm' | 'PCLinuxOS' | 'Plan9' | 'Playstation' | 'QNX' | 'RedHat' | 'RIM Tablet OS' | 'RISC OS' | 'Sailfish' | 'Series40' | 'Slackware' | 'Solaris' | 'SUSE' | 'Symbian' | 'Tizen' | 'Ubuntu' | 'UNIX' | 'VectorLinux' | 'WebOS' | 'Windows' | 'Windows Phone' | 'Windows Mobile' | 'Zenwalk' | null;
216
+ osVersion?: string;
188
217
  isTouch: boolean;
189
218
  screenSize: ScreenSize;
190
219
  };
@@ -739,7 +768,8 @@ export declare enum RuntimeEnviroment {
739
768
  ChaynsWeb = 2,
740
769
  ChaynsRuntime = 3,
741
770
  IntercomPlugin = 4,
742
- PagemakerPlugin = 5
771
+ PagemakerPlugin = 5,
772
+ Dialog = 6
743
773
  }
744
774
  export declare enum DeviceOs {
745
775
  Unknown = "unknown",
@@ -1,5 +1,7 @@
1
1
  import { ChaynsApiDevice, ScreenSize } from '../types/IChaynsReact';
2
- declare const getDeviceInfo: (userAgent: string, acceptHeader: string) => ChaynsApiDevice;
2
+ declare const getDeviceInfo: (userAgent: string, acceptHeader: string, { imei }?: {
3
+ imei?: string | undefined;
4
+ }) => ChaynsApiDevice;
3
5
  export declare const getClientDeviceInfo: () => {
4
6
  isTouch: boolean;
5
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "1.2.0-1",
3
+ "version": "1.2.0-2",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -42,7 +42,7 @@
42
42
  "extends": "@chayns-toolkit"
43
43
  },
44
44
  "dependencies": {
45
- "@module-federation/runtime": "^0.1.13",
45
+ "@module-federation/runtime": "^0.6.9",
46
46
  "@types/semver": "^7.5.8",
47
47
  "comlink": "4.3.1",
48
48
  "htmlescape": "^1.1.1",