@robotical/webapp-types 3.11.0 → 3.11.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.
@@ -1,89 +1,89 @@
1
1
  import RAFT from "./RAFT";
2
2
  export declare const raftConnectingSubscriptionHelper: (raft: RAFT) => {
3
3
  subscribe: (callback: any) => void;
4
- unsubscribe: () => void;
4
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
5
5
  };
6
6
  export declare const createRaftConnectingHelper: (raft: RAFT) => {
7
7
  subscribe: (callback: any) => void;
8
- unsubscribe: () => void;
8
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
9
9
  };
10
10
  export declare const raftConnectionIssueDetectedSubscriptionHelper: (raft: RAFT) => {
11
11
  subscribe: (callback: any) => void;
12
- unsubscribe: () => void;
12
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
13
13
  };
14
14
  export declare const createRaftConnectionIssueDetectedHelper: (raft: RAFT) => {
15
15
  subscribe: (callback: any) => void;
16
- unsubscribe: () => void;
16
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
17
17
  };
18
18
  export declare const raftConnectionIssueResolvedSubscriptionHelper: (raft: RAFT) => {
19
19
  subscribe: (callback: any) => void;
20
- unsubscribe: () => void;
20
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
21
21
  };
22
22
  export declare const createRaftConnectionIssueResolvedHelper: (raft: RAFT) => {
23
23
  subscribe: (callback: any) => void;
24
- unsubscribe: () => void;
24
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
25
25
  };
26
26
  export declare const raftConnectedSubscriptionHelper: (raft: RAFT) => {
27
27
  subscribe: (callback: any) => void;
28
- unsubscribe: () => void;
28
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
29
29
  };
30
30
  export declare const createRaftConnectedHelper: (raft: RAFT) => {
31
31
  subscribe: (callback: any) => void;
32
- unsubscribe: () => void;
32
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
33
33
  };
34
34
  export declare const raftDisconnectedSubscriptionHelper: (raft: RAFT) => {
35
35
  subscribe: (callback: any) => void;
36
- unsubscribe: () => void;
36
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
37
37
  };
38
38
  export declare const createRaftDisconnectedHelper: (raft: RAFT) => {
39
39
  subscribe: (callback: any) => void;
40
- unsubscribe: () => void;
40
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
41
41
  };
42
42
  export declare const raftVerifiedSubscriptionHelper: (raft: RAFT) => {
43
43
  subscribe: (callback: any) => void;
44
- unsubscribe: () => void;
44
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
45
45
  };
46
46
  export declare const createRaftVerifiedHelper: (raft: RAFT) => {
47
47
  subscribe: (callback: any) => void;
48
- unsubscribe: () => void;
48
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
49
49
  };
50
50
  export declare const raftFoundSubscriptionHelper: () => {
51
51
  subscribe: (callback: any) => void;
52
- unsubscribe: () => void;
52
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
53
53
  };
54
54
  export declare const createRaftFoundHelper: () => {
55
55
  subscribe: (callback: any) => void;
56
- unsubscribe: () => void;
56
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
57
57
  };
58
58
  export declare const raftDiscoveryFinishedSubscriptionHelper: () => {
59
59
  subscribe: (callback: any) => void;
60
- unsubscribe: () => void;
60
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
61
61
  };
62
62
  export declare const createRaftDiscoveryFinishedHelper: () => {
63
63
  subscribe: (callback: any) => void;
64
- unsubscribe: () => void;
64
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
65
65
  };
66
66
  export declare const raftDiscoveryStartedSubscriptionHelper: () => {
67
67
  subscribe: (callback: any) => void;
68
- unsubscribe: () => void;
68
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
69
69
  };
70
70
  export declare const createRaftDiscoveryStartedHelper: () => {
71
71
  subscribe: (callback: any) => void;
72
- unsubscribe: () => void;
72
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
73
73
  };
74
74
  export declare const raftRejectedSubscriptionHelper: (raft: RAFT) => {
75
75
  subscribe: (callback: any) => void;
76
- unsubscribe: () => void;
76
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
77
77
  };
78
78
  export declare const createRaftRejectedHelper: (raft: RAFT) => {
79
79
  subscribe: (callback: any) => void;
80
- unsubscribe: () => void;
80
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
81
81
  };
