chayns-api 2.2.0-beta.1 → 2.2.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/cjs/calls/index.js +3 -3
  2. package/dist/cjs/hooks/index.js +3 -3
  3. package/dist/cjs/hooks/useStyleSettings.js +9 -0
  4. package/dist/cjs/host/ChaynsHost.js +3 -3
  5. package/dist/cjs/host/iframe/HostIframe.js +3 -3
  6. package/dist/cjs/host/module/ModuleHost.js +2 -2
  7. package/dist/cjs/types/IChaynsReact.js +6 -1
  8. package/dist/cjs/util/deviceHelper.js +1 -0
  9. package/dist/cjs/wrapper/AppWrapper.js +11 -7
  10. package/dist/cjs/wrapper/StaticChaynsApi.js +1 -1
  11. package/dist/esm/calls/index.js +1 -1
  12. package/dist/esm/hooks/index.js +1 -1
  13. package/dist/esm/hooks/useStyleSettings.js +2 -0
  14. package/dist/esm/host/ChaynsHost.js +3 -3
  15. package/dist/esm/host/iframe/HostIframe.js +3 -3
  16. package/dist/esm/host/module/ModuleHost.js +2 -2
  17. package/dist/esm/types/IChaynsReact.js +5 -0
  18. package/dist/esm/util/deviceHelper.js +2 -1
  19. package/dist/esm/wrapper/AppWrapper.js +11 -7
  20. package/dist/esm/wrapper/StaticChaynsApi.js +1 -1
  21. package/dist/types/calls/index.d.ts +1 -1
  22. package/dist/types/hooks/index.d.ts +1 -1
  23. package/dist/types/hooks/useStyleSettings.d.ts +2 -0
  24. package/dist/types/host/ChaynsHost.d.ts +1 -1
  25. package/dist/types/host/iframe/HostIframe.d.ts +1 -1
  26. package/dist/types/host/module/ModuleHost.d.ts +1 -1
  27. package/dist/types/types/IChaynsReact.d.ts +16 -6
  28. package/dist/types/wrapper/AppWrapper.d.ts +2 -2
  29. package/dist/types/wrapper/StaticChaynsApi.d.ts +24 -10
  30. package/package.json +1 -1
  31. package/dist/cjs/hooks/useSiteSettings.js +0 -9
  32. package/dist/esm/hooks/useSiteSettings.js +0 -2
  33. package/dist/types/hooks/useSiteSettings.d.ts +0 -2
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.vibrate = exports.user = exports.storageSetItem = exports.storageRemoveItem = exports.storageGetItem = exports.site = exports.setWaitCursor = exports.setTempDesignSettings = exports.setScanQrCode = exports.setRefreshScrollEnabled = exports.setOverlay = exports.setHeight = exports.setFloatingButton = exports.setDisplayTimeout = exports.setAdminMode = exports.sendMessageToUser = exports.sendMessageToPage = exports.sendMessageToGroup = exports.selectPage = exports.scrollToY = exports.scrollByY = exports.removeWindowMetricsListener = exports.removeVisibilityChangeListener = exports.removeToolbarChangeListener = exports.removeScrollListener = exports.removeGeoLocationListener = exports.refreshData = exports.refreshAccessToken = exports.parameters = exports.pages = exports.openVideo = exports.openUrl = exports.openMedia = exports.openImage = exports.navigateBack = exports.logout = exports.login = exports.language = exports.invokeDialogCall = exports.invokeCall = exports.getWindowMetrics = exports.getUserInfo = exports.getUser = exports.getSiteSettings = exports.getSite = exports.getScrollPosition = exports.getParameters = exports.getPages = exports.getLanguage = exports.getGeoLocation = exports.getEnvironment = exports.getDevice = exports.getCustomFunction = exports.getCurrentPage = exports.getAvailableSharingServices = exports.getAccessToken = exports.environment = exports.device = exports.customCallbackFunction = exports.createDialog = exports.addWindowMetricsListener = exports.addVisibilityChangeListener = exports.addToolbarChangeListener = exports.addScrollListener = exports.addGeoLocationListener = exports.addAnonymousAccount = void 0;
6
+ exports.vibrate = exports.user = exports.storageSetItem = exports.storageRemoveItem = exports.storageGetItem = exports.site = exports.setWaitCursor = exports.setTempDesignSettings = exports.setScanQrCode = exports.setRefreshScrollEnabled = exports.setOverlay = exports.setHeight = exports.setFloatingButton = exports.setDisplayTimeout = exports.setAdminMode = exports.sendMessageToUser = exports.sendMessageToPage = exports.sendMessageToGroup = exports.selectPage = exports.scrollToY = exports.scrollByY = exports.removeWindowMetricsListener = exports.removeVisibilityChangeListener = exports.removeToolbarChangeListener = exports.removeScrollListener = exports.removeGeoLocationListener = exports.refreshData = exports.refreshAccessToken = exports.parameters = exports.pages = exports.openVideo = exports.openUrl = exports.openMedia = exports.openImage = exports.navigateBack = exports.logout = exports.login = exports.language = exports.invokeDialogCall = exports.invokeCall = exports.getWindowMetrics = exports.getUserInfo = exports.getUser = exports.getStyleSettings = exports.getSite = exports.getScrollPosition = exports.getParameters = exports.getPages = exports.getLanguage = exports.getGeoLocation = exports.getEnvironment = exports.getDevice = exports.getCustomFunction = exports.getCurrentPage = exports.getAvailableSharingServices = exports.getAccessToken = exports.environment = exports.device = exports.customCallbackFunction = exports.createDialog = exports.addWindowMetricsListener = exports.addVisibilityChangeListener = exports.addToolbarChangeListener = exports.addScrollListener = exports.addGeoLocationListener = exports.addAnonymousAccount = void 0;
7
7
  var _moduleWrapper = require("../components/moduleWrapper");
