chayns-api 1.0.57 → 1.0.60

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.
@@ -28,8 +28,11 @@ Comlink.transferHandlers.set("FUNCTION", {
28
28
  },
29
29
  deserialize(obj) {
30
30
  obj._functionKeys.forEach(x => {
31
- obj[x].start();
32
- obj[x] = Comlink.wrap(obj[x]);
31
+ // under certain conditions deserialize can be called more than once on same object
32
+ if (obj[x] instanceof MessagePort) {
33
+ obj[x].start();
34
+ obj[x] = Comlink.wrap(obj[x]);
35
+ }
33
36
  });
34
37
  return obj;
35
38
  }
@@ -553,10 +553,18 @@ class AppWrapper {
553
553
  }
554
554
  async init() {
555
555
  this.values = this.mapOldApiToNew(await this.appCall(18));
556
- this.appCall(66, {
557
- enabled: true
558
- }, value => {
556
+ const callbackName = `chaynsApiV5Callback_${this.counter++}`;
557
+ window.disablev4AccessTokenChangeListener = true;
558
+ window[callbackName] = ({
559
+ retVal: value
560
+ }) => {
559
561
  this.mapOldApiToNew(value);
562
+ };
563
+ this.appCall(66, {
564
+ enabled: true,
565
+ callback: callbackName
566
+ }, {
567
+ awaitResult: false
560
568
  });
561
569
  return undefined;
562
570
  }
@@ -24,8 +24,11 @@ Comlink.transferHandlers.set("FUNCTION", {
24
24
  },
25
25
  deserialize(obj) {
26
26
  obj._functionKeys.forEach(x => {
27
- obj[x].start();
28
- obj[x] = Comlink.wrap(obj[x]);
27
+ // under certain conditions deserialize can be called more than once on same object
28
+ if (obj[x] instanceof MessagePort) {
29
+ obj[x].start();
30
+ obj[x] = Comlink.wrap(obj[x]);
31
+ }
29
32
  });
30
33
  return obj;
31
34
  }
@@ -551,10 +551,19 @@ export class AppWrapper {
551
551
  }
552
552
  async init() {
553
553
  this.values = this.mapOldApiToNew(await this.appCall(18));
554
- this.appCall(66, {
555
- enabled: true
556
- }, value => {
554
+ const callbackName = `chaynsApiV5Callback_${this.counter++}`;
555
+ window.disablev4AccessTokenChangeListener = true;
556
+ window[callbackName] = _ref2 => {
557
+ let {
558
+ retVal: value
559
+ } = _ref2;
557
560
  this.mapOldApiToNew(value);
561
+ };
562
+ this.appCall(66, {
563
+ enabled: true,
564
+ callback: callbackName
565
+ }, {
566
+ awaitResult: false
558
567
  });
559
568
  return undefined;
560
569
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "1.0.57",
3
+ "version": "1.0.60",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",