82
82
  export declare const raftPubSubscriptionHelper: (raft: RAFT) => {
83
83
  subscribe: (callback: (eventData: any) => void) => void;
84
- unsubscribe: () => void;
84
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
85
85
  };
86
86
  export declare const createRaftPubSubscriptionHelper: (raft: RAFT) => {
87
87
  subscribe: (callback: (eventData: any) => void) => void;
88
- unsubscribe: () => void;
88
+ unsubscribe: (shouldDestroyInstance?: boolean) => void;
89
89
  };
@@ -16,10 +16,14 @@ export var createRaftConnectingHelper = function (raft) {
16
16
  observer = raftConnectingSubscriptionObserver_(callback);
17
17
  raft.subscribe(observer, ["conn"]);
18
18
  },
19
- unsubscribe: function () {
19
+ unsubscribe: function (shouldDestroyInstance) {
20
+ if (shouldDestroyInstance === void 0) { shouldDestroyInstance = true; }
20
21
  if (observer) {
21
22
  raft.unsubscribe(observer);
22
23
  }
24
+ if (shouldDestroyInstance) {
25
+ raftConnectingHelperInstance = null;
26
+ }
23
27
  }
24
28
  };
25
29
  };
@@ -27,18 +31,10 @@ var raftConnectingSubscriptionObserver_ = function (callback) {
27
31
  return {
28
32
  notify: function (eventType, eventEnum, eventName, eventData) {
29
33
  switch (eventType) {
30
- // case "conn":
31
- // switch (eventEnum) {
32
- // case RaftConnEvent.BLE_VERIFYING_CORRECT:
33
- // callback(eventData.bondingColors);
34
- // break;
35
- // default:
36
- // break;
37
- // }
38
- // break;
39
34
  case "conn":
40
35
  switch (eventEnum) {
41
36
  case RaftConnEvent.CONN_VERIFYING_CORRECT:
37
+ console.log("got bonding colours", eventData);
42
38
  callback(eventData);
43
39
  break;
44
40
  default:
@@ -66,10 +62,14 @@ export var createRaftConnectionIssueDetectedHelper = function (raft) {
66
62
  observer = raftConnectionIssueDetectedSubscriptionObserver_(callback);
67
63
  raft.subscribe(observer, ["conn"]);
68
64
  },
69
- unsubscribe: function () {
65
+ unsubscribe: function (shouldDestroyInstance) {
66
+ if (shouldDestroyInstance === void 0) { shouldDestroyInstance = true; }
70
67
  if (observer) {
71
68
  raft.unsubscribe(observer);
72
69
  }
70
+ if (shouldDestroyInstance) {
71
+ raftConnectionIssueDetectedHelperInstance = null;
72
+ }
73
73
  }
74
74
  };
75
75
  };
@@ -110,10 +110,14 @@ export var createRaftConnectionIssueResolvedHelper = function (raft) {
110
110
  observer = raftConnectionIssueResolvedSubscriptionObserver_(callback);
111
111
  raft.subscribe(observer, ["conn"]);
112
112
  },
113
- unsubscribe: function () {
113
+ unsubscribe: function (shouldDestroyInstance) {
114
+ if (shouldDestroyInstance === void 0) { shouldDestroyInstance = true; }
114
115
  if (observer) {
115
116
  raft.unsubscribe(observer);
116
117
  }
118
+ if (shouldDestroyInstance) {
119
+ raftConnectionIssueResolvedHelperInstance = null;
120
+ }
117
121
  }
118
122
  };
119
123
  };
@@ -154,10 +158,14 @@ export var createRaftConnectedHelper = function (raft) {
154
158
  observer = raftConnectedSubscriptionObserver_(callback);
155
159
  raft.subscribe(observer, ["conn"]);
156
160
  },
157
- unsubscribe: function () {
161
+ unsubscribe: function (shouldDestroyInstance) {
162
+ if (shouldDestroyInstance === void 0) { shouldDestroyInstance = true; }
158
163
  if (observer) {
159
164
  raft.unsubscribe(observer);
160
165
  }
166
+ if (shouldDestroyInstance) {
167
+ raftConnectedHelperInstance = null;
168
+ }
161
169
  }
162
170
  };
163
171
  };
@@ -206,10 +214,14 @@ export var createRaftDisconnectedHelper = function (raft) {
206
214
  observer = raftDisconnectedSubscriptionObserver_(callback);
207
215
  raft.subscribe(observer, ["conn"]);
208
216
  },
209
- unsubscribe: function () {
217
+ unsubscribe: function (shouldDestroyInstance) {
218
+ if (shouldDestroyInstance === void 0) { shouldDestroyInstance = true; }
210
219
  if (observer) {
211
220
  raft.unsubscribe(observer);
212
221
  }
222
+ if (shouldDestroyInstance) {
223
+ raftDisconnectedHelperInstance = null;
224
+ }
213
225
  }
214
226
  };
215
227
  };
@@ -258,10 +270,14 @@ export var createRaftVerifiedHelper = function (raft) {
258
270
  observer = raftVerifiedSubscriptionObserver_(callback);
259
271
  raft.subscribe(observer, ["conn"]);
260
272
  },
261
- unsubscribe: function () {
273
+ unsubscribe: function (shouldDestroyInstance) {
274
+ if (shouldDestroyInstance === void 0) { shouldDestroyInstance = true; }
262
275
  if (observer) {
263
276
  raft.unsubscribe(observer);
264
277
  }
278
+ if (shouldDestroyInstance) {
279
+ raftVerifiedHelperInstance = null;
280
+ }
265
281
  }
266
282
  };
267
283
  };
