@robotical/webapp-types 1.1.0 → 1.1.2
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-types/src/application/ApplicationManager/ApplicationManager.d.ts +13 -3
- package/dist-types/src/application/ApplicationManager/ApplicationManager.js +62 -26
- package/dist-types/src/application/RAFTs/Cog/Cog.d.ts +7 -2
- package/dist-types/src/application/RAFTs/Cog/Cog.js +27 -12
- package/dist-types/src/application/RAFTs/Cog/PublishedDataAnalyser.d.ts +64 -4
- package/dist-types/src/application/RAFTs/Cog/PublishedDataAnalyser.js +98 -37
- package/dist-types/src/application/RAFTs/Marty/Marty.js +1 -1
- package/dist-types/src/application/RAFTs/RAFT.d.ts +5 -4
- package/dist-types/src/application/RAFTs/RAFT.js +4 -4
- package/dist-types/src/application/communicators/SelfdestructiveMessagePromise.js +1 -1
- package/dist-types/src/components/modals/ConnectingLoadingSpinnerModal/index.d.ts +3 -0
- package/dist-types/src/components/modals/ConnectingLoadingSpinnerModal/index.js +16 -0
- package/dist-types/src/components/modals/DisconnectConfirmation/index.d.ts +1 -6
- package/dist-types/src/components/modals/DisconnectConfirmation/index.js +2 -59
- package/dist-types/src/components/modals/VerificationModal/index.js +1 -1
- package/dist-types/src/components/modals/VerificationModalPhoneApp/index.js +11 -6
- package/dist-types/src/services/logger/Logger.d.ts +1 -0
- package/dist-types/src/services/logger/Logger.js +10 -4
- package/dist-types/src/state-observables/modal/ModalObserver.d.ts +1 -0
- package/dist-types/src/state-observables/modal/ModalState.d.ts +1 -1
- package/dist-types/src/state-observables/modal/ModalState.js +3 -2
- package/dist-types/src/types/communication-between-apps/wrapper-communication.d.ts +4 -1
- package/dist-types/src/types/communication-between-apps/wrapper-communication.js +3 -0
- package/dist-types/src/wrapper-app/WrapperAppManager.d.ts +1 -1
- package/dist-types/src/wrapper-app/WrapperAppManager.js +2 -2
- package/dist-types/src/wrapper-app/communicators/WebAppCommunicator.js +1 -1
- package/dist-types/src/wrapper-app/connectors/CogConnector/CogConnector.d.ts +5 -0
- package/dist-types/src/wrapper-app/connectors/CogConnector/CogConnector.js +33 -1
- package/dist-types/src/wrapper-app/connectors/Connector.d.ts +4 -1
- package/dist-types/src/wrapper-app/connectors/Connector.js +10 -11
- package/dist-types/src/wrapper-app/connectors/ConnectorFactory.d.ts +1 -1
- package/dist-types/src/wrapper-app/connectors/ConnectorFactory.js +2 -2
- package/dist-types/src/wrapper-app/connectors/MartyConnector/MartyConnector.d.ts +5 -0
- package/dist-types/src/wrapper-app/connectors/MartyConnector/MartyConnector.js +24 -0
- package/package.json +1 -1
|
@@ -146,7 +146,7 @@ var receivedMessageHandler = function (receivedMessage, data, messagePromiseId)
|
|
|
146
146
|
return [3 /*break*/, 29];
|
|
147
147
|
case 2:
|
|
148
148
|
_b.trys.push([2, 4, , 5]);
|
|
149
|
-
return [4 /*yield*/, wrapperAppManager.connect(data.method, data.
|
|
149
|
+
return [4 /*yield*/, wrapperAppManager.connect(data.method, data.uuids)];
|
|
150
150
|
case 3:
|
|
151
151
|
connectionResults = _b.sent();
|
|
152
152
|
window.wrapperCommunicator.onMessageResponse({ success: true, error: "", results: connectionResults, messagePromiseId: messagePromiseId });
|
|
@@ -7,6 +7,11 @@ import { ConnManager } from "@robotical/roboticaljs";
|
|
|
7
7
|
declare class CogConnector extends Connector implements ConnectorInterface {
|
|
8
8
|
type: RaftTypeE;
|
|
9
9
|
constructor(raftId: string, connManager: ConnManager);
|
|
10
|
+
/**
|
|
11
|
+
* Publish an event to all observers
|
|
12
|
+
* Set in RICConnector as an event listener callback
|
|
13
|
+
*/
|
|
14
|
+
publish(eventType: string, eventEnum: RaftConnEvent | RaftUpdateEvent | RaftPublishEvent | RaftInfoEvents, eventName: string, eventData: any): void;
|
|
10
15
|
/**
|
|
11
16
|
* Connect to a RAFT
|
|
12
17
|
*/
|
|
@@ -49,10 +49,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
49
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
+
import { RaftInfoEvents } from "../../../types/events/raft-info";
|
|
52
53
|
import Logger from "../../../services/logger/Logger";
|
|
53
54
|
import { RaftTypeE } from "../../../types/raft";
|
|
54
55
|
import Connector from "../Connector";
|
|
55
|
-
import { RaftConnEvent, RaftUpdateEvent } from "@robotical/raftjs";
|
|
56
|
+
import { RaftConnEvent, RaftPublishEvent, RaftUpdateEvent } from "@robotical/raftjs";
|
|
57
|
+
import { CogPublishedDataGetter } from "@robotical/roboticaljs";
|
|
58
|
+
import { WrapperSentMessage } from "../../../types/communication-between-apps/wrapper-communication";
|
|
56
59
|
var SHOW_LOGS = true;
|
|
57
60
|
var TAG = "CogConnector";
|
|
58
61
|
var CogConnector = /** @class */ (function (_super) {
|
|
@@ -62,6 +65,19 @@ var CogConnector = /** @class */ (function (_super) {
|
|
|
62
65
|
_this.type = RaftTypeE.COG;
|
|
63
66
|
return _this;
|
|
64
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Publish an event to all observers
|
|
70
|
+
* Set in RICConnector as an event listener callback
|
|
71
|
+
*/
|
|
72
|
+
CogConnector.prototype.publish = function (eventType, eventEnum, eventName, eventData) {
|
|
73
|
+
window.WebAppCommunicator.sendMessageNoWait(WrapperSentMessage.RAFT_PUBLISHED_EVENT, { raftId: this.id, eventType: eventType, eventEnum: eventEnum, eventName: eventName, eventData: eventData });
|
|
74
|
+
if (this._observers.hasOwnProperty(eventType)) {
|
|
75
|
+
for (var _i = 0, _a = this._observers[eventType]; _i < _a.length; _i++) {
|
|
76
|
+
var observer = _a[_i];
|
|
77
|
+
observer.notify(eventType, eventEnum, eventName, eventData);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
65
81
|
/**
|
|
66
82
|
* Connect to a RAFT
|
|
67
83
|
*/
|
|
@@ -163,8 +179,24 @@ var CogConnector = /** @class */ (function (_super) {
|
|
|
163
179
|
*/
|
|
164
180
|
CogConnector.prototype.pubEventHandler = function (eventEnum, eventName, data) {
|
|
165
181
|
return __awaiter(this, void 0, void 0, function () {
|
|
182
|
+
var systemType, stateInfo, simplifiedInfo;
|
|
166
183
|
return __generator(this, function (_a) {
|
|
167
184
|
switch (eventEnum) {
|
|
185
|
+
case RaftPublishEvent.PUBLISH_EVENT_DATA:
|
|
186
|
+
systemType = this.connManager.getConnector().getSystemType();
|
|
187
|
+
if (systemType) {
|
|
188
|
+
stateInfo = systemType.getStateInfo();
|
|
189
|
+
if (stateInfo.deviceManager) {
|
|
190
|
+
simplifiedInfo = {
|
|
191
|
+
power: CogPublishedDataGetter.getPowerData(stateInfo.deviceManager),
|
|
192
|
+
accelerometer: CogPublishedDataGetter.getAccelerometerData(stateInfo.deviceManager),
|
|
193
|
+
light: CogPublishedDataGetter.getLightData(stateInfo.deviceManager),
|
|
194
|
+
gyroscope: CogPublishedDataGetter.getGyroscopeData(stateInfo.deviceManager)
|
|
195
|
+
};
|
|
196
|
+
this.publish("raftinfo", RaftInfoEvents.STATE_INFO, "StateInfo", { stateInfo: simplifiedInfo });
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
break;
|
|
168
200
|
default:
|
|
169
201
|
break;
|
|
170
202
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { RaftInfoEvents } from "../../types/events/raft-info";
|
|
2
2
|
import { ConnectionAttemptResults, RaftTypeE } from "../../types/raft";
|
|
3
|
+
import { RaftObserver } from "../../application/RAFTs/RaftObserver";
|
|
3
4
|
import ConnectorInterface from "./ConnectorInterface";
|
|
4
5
|
import { ConnManager, RICLedLcdColours } from "@robotical/roboticaljs";
|
|
5
6
|
import { RaftOKFail, RaftConnEvent, RaftUpdateEvent, RaftPublishEvent } from "@robotical/raftjs";
|
|
6
7
|
declare class Connector implements ConnectorInterface {
|
|
7
8
|
id: string;
|
|
8
9
|
type: RaftTypeE;
|
|
9
|
-
|
|
10
|
+
protected _observers: {
|
|
11
|
+
[key: string]: Array<RaftObserver>;
|
|
12
|
+
};
|
|
10
13
|
connManager: ConnManager;
|
|
11
14
|
constructor(id: string, connManager: ConnManager);
|
|
12
15
|
/**
|
|
@@ -38,7 +38,7 @@ import { RaftInfoEvents } from "../../types/events/raft-info";
|
|
|
38
38
|
import { WrapperSentMessage } from "../../types/communication-between-apps/wrapper-communication";
|
|
39
39
|
import Logger from "../../services/logger/Logger";
|
|
40
40
|
import { RaftTypeE } from "../../types/raft";
|
|
41
|
-
import { RaftConnEvent, RaftUpdateEvent,
|
|
41
|
+
import { RaftConnEvent, RaftUpdateEvent, } from "@robotical/raftjs";
|
|
42
42
|
var SHOW_LOGS = true;
|
|
43
43
|
var TAG = "Connector";
|
|
44
44
|
var Connector = /** @class */ (function () {
|
|
@@ -53,11 +53,14 @@ var Connector = /** @class */ (function () {
|
|
|
53
53
|
// Set the listener function
|
|
54
54
|
// Subscribe to connManager events
|
|
55
55
|
this.connManager.setConnectionEventListener(function (eventType, eventEnum, eventName, eventData) {
|
|
56
|
-
if (eventType
|
|
56
|
+
if (eventType === "pub") {
|
|
57
|
+
// if it's a pub event, we are publishing it from _pubEventHandler method (in child classes)
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
57
60
|
Logger.info(SHOW_LOGS, TAG, "eventType: ".concat(eventType, " eventEnum: ").concat(eventEnum, " eventName: ").concat(eventName, " eventData: ").concat(eventData));
|
|
61
|
+
_this.publish(eventType, eventEnum, eventName, eventData);
|
|
58
62
|
}
|
|
59
63
|
_this.eventHandler(eventType, eventEnum, eventName, eventData);
|
|
60
|
-
_this.publish(eventType, eventEnum, eventName, eventData);
|
|
61
64
|
});
|
|
62
65
|
}
|
|
63
66
|
/**
|
|
@@ -192,6 +195,10 @@ var Connector = /** @class */ (function () {
|
|
|
192
195
|
* Set in RICConnector as an event listener callback
|
|
193
196
|
*/
|
|
194
197
|
Connector.prototype.publish = function (eventType, eventEnum, eventName, eventData) {
|
|
198
|
+
if (eventType === "raftinfo") {
|
|
199
|
+
// should be handled from child class
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
195
202
|
window.WebAppCommunicator.sendMessageNoWait(WrapperSentMessage.RAFT_PUBLISHED_EVENT, { raftId: this.id, eventType: eventType, eventEnum: eventEnum, eventName: eventName, eventData: eventData });
|
|
196
203
|
if (this._observers.hasOwnProperty(eventType)) {
|
|
197
204
|
for (var _i = 0, _a = this._observers[eventType]; _i < _a.length; _i++) {
|
|
@@ -293,16 +300,8 @@ var Connector = /** @class */ (function () {
|
|
|
293
300
|
*/
|
|
294
301
|
Connector.prototype._pubEventHandler = function (eventEnum, eventName, data) {
|
|
295
302
|
return __awaiter(this, void 0, void 0, function () {
|
|
296
|
-
var systemType, stateInfo;
|
|
297
303
|
return __generator(this, function (_a) {
|
|
298
304
|
switch (eventEnum) {
|
|
299
|
-
case RaftPublishEvent.PUBLISH_EVENT_DATA:
|
|
300
|
-
systemType = this.connManager.getConnector().getSystemType();
|
|
301
|
-
if (systemType) {
|
|
302
|
-
stateInfo = systemType.getStateInfo();
|
|
303
|
-
this.publish("raftinfo", RaftInfoEvents.STATE_INFO, "StateInfo", { stateInfo: stateInfo });
|
|
304
|
-
}
|
|
305
|
-
break;
|
|
306
305
|
default:
|
|
307
306
|
break;
|
|
308
307
|
}
|
|
@@ -10,6 +10,6 @@ export default class ConnectorFactory {
|
|
|
10
10
|
* @returns Promise<ConnectionAttemptResults>
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
|
-
static connectToRaftHelper(method: RaftConnectionMethod,
|
|
13
|
+
static connectToRaftHelper(method: RaftConnectionMethod, uuids: string[]): Promise<Connector | null>;
|
|
14
14
|
static createConnector(raftType: string | undefined, connManager: ConnManager): Connector;
|
|
15
15
|
}
|
|
@@ -52,7 +52,7 @@ var ConnectorFactory = /** @class */ (function () {
|
|
|
52
52
|
* @returns Promise<ConnectionAttemptResults>
|
|
53
53
|
*
|
|
54
54
|
*/
|
|
55
|
-
ConnectorFactory.connectToRaftHelper = function (method,
|
|
55
|
+
ConnectorFactory.connectToRaftHelper = function (method, uuids) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function () {
|
|
57
57
|
var connManager, wasConnected, systemInfo, raftType, connector;
|
|
58
58
|
return __generator(this, function (_a) {
|
|
@@ -60,7 +60,7 @@ var ConnectorFactory = /** @class */ (function () {
|
|
|
60
60
|
case 0:
|
|
61
61
|
connManager = new ConnManager();
|
|
62
62
|
Logger.info(SHOW_LOGS, TAG, "Connecting to RAFT with method: ".concat(method));
|
|
63
|
-
return [4 /*yield*/, connManager.connect(method, "",
|
|
63
|
+
return [4 /*yield*/, connManager.connect(method, "", uuids)];
|
|
64
64
|
case 1:
|
|
65
65
|
wasConnected = _a.sent();
|
|
66
66
|
Logger.info(SHOW_LOGS, TAG, "Was connected to RAFT: ".concat(wasConnected));
|
|
@@ -7,6 +7,11 @@ import { ConnManager } from "@robotical/roboticaljs";
|
|
|
7
7
|
declare class MartyConnector extends Connector implements ConnectorInterface {
|
|
8
8
|
type: RaftTypeE;
|
|
9
9
|
constructor(raftId: string, connManager: ConnManager);
|
|
10
|
+
/**
|
|
11
|
+
* Publish an event to all observers
|
|
12
|
+
* Set in RICConnector as an event listener callback
|
|
13
|
+
*/
|
|
14
|
+
publish(eventType: string, eventEnum: RaftConnEvent | RaftUpdateEvent | RaftPublishEvent | RaftInfoEvents, eventName: string, eventData: any): void;
|
|
10
15
|
/**
|
|
11
16
|
* Connect to a RAFT
|
|
12
17
|
*/
|
|
@@ -50,11 +50,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
import { RICRoboticalAddOns } from "@robotical/ricjs-robotical-addons";
|
|
53
|
+
import { RaftInfoEvents } from "../../../types/events/raft-info";
|
|
53
54
|
import Logger from "../../../services/logger/Logger";
|
|
54
55
|
import { RaftTypeE } from "../../../types/raft";
|
|
55
56
|
import Connector from "../Connector";
|
|
56
57
|
import { RaftConnEvent, RaftUpdateEvent, RaftPublishEvent, } from "@robotical/raftjs";
|
|
57
58
|
import { RICServoParamUpdater, RICSystemUtils, } from "@robotical/roboticaljs";
|
|
59
|
+
import { WrapperSentMessage } from "../../../types/communication-between-apps/wrapper-communication";
|
|
58
60
|
var SHOW_LOGS = true;
|
|
59
61
|
var TAG = "MartyConnector";
|
|
60
62
|
var MartyConnector = /** @class */ (function (_super) {
|
|
@@ -64,6 +66,22 @@ var MartyConnector = /** @class */ (function (_super) {
|
|
|
64
66
|
_this.type = RaftTypeE.MARTY;
|
|
65
67
|
return _this;
|
|
66
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Publish an event to all observers
|
|
71
|
+
* Set in RICConnector as an event listener callback
|
|
72
|
+
*/
|
|
73
|
+
MartyConnector.prototype.publish = function (eventType, eventEnum, eventName, eventData) {
|
|
74
|
+
if (eventType === "raftinfo") {
|
|
75
|
+
// marty info do not need manipulation like Cog
|
|
76
|
+
}
|
|
77
|
+
window.WebAppCommunicator.sendMessageNoWait(WrapperSentMessage.RAFT_PUBLISHED_EVENT, { raftId: this.id, eventType: eventType, eventEnum: eventEnum, eventName: eventName, eventData: eventData });
|
|
78
|
+
if (this._observers.hasOwnProperty(eventType)) {
|
|
79
|
+
for (var _i = 0, _a = this._observers[eventType]; _i < _a.length; _i++) {
|
|
80
|
+
var observer = _a[_i];
|
|
81
|
+
observer.notify(eventType, eventEnum, eventName, eventData);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
67
85
|
/**
|
|
68
86
|
* Connect to a RAFT
|
|
69
87
|
*/
|
|
@@ -203,9 +221,15 @@ var MartyConnector = /** @class */ (function (_super) {
|
|
|
203
221
|
*/
|
|
204
222
|
MartyConnector.prototype.pubEventHandler = function (eventEnum, eventName, data) {
|
|
205
223
|
return __awaiter(this, void 0, void 0, function () {
|
|
224
|
+
var systemType, stateInfo;
|
|
206
225
|
return __generator(this, function (_a) {
|
|
207
226
|
switch (eventEnum) {
|
|
208
227
|
case RaftPublishEvent.PUBLISH_EVENT_DATA:
|
|
228
|
+
systemType = this.connManager.getConnector().getSystemType();
|
|
229
|
+
if (systemType) {
|
|
230
|
+
stateInfo = systemType.getStateInfo();
|
|
231
|
+
this.publish("raftinfo", RaftInfoEvents.STATE_INFO, "StateInfo", { stateInfo: stateInfo });
|
|
232
|
+
}
|
|
209
233
|
break;
|
|
210
234
|
default:
|
|
211
235
|
break;
|