chayns-api 2.4.21 → 2.4.23

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);
@@ -33,7 +33,14 @@ class FrameWrapper {
33
33
  if (!this.initialized) await this.ready;
34
34
  return this.exposedFunctions.addScrollListener(value, callback && comlink.proxy(result => callback(result)));
35
35
  },
36
- addVisibilityChangeListener: async callback => (0, _visibilityChangeListener.addVisibilityChangeListener)(callback),
36
+ addVisibilityChangeListener: async callback => {
37
+ if (!this.initialized) await this.ready;
38
+ try {
39
+ return await this.exposedFunctions.addVisibilityChangeListener(comlink.proxy(result => callback(result)));
40
+ } catch (ex) {
41
+ return (0, _visibilityChangeListener.addVisibilityChangeListener)(callback);
42
+ }
43
+ },
37
44
  addToolbarChangeListener: async callback => {
38
45
  if (!this.initialized) await this.ready;
39
46
  return this.exposedFunctions.addToolbarChangeListener(callback && comlink.proxy(result => callback(result)));
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);
@@ -29,7 +29,14 @@ export class FrameWrapper {
29
29
  if (!this.initialized) await this.ready;
30
30
  return this.exposedFunctions.addScrollListener(value, callback && comlink.proxy(result => callback(result)));
31
31
  },
32
- addVisibilityChangeListener: async callback => addVisibilityChangeListener(callback),
32
+ addVisibilityChangeListener: async callback => {
33
+ if (!this.initialized) await this.ready;
34
+ try {
35
+ return await this.exposedFunctions.addVisibilityChangeListener(comlink.proxy(result => callback(result)));
36
+ } catch (ex) {
37
+ return addVisibilityChangeListener(callback);
38
+ }
39
+ },
33
40
  addToolbarChangeListener: async callback => {
34
41
  if (!this.initialized) await this.ready;
35
42
  return this.exposedFunctions.addToolbarChangeListener(callback && comlink.proxy(result => callback(result)));
@@ -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';
@@ -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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "2.4.21",
3
+ "version": "2.4.23",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",