@cpzxrobot/sdk 1.3.17 → 1.3.18

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.
@@ -10,19 +10,11 @@ class MobilePlatform {
10
10
  this.port = null;
11
11
  // @ts-ignore
12
12
  this.platform = window.flutter_inappwebview;
13
+ console.log("init message channel", JSON.stringify(event));
13
14
  window.addEventListener('message', (event) => {
14
- console.log("got message from flutter top", JSON.stringify(event));
15
- if (event.data == 'capturePort') {
16
- this.port = event.ports[0];
17
- if (this.port != null) {
18
- this.port.onmessage = (event) => {
19
- console.log("got message from flutter", JSON.stringify(event));
20
- if (event.data.id != undefined) {
21
- const callback = this.sseCallbacks[event.data.id];
22
- callback === null || callback === void 0 ? void 0 : callback(event.data.data);
23
- }
24
- };
25
- }
15
+ if (event.data.id != undefined) {
16
+ const callback = this.sseCallbacks[event.data.id];
17
+ callback === null || callback === void 0 ? void 0 : callback(event.data.data);
26
18
  }
27
19
  }, false);
28
20
  }
@@ -15,19 +15,12 @@ export class MobilePlatform implements PlatformInterface {
15
15
  // @ts-ignore
16
16
  this.platform = window.flutter_inappwebview;
17
17
 
18
+ console.log("init message channel", JSON.stringify(event));
18
19
  window.addEventListener('message', (event) => {
19
- console.log("got message from flutter top",JSON.stringify(event));
20
- if (event.data == 'capturePort') {
21
- this.port = event.ports[0];
22
- if (this.port != null) {
23
- this.port.onmessage = (event: MessageEvent) => {
24
- console.log("got message from flutter",JSON.stringify(event));
25
- if (event.data.id != undefined) {
26
- const callback = this.sseCallbacks[event.data.id];
27
- callback?.(event.data.data);
28
- }
29
- };
30
- }
20
+ console.log("got message", event.data);
21
+ if (event.data.id != undefined) {
22
+ const callback = this.sseCallbacks[event.data.id];
23
+ callback?.(event.data.data);
31
24
  }
32
25
  }, false);
33
26
  }
@@ -36,12 +29,12 @@ export class MobilePlatform implements PlatformInterface {
36
29
  }
37
30
  setToken(token: string): void {
38
31
  }
39
-
32
+
40
33
  setSelectedFarm(farm: Factory): void {
41
34
  throw new Error("Method not implemented.");
42
35
  }
43
36
  setSelectedUnit(unit: Unit): void {
44
- this.platform.callHandler("selectUnit", unit).then((_res:any) => {
37
+ this.platform.callHandler("selectUnit", unit).then((_res: any) => {
45
38
  // @ts-ignore
46
39
  window._notifyUnitChanged?.(unit);
47
40
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.17",
3
+ "version": "1.3.18",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {