@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.
- package/dist/mobile_platform.js +4 -12
- package/mobile_platform.ts +7 -14
- package/package.json +1 -1
package/dist/mobile_platform.js
CHANGED
|
@@ -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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
}
|
package/mobile_platform.ts
CHANGED
|
@@ -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
|
|
20
|
-
if (event.data
|
|
21
|
-
|
|
22
|
-
|
|
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
|
})
|