chayns-api 2.4.20 → 2.4.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -191,6 +191,18 @@ Object.keys(_bindChaynsApi).forEach(function (key) {
191
191
  }
192
192
  });
193
193
  });
194
+ var _appStorage = require("./util/appStorage");
195
+ Object.keys(_appStorage).forEach(function (key) {
196
+ if (key === "default" || key === "__esModule") return;
197
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
198
+ if (key in exports && exports[key] === _appStorage[key]) return;
199
+ Object.defineProperty(exports, key, {
200
+ enumerable: true,
201
+ get: function () {
202
+ return _appStorage[key];
203
+ }
204
+ });
205
+ });
194
206
  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); }
195
207
  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; }
196
208
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -18,8 +18,8 @@ function isAppStorageAvailable() {
18
18
  }
19
19
  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);
20
20
  }
21
- function getAppStorageItem(storeName, key) {
22
- const callbackName = `chaynsApiV5Callback_${this.counter++}`;
21
+ function getAppStorageItem(storeName, key, callbackPrefix = 'chaynsApiV5Callback') {
22
+ const callbackName = `${callbackPrefix}_${this.counter++}`;
23
23
  return new Promise(resolve => {
24
24
  window[callbackName] = (_key, _storeName, value) => {
25
25
  try {
@@ -41,8 +41,8 @@ function getAppStorageItem(storeName, key) {
41
41
  }
42
42
  });
43
43
  }
44
- function setAppStorageItem(storeName, key, value) {
45
- const callbackName = `chaynsApiV5Callback_${this.counter++}`;
44
+ function setAppStorageItem(storeName, key, value, callbackPrefix = 'chaynsApiV5Callback') {
45
+ const callbackName = `${callbackPrefix}_${this.counter++}`;
46
46
  return new Promise((resolve, reject) => {
47
47
  window[callbackName] = () => {
48
48
  resolve();
@@ -79,8 +79,8 @@ function clearAppStorage(storeName) {
79
79
  window.chaynsWebViewStorage.chaynsDataErase(storeName);
80
80
  }
81
81
  }
82
- async function addAppStorageListener(storeName, prefix, callback) {
83
- const callbackName = `chaynsApiV5Callback_${this.counter++}`;
82
+ async function addAppStorageListener(storeName, prefix, callback, callbackPrefix = 'chaynsApiV5Callback') {
83
+ const callbackName = `${callbackPrefix}_${this.counter++}`;
84
84
  const {
85
85
  shouldInitialize
86
86
  } = (0, _apiListenerHelper.addApiListener)(`appStorageListener/${storeName}`, callback);
package/dist/esm/index.js CHANGED
@@ -16,4 +16,5 @@ export { default as DialogHandler } from './handler/DialogHandler';
16
16
  import * as _dialog from './calls/dialogs/index';
17
17
  export { _dialog as dialog };
18
18
  export * from './util/initModuleFederationSharing';
19
- export * from './util/bindChaynsApi';
19
+ export * from './util/bindChaynsApi';
20
+ export * from './util/appStorage';
@@ -8,7 +8,8 @@ export function isAppStorageAvailable() {
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
10
  export function getAppStorageItem(storeName, key) {
11
- const callbackName = `chaynsApiV5Callback_${this.counter++}`;
11
+ let callbackPrefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'chaynsApiV5Callback';
12
+ const callbackName = `${callbackPrefix}_${this.counter++}`;
12
13
  return new Promise(resolve => {
13
14
  window[callbackName] = (_key, _storeName, value) => {
14
15
  try {
@@ -31,7 +32,8 @@ export function getAppStorageItem(storeName, key) {
31
32
  });
32
33
  }
33
34
  export function setAppStorageItem(storeName, key, value) {
34
- const callbackName = `chaynsApiV5Callback_${this.counter++}`;
35
+ let callbackPrefix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'chaynsApiV5Callback';
36
+ const callbackName = `${callbackPrefix}_${this.counter++}`;
35
37
  return new Promise((resolve, reject) => {
36
38
  window[callbackName] = () => {
37
39
  resolve();
@@ -69,7 +71,8 @@ export function clearAppStorage(storeName) {
69
71
  }
70
72
  }
71
73
  export async function addAppStorageListener(storeName, prefix, callback) {
72
- const callbackName = `chaynsApiV5Callback_${this.counter++}`;
74
+ let callbackPrefix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'chaynsApiV5Callback';
75
+ const callbackName = `${callbackPrefix}_${this.counter++}`;
73
76
  const {
74
77
  shouldInitialize
75
78
  } = addApiListener(`appStorageListener/${storeName}`, callback);
@@ -253,7 +253,7 @@ export declare const getStyleSettings: () => import("../types/IChaynsReact").Cha
253
253
  * Returns the customFunction. Prefer usage via useCustomFunction when possible
254
254
  * @param key functionName
255
255
  */
256
- export declare const getCustomFunction: <A extends Array<any>, T>(key: string) => (...args: A) => Promise<T>;
256
+ export declare const getCustomFunction: <A extends (...args: any[]) => Promise<any>>(key: string) => A;
257
257
  export declare const user: UserInfo;
258
258
  export declare const site: ChaynsApiSite;
259
259
  export declare const device: ChaynsApiDevice;
@@ -3,4 +3,4 @@
3
3
  * @category Hooks
4
4
  * @param key functionName
5
5
  */
6
- export declare const useCustomFunction: <A extends Array<any>, T>(key: string) => (...args: A) => Promise<T>;
6
+ export declare const useCustomFunction: <A extends (...args: any[]) => Promise<any>>(key: string) => A;
@@ -16,3 +16,4 @@ export { default as DialogHandler } from './handler/DialogHandler';
16
16
  export * as dialog from './calls/dialogs/index';
17
17
  export * from './util/initModuleFederationSharing';
18
18
  export * from './util/bindChaynsApi';
19
+ export * from './util/appStorage';
@@ -451,7 +451,7 @@ export interface ChaynsReactFunctions {
451
451
  }) => Promise<void>;
452
452
  }
453
453
  export type ChaynsReactCustomFunctions = {
454
- [key: string]: <A extends Array<any>, O>(...args: A) => Promise<O>;
454
+ [key: string]: (...args: any[]) => Promise<any>;
455
455
  };
456
456
  export type DialogResult = {
457
457
  open: () => Promise<any>;
@@ -1,7 +1,7 @@
1
1
  import { AppWrapper } from '../wrapper/AppWrapper';
2
2
  export declare function isAppStorageAvailable(this: AppWrapper): boolean;
3
- export declare function getAppStorageItem<T extends unknown>(this: AppWrapper, storeName: string, key?: string): Promise<T>;
4
- export declare function setAppStorageItem<T extends string | object>(this: AppWrapper, storeName: string, key: string, value: T): Promise<void>;
3
+ export declare function getAppStorageItem<T extends unknown>(this: AppWrapper, storeName: string, key?: string, callbackPrefix?: string): Promise<T>;
4
+ export declare function setAppStorageItem<T extends string | object>(this: AppWrapper, storeName: string, key: string, value: T, callbackPrefix?: string): Promise<void>;
5
5
  export declare function removeAppStorageItem(this: AppWrapper, storeName: string, key: string): void;
6
6
  export declare function clearAppStorage(this: AppWrapper, storeName: string): void;
7
- export declare function addAppStorageListener<T extends string | object>(this: AppWrapper, storeName: string, prefix: string, callback: (value: T | undefined) => void): Promise<void>;
7
+ export declare function addAppStorageListener<T extends string | object>(this: AppWrapper, storeName: string, prefix: string, callback: (value: T | undefined) => void, callbackPrefix?: string): Promise<void>;
@@ -29,6 +29,6 @@ declare class StaticChaynsApi {
29
29
  runtimeEnvironment: import("../types/IChaynsReact").RuntimeEnviroment | string;
30
30
  };
31
31
  getStyleSettings: () => import("../types/IChaynsReact").ChaynsStyleSettings | undefined;
32
- getCustomFunction: (key: string) => <A extends Array<any>, O>(...args: A) => Promise<O>;
32
+ getCustomFunction: (key: string) => (...args: any[]) => Promise<any>;
33
33
  }
34
34
  export default StaticChaynsApi;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "2.4.20",
3
+ "version": "2.4.22",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",