8
8
  const addGeoLocationListener = (...args) => _moduleWrapper.moduleWrapper.current.functions.addGeoLocationListener(...args);
9
9
  exports.addGeoLocationListener = addGeoLocationListener;
@@ -119,8 +119,8 @@ const getPages = () => _moduleWrapper.moduleWrapper.current.values.pages;
119
119
  exports.getPages = getPages;
120
120
  const getEnvironment = () => _moduleWrapper.moduleWrapper.current.values.environment;
121
121
  exports.getEnvironment = getEnvironment;
122
- const getSiteSettings = () => _moduleWrapper.moduleWrapper.current.values.siteSettings;
123
- exports.getSiteSettings = getSiteSettings;
122
+ const getStyleSettings = () => _moduleWrapper.moduleWrapper.current.values.styleSettings;
123
+ exports.getStyleSettings = getStyleSettings;
124
124
  const getCustomFunction = key => _moduleWrapper.moduleWrapper.current.customFunctions[key];
125
125
  exports.getCustomFunction = getCustomFunction;
126
126
  const user = exports.user = new Proxy({}, {
@@ -141,10 +141,10 @@ Object.defineProperty(exports, "useSite", {
141
141
  return _useSite.useSite;
142
142
  }
143
143
  });
144
- Object.defineProperty(exports, "useSiteSettings", {
144
+ Object.defineProperty(exports, "useStyleSettings", {
145
145
  enumerable: true,
146
146
  get: function () {
147
- return _useSiteSettings.useSiteSettings;
147
+ return _useStyleSettings.useStyleSettings;
148
148
  }
149
149
  });
150
150
  Object.defineProperty(exports, "useUser", {
@@ -190,4 +190,4 @@ var _useCustomData = require("./useCustomData");
190
190
  var _useDialogState = require("./useDialogState");
191
191
  var _useCustomCallbackFunction = require("./useCustomCallbackFunction");
192
192
  var _useCustomFunction = require("./useCustomFunction");
193
- var _useSiteSettings = require("./useSiteSettings");
193
+ var _useStyleSettings = require("./useStyleSettings");
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useStyleSettings = void 0;
7
+ var _context = require("./context");
8
+ const useStyleSettings = () => (0, _context.useValuesSelector)(state => state.styleSettings);
9
+ exports.useStyleSettings = useStyleSettings;
@@ -31,7 +31,7 @@ const ChaynsHost = ({
31
31
  environment,
32
32
  preventStagingReplacement,
33
33
  dialog,
34
- siteSettings
34
+ styleSettings
35
35
  }) => {
36
36
  const [isVisible, setIsVisible] = (0, _react.useState)(type !== 'client-module' && (type !== 'server-module' || !!(system !== null && system !== void 0 && system.serverUrl)));
37
37
  (0, _react.useEffect)(() => {
@@ -69,7 +69,7 @@ const ChaynsHost = ({
69
69
  customData: customData,
70
70
  preventStagingReplacement: preventStagingReplacement,
71
71
  dialog: dialog,
72
- siteSettings: siteSettings
72
+ styleSettings: styleSettings
73
73
  });
74
74
  case 'client-module':
75
75
  case 'server-module':
@@ -90,7 +90,7 @@ const ChaynsHost = ({
90
90
  environment: environment,
91
91
  preventStagingReplacement: preventStagingReplacement,
92
92
  dialog: dialog,
93
- siteSettings: siteSettings
93
+ styleSettings: styleSettings
94
94
  });
95
95
  default:
96
96
  return null;
@@ -32,7 +32,7 @@ const HostIframe = ({
32
32
  customData,
33
33
  preventStagingReplacement,
34
34
  dialog,
35
- siteSettings
35
+ styleSettings
36
36
  }) => {
37
37
  const eventTarget = (0, _react.useRef)();
38
38
  const ref = (0, _react.useRef)();
@@ -59,7 +59,7 @@ const HostIframe = ({
59
59
  environment,
60
60
  customData,
61
61
  dialog,
62
- siteSettings
62
+ styleSettings
63
63
  };
64
64
  currentDataRef.current = initialData;
65
65
  (0, _react.useEffect)(() => {
@@ -114,7 +114,7 @@ const HostIframe = ({
114
114
  (0, _useUpdateData.default)(eventTarget.current, 'environment', environment);
115
115
  (0, _useUpdateData.default)(eventTarget.current, 'customData', customData);
116
116
  (0, _useUpdateData.default)(eventTarget.current, 'dialog', dialog);
117
- (0, _useUpdateData.default)(eventTarget.current, 'siteSettings', siteSettings);
117
+ (0, _useUpdateData.default)(eventTarget.current, 'styleSettings', styleSettings);
118
118
  return _react.default.createElement("iframe", _extends({
119
119
  ref: r => {
120
120
  ref.current = r;
@@ -37,7 +37,7 @@ const ModuleHost = ({
37
37
  dialog,
38
38
  environment,
39
39
  preventStagingReplacement,
40
- siteSettings
40
+ styleSettings
41
41
  }) => {
42
42
  const initialData = {
43
43
  site,
@@ -49,7 +49,7 @@ const ModuleHost = ({
49
49
  parameters,
50
50
  customData,
51
51
  environment,
52
- siteSettings
52
+ styleSettings
53
53
  };
54
54
  if (user) {
55
55
  initialData.user = user;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WeekDayType = exports.ToastType = exports.TappEvent = exports.SharingApp = exports.ScreenSize = exports.ScanQrCodeCodeType = exports.ScanQrCodeCameraTypes = exports.RuntimeEnviroment = exports.MediaType = exports.Language = exports.IconType = exports.IconStyle = exports.Gender = exports.Font = exports.FloatingButtonPosition = exports.FloatingButtonAnimation = 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.IconStyle = exports.Gender = exports.Font = exports.FloatingButtonPosition = exports.FloatingButtonAnimation = 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.AppFlavor = exports.AccessMode = void 0;
7
7
  let DateType = exports.DateType = function (DateType) {
8
8
  DateType[DateType["DATE"] = 0] = "DATE";
9
9
  DateType[DateType["TIME"] = 1] = "TIME";
@@ -64,6 +64,11 @@ let ScreenSize = exports.ScreenSize = function (ScreenSize) {
64
64
  ScreenSize[ScreenSize["XL"] = 4] = "XL";
65
65
  return ScreenSize;
66
66
  }({});
67
+ let AppFlavor = exports.AppFlavor = function (AppFlavor) {
68
+ AppFlavor["None"] = "none";
69
+ AppFlavor["Chayns"] = "chayns";
70
+ return AppFlavor;
71
+ }({});
67
72
  let AccessMode = exports.AccessMode = function (AccessMode) {
68
73
  AccessMode[AccessMode["public"] = 0] = "public";
69
74
  AccessMode[AccessMode["protected"] = 1] = "protected";
@@ -45,6 +45,7 @@ const getDeviceInfo = (userAgent, acceptHeader, {
45
45
  };
46
46
  result.app = {
47
47
  name: appName,
48
+ flavor: appName === _IChaynsReact.AppName.Unknown ? _IChaynsReact.AppFlavor.None : _IChaynsReact.AppFlavor.Chayns,
48
49
  version: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN,
49
50
  appVersion,
50
51
  callVersion: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
@@ -23,7 +23,7 @@ class AppWrapper {
23
23
  accessToken = '';
24
24
  listeners = [];
25
25
  customFunctions = {};
26
- async loadSiteSettings(siteId) {
26
+ async loadStyleSettings(siteId) {
27
27
  try {
28
28
  var _AbortSignal$timeout, _AbortSignal;
29
29
  const res = await fetch(`https://style.tobit.cloud/css/${siteId}/components`, {
@@ -32,9 +32,9 @@ class AppWrapper {
32
32
  if (res.status === 200) {
33
33
  return await res.json();
34
34
  }
35
- console.error(`[chayns-api] failed to load site settings with status code: ${res.status}`);
35
+ console.error(`[chayns-api] failed to load style settings with status code: ${res.status}`);
36
36
  } catch (ex) {
37
- console.error('[chayns-api] failed to load site settings', ex);
37
+ console.error('[chayns-api] failed to load style settings', ex);
38
38
  }
39
39
  return undefined;
40
40
  }
@@ -124,6 +124,7 @@ class AppWrapper {
124
124
  gender: _IChaynsReact.Gender.Unknown,
125
125
  userId: userId,
126
126
  personId: AppUser.PersonID,
127
+ isAnonymous: AppUser.IsAnonymous,
127
128
  uacGroups: []
128
129
  },
129
130
  customData: null,
@@ -601,7 +602,7 @@ class AppWrapper {
601
602
  dialogs = [];
602
603
  async init() {
603
604
  this.values = this.mapOldApiToNew(await this.appCall(18));
604
- this.values.siteSettings = await this.loadSiteSettings(this.values.site.id);
605
+ this.values.styleSettings = await this.loadStyleSettings(this.values.site.id);
605
606
  document.documentElement.classList.add('chayns-api--app');
606
607
  this.appCall(66, {
607
608
  enabled: true
@@ -624,9 +625,12 @@ class AppWrapper {
624
625
  callback: ({
625
626
  colorMode
626
627
  }) => {
627
- this.values.site = {
628
- ...this.values.site,
629
- colorMode
628
+ this.values = {
629
+ ...this.values,
630
+ site: {
631
+ ...this.values.site,
632
+ colorMode
633
+ }
630
634
  };
631
635
  document.dispatchEvent(new CustomEvent('chayns_api_data', {
632
636
  detail: {
@@ -39,7 +39,7 @@ class StaticChaynsApi {
39
39
  getParameters = () => this._wrapper.values.parameters;
40
40
  getPages = () => this._wrapper.values.pages;
41
41
  getEnvironment = () => this._wrapper.values.environment;
42
- getSiteSettings = () => this._wrapper.values.siteSettings;
42
+ getStyleSettings = () => this._wrapper.values.styleSettings;
43
43
  getCustomFunction = key => this._wrapper.customFunctions[key];
44
44
  }
45
45
  var _default = exports.default = StaticChaynsApi;
@@ -150,7 +150,7 @@ export const getLanguage = () => moduleWrapper.current.values.language;
150
150
  export const getParameters = () => moduleWrapper.current.values.parameters;
151
151
  export const getPages = () => moduleWrapper.current.values.pages;
152
152
  export const getEnvironment = () => moduleWrapper.current.values.environment;
153
- export const getSiteSettings = () => moduleWrapper.current.values.siteSettings;
153
+ export const getStyleSettings = () => moduleWrapper.current.values.styleSettings;
154
154
  export const getCustomFunction = key => moduleWrapper.current.customFunctions[key];
155
155
  export const user = new Proxy({}, {
156
156
  get: (target, prop) => {
@@ -17,4 +17,4 @@ export { useCustomData } from './useCustomData';
17
17
  export { useDialogState, useDialogData } from './useDialogState';
18
18
  export { useCustomCallbackFunction } from './useCustomCallbackFunction';
19
19
  export { useCustomFunction } from './useCustomFunction';
20
- export { useSiteSettings } from './useSiteSettings';
20
+ export { useStyleSettings } from './useStyleSettings';
@@ -0,0 +1,2 @@
1
+ import { useValuesSelector } from './context';
2
+ export const useStyleSettings = () => useValuesSelector(state => state.styleSettings);
@@ -23,7 +23,7 @@ const ChaynsHost = _ref => {
23
23
  environment,
24
24
  preventStagingReplacement,
25
25
  dialog,
26
- siteSettings
26
+ styleSettings
27
27
  } = _ref;
28
28
  const [isVisible, setIsVisible] = useState(type !== 'client-module' && (type !== 'server-module' || !!(system !== null && system !== void 0 && system.serverUrl)));
29
29
  useEffect(() => {
@@ -61,7 +61,7 @@ const ChaynsHost = _ref => {
61
61
  customData: customData,
62
62
  preventStagingReplacement: preventStagingReplacement,
63
63
  dialog: dialog,
64
- siteSettings: siteSettings
64
+ styleSettings: styleSettings
65
65
  });
66
66
  case 'client-module':
67
67
  case 'server-module':
@@ -82,7 +82,7 @@ const ChaynsHost = _ref => {
82
82
  environment: environment,
83
83
  preventStagingReplacement: preventStagingReplacement,
84
84
  dialog: dialog,
85
- siteSettings: siteSettings
85
+ styleSettings: styleSettings
86
86
  });
87
87
  default:
88
88
  return null;
@@ -24,7 +24,7 @@ const HostIframe = _ref => {
24
24
  customData,
25
25
  preventStagingReplacement,
26
26
  dialog,
27
- siteSettings
27
+ styleSettings
28
28
  } = _ref;
29
29
  const eventTarget = useRef();
30
30
  const ref = useRef();
@@ -51,7 +51,7 @@ const HostIframe = _ref => {
51
51
  environment,
52
52
  customData,
53
53
  dialog,
54
- siteSettings
54
+ styleSettings
55
55
  };
56
56
  currentDataRef.current = initialData;
57
57
  useEffect(() => {
@@ -106,7 +106,7 @@ const HostIframe = _ref => {
106
106
  useUpdateData(eventTarget.current, 'environment', environment);
107
107
  useUpdateData(eventTarget.current, 'customData', customData);
108
108
  useUpdateData(eventTarget.current, 'dialog', dialog);
109
- useUpdateData(eventTarget.current, 'siteSettings', siteSettings);
109
+ useUpdateData(eventTarget.current, 'styleSettings', styleSettings);
110
110
  return React.createElement("iframe", _extends({
111
111
  ref: r => {
112
112
  ref.current = r;
@@ -30,7 +30,7 @@ const ModuleHost = _ref2 => {
30
30
  dialog,
31
31
  environment,
32
32
  preventStagingReplacement,
33
- siteSettings
33
+ styleSettings
34
34
  } = _ref2;
35
35
  const initialData = {
36
36
  site,
@@ -42,7 +42,7 @@ const ModuleHost = _ref2 => {
42
42
  parameters,
43
43
  customData,
44
44
  environment,
45
- siteSettings
45
+ styleSettings
46
46
  };
47
47
  if (user) {
48
48
  initialData.user = user;
@@ -58,6 +58,11 @@ export let ScreenSize = function (ScreenSize) {
58
58
  ScreenSize[ScreenSize["XL"] = 4] = "XL";
59
59
  return ScreenSize;
60
60
  }({});
61
+ export let AppFlavor = function (AppFlavor) {
62
+ AppFlavor["None"] = "none";
63
+ AppFlavor["Chayns"] = "chayns";
64
+ return AppFlavor;
65
+ }({});
61
66
  export let AccessMode = function (AccessMode) {
62
67
  AccessMode[AccessMode["public"] = 0] = "public";
63
68
  AccessMode[AccessMode["protected"] = 1] = "protected";
@@ -1,5 +1,5 @@
1
1
  import { UAParser } from 'ua-parser-js';
2
- import { AppName, ScreenSize } from '../types/IChaynsReact';
2
+ import { AppFlavor, AppName, ScreenSize } from '../types/IChaynsReact';
3
3
  const getDeviceInfo = function (userAgent, acceptHeader) {
4
4
  var _match$groups, _match$groups2, _customMatch$groups, _browser$version$spli, _browser$version, _uaParser$getOS, _uaParser$getOS2, _uaParser$getOS3;
5
5
  let {
@@ -40,6 +40,7 @@ const getDeviceInfo = function (userAgent, acceptHeader) {
40
40
  };
41
41
  result.app = {
42
42
  name: appName,
43
+ flavor: appName === AppName.Unknown ? AppFlavor.None : AppFlavor.Chayns,
43
44
  version: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN,
44
45
  appVersion,
45
46
  callVersion: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
@@ -13,7 +13,7 @@ import { DeviceLanguage } from '../constants/languages';
13
13
  import { isAppCallSupported } from '../util/is';
14
14
  let appWrapperDialogId = 0;
15
15
  export class AppWrapper {
16
- async loadSiteSettings(siteId) {
16
+ async loadStyleSettings(siteId) {
17
17
  try {
18
18
  var _AbortSignal$timeout, _AbortSignal;
19
19
  const res = await fetch(`https://style.tobit.cloud/css/${siteId}/components`, {
@@ -22,9 +22,9 @@ export class AppWrapper {
22
22
  if (res.status === 200) {
23
23
  return await res.json();
24
24
  }
25
- console.error(`[chayns-api] failed to load site settings with status code: ${res.status}`);
25
+ console.error(`[chayns-api] failed to load style settings with status code: ${res.status}`);
26
26
  } catch (ex) {
27
- console.error('[chayns-api] failed to load site settings', ex);
27
+ console.error('[chayns-api] failed to load style settings', ex);
28
28
  }
29
29
  return undefined;
30
30
  }
@@ -114,6 +114,7 @@ export class AppWrapper {
114
114
  gender: Gender.Unknown,
115
115
  userId: userId,
116
116
  personId: AppUser.PersonID,
117
+ isAnonymous: AppUser.IsAnonymous,
117
118
  uacGroups: []
118
119
  },
119
120
  customData: null,
@@ -611,7 +612,7 @@ export class AppWrapper {
611
612
  }
612
613
  async init() {
613
614
  this.values = this.mapOldApiToNew(await this.appCall(18));
614
- this.values.siteSettings = await this.loadSiteSettings(this.values.site.id);
615
+ this.values.styleSettings = await this.loadStyleSettings(this.values.site.id);
615
616
  document.documentElement.classList.add('chayns-api--app');
616
617
  this.appCall(66, {
617
618
  enabled: true
@@ -635,9 +636,12 @@ export class AppWrapper {
635
636
  let {
636
637
  colorMode
637
638
  } = _ref3;
638
- this.values.site = {
639
- ...this.values.site,
640
- colorMode
639
+ this.values = {
640
+ ...this.values,
641
+ site: {
642
+ ...this.values.site,
643
+ colorMode
644
+ }
641
645
  };
642
646
  document.dispatchEvent(new CustomEvent('chayns_api_data', {
643
647
  detail: {
@@ -18,7 +18,7 @@ class StaticChaynsApi {
18
18
  _defineProperty(this, "getParameters", () => this._wrapper.values.parameters);
19
19
  _defineProperty(this, "getPages", () => this._wrapper.values.pages);
20
20
  _defineProperty(this, "getEnvironment", () => this._wrapper.values.environment);
21
- _defineProperty(this, "getSiteSettings", () => this._wrapper.values.siteSettings);
21
+ _defineProperty(this, "getStyleSettings", () => this._wrapper.values.styleSettings);
22
22
  _defineProperty(this, "getCustomFunction", key => this._wrapper.customFunctions[key]);
23
23
  let wrapper;
24
24
  const deviceInfo = getDeviceInfo(navigator.userAgent, '');
@@ -236,7 +236,7 @@ export declare const getEnvironment: () => {
236
236
  buildEnvironment: import("../types/IChaynsReact").Environment;
237
237
  runtimeEnvironment: import("../types/IChaynsReact").RuntimeEnviroment | string;
238
238
  };
239
- export declare const getSiteSettings: () => import("../types/IChaynsReact").ChaynsSiteSettings | undefined;
239
+ export declare const getStyleSettings: () => import("../types/IChaynsReact").ChaynsStyleSettings | undefined;
240
240
  /**
241
241
  * Returns the customFunction. Prefer usage via useCustomFunction when possible
242
242
  * @param key functionName
@@ -17,4 +17,4 @@ export { useCustomData } from './useCustomData';
17
17
  export { useDialogState, useDialogData } from './useDialogState';
18
18
  export { useCustomCallbackFunction } from './useCustomCallbackFunction';
19
19
  export { useCustomFunction } from './useCustomFunction';
20
- export { useSiteSettings } from './useSiteSettings';
20
+ export { useStyleSettings } from './useStyleSettings';
@@ -0,0 +1,2 @@
1
+ import { ChaynsStyleSettings } from '../types/IChaynsReact';
2
+ export declare const useStyleSettings: () => ChaynsStyleSettings | undefined;
@@ -25,7 +25,7 @@ type ChaynsHostType = {
25
25
  environment: ChaynsReactValues["environment"];
26
26
  preventStagingReplacement?: boolean;
27
27
  dialog: ChaynsReactValues["dialog"];
28
- siteSettings?: ChaynsReactValues["siteSettings"];
28
+ styleSettings?: ChaynsReactValues["styleSettings"];
29
29
  };
30
30
  declare const ChaynsHost: FC<ChaynsHostType>;
31
31
  export default ChaynsHost;
@@ -22,7 +22,7 @@ type HostIframeProps = {
22
22
  customData: ChaynsReactValues["customData"];
23
23
  preventStagingReplacement?: boolean;
24
24
  dialog: ChaynsReactValues["dialog"];
25
- siteSettings: ChaynsReactValues["siteSettings"];
25
+ styleSettings: ChaynsReactValues["styleSettings"];
26
26
  };
27
27
  declare const HostIframe: FC<HostIframeProps>;
28
28
  export default HostIframe;
@@ -24,7 +24,7 @@ type ModulePropTypes = {
24
24
  preventStagingReplacement?: boolean;
25
25
  dialog: ChaynsReactValues["dialog"];
26
26
  children?: ReactNode;
27
- siteSettings: ChaynsReactValues["siteSettings"];
27
+ styleSettings: ChaynsReactValues["styleSettings"];
28
28
  };
29
29
  declare const ModuleHost: FC<ModulePropTypes>;
30
30
  export default ModuleHost;
@@ -165,6 +165,7 @@ export type ChaynsApiUser = {
165
165
  uacGroups?: UacGroup[];
166
166
  userId?: number;
167
167
  personId?: string;
168
+ isAnonymous?: boolean;
168
169
  };
169
170
  export type ChaynsApiSite = {
170
171
  id: string;
@@ -192,7 +193,7 @@ export declare enum IconStyle {
192
193
  DUOTONE = 3,
193
194
  SHARP = 4
194
195
  }
195
- export interface DesignSettings {
196
+ export interface ChaynsDesignSettings {
196
197
  siteId?: string;
197
198
  color: string;
198
199
  secondaryColor?: string;
@@ -209,7 +210,7 @@ export interface DesignSettings {
209
210
  cardBackgroundOpacity?: number;
210
211
  cardShadow?: number;
211
212
  }
212
- export interface ParagraphFormat {
213
+ export interface ChaynsParagraphFormat {
213
214
  selector: string;
214
215
  fontSizePx?: number;
215
216
  lineHeight?: number;
@@ -220,9 +221,9 @@ export interface ParagraphFormat {
220
221
  buttonDesignType?: number;
221
222
  backgroundColor?: string;
222
223
  }
223
- export type ChaynsSiteSettings = {
224
- designSettings: DesignSettings;
225
- paragraphFormats: ParagraphFormat[];
224
+ export type ChaynsStyleSettings = {
225
+ designSettings: ChaynsDesignSettings;
226
+ paragraphFormats: ChaynsParagraphFormat[];
226
227
  };
227
228
  export declare enum ScreenSize {
228
229
  /** screen width smaller than or equal 556px */
@@ -236,6 +237,10 @@ export declare enum ScreenSize {
236
237
  /** screen width larger than 1200px */
237
238
  XL = 4
238
239
  }
240
+ export declare enum AppFlavor {
241
+ None = "none",
242
+ Chayns = "chayns"
243
+ }
239
244
  export type ChaynsApiDevice = {
240
245
  app?: {
241
246
  name: AppName;
@@ -246,6 +251,8 @@ export type ChaynsApiDevice = {
246
251
  /** the version of the chayns call interface */
247
252
  callVersion: number;
248
253
  storePackageName?: string;
254
+ /** the flavor of the app, e. g. all chayns apps including chat app, sidekick, team */
255
+ flavor: AppFlavor;
249
256
  };
250
257
  browser?: {
251
258
  name?: IBrowser["name"] | 'bot' | null;
@@ -301,7 +308,7 @@ export interface ChaynsReactValues {
301
308
  dialogInput: any;
302
309
  isClosingRequested: boolean;
303
310
  };
304
- siteSettings?: ChaynsSiteSettings;
311
+ styleSettings?: ChaynsStyleSettings;
305
312
  }
306
313
  export interface DialogResultFile {
307
314
  blockDownload?: boolean;
@@ -433,6 +440,9 @@ export interface RefreshData {
433
440
  suffix?: boolean;
434
441
  tapps?: boolean;
435
442
  user?: boolean;
443
+ chaynsProData?: boolean;
444
+ ignoreUacCache?: boolean;
445
+ chaynsInfo?: boolean;
436
446
  }
437
447
  export type IntercomMessage = {
438
448
  text: string;
@@ -1,10 +1,10 @@
1
- import { ChaynsReactFunctions, ChaynsReactValues, ChaynsSiteSettings, CleanupCallback, DataChangeCallback, IChaynsReact } from '../types/IChaynsReact';
1
+ import { ChaynsReactFunctions, ChaynsReactValues, ChaynsStyleSettings, CleanupCallback, DataChangeCallback, IChaynsReact } from '../types/IChaynsReact';
2
2
  export declare class AppWrapper implements IChaynsReact {
3
3
  values: ChaynsReactValues;
4
4
  accessToken: string;
5
5
  listeners: (() => void)[];
6
6
  customFunctions: {};
7
- loadSiteSettings(siteId: string): Promise<ChaynsSiteSettings | undefined>;
7
+ loadStyleSettings(siteId: string): Promise<ChaynsStyleSettings | undefined>;
8
8
  mapOldApiToNew(retVal: any): ChaynsReactValues;
9
9
  constructor();
10
10
  notImplemented(call: string): void;
@@ -4,15 +4,29 @@ declare class StaticChaynsApi {
4
4
  addDataListener: (cb: DataChangeCallback) => () => void;
5
5
  private _wrapper;
6
6
  constructor(values: any, functions: any);
7
- getUser: () => any;
8
- getSite: () => any;
9
- getCurrentPage: () => any;
10
- getDevice: () => any;
11
- getLanguage: () => any;
12
- getParameters: () => any;
13
- getPages: () => any;
14
- getEnvironment: () => any;
15
- getSiteSettings: () => any;
16
- getCustomFunction: (key: string) => any;
7
+ getUser: () => import("../types/IChaynsReact").ChaynsApiUser | undefined;
8
+ getSite: () => import("../types/IChaynsReact").ChaynsApiSite;
9
+ getCurrentPage: () => {
10
+ id: number;
11
+ siteId: string;
12
+ };
13
+ getDevice: () => import("../types/IChaynsReact").ChaynsApiDevice;
14
+ getLanguage: () => {
15
+ site: import("../types/IChaynsReact").Language;
16
+ translation: import("../types/IChaynsReact").Language | null;
17
+ device: import("../types/IChaynsReact").Language;
18
+ active: import("../types/IChaynsReact").Language;
19
+ };
20
+ getParameters: () => {
21
+ [key: string]: string | string[];
22
+ [key: symbol]: string | string[];
23
+ };
24
+ getPages: () => import("../types/IChaynsReact").Page[];
25
+ getEnvironment: () => {
26
+ buildEnvironment: import("../types/IChaynsReact").Environment;
27
+ runtimeEnvironment: import("../types/IChaynsReact").RuntimeEnviroment | string;
28
+ };
29
+ getStyleSettings: () => import("../types/IChaynsReact").ChaynsStyleSettings | undefined;
30
+ getCustomFunction: (key: string) => <A extends Array<any>, O>(...args: A) => Promise<O>;
17
31
  }
18
32
  export default StaticChaynsApi;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "2.2.0-beta.1",
3
+ "version": "2.2.0-beta.3",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useSiteSettings = void 0;
7
- var _context = require("./context");
8
- const useSiteSettings = () => (0, _context.useValuesSelector)(state => state.siteSettings);
9
- exports.useSiteSettings = useSiteSettings;
@@ -1,2 +0,0 @@
1
- import { useValuesSelector } from './context';
2
- export const useSiteSettings = () => useValuesSelector(state => state.siteSettings);
@@ -1,2 +0,0 @@
1
- import { ChaynsSiteSettings } from '../types/IChaynsReact';
2
- export declare const useSiteSettings: () => ChaynsSiteSettings | undefined;