@robotical/webapp-types 1.0.0 → 1.0.1

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.
@@ -26,12 +26,14 @@ export default class ApplicationManager {
26
26
  constructor();
27
27
  createNewCog(id: string): Cog;
28
28
  createNewMarty(id: string): Marty;
29
+ connectGenericMarty(afterRaftConnectedCb: (raft: RAFT) => void): Promise<void>;
30
+ connectGenericCog(afterRaftConnectedCb: (raft: RAFT) => void): Promise<void>;
29
31
  /**
30
32
  * Generic Connect method
31
33
  * This method is called from various environments (connection button, blocksjr, blocks etc.)
32
34
  * Known issue: connecting to a raft from within a platform won't add the newly connected raft to the connectedRafts hook
33
35
  */
34
- connectGeneric(afterRaftConnectedCb: (raft: RAFT) => void): Promise<void>;
36
+ connectGeneric(afterRaftConnectedCb: (raft: RAFT) => void, uuid: string): Promise<void>;
35
37
  /**
36
38
  * Disconnect from RAFT generic
37
39
  * This method is called from various environments (connection button, blocksjr, blocks etc.)
@@ -41,7 +43,7 @@ export default class ApplicationManager {
41
43
  * Selects a RAFT in Phone's verification modal
42
44
  */
43
45
  selectRaft(ricToConnectTo: FOUND_RAFT_ON_DISCOVERY_RESPONSE['foundRIC'], method: RaftConnectionMethod): Promise<RAFT | null>;
44
- connectToRIC(method: RaftConnectionMethod): Promise<RAFT | null>;
46
+ connectToRIC(method: RaftConnectionMethod, uuid: string): Promise<RAFT | null>;
45
47
  /**
46
48
  * Disconnect from RAFT
47
49
  */
@@ -45,6 +45,7 @@ import VerificationModal from "../../components/modals/VerificationModal";
45
45
  import { raftFoundSubscriptionHelper } from "../RAFTs/raft-subscription-helpers";
46
46
  import { AppSentMessage } from "../../types/communication-between-apps/wrapper-communication";
47
47
  import VerificationModalPhoneApp from "../../components/modals/VerificationModalPhoneApp";
48
+ import { RaftChannelBLE, } from "@robdobsn/raftjs";
48
49
  import Logger from "../../services/logger/Logger";
49
50
  import isPhoneApp from "../../utils/phone-app-communication/is-phone-app";
50
51
  import DisconnectConfirmationModal from "../../components/modals/DisconnectConfirmation";
@@ -82,6 +83,8 @@ var ApplicationManager = /** @class */ (function () {
82
83
  this.isPhoneApp = isPhoneApp;
83
84
  // super();
84
85
  // AnalyticsManager.appStartSession();
86
+ this.connectGenericMarty = this.connectGenericMarty.bind(this);
87
+ this.connectGenericCog = this.connectGenericCog.bind(this);
85
88
  }
86
89
  ApplicationManager.prototype.createNewCog = function (id) {
87
90
  return new Cog(id);
@@ -89,12 +92,26 @@ var ApplicationManager = /** @class */ (function () {
89
92
  ApplicationManager.prototype.createNewMarty = function (id) {
90
93
  return new Marty(id);
91
94
  };
95
+ ApplicationManager.prototype.connectGenericMarty = function (afterRaftConnectedCb) {
96
+ return __awaiter(this, void 0, void 0, function () {
97
+ return __generator(this, function (_a) {
98
+ return [2 /*return*/, this.connectGeneric(afterRaftConnectedCb, RaftChannelBLE.RICServiceUUID)];
99
+ });
100
+ });
101
+ };
102
+ ApplicationManager.prototype.connectGenericCog = function (afterRaftConnectedCb) {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ return __generator(this, function (_a) {
105
+ return [2 /*return*/, this.connectGeneric(afterRaftConnectedCb, RaftChannelBLE.CogServiceUUID)];
106
+ });
107
+ });
108
+ };
92
109
  /**
93
110
  * Generic Connect method
94
111
  * This method is called from various environments (connection button, blocksjr, blocks etc.)
95
112
  * Known issue: connecting to a raft from within a platform won't add the newly connected raft to the connectedRafts hook
96
113
  */
97
- ApplicationManager.prototype.connectGeneric = function (afterRaftConnectedCb) {
114
+ ApplicationManager.prototype.connectGeneric = function (afterRaftConnectedCb, uuid) {
98
115
  return __awaiter(this, void 0, void 0, function () {
99
116
  var e_1, newRaft, e_2;
100
117
  var _this = this;
@@ -119,7 +136,7 @@ var ApplicationManager = /** @class */ (function () {
119
136
  case 4: return [3 /*break*/, 8];
120
137
  case 5:
121
138
  _a.trys.push([5, 7, , 8]);
122
- return [4 /*yield*/, window.applicationManager.connectToRIC(RaftConnectionMethod.WEB_BLE)];
139
+ return [4 /*yield*/, window.applicationManager.connectToRIC(RaftConnectionMethod.WEB_BLE, uuid)];
123
140
  case 6:
124
141
  newRaft = _a.sent();
125
142
  if (newRaft) {
@@ -215,13 +232,13 @@ var ApplicationManager = /** @class */ (function () {
215
232
  });
216
233
  });
217
234
  };
218
- ApplicationManager.prototype.connectToRIC = function (method) {
235
+ ApplicationManager.prototype.connectToRIC = function (method, uuid) {
219
236
  var _a, _b;
220
237
  return __awaiter(this, void 0, void 0, function () {
221
238
  var wasConnectedObj, raftId, raftType, raft;
222
239
  return __generator(this, function (_c) {
223
240
  switch (_c.label) {
224
- case 0: return [4 /*yield*/, RAFT.connect(method)];
241
+ case 0: return [4 /*yield*/, RAFT.connect(method, uuid)];
225
242
  case 1:
226
243
  wasConnectedObj = _c.sent();
227
244
  if (!wasConnectedObj.success) return [3 /*break*/, 3];
@@ -29,7 +29,7 @@ export default class RAFT implements RICInterface {
29
29
  * Connect to a RAFT
30
30
  * We first connect, then we discover the raft type, and then we create the appopriate raft instance
31
31
  */
32
- static connect(method: RaftConnectionMethod): Promise<ConnectionAttemptResults>;
32
+ static connect(method: RaftConnectionMethod, uuid: string): Promise<ConnectionAttemptResults>;
33
33
  /**
34
34
  * Disconnect from a RAFT
35
35
  */
@@ -85,12 +85,12 @@ var RAFT = /** @class */ (function () {
85
85
  * Connect to a RAFT
86
86
  * We first connect, then we discover the raft type, and then we create the appopriate raft instance
87
87
  */
88
- RAFT.connect = function (method) {
88
+ RAFT.connect = function (method, uuid) {
89
89
  return __awaiter(this, void 0, void 0, function () {
90
90
  var connectResults;
91
91
  return __generator(this, function (_a) {
92
92
  switch (_a.label) {
93
- case 0: return [4 /*yield*/, window.wrapperCommunicator.sendMessageAndWait(AppSentMessage.RAFT_CONNECT, { method: method })];
93
+ case 0: return [4 /*yield*/, window.wrapperCommunicator.sendMessageAndWait(AppSentMessage.RAFT_CONNECT, { method: method, uuid: uuid })];
94
94
  case 1:
95
95
  connectResults = _a.sent();
96
96
  return [2 /*return*/, connectResults];
@@ -14,7 +14,7 @@ export declare class WrapperAppManager {
14
14
  * @returns Promise<ConnectionAttemptResults>
15
15
  *
16
16
  */
17
- connect(method: RaftConnectionMethod): Promise<ConnectionAttemptResults>;
17
+ connect(method: RaftConnectionMethod, uuid: string): Promise<ConnectionAttemptResults>;
18
18
  /**
19
19
  * Re-triggers the connect event which was missed due to the connection logic
20
20
  */
@@ -55,12 +55,12 @@ var WrapperAppManager = /** @class */ (function () {
55
55
  * @returns Promise<ConnectionAttemptResults>
56
56
  *
57
57
  */
58
- WrapperAppManager.prototype.connect = function (method) {
58
+ WrapperAppManager.prototype.connect = function (method, uuid) {
59
59
  return __awaiter(this, void 0, void 0, function () {
60
60
  var connector, connectionResults;
61
61
  return __generator(this, function (_a) {
62
62
  switch (_a.label) {
63
- case 0: return [4 /*yield*/, ConnectorFactory.connectToRaftHelper(method)];
63
+ case 0: return [4 /*yield*/, ConnectorFactory.connectToRaftHelper(method, uuid)];
64
64
  case 1:
65
65
  connector = _a.sent();
66
66
  if (!connector) {
@@ -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)];
149
+ return [4 /*yield*/, wrapperAppManager.connect(data.method, data.uuid)];
150
150
  case 3:
151
151
  connectionResults = _b.sent();
152
152
  window.wrapperCommunicator.onMessageResponse({ success: true, error: "", results: connectionResults, messagePromiseId: messagePromiseId });
@@ -10,6 +10,6 @@ export default class ConnectorFactory {
10
10
  * @returns Promise<ConnectionAttemptResults>
11
11
  *
12
12
  */
13
- static connectToRaftHelper(method: RaftConnectionMethod): Promise<Connector | null>;
13
+ static connectToRaftHelper(method: RaftConnectionMethod, uuid: 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, uuid) {
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, "", uuid)];
64
64
  case 1:
65
65
  wasConnected = _a.sent();
66
66
  Logger.info(SHOW_LOGS, TAG, "Was connected to RAFT: ".concat(wasConnected));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robotical/webapp-types",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Type definitions for the Application Manager",
5
5
  "main": "dist/application-manager.d.ts",
6
6
  "types": "dist/application-manager.d.ts",