chayns-api 2.5.1 → 2.5.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 (60) hide show
  1. package/dist/cjs/calls/dialogs/date.js +1 -1
  2. package/dist/cjs/calls/dialogs/iFrame.js +9 -6
  3. package/dist/cjs/components/ChaynsProvider.js +1 -2
  4. package/dist/cjs/components/withCompatMode.js +1 -2
  5. package/dist/cjs/components/withHydrationBoundary.js +1 -2
  6. package/dist/cjs/host/ChaynsHost.js +1 -2
  7. package/dist/cjs/host/iframe/HostIframe.js +1 -2
  8. package/dist/cjs/host/module/ModuleHost.js +1 -2
  9. package/dist/cjs/index.js +1 -2
  10. package/dist/cjs/types/IChaynsReact.js +2 -0
  11. package/dist/cjs/umd.index.js +1 -2
  12. package/dist/cjs/util/deviceHelper.js +17 -4
  13. package/dist/cjs/util/is.js +9 -4
  14. package/dist/cjs/util/transferNestedFunctions.js +1 -2
  15. package/dist/cjs/wrapper/AppWrapper.js +4 -3
  16. package/dist/cjs/wrapper/FrameWrapper.js +2 -3
  17. package/dist/cjs/wrapper/StaticChaynsApi.js +1 -3
  18. package/dist/esm/calls/dialogs/alert.js +1 -3
  19. package/dist/esm/calls/dialogs/communication.js +3 -6
  20. package/dist/esm/calls/dialogs/confirm.js +1 -4
  21. package/dist/esm/calls/dialogs/date.js +4 -8
  22. package/dist/esm/calls/dialogs/dropUpAlert.js +1 -2
  23. package/dist/esm/calls/dialogs/fileSelect.js +1 -2
  24. package/dist/esm/calls/dialogs/iFrame.js +11 -9
  25. package/dist/esm/calls/dialogs/input.js +1 -2
  26. package/dist/esm/calls/dialogs/mediaSelect.js +1 -2
  27. package/dist/esm/calls/dialogs/toast.js +1 -2
  28. package/dist/esm/calls/dialogs/utils/callback.js +1 -2
  29. package/dist/esm/calls/index.js +53 -159
  30. package/dist/esm/components/ChaynsProvider.js +16 -19
  31. package/dist/esm/components/WaitUntil.js +5 -6
  32. package/dist/esm/components/withHydrationBoundary.js +5 -6
  33. package/dist/esm/handler/DialogHandler.js +1 -2
  34. package/dist/esm/hooks/geoLocationListener.js +5 -6
  35. package/dist/esm/hooks/scrollListener.js +12 -15
  36. package/dist/esm/hooks/usePages.js +16 -19
  37. package/dist/esm/hooks/windowMetricsListener.js +3 -4
  38. package/dist/esm/host/ChaynsHost.js +23 -24
  39. package/dist/esm/host/iframe/HostIframe.js +21 -22
  40. package/dist/esm/host/module/ModuleHost.js +24 -26
  41. package/dist/esm/host/module/utils/loadComponent.js +2 -5
  42. package/dist/esm/types/IChaynsReact.js +2 -0
  43. package/dist/esm/util/appStorage.js +3 -6
  44. package/dist/esm/util/deviceHelper.js +20 -8
  45. package/dist/esm/util/initModuleFederationSharing.js +3 -4
  46. package/dist/esm/util/is.js +11 -8
  47. package/dist/esm/util/transferNestedFunctions.js +1 -2
  48. package/dist/esm/wrapper/AppWrapper.js +18 -26
  49. package/dist/esm/wrapper/FrameWrapper.js +10 -21
  50. package/dist/esm/wrapper/ModuleFederationWrapper.js +2 -5
  51. package/dist/esm/wrapper/StaticChaynsApi.js +2 -5
  52. package/dist/types/calls/dialogs/iFrame.d.ts +10 -4
  53. package/dist/types/types/IChaynsReact.d.ts +25 -6
  54. package/dist/types/util/is.d.ts +1 -0
  55. package/dist/types/wrapper/StaticChaynsApi.d.ts +68 -4
  56. package/eslint.config.mjs +3 -0
  57. package/package.json +23 -21
  58. package/{toolkit.config.js → toolkit.config.ts} +6 -3
  59. package/tsconfig.json +1 -0
  60. package/.eslintrc +0 -17