@@ -309,10 +325,14 @@ export var createRaftFoundHelper = function () {
309
325
  observer = raftFoundSubscriptionObserver_(callback);
310
326
  window.applicationManager.subscribe(observer, ["conn"]);
311
327
  },
312
- unsubscribe: function () {
328
+ unsubscribe: function (shouldDestroyInstance) {
329
+ if (shouldDestroyInstance === void 0) { shouldDestroyInstance = true; }
313
330
  if (observer) {
314
331
  window.applicationManager.unsubscribe(observer);
315
332
  }
333
+ if (shouldDestroyInstance) {
334
+ raftFoundHelperInstance = null;
335
+ }
316
336
  }
317
337
  };
318
338
  };
@@ -350,10 +370,14 @@ export var createRaftDiscoveryFinishedHelper = function () {
350
370
  observer = raftDiscoveryFinishedSubscriptionObserver_(callback);
351
371
  window.applicationManager.subscribe(observer, ["conn"]);
352
372
  },
353
- unsubscribe: function () {
373
+ unsubscribe: function (shouldDestroyInstance) {
374
+ if (shouldDestroyInstance === void 0) { shouldDestroyInstance = true; }
354
375
  if (observer) {
355
376
  window.applicationManager.unsubscribe(observer);
356
377
  }
378
+ if (shouldDestroyInstance) {
379
+ raftDiscoveryFinishedHelperInstance = null;
380
+ }
357
381
  }
358
382
  };
359
383
  };
@@ -391,10 +415,14 @@ export var createRaftDiscoveryStartedHelper = function () {
391
415
  observer = raftDiscoveryStartedSubscriptionObserver_(callback);
392
416
  window.applicationManager.subscribe(observer, ["conn"]);
393
417
  },
394
- unsubscribe: function () {
418
+ unsubscribe: function (shouldDestroyInstance) {
419
+ if (shouldDestroyInstance === void 0) { shouldDestroyInstance = true; }
395
420
  if (observer) {
396
421
  window.applicationManager.unsubscribe(observer);
397
422
  }
423
+ if (shouldDestroyInstance) {
424
+ raftDiscoveryStartedHelperInstance = null;
425
+ }
398
426
  }
399
427
  };
400
428
  };
@@ -433,10 +461,14 @@ export var createRaftRejectedHelper = function (raft) {
433
461
  observer = raftRejectedSubscriptionObserver_(callback);
434
462
  raft.subscribe(observer, ["conn"]);
435
463
  },
436
- unsubscribe: function () {
464
+ unsubscribe: function (shouldDestroyInstance) {
465
+ if (shouldDestroyInstance === void 0) { shouldDestroyInstance = true; }
437
466
  if (observer) {
438
467
  raft.unsubscribe(observer);
439
468
  }
469
+ if (shouldDestroyInstance) {
470
+ raftRejectedHelperInstance = null;
471
+ }
440
472
  }
441
473
  };