@@ -60,6 +60,7 @@ export let ScreenSize = function (ScreenSize) {
60
60
  export let AppFlavor = function (AppFlavor) {
61
61
  AppFlavor["None"] = "none";
62
62
  AppFlavor["Chayns"] = "chayns";
63
+ AppFlavor["Electron"] = "electron";
63
64
  return AppFlavor;
64
65
  }({});
65
66
  export let AccessMode = function (AccessMode) {
@@ -245,6 +246,7 @@ export let AppName = function (AppName) {
245
246
  AppName[AppName["Team"] = 8] = "Team";
246
247
  AppName[AppName["CityApp"] = 9] = "CityApp";
247
248
  AppName[AppName["ElectronChayns"] = 10] = "ElectronChayns";
249
+ AppName[AppName["ElectronTeam"] = 11] = "ElectronTeam";
248
250
  return AppName;
249
251
  }({});
250
252
  export let BrowserName = function (BrowserName) {
@@ -7,8 +7,7 @@ export function isAppStorageAvailable() {
7
7
  }
8
8
  return ((_this$values$device$a2 = this.values.device.app) === null || _this$values$device$a2 === void 0 ? void 0 : _this$values$device$a2.appVersion) >= (['iOS', 'Mac OS'].includes(this.values.device.os) ? 1046 : 1033);
9
9
  }
10
- export function getAppStorageItem(storeName, key) {
11
- let callbackPrefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'chaynsApiV5Callback';
10
+ export function getAppStorageItem(storeName, key, callbackPrefix = 'chaynsApiV5Callback') {
12
11
  const callbackName = `${callbackPrefix}_${this.counter++}`;
13
12
  return new Promise(resolve => {
14
13
  window[callbackName] = (_key, _storeName, value) => {
@@ -31,8 +30,7 @@ export function getAppStorageItem(storeName, key) {
31
30
  }
32
31
  });
33
32
  }
34
- export function setAppStorageItem(storeName, key, value) {
35
- let callbackPrefix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'chaynsApiV5Callback';
33
+ export function setAppStorageItem(storeName, key, value, callbackPrefix = 'chaynsApiV5Callback') {
36
34
  const callbackName = `${callbackPrefix}_${this.counter++}`;
37
35
  return new Promise((resolve, reject) => {
38
36
  window[callbackName] = () => {
@@ -70,8 +68,7 @@ export function clearAppStorage(storeName) {
70
68
  window.chaynsWebViewStorage.chaynsDataErase(storeName);
71
69
  }
72
70
  }
73
- export async function addAppStorageListener(storeName, prefix, callback) {
74
- let callbackPrefix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'chaynsApiV5Callback';
71
+ export async function addAppStorageListener(storeName, prefix, callback, callbackPrefix = 'chaynsApiV5Callback') {
75
72
  const callbackName = `${callbackPrefix}_${this.counter++}`;
76
73
  const {
77
74
  shouldInitialize
@@ -1,32 +1,44 @@
1
1
  import { UAParser } from 'ua-parser-js';
2
2
  import { AppFlavor, AppName, ScreenSize } from '../types/IChaynsReact';
3
- const getDeviceInfo = function (userAgent, acceptHeader) {
3
+ const getDeviceInfo = (userAgent, acceptHeader, {
4
+ imei
5
+ } = {}) => {
4
6
  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] : {};
8
7
  const uaParser = new UAParser(userAgent);
9
8
  let appName = AppName.Unknown;
10
- const match = /(?:my)?chayns\/(?<version>\d+).*(?<siteId>\d{5}-\d{5})/i.exec(userAgent);
11
- const customMatch = /\s(?<name>intercom|sidekick|team|cityApp|electron-chayns|electron-d3sc)\/(?<version>\d+)/i.exec(userAgent);
9
+ let appFlavor = AppFlavor.None;
10
+ const match = /(?:^|\s)(?:my)?chayns\/(?<version>\d+).*(?<siteId>\d{5}-\d{5})/i.exec(userAgent);
11
+ const customMatch = /\s(?<name>intercom|sidekick|team|cityApp|electron-chayns|electron-d3sc|electron-team)\/(?<version>\d+)/i.exec(userAgent);
12
12
  if (/\sintercom\/\d+/i.test(userAgent)) {
13
13
  appName = AppName.TobitChat;
14
+ appFlavor = AppFlavor.Chayns;
14
15
  } else if (/\ssidekick\/\d+/i.test(userAgent)) {
15
16
  appName = AppName.Sidekick;
17
+ appFlavor = AppFlavor.Chayns;
16
18
  } else if (/\steam\/\d+/i.test(userAgent)) {
17
19
  appName = AppName.Team;
20
+ appFlavor = AppFlavor.Chayns;
18
21
  } else if (/\scityApp\/\d+/i.test(userAgent)) {
19
22
  appName = AppName.CityApp;
23
+ appFlavor = AppFlavor.Chayns;
20
24
  } else if ((match === null || match === void 0 || (_match$groups = match.groups) === null || _match$groups === void 0 ? void 0 : _match$groups.siteId) === '60021-08989') {
21
25
  appName = AppName.Chayns;
26
+ appFlavor = AppFlavor.Chayns;
22
27
  } else if ((match === null || match === void 0 || (_match$groups2 = match.groups) === null || _match$groups2 === void 0 ? void 0 : _match$groups2.siteId) === '77892-10814') {
23
28
  appName = AppName.David;
29
+ appFlavor = AppFlavor.Chayns;
24
30
  } else if (match) {
25
31
  appName = AppName.Location;
32
+ appFlavor = AppFlavor.Chayns;
26
33
  } else if (/dface|h96pp|h96max|jabiru|chaynsterminal|wayter|odroidn2p|chayns-runtime-custom/i.test(userAgent)) {
27
34
  appName = AppName.ChaynsLauncher;
35
+ appFlavor = AppFlavor.Chayns;
28
36
  } else if (/electron-chayns|electron-d3sc/i.test(userAgent)) {
29
37
  appName = AppName.ElectronChayns;
38
+ appFlavor = AppFlavor.Electron;
39
+ } else if (/electron-team/i.test(userAgent)) {
40
+ appName = AppName.ElectronTeam;
41
+ appFlavor = AppFlavor.Electron;
30
42
  }
31
43
  let appVersion = match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN;
32
44
  if (customMatch !== null && customMatch !== void 0 && (_customMatch$groups = customMatch.groups) !== null && _customMatch$groups !== void 0 && _customMatch$groups.version) {
@@ -42,7 +54,7 @@ const getDeviceInfo = function (userAgent, acceptHeader) {
42
54
  };
43
55
  result.app = {
44
56
  name: appName,
45
- flavor: appName === AppName.Unknown || appName === AppName.ElectronChayns ? AppFlavor.None : AppFlavor.Chayns,
57
+ flavor: appFlavor,
46
58
  version: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN,
47
59
  appVersion,
48
60
  callVersion: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
@@ -56,7 +68,7 @@ const getDeviceInfo = function (userAgent, acceptHeader) {
56
68
  result.isTouch = getClientDeviceInfo().isTouch;
57
69
  } else {
58
70
  const screenSizeByUA = /mobi/i.test(userAgent) ? ScreenSize.SM : ScreenSize.XL;
59
- result.screenSize = appName !== AppName.Unknown && appName !== AppName.ElectronChayns ? ScreenSize.XS : screenSizeByUA;
71
+ result.screenSize = appFlavor === AppFlavor.Chayns ? ScreenSize.XS : screenSizeByUA;
60
72
  }
61
73
  return result;
62
74
  };
@@ -5,10 +5,9 @@ let ReactDOMClient;
5
5
  try {
6
6
  ReactDOMClient = require('react-dom/client');
7
7
  } catch (e) {}
8
- export const initModuleFederationSharing = _ref => {
9
- let {
10
- name
11
- } = _ref;
8
+ export const initModuleFederationSharing = ({
9
+ name
10
+ }) => {
12
11
  if (globalThis.moduleFederationRuntime) {
13
12
  return;
14
13
  }
@@ -1,15 +1,14 @@
1
1
  import { getDevice } from '../calls';
2
- import { AppName } from '../types/IChaynsReact';
2
+ import { AppFlavor } from '../types/IChaynsReact';
3
3
  export const isApp = () => {
4
- var _getDevice$app$name, _getDevice$app;
5
- return ((_getDevice$app$name = (_getDevice$app = getDevice().app) === null || _getDevice$app === void 0 ? void 0 : _getDevice$app.name) !== null && _getDevice$app$name !== void 0 ? _getDevice$app$name : AppName.Unknown) !== AppName.Unknown;
4
+ var _getDevice$app;
5
+ return ((_getDevice$app = getDevice().app) === null || _getDevice$app === void 0 ? void 0 : _getDevice$app.flavor) === AppFlavor.Chayns;
6
6
  };
7
- export const isAppCallSupported = _ref => {
7
+ export const isAppCallSupported = ({
8
+ minAndroidVersion = 1,
9
+ minIOSVersion = 1
10
+ }) => {
8
11
  var _device$app;
9
- let {
10
- minAndroidVersion = 1,
11
- minIOSVersion = 1
12
- } = _ref;
13
12
  if (!isApp()) return false;
14
13
  const device = getDevice();
15
14
  if (!((_device$app = device.app) !== null && _device$app !== void 0 && _device$app.callVersion) || isNaN(device.app.callVersion)) return false;
@@ -20,4 +19,8 @@ export const isAppCallSupported = _ref => {
20
19
  return device.app.callVersion >= minAndroidVersion;
21
20
  }
22
21
  return false;
22
+ };
23
+ export const isElectron = () => {
24
+ var _getDevice$app2;
25
+ return ((_getDevice$app2 = getDevice().app) === null || _getDevice$app2 === void 0 ? void 0 : _getDevice$app2.flavor) === AppFlavor.Electron;
23
26
  };
@@ -6,8 +6,7 @@ Comlink.transferHandlers.set("FUNCTION", {
6
6
  serialize(obj) {
7
7
  obj._functionKeys = [];
8
8
  const ports = [];
9
- Object.entries(obj).forEach(_ref => {
10
- let [k, v] = _ref;
9
+ Object.entries(obj).forEach(([k, v]) => {
11
10
  if (typeof v === 'function') {
12
11
  const {
13
12
  port1,
@@ -4,6 +4,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
4
4
  import throttle from 'lodash.throttle';
5
5
  import getUserInfo from '../calls/getUserInfo';
6
6
  import { sendMessageToGroup, sendMessageToPage, sendMessageToUser } from '../calls/sendMessage';
7
+ import { DefaultLoginDialogOptions } from '../constants';
7
8
  import { DeviceLanguage } from '../constants/languages';
8
9
  import DialogHandler from '../handler/DialogHandler';
9
10
  import { addApiListener, dispatchApiEvent, removeApiListener } from '../helper/apiListenerHelper';
@@ -12,7 +13,6 @@ import invokeAppCall from '../util/appCall';
12
13
  import { addAppStorageListener, clearAppStorage, isAppStorageAvailable, setAppStorageItem } from '../util/appStorage';
13
14
  import getDeviceInfo, { getScreenSize } from '../util/deviceHelper';
14
15
  import { isAppCallSupported } from '../util/is';
15
- import { DefaultLoginDialogOptions } from '../constants';
16
16
  export class AppWrapper {
17
17
  async loadStyleSettings(siteId) {
18
18
  try {
@@ -145,7 +145,6 @@ export class AppWrapper {
145
145
  };
146
146
  }
147
147
  constructor() {
148
- var _this = this;
149
148
  _defineProperty(this, "values", null);
150
149
  _defineProperty(this, "accessToken", '');
151
150
  _defineProperty(this, "listeners", []);
@@ -304,10 +303,9 @@ export class AppWrapper {
304
303
  },
305
304
  invokeDialogCall: async (value, callback) => {
306
305
  const callbackName = `chaynsApiV5Callback_${this.counter++}`;
307
- window[callbackName] = _ref => {
308
- let {
309
- retVal
310
- } = _ref;
306
+ window[callbackName] = ({
307
+ retVal
308
+ }) => {
311
309
  callback === null || callback === void 0 || callback(retVal);
312
310
  delete window[callbackName];
313
311
  };
@@ -320,20 +318,18 @@ export class AppWrapper {
320
318
  };
321
319
  invokeAppCall(callObj);
322
320
  },
323
- login: async function () {
324
- let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
325
- let callback = arguments.length > 1 ? arguments[1] : undefined;
326
- let closeCallback = arguments.length > 2 ? arguments[2] : undefined;
321
+ login: async (value = {}, callback, closeCallback) => {
327
322
  const {
328
323
  result,
329
324
  buttonType
330
- } = await _this.functions.createDialog({
325
+ } = await this.functions.createDialog({
331
326
  ...DefaultLoginDialogOptions,
332
327
  ...value
333
328
  }).open();
334
329
  if (buttonType === DialogButtonType.OK && result.token) {
335
330
  const response = {
336
331
  loginState: LoginState.SUCCESS,
332
+ buttonType,
337
333
  ...result
338
334
  };
339
335
  if (callback) callback(response);
@@ -341,6 +337,7 @@ export class AppWrapper {
341
337
  }
342
338
  const response = {
343
339
  loginState: LoginState.LoginFailed,
340
+ buttonType,
344
341
  ...result
345
342
  };
346
343
  if (closeCallback) closeCallback(response);
@@ -436,8 +433,7 @@ export class AppWrapper {
436
433
  url.pathname += `/${options.path}`;
437
434
  }
438
435
  if (options.params) {
439
- Object.entries(options.params).forEach(_ref2 => {
440
- let [k, v] = _ref2;
436
+ Object.entries(options.params).forEach(([k, v]) => {
441
437
  url.searchParams.set(k, v);
442
438
  });
443
439
  }
@@ -617,9 +613,8 @@ export class AppWrapper {
617
613
  });
618
614
  return currentDialogId;
619
615
  },
620
- closeDialog: function (dialogId, result) {
621
- let buttonType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
622
- const dialog = _this.dialogs.find(x => x.dialogId === dialogId);
616
+ closeDialog: (dialogId, result, buttonType = -1) => {
617
+ const dialog = this.dialogs.find(x => x.dialogId === dialogId);
623
618
  if (dialog) {
624
619
  dialog.resolve({
625
620
  buttonType,
@@ -689,12 +684,10 @@ export class AppWrapper {
689
684
  notImplemented(call) {
690
685
  console.warn(`call ${call} not implement in app`);
691
686
  }
692
- appCall(action) {
693
- let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
694
- let {
695
- callback,
696
- awaitResult = true
697
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
687
+ appCall(action, value = {}, {
688
+ callback,
689
+ awaitResult = true
690
+ } = {}) {
698
691
  if (!awaitResult) {
699
692
  invokeAppCall({
700
693
  action,
@@ -747,10 +740,9 @@ export class AppWrapper {
747
740
  this.appCall(254, {
748
741
  enabled: true
749
742
  }, {
750
- callback: _ref3 => {
751
- let {
752
- colorMode
753
- } = _ref3;
743
+ callback: ({
744
+ colorMode
745
+ }) => {
754
746
  this.values = {
755
747
  ...this.values,
756
748
  site: {
@@ -9,7 +9,6 @@ import { sendMessageToGroup, sendMessageToPage, sendMessageToUser } from '../cal
9
9
  import { setTappHeight } from '../util/heightHelper';
10
10
  export class FrameWrapper {
11
11
  constructor() {
12
- var _this = this;
13
12
  _defineProperty(this, "resolve", null);
14
13
  _defineProperty(this, "exposedFunctions", null);
15
14
  _defineProperty(this, "exposedCustomFunctions", {});
@@ -33,7 +32,7 @@ export class FrameWrapper {
33
32
  if (!this.initialized) await this.ready;
34
33
  try {
35
34
  return await this.exposedFunctions.addVisibilityChangeListener(comlink.proxy(result => callback(result)));
36
- } catch (ex) {
35
+ } catch {
37
36
  return addVisibilityChangeListener(callback);
38
37
  }
39
38
  },
@@ -303,13 +302,10 @@ export class FrameWrapper {
303
302
  if (p in target) {
304
303
  return target[p];
305
304
  }
306
- return target[p] = async function () {
307
- if (!_this.initialized) await _this.ready;
308
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
309
- args[_key] = arguments[_key];
310
- }
305
+ return target[p] = async (...args) => {
306
+ if (!this.initialized) await this.ready;
311
307
  const wrappedArgs = args.map(v => typeof v === 'function' ? comlink.proxy(v) : v);
312
- return _this.exposedCustomFunctions[p](...wrappedArgs);
308
+ return this.exposedCustomFunctions[p](...wrappedArgs);
313
309
  };
314
310
  }
315
311
  }));
@@ -329,15 +325,13 @@ export class FrameWrapper {
329
325
  }
330
326
  }
331
327
  async init() {
332
- var _await$exposed$_custo,
333
- _this2 = this;
328
+ var _await$exposed$_custo;
334
329
  if (this.initialized) return;
335
330
  const exposed = comlink.wrap(comlink.windowEndpoint(window.parent))[window.name];
336
- const dataListener = () => exposed.addDataListener(comlink.proxy(_ref => {
337
- let {
338
- type,
339
- value
340
- } = _ref;
331
+ const dataListener = () => exposed.addDataListener(comlink.proxy(({
332
+ type,
333
+ value
334
+ }) => {
341
335
  if (this.initialized) {
342
336
  this.values = {
343
337
  ...this.values,
@@ -365,12 +359,7 @@ export class FrameWrapper {
365
359
  this.exposedCustomFunctions = exposed.customFunctions;
366
360
  this.exposedCustomFunctionNames = (_await$exposed$_custo = await exposed._customFunctionNames) !== null && _await$exposed$_custo !== void 0 ? _await$exposed$_custo : [];
367
361
  this.customFunctions = this.exposedCustomFunctionNames.reduce((p, e) => {
368
- p[e] = function () {
369
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
370
- args[_key2] = arguments[_key2];
371
- }
372
- return _this2.exposedCustomFunctions[e](...args.map(a => typeof a === 'function' ? comlink.proxy(a) : a));
373
- };
362
+ p[e] = (...args) => this.exposedCustomFunctions[e](...args.map(a => typeof a === 'function' ? comlink.proxy(a) : a));
374
363
  return p;
375
364
  }, {});
376
365
  this.initialized = true;
@@ -26,11 +26,8 @@ export class ModuleFederationWrapper {
26
26
  this.functions.sendMessageToGroup = async (groupId, object) => sendMessageToGroup(this, object, groupId);
27
27
  this.functions.sendMessageToPage = async object => sendMessageToPage(this, object);
28
28
  this.functions.sendMessageToUser = async (userId, object) => sendMessageToUser(this, object, userId);
29
- Object.entries(functions).forEach(_ref => {
30
- let [k, fn] = _ref;
31
- this.functions[k] = async function () {
32
- return fn(...arguments);
33
- };
29
+ Object.entries(functions).forEach(([k, fn]) => {
30
+ this.functions[k] = async (...args) => fn(...args);
34
31
  });
35
32
  if (customFunctions) {
36
33
  this.customFunctions = customFunctions;
@@ -6,7 +6,7 @@ import { AppFlavor } from '../types/IChaynsReact';
6
6
  import getDeviceInfo from '../util/deviceHelper';
7
7
  import { AppWrapper } from './AppWrapper';
8
8
  import { FrameWrapper } from './FrameWrapper';
9
- import { ModuleFederationWrapper } from "./ModuleFederationWrapper";
9
+ import { ModuleFederationWrapper } from './ModuleFederationWrapper';
10
10
  class StaticChaynsApi {
11
11
  constructor(values, functions) {
12
12
  var _deviceInfo$app;
@@ -34,10 +34,7 @@ class StaticChaynsApi {
34
34
  this._wrapper = wrapper;
35
35
  this.ready = wrapper.init();
36
36
  this.addDataListener = wrapper.addDataListener;
37
- Object.entries(wrapper.functions).forEach(_ref => {
38
- let [k, v] = _ref;
39
- this[k] = v;
40
- });
37
+ Object.assign(this, wrapper.functions);
41
38
  }
42
39
  }
43
40
  export default StaticChaynsApi;
@@ -1,10 +1,16 @@
1
1
  import { DialogButtonOld } from "../../types/dialog";
2
- type iFrameDialog = {
2
+ type IFrameDialog = {
3
3
  buttons?: DialogButtonOld[];
4
- callType?: number;
5
- tappIframeName?: string;
6
4
  url: string;
5
+ input?: object;
6
+ seamless?: boolean;
7
+ transparent?: boolean;
8
+ waitCursor?: boolean;
9
+ maxHeight?: string;
10
+ width?: number;
11
+ fullHeight?: boolean;
12
+ customTransitionTimeout?: number;
7
13
  };
8
- export declare function iFrame(dialog?: iFrameDialog): Promise<unknown>;
14
+ export declare function iFrame(dialog?: IFrameDialog): Promise<unknown>;
9
15
  export declare function _chaynsCallResponder(obj: any): void;
10
16
  export {};
@@ -259,7 +259,8 @@ export declare enum ScreenSize {
259
259
  }
260
260
  export declare enum AppFlavor {
261
261
  None = "none",
262
- Chayns = "chayns"
262
+ Chayns = "chayns",
263
+ Electron = "electron"
263
264
  }
264
265
  export type ChaynsApiDevice = {
265
266
  app?: {
@@ -699,11 +700,28 @@ export declare enum LoginState {
699
700
  SUCCESS = 4
700
701
  }
701
702
  export interface LoginResult {
703
+ /** @deprecated Check buttonType instead **/
702
704
  loginState: LoginState;
703
- }
704
- export interface Login {
705
- ignoreAuthenticated: boolean;
706
- }
705
+ buttonType: DialogButtonType;
706
+ token?: string;
707
+ confirmationToken?: string;
708
+ authCode?: string;
709
+ redirectUri?: string;
710
+ }
711
+ export type Login = BaseDialog & DialogModule<{
712
+ preventLogin?: boolean;
713
+ restore?: number;
714
+ tokenType?: number;
715
+ /**
716
+ * SiteId for which site the token should be generated.
717
+ * @warning Only works when tokenLocationId is defined too
718
+ **/
719
+ tokenSiteId?: string;
720
+ /**
721
+ * @warning Only works when tokenSiteId is defined too
722
+ */
723
+ tokenLocationId?: number;
724
+ }>;
707
725
  export interface InvokeCall {
708
726
  action: number;
709
727
  value?: object;
@@ -904,7 +922,8 @@ export declare enum AppName {
904
922
  Sidekick = 7,
905
923
  Team = 8,
906
924
  CityApp = 9,
907
- ElectronChayns = 10
925
+ ElectronChayns = 10,
926
+ ElectronTeam = 11
908
927
  }
909
928
  export declare enum BrowserName {
910
929
  Unknown = "unknown",
@@ -3,3 +3,4 @@ export declare const isAppCallSupported: ({ minAndroidVersion, minIOSVersion }:
3
3
  minAndroidVersion?: number | undefined;
4
4
  minIOSVersion?: number | undefined;
5
5
  }) => boolean;
6
+ export declare const isElectron: () => boolean;
@@ -1,9 +1,73 @@
1
- import { DataChangeCallback } from '../types/IChaynsReact';
2
- declare class StaticChaynsApi {
1
+ import { ChaynsReactFunctions, ChaynsReactValues, DataChangeCallback } from '../types/IChaynsReact';
2
+ declare class StaticChaynsApi implements ChaynsReactFunctions {
3
+ addGeoLocationListener: ChaynsReactFunctions['addGeoLocationListener'];
4
+ addScrollListener: ChaynsReactFunctions['addScrollListener'];
5
+ addVisibilityChangeListener: ChaynsReactFunctions['addVisibilityChangeListener'];
6
+ addToolbarChangeListener: ChaynsReactFunctions['addToolbarChangeListener'];
7
+ addWindowMetricsListener: ChaynsReactFunctions['addWindowMetricsListener'];
8
+ customCallbackFunction: ChaynsReactFunctions['customCallbackFunction'];
9
+ getAvailableSharingServices: ChaynsReactFunctions['getAvailableSharingServices'];
10
+ getAccessToken: ChaynsReactFunctions['getAccessToken'];
11
+ getCustomCookie: ChaynsReactFunctions['getCustomCookie'];
12
+ getGeoLocation: ChaynsReactFunctions['getGeoLocation'];
13
+ getUserInfo: ChaynsReactFunctions['getUserInfo'];
14
+ getScrollPosition: ChaynsReactFunctions['getScrollPosition'];
15
+ getWindowMetrics: ChaynsReactFunctions['getWindowMetrics'];
16
+ invokeCall: ChaynsReactFunctions['invokeCall'];
17
+ invokePaymentCall: ChaynsReactFunctions['invokePaymentCall'];
18
+ invokeDialogCall: ChaynsReactFunctions['invokeDialogCall'];
19
+ login: ChaynsReactFunctions['login'];
20
+ logout: ChaynsReactFunctions['logout'];
21
+ navigateBack: ChaynsReactFunctions['navigateBack'];
22
+ openImage: ChaynsReactFunctions['openImage'];
23
+ openUrl: ChaynsReactFunctions['openUrl'];
24
+ openVideo: ChaynsReactFunctions['openVideo'];
25
+ openMedia: ChaynsReactFunctions['openMedia'];
26
+ refreshData: ChaynsReactFunctions['refreshData'];
27
+ refreshAccessToken: ChaynsReactFunctions['refreshAccessToken'];
28
+ removeGeoLocationListener: ChaynsReactFunctions['removeGeoLocationListener'];
29
+ removeScrollListener: ChaynsReactFunctions['removeScrollListener'];
30
+ removeVisibilityChangeListener: ChaynsReactFunctions['removeVisibilityChangeListener'];
31
+ removeToolbarChangeListener: ChaynsReactFunctions['removeToolbarChangeListener'];
32
+ removeWindowMetricsListener: ChaynsReactFunctions['removeWindowMetricsListener'];
33
+ selectPage: ChaynsReactFunctions['selectPage'];
34
+ scrollToY: ChaynsReactFunctions['scrollToY'];
35
+ sendMessageToGroup: ChaynsReactFunctions['sendMessageToGroup'];
36
+ sendMessageToPage: ChaynsReactFunctions['sendMessageToPage'];
37
+ sendMessageToUser: ChaynsReactFunctions['sendMessageToUser'];
38
+ setAdminMode: ChaynsReactFunctions['setAdminMode'];
39
+ setCustomCookie: ChaynsReactFunctions['setCustomCookie'];
40
+ setDisplayTimeout: ChaynsReactFunctions['setDisplayTimeout'];
41
+ setFloatingButton: ChaynsReactFunctions['setFloatingButton'];
42
+ setHeight: ChaynsReactFunctions['setHeight'];
43
+ setRefreshScrollEnabled: ChaynsReactFunctions['setRefreshScrollEnabled'];
44
+ setScanQrCode: ChaynsReactFunctions['setScanQrCode'];
45
+ setTempDesignSettings: ChaynsReactFunctions['setTempDesignSettings'];
46
+ setWaitCursor: ChaynsReactFunctions['setWaitCursor'];
47
+ storageGetItem: ChaynsReactFunctions['storageGetItem'];
48
+ storageRemoveItem: ChaynsReactFunctions['storageRemoveItem'];
49
+ storageSetItem: ChaynsReactFunctions['storageSetItem'];
50
+ vibrate: ChaynsReactFunctions['vibrate'];
51
+ scrollByY: ChaynsReactFunctions['scrollByY'];
52
+ setOverlay: ChaynsReactFunctions['setOverlay'];
53
+ createDialog: ChaynsReactFunctions['createDialog'];
54
+ openDialog: ChaynsReactFunctions['openDialog'];
55
+ closeDialog: ChaynsReactFunctions['closeDialog'];
56
+ setDialogResult: ChaynsReactFunctions['setDialogResult'];
57
+ dispatchEventToDialogClient: ChaynsReactFunctions['dispatchEventToDialogClient'];
58
+ addDialogClientEventListener: ChaynsReactFunctions['addDialogClientEventListener'];
59
+ removeDialogClientEventListener: ChaynsReactFunctions['removeDialogClientEventListener'];
60
+ dispatchEventToDialogHost: ChaynsReactFunctions['dispatchEventToDialogHost'];
61
+ addDialogHostEventListener: ChaynsReactFunctions['addDialogHostEventListener'];
62
+ removeDialogHostEventListener: ChaynsReactFunctions['removeDialogHostEventListener'];
63
+ addAnonymousAccount: ChaynsReactFunctions['addAnonymousAccount'];
64
+ addAccessTokenChangeListener: ChaynsReactFunctions['addAccessTokenChangeListener'];
65
+ removeAccessTokenChangeListener: ChaynsReactFunctions['removeAccessTokenChangeListener'];
66
+ redirect: ChaynsReactFunctions['redirect'];
3
67
  ready: Promise<void>;
4
68
  addDataListener: (cb: DataChangeCallback) => () => void;
5
69
  private _wrapper;
6
- constructor(values: any, functions: any);
70
+ constructor(values?: ChaynsReactValues, functions?: ChaynsReactFunctions);
7
71
  getUser: () => import("../types/IChaynsReact").ChaynsApiUser | undefined;
8
72
  getSite: () => import("../types/IChaynsReact").ChaynsApiSite;
9
73
  getCurrentPage: () => {
@@ -30,6 +94,6 @@ declare class StaticChaynsApi {
30
94
  };
31
95
  getStyleSettings: () => import("../types/IChaynsReact").ChaynsStyleSettings | undefined;
32
96
  getCustomFunction: (key: string) => (...args: any[]) => Promise<any>;
33
- getDialogInput: () => any;
97
+ getDialogInput: <T>() => T;
34
98
  }
35
99
  export default StaticChaynsApi;
@@ -0,0 +1,3 @@
1
+ import config from '@chayns-toolkit/eslint-config';
2
+
3
+ export default config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "2.5.1",
3
+ "version": "2.5.3",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -13,6 +13,9 @@
13
13
  "default": "./dist/esm/index.js"
14
14
  }
15
15
  },
16
+ "sideEffects": [
17
+ "**/utils/transferNestedFunctions.*"
18
+ ],
16
19
  "keywords": [
17
20
  "chayns",
18
21
  "chayns-toolkit",
@@ -48,33 +51,32 @@
48
51
  "comlink": "4.3.1",
49
52
  "htmlescape": "^1.1.1",
50
53
  "lodash.throttle": "^4.1.1",
51
- "ua-parser-js": "^1.0.40",
52
- "use-sync-external-store": "^1.4.0"
54
+ "ua-parser-js": "^1.0.41",
55
+ "use-sync-external-store": "^1.6.0"
53
56
  },
54
57
  "devDependencies": {
55
- "@babel/cli": "^7.26.4",
56
- "@babel/core": "^7.26.9",
57
- "@babel/preset-env": "^7.26.9",
58
- "@babel/preset-react": "^7.26.3",
59
- "@babel/preset-typescript": "^7.26.0",
60
- "@chayns-toolkit/eslint-config": "^2.0.0",
61
- "@rsbuild/plugin-umd": "^1.0.4",
58
+ "@babel/cli": "^7.28.3",
59
+ "@babel/core": "^7.28.5",
60
+ "@babel/preset-env": "^7.28.5",
61
+ "@babel/preset-react": "^7.28.5",
62
+ "@babel/preset-typescript": "^7.28.5",
63
+ "@chayns-toolkit/eslint-config": "^3.0.2",
64
+ "@rsbuild/plugin-umd": "^1.0.5",
62
65
  "@types/htmlescape": "^1.1.3",
63
66
  "@types/lodash.throttle": "^4.1.9",
64
- "@types/prop-types": "^15.7.14",
65
- "@types/react": "^18.3.18",
66
- "@types/react-dom": "^18.3.5",
67
+ "@types/prop-types": "^15.7.15",
68
+ "@types/react": "^18.3.27",
69
+ "@types/react-dom": "^18.3.7",
67
70
  "@types/ua-parser-js": "^0.7.39",
68
- "@types/use-sync-external-store": "^0.0.6",
69
- "@typescript-eslint/parser": "^7.6.0",
70
- "chayns-toolkit": "^3.2.6",
71
- "concurrently": "^9.1.2",
72
- "cross-env": "^7.0.3",
73
- "prettier": "^3.5.3",
74
- "prettier-plugin-packagejson": "^2.5.10",
71
+ "@types/use-sync-external-store": "^1.5.0",
72
+ "chayns-toolkit": "^3.3.6",
73
+ "concurrently": "^9.2.1",
74
+ "cross-env": "^10.1.0",
75
+ "prettier": "^3.7.4",
76
+ "prettier-plugin-packagejson": "^2.5.20",
75
77
  "react": "^18.3.1",
76
78
  "react-dom": "^18.3.1",
77
- "typescript": "^5.8.2"
79
+ "typescript": "^5.9.3"
78
80
  },
79
81
  "peerDependencies": {
80
82
  "react": "^16.8 || ^17.0.1 || ^18.0.0 || ^19.0.0",