442
474
  };
@@ -480,10 +512,14 @@ export var createRaftPubSubscriptionHelper = function (raft) {
480
512
  observer = raftPubSubscriptionObserver_(callback);
481
513
  raft.subscribe(observer, ["raftinfo"]);
482
514
  },
483
- unsubscribe: function () {
515
+ unsubscribe: function (shouldDestroyInstance) {
516
+ if (shouldDestroyInstance === void 0) { shouldDestroyInstance = true; }
484
517
  if (observer) {
485
518
  raft.unsubscribe(observer);
486
519
  }
520
+ if (shouldDestroyInstance) {
521
+ raftPubSubscriptionHelperInstance = null;
522
+ }
487
523
  }
488
524
  };
489
525
  };
@@ -62,31 +62,31 @@ function VerificationModal(_a) {
62
62
  var _this = this;
63
63
  var connectedRAFT_ = _a.connectedRAFT_;
64
64
  var _b = useState([]), randomColours = _b[0], setRandomColours = _b[1];
65
- var _c = useState(connectedRAFT_), connectedRaft = _c[0], setConnectedRaft = _c[1];
66
- var _d = useState(-200), RSSI = _d[0], setRSSI = _d[1];
65
+ // const [connectedRaft, setConnectedRaft] = useState<RAFT | undefined>(connectedRAFT_);
66
+ var _c = useState(-200), RSSI = _c[0], setRSSI = _c[1];
67
67
  var removeConnectedRaft = useConnectedRafts().removeConnectedRaft;
68
68
  useEffect(function () {
69
69
  /* Subscribe to the connectedRaft's SIGNAL strength */
70
- if (!connectedRaft)
70
+ if (!connectedRAFT_)
71
71
  return;
72
72
  var signalUpdateTimout = setInterval(function () {
73
- setRSSI(connectedRaft.getRSSI());
73
+ setRSSI(connectedRAFT_.getRSSI());
74
74
  }, 1000);
75
75
  return function () { return clearInterval(signalUpdateTimout); };
76
- }, [connectedRaft]);
76
+ }, [connectedRAFT_]);
77
77
  var onCancel = function () { return __awaiter(_this, void 0, void 0, function () {
78
78
  return __generator(this, function (_a) {
79
79
  switch (_a.label) {
80
80
  case 0:
81
81
  // close modal, stop verification process, disconnect, scan again
82
82
  modalState.closeModal();
83
- if (!connectedRaft)
83
+ if (!connectedRAFT_)
84
84
  return [2 /*return*/];
85
- removeConnectedRaft(connectedRaft.id);
86
- return [4 /*yield*/, window.applicationManager.stopVerifyingRaft(connectedRaft.id, false)];
85
+ removeConnectedRaft(connectedRAFT_.id);
86
+ return [4 /*yield*/, window.applicationManager.stopVerifyingRaft(connectedRAFT_.id, false)];
87
87
  case 1:
88
88
  _a.sent();
89
- return [4 /*yield*/, connectedRaft.disconnect()];
89
+ return [4 /*yield*/, connectedRAFT_.disconnect()];
90
90
  case 2:
91
91
  _a.sent();
92
92
  return [2 /*return*/];
@@ -98,7 +98,7 @@ function VerificationModal(_a) {
98
98
  switch (_a.label) {
99
99
  case 0:
100
100
  modalState.closeModal();
101
- return [4 /*yield*/, (connectedRaft === null || connectedRaft === void 0 ? void 0 : connectedRaft.stopVerifyingRaft(true))];
101
+ return [4 /*yield*/, (connectedRAFT_ === null || connectedRAFT_ === void 0 ? void 0 : connectedRAFT_.stopVerifyingRaft(true))];
102
102
  case 1:
103
103
  _a.sent();
104
104
  return [2 /*return*/];
@@ -107,18 +107,19 @@ function VerificationModal(_a) {
107
107
  }); };
108
108
  useEffect(function () {
109
109
  /* Subscribe to the connectedRaft's Connection state */
110
- if (!connectedRaft)
110
+ if (!connectedRAFT_)
111
111
  return;
112
- raftConnectingSubscriptionHelper(connectedRaft).subscribe(setRandomColours);
112
+ var subHelper = raftConnectingSubscriptionHelper(connectedRAFT_);
113
+ subHelper.subscribe(setRandomColours);
113
114
  return function () {
114
- raftConnectingSubscriptionHelper(connectedRaft).unsubscribe();
115
+ subHelper.unsubscribe();
115
116
  };
116
- }, [connectedRaft]);
117
+ }, [connectedRAFT_]);
117
118
  useEffect(function () {
118
119
  /* Verify the connectedRaft once it's connected */
119
- connectedRaft === null || connectedRaft === void 0 ? void 0 : connectedRaft.verifyRaft();
120
- }, [connectedRaft]);
121
- var contentJSX = _jsxs("div", __assign({ className: "verification-modal-container" }, { children: [_jsxs("div", __assign({ className: "verification-modal-martys-container" }, { children: [_jsxs("div", __assign({ className: "verification-modal-marty-name-row-container" }, { children: [_jsx("p", __assign({ className: "verification-modal-marty-name" }, { children: connectedRaft === null || connectedRaft === void 0 ? void 0 : connectedRaft.getFriendlyName() })), _jsx("div", __assign({ className: "verification-modal-marty-signal-container" }, { children: _jsx(RICSignal, { signalStrength: RSSI }) })), _jsx(BluetoothSVG, { fill: MAIN_BLUE })] })), _jsxs("p", __assign({ className: "verification-modal-martys-back-hint" }, { children: ["Look on ", connectedRaft === null || connectedRaft === void 0 ? void 0 : connectedRaft.type, "'s back, is it displaying these lights?"] })), _jsxs("div", __assign({ className: "verification-modal-led-row-container" }, { children: [_jsx(LEDs, { coloursArr: randomColours, connectedRaft: connectedRaft }), _jsx(SimpleButton, { onClick: onCancel, title: "No", borderColour: "red", colour: "white", textColour: "red" }), _jsx(SimpleButton, { onClick: onYes, title: "YES" })] }))] })), _jsxs("div", __assign({ className: "verification-modal-bottom-btns-container" }, { children: [_jsx("div", { className: "dummy-gap" }), _jsx(SimpleButton, { onClick: onCancel, title: "CANCEL" })] }))] }));
120
+ connectedRAFT_ === null || connectedRAFT_ === void 0 ? void 0 : connectedRAFT_.verifyRaft();
121
+ }, [connectedRAFT_]);
122
+ var contentJSX = _jsxs("div", __assign({ className: "verification-modal-container" }, { children: [_jsxs("div", __assign({ className: "verification-modal-martys-container" }, { children: [_jsxs("div", __assign({ className: "verification-modal-marty-name-row-container" }, { children: [_jsx("p", __assign({ className: "verification-modal-marty-name" }, { children: connectedRAFT_ === null || connectedRAFT_ === void 0 ? void 0 : connectedRAFT_.getFriendlyName() })), _jsx("div", __assign({ className: "verification-modal-marty-signal-container" }, { children: _jsx(RICSignal, { signalStrength: RSSI }) })), _jsx(BluetoothSVG, { fill: MAIN_BLUE })] })), _jsxs("p", __assign({ className: "verification-modal-martys-back-hint" }, { children: ["Look on ", connectedRAFT_ === null || connectedRAFT_ === void 0 ? void 0 : connectedRAFT_.type, "'s back, is it displaying these lights?"] })), _jsxs("div", __assign({ className: "verification-modal-led-row-container" }, { children: [_jsx(LEDs, { coloursArr: randomColours, connectedRaft: connectedRAFT_ }), _jsx(SimpleButton, { onClick: onCancel, title: "No", borderColour: "red", colour: "white", textColour: "red" }), _jsx(SimpleButton, { onClick: onYes, title: "YES" })] }))] })), _jsxs("div", __assign({ className: "verification-modal-bottom-btns-container" }, { children: [_jsx("div", { className: "dummy-gap" }), _jsx(SimpleButton, { onClick: onCancel, title: "CANCEL" })] }))] }));
122
123
  return contentJSX;
123
124
  }
124
125
  export default VerificationModal;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robotical/webapp-types",
3
- "version": "3.11.0",
3
+ "version": "3.11.2",
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",