@robotical/webapp-types 0.6.58
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/application-manager.ts +20 -0
- package/dist-types/src/analytics/AnalyticsManager.d.ts +28 -0
- package/dist-types/src/analytics/AnalyticsManager.js +171 -0
- package/dist-types/src/application/ApplicationManager/ApplicationManager.d.ts +117 -0
- package/dist-types/src/application/ApplicationManager/ApplicationManager.js +567 -0
- package/dist-types/src/application/RAFTs/Cog/Cog.d.ts +50 -0
- package/dist-types/src/application/RAFTs/Cog/Cog.js +223 -0
- package/dist-types/src/application/RAFTs/Cog/PublishedDataAnalyser.d.ts +120 -0
- package/dist-types/src/application/RAFTs/Cog/PublishedDataAnalyser.js +533 -0
- package/dist-types/src/application/RAFTs/Marty/Marty.d.ts +42 -0
- package/dist-types/src/application/RAFTs/Marty/Marty.js +187 -0
- package/dist-types/src/application/RAFTs/RAFT.d.ts +114 -0
- package/dist-types/src/application/RAFTs/RAFT.js +341 -0
- package/dist-types/src/application/RAFTs/RAFTInterface.d.ts +13 -0
- package/dist-types/src/application/RAFTs/RAFTInterface.js +6 -0
- package/dist-types/src/application/RAFTs/RaftObserver.d.ts +10 -0
- package/dist-types/src/application/RAFTs/RaftObserver.js +1 -0
- package/dist-types/src/application/RAFTs/raft-subscription-helpers.d.ts +63 -0
- package/dist-types/src/application/RAFTs/raft-subscription-helpers.js +355 -0
- package/dist-types/src/application/communicators/SelfdestructiveMessagePromise.d.ts +10 -0
- package/dist-types/src/application/communicators/SelfdestructiveMessagePromise.js +31 -0
- package/dist-types/src/application/communicators/WrapperCommunicator.d.ts +24 -0
- package/dist-types/src/application/communicators/WrapperCommunicator.js +137 -0
- package/dist-types/src/components/disposables/LoadingSpinner/index.d.ts +7 -0
- package/dist-types/src/components/disposables/LoadingSpinner/index.js +29 -0
- package/dist-types/src/components/disposables/buttons/SVGImageButton/index.d.ts +14 -0
- package/dist-types/src/components/disposables/buttons/SVGImageButton/index.js +19 -0
- package/dist-types/src/components/disposables/buttons/SimpleButton/index.d.ts +14 -0
- package/dist-types/src/components/disposables/buttons/SimpleButton/index.js +18 -0
- package/dist-types/src/components/modals/ SensorsDashboardModal/index.d.ts +2 -0
- package/dist-types/src/components/modals/ SensorsDashboardModal/index.js +61 -0
- 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/DetailedFeedbackModal/index.d.ts +5 -0
- package/dist-types/src/components/modals/DetailedFeedbackModal/index.js +37 -0
- package/dist-types/src/components/modals/DisconnectConfirmation/index.d.ts +1 -0
- package/dist-types/src/components/modals/DisconnectConfirmation/index.js +8 -0
- package/dist-types/src/components/modals/DisconnectConfirmation/styles.d.ts +1 -0
- package/dist-types/src/components/modals/DisconnectConfirmation/styles.js +7 -0
- package/dist-types/src/components/modals/InUnplugged/index.d.ts +1 -0
- package/dist-types/src/components/modals/InUnplugged/index.js +12 -0
- package/dist-types/src/components/modals/InUnplugged/styles.d.ts +5 -0
- package/dist-types/src/components/modals/InUnplugged/styles.js +11 -0
- package/dist-types/src/components/modals/VerificationModal/index.d.ts +6 -0
- package/dist-types/src/components/modals/VerificationModal/index.js +124 -0
- package/dist-types/src/components/modals/VerificationModalPhoneApp/index.d.ts +6 -0
- package/dist-types/src/components/modals/VerificationModalPhoneApp/index.js +195 -0
- package/dist-types/src/components/oneoffs/LEDs/index.d.ts +8 -0
- package/dist-types/src/components/oneoffs/LEDs/index.js +39 -0
- package/dist-types/src/components/oneoffs/RaftSignal/index.d.ts +7 -0
- package/dist-types/src/components/oneoffs/RaftSignal/index.js +29 -0
- package/dist-types/src/services/logger/Logger.d.ts +8 -0
- package/dist-types/src/services/logger/Logger.js +25 -0
- package/dist-types/src/state-observables/modal/DraggableModalState.d.ts +16 -0
- package/dist-types/src/state-observables/modal/DraggableModalState.js +52 -0
- package/dist-types/src/state-observables/modal/ModalObserver.d.ts +18 -0
- package/dist-types/src/state-observables/modal/ModalObserver.js +1 -0
- package/dist-types/src/state-observables/modal/ModalState.d.ts +25 -0
- package/dist-types/src/state-observables/modal/ModalState.js +71 -0
- package/dist-types/src/store/SelectedRaftContext.d.ts +19 -0
- package/dist-types/src/store/SelectedRaftContext.js +84 -0
- package/dist-types/src/styles/colors.d.ts +35 -0
- package/dist-types/src/styles/colors.js +42 -0
- package/dist-types/src/types/communication-between-apps/wrapper-communication.d.ts +48 -0
- package/dist-types/src/types/communication-between-apps/wrapper-communication.js +28 -0
- package/dist-types/src/types/events/raft-info.d.ts +10 -0
- package/dist-types/src/types/events/raft-info.js +11 -0
- package/dist-types/src/types/phone-app-communicator.d.ts +20 -0
- package/dist-types/src/types/phone-app-communicator.js +5 -0
- package/dist-types/src/types/raft.d.ts +18 -0
- package/dist-types/src/types/raft.js +14 -0
- package/dist-types/src/utils/Toaster.d.ts +13 -0
- package/dist-types/src/utils/Toaster.js +38 -0
- package/dist-types/src/utils/helpers/compare-version.d.ts +2 -0
- package/dist-types/src/utils/helpers/compare-version.js +19 -0
- package/dist-types/src/utils/helpers/randomHashGenerator.d.ts +1 -0
- package/dist-types/src/utils/helpers/randomHashGenerator.js +10 -0
- package/dist-types/src/utils/helpers/rescale-range.d.ts +2 -0
- package/dist-types/src/utils/helpers/rescale-range.js +4 -0
- package/dist-types/src/utils/helpers/wifi-configuration-subtitle-gen.d.ts +3 -0
- package/dist-types/src/utils/helpers/wifi-configuration-subtitle-gen.js +34 -0
- package/dist-types/src/utils/phone-app-communication/is-phone-app.d.ts +5 -0
- package/dist-types/src/utils/phone-app-communication/is-phone-app.js +7 -0
- package/dist-types/src/wrapper-app/WrapperAppManager.d.ts +58 -0
- package/dist-types/src/wrapper-app/WrapperAppManager.js +176 -0
- package/dist-types/src/wrapper-app/communicators/WebAppCommunicator.d.ts +24 -0
- package/dist-types/src/wrapper-app/communicators/WebAppCommunicator.js +243 -0
- package/dist-types/src/wrapper-app/connectors/CogConnector/CogConnector.d.ts +40 -0
- package/dist-types/src/wrapper-app/connectors/CogConnector/CogConnector.js +209 -0
- package/dist-types/src/wrapper-app/connectors/Connector.d.ts +72 -0
- package/dist-types/src/wrapper-app/connectors/Connector.js +314 -0
- package/dist-types/src/wrapper-app/connectors/ConnectorFactory.d.ts +15 -0
- package/dist-types/src/wrapper-app/connectors/ConnectorFactory.js +99 -0
- package/dist-types/src/wrapper-app/connectors/ConnectorInterface.d.ts +10 -0
- package/dist-types/src/wrapper-app/connectors/ConnectorInterface.js +6 -0
- package/dist-types/src/wrapper-app/connectors/MartyConnector/MartyConnector.d.ts +40 -0
- package/dist-types/src/wrapper-app/connectors/MartyConnector/MartyConnector.js +243 -0
- package/dist-types/types-package/application-manager.d.ts +17 -0
- package/dist-types/types-package/application-manager.js +5 -0
- package/package.json +13 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is needed so we can build and publish the ApplicationManager interface to the children projects
|
|
3
|
+
*/
|
|
4
|
+
import ApplicationManager from "../src/application/ApplicationManager/ApplicationManager";
|
|
5
|
+
import WrapperCommunicator from "../src/application/communicators/WrapperCommunicator";
|
|
6
|
+
import Logger from "../src/services/logger/Logger";
|
|
7
|
+
import WebAppCommunicator from "../src/wrapper-app/communicators/WebAppCommunicator";
|
|
8
|
+
|
|
9
|
+
export { ApplicationManager }
|
|
10
|
+
|
|
11
|
+
declare global {
|
|
12
|
+
interface Window {
|
|
13
|
+
ReactNativeWebView: any;
|
|
14
|
+
// marty: Marty;
|
|
15
|
+
WebAppCommunicator: WebAppCommunicator;
|
|
16
|
+
wrapperCommunicator: WrapperCommunicator;
|
|
17
|
+
applicationManager: ApplicationManager;
|
|
18
|
+
Logger: Logger;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AnalyticsManager
|
|
3
|
+
*
|
|
4
|
+
* This class is responsible for managing the analytics services for the testing phase.
|
|
5
|
+
* Analytics gathered:
|
|
6
|
+
* - Connections
|
|
7
|
+
* - Disconnections
|
|
8
|
+
* - Visited pages
|
|
9
|
+
* - emoji feedback
|
|
10
|
+
* - text feedback
|
|
11
|
+
*
|
|
12
|
+
* Each of them will be stored as an event. They will stored in the order they were received so we can track the user's journey.
|
|
13
|
+
* There will be a timestamp for each event.
|
|
14
|
+
*
|
|
15
|
+
* We store client's id in a cookie so we can track the user's journey.
|
|
16
|
+
*/
|
|
17
|
+
type EventType = "connection" | "disconnection" | "page" | "emojifeedback" | "textfeedback" | "connection_issue" | "connection_issue_resolved";
|
|
18
|
+
export declare class AnalyticsManager {
|
|
19
|
+
private static instance;
|
|
20
|
+
private clientId;
|
|
21
|
+
private eventsStorer;
|
|
22
|
+
private constructor();
|
|
23
|
+
static getInstance(): AnalyticsManager;
|
|
24
|
+
private getClientId;
|
|
25
|
+
private generateClientId;
|
|
26
|
+
logEvent(eventType: EventType, data: any): void;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AnalyticsManager
|
|
3
|
+
*
|
|
4
|
+
* This class is responsible for managing the analytics services for the testing phase.
|
|
5
|
+
* Analytics gathered:
|
|
6
|
+
* - Connections
|
|
7
|
+
* - Disconnections
|
|
8
|
+
* - Visited pages
|
|
9
|
+
* - emoji feedback
|
|
10
|
+
* - text feedback
|
|
11
|
+
*
|
|
12
|
+
* Each of them will be stored as an event. They will stored in the order they were received so we can track the user's journey.
|
|
13
|
+
* There will be a timestamp for each event.
|
|
14
|
+
*
|
|
15
|
+
* We store client's id in a cookie so we can track the user's journey.
|
|
16
|
+
*/
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
44
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var AnalyticsManager = /** @class */ (function () {
|
|
65
|
+
function AnalyticsManager() {
|
|
66
|
+
this.clientId = this.getClientId();
|
|
67
|
+
this.eventsStorer = new EventsStorer(this.clientId);
|
|
68
|
+
}
|
|
69
|
+
AnalyticsManager.getInstance = function () {
|
|
70
|
+
if (!AnalyticsManager.instance) {
|
|
71
|
+
AnalyticsManager.instance = new AnalyticsManager();
|
|
72
|
+
}
|
|
73
|
+
return AnalyticsManager.instance;
|
|
74
|
+
};
|
|
75
|
+
AnalyticsManager.prototype.getClientId = function () {
|
|
76
|
+
var clientId = localStorage.getItem('@robotical/webapp/analytics/clientId');
|
|
77
|
+
if (!clientId) {
|
|
78
|
+
clientId = this.generateClientId();
|
|
79
|
+
localStorage.setItem('@robotical/webapp/analytics/clientId', clientId);
|
|
80
|
+
}
|
|
81
|
+
return clientId;
|
|
82
|
+
};
|
|
83
|
+
AnalyticsManager.prototype.generateClientId = function () {
|
|
84
|
+
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
85
|
+
};
|
|
86
|
+
AnalyticsManager.prototype.logEvent = function (eventType, data) {
|
|
87
|
+
var event = new AnalyticsEvent(eventType, data);
|
|
88
|
+
this.eventsStorer.addEvent(event);
|
|
89
|
+
};
|
|
90
|
+
return AnalyticsManager;
|
|
91
|
+
}());
|
|
92
|
+
export { AnalyticsManager };
|
|
93
|
+
var AnalyticsEvent = /** @class */ (function () {
|
|
94
|
+
function AnalyticsEvent(type, data) {
|
|
95
|
+
this.type = type;
|
|
96
|
+
this.data = data;
|
|
97
|
+
this.isProcessed = false;
|
|
98
|
+
this.timestamp = new Date().toString();
|
|
99
|
+
this.urlSafeTimestamp = new Date().toISOString().replaceAll("T", "_").replaceAll(":", "-").replaceAll("/", "-").replaceAll(".", "_");
|
|
100
|
+
}
|
|
101
|
+
AnalyticsEvent.prototype.process = function () {
|
|
102
|
+
this.isProcessed = true;
|
|
103
|
+
};
|
|
104
|
+
return AnalyticsEvent;
|
|
105
|
+
}());
|
|
106
|
+
var EventsStorer = /** @class */ (function () {
|
|
107
|
+
function EventsStorer(clientId) {
|
|
108
|
+
this.clientId = clientId;
|
|
109
|
+
this.events = [];
|
|
110
|
+
this.processing = false;
|
|
111
|
+
}
|
|
112
|
+
EventsStorer.prototype.addEvent = function (event) {
|
|
113
|
+
this.events.push(event);
|
|
114
|
+
this._processEvents();
|
|
115
|
+
};
|
|
116
|
+
EventsStorer.prototype._processEvents = function () {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
var _i, _a, event_1;
|
|
119
|
+
return __generator(this, function (_b) {
|
|
120
|
+
switch (_b.label) {
|
|
121
|
+
case 0:
|
|
122
|
+
if (this.processing)
|
|
123
|
+
return [2 /*return*/];
|
|
124
|
+
this.processing = true;
|
|
125
|
+
_i = 0, _a = this.events;
|
|
126
|
+
_b.label = 1;
|
|
127
|
+
case 1:
|
|
128
|
+
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
129
|
+
event_1 = _a[_i];
|
|
130
|
+
if (!!event_1.isProcessed) return [3 /*break*/, 3];
|
|
131
|
+
this._processEvent(event_1);
|
|
132
|
+
return [4 /*yield*/, this._delay(1000)];
|
|
133
|
+
case 2:
|
|
134
|
+
_b.sent(); // 1 second debounce time
|
|
135
|
+
_b.label = 3;
|
|
136
|
+
case 3:
|
|
137
|
+
_i++;
|
|
138
|
+
return [3 /*break*/, 1];
|
|
139
|
+
case 4:
|
|
140
|
+
this.processing = false;
|
|
141
|
+
return [2 /*return*/];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
EventsStorer.prototype._delay = function (ms) {
|
|
147
|
+
return new Promise(function (resolve) { return setTimeout(resolve, ms); });
|
|
148
|
+
};
|
|
149
|
+
EventsStorer.prototype._processEvent = function (event) {
|
|
150
|
+
event.process();
|
|
151
|
+
var data = __assign(__assign(__assign({}, event), event.data), { data: undefined, isProcessed: undefined, urlSafeTimestamp: undefined });
|
|
152
|
+
var path = "".concat(this.clientId, "/").concat(event.urlSafeTimestamp, "-").concat(event.type);
|
|
153
|
+
FirebaseInteractor.put(path, data);
|
|
154
|
+
};
|
|
155
|
+
return EventsStorer;
|
|
156
|
+
}());
|
|
157
|
+
var FirebaseInteractor = /** @class */ (function () {
|
|
158
|
+
function FirebaseInteractor() {
|
|
159
|
+
}
|
|
160
|
+
FirebaseInteractor.put = function (path, data) {
|
|
161
|
+
fetch("".concat(this.db_href, "/").concat(path, ".json"), {
|
|
162
|
+
method: 'PUT',
|
|
163
|
+
body: JSON.stringify(data),
|
|
164
|
+
headers: {
|
|
165
|
+
'Content-Type': 'application/json'
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
FirebaseInteractor.db_href = "https://app-v2-analytics-default-rtdb.firebaseio.com";
|
|
170
|
+
return FirebaseInteractor;
|
|
171
|
+
}());
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { RaftConnectionMethod, RaftTypeE } from "../../types/raft";
|
|
2
|
+
import WebAppCommunicator from "../../wrapper-app/communicators/WebAppCommunicator";
|
|
3
|
+
import RAFT from "../RAFTs/RAFT";
|
|
4
|
+
import Marty from "../RAFTs/Marty/Marty";
|
|
5
|
+
import Cog from "../RAFTs/Cog/Cog";
|
|
6
|
+
import { FOUND_RAFT_ON_DISCOVERY_RESPONSE } from "../../types/phone-app-communicator";
|
|
7
|
+
import { RaftObserver } from "../RAFTs/RaftObserver";
|
|
8
|
+
import { RaftInfoEvents } from "../../types/events/raft-info";
|
|
9
|
+
import { RaftConnEvent, RaftUpdateEvent, RaftPublishEvent } from "@robotical/raftjs";
|
|
10
|
+
import { ConnectedRaftItem } from "../../store/SelectedRaftContext";
|
|
11
|
+
import Toaster from "../../utils/Toaster";
|
|
12
|
+
import { AnalyticsManager } from "../../analytics/AnalyticsManager";
|
|
13
|
+
export default class ApplicationManager {
|
|
14
|
+
private _observers;
|
|
15
|
+
static wrapperAppCommunicator: WebAppCommunicator;
|
|
16
|
+
connectedRafts: {
|
|
17
|
+
[key: string]: RAFT;
|
|
18
|
+
};
|
|
19
|
+
connectedRaftsContext: ConnectedRaftItem[];
|
|
20
|
+
returnToMainApp: () => void;
|
|
21
|
+
private _router;
|
|
22
|
+
setRouter(router: any): void;
|
|
23
|
+
navigateTo(path: string): void;
|
|
24
|
+
ricSelectedCb: ((raft: RAFT) => void) | null;
|
|
25
|
+
toaster: typeof Toaster;
|
|
26
|
+
analyticsManager: AnalyticsManager;
|
|
27
|
+
showBackHomeButton: () => void;
|
|
28
|
+
hideBackHomeButton: () => void;
|
|
29
|
+
connectedRaftContextMethods: {
|
|
30
|
+
addConnectedRaft: (connectedRaft: ConnectedRaftItem) => void;
|
|
31
|
+
removeConnectedRaft: (connectedRaftId: string) => void;
|
|
32
|
+
setSelectedRaft: (connectedRaftId: string) => void;
|
|
33
|
+
};
|
|
34
|
+
isPhoneApp: () => boolean;
|
|
35
|
+
constructor();
|
|
36
|
+
createNewCog(id: string): Cog;
|
|
37
|
+
createNewMarty(id: string): Marty;
|
|
38
|
+
connectGenericMarty(afterRaftConnectedCb: (raft: RAFT) => void): Promise<void>;
|
|
39
|
+
connectGenericCog(afterRaftConnectedCb: (raft: RAFT) => void): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Generic Connect method
|
|
42
|
+
* This method is called from various environments (connection button, blocksjr, blocks etc.)
|
|
43
|
+
* Known issue: connecting to a raft from within a platform won't add the newly connected raft to the connectedRafts hook
|
|
44
|
+
*/
|
|
45
|
+
connectGeneric(afterRaftConnectedCb: (raft: RAFT) => void, uuids?: string[]): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Disconnect from RAFT generic
|
|
48
|
+
* This method is called from various environments (connection button, blocksjr, blocks etc.)
|
|
49
|
+
*/
|
|
50
|
+
disconnectGeneric(raft: RAFT, afterRaftDisconnectedCb?: () => void): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Selects a RAFT in Phone's verification modal
|
|
53
|
+
*/
|
|
54
|
+
selectRaft(ricToConnectTo: FOUND_RAFT_ON_DISCOVERY_RESPONSE['foundRIC'], method: RaftConnectionMethod): Promise<RAFT | null>;
|
|
55
|
+
connectToRIC(method: RaftConnectionMethod, uuids: string[]): Promise<RAFT | null>;
|
|
56
|
+
/**
|
|
57
|
+
* Toggles the Sensors Dashboard modal
|
|
58
|
+
*/
|
|
59
|
+
toggleSensorsDashboard(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Disconnect from RAFT
|
|
62
|
+
*/
|
|
63
|
+
disconnectFromRaft(raftId: string): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Removes raft after a certain time
|
|
66
|
+
* Removes from the rics list after x seconds so that we can still get the last event
|
|
67
|
+
*/
|
|
68
|
+
_removeRaft(raftId: string, timeout: number): void;
|
|
69
|
+
/**
|
|
70
|
+
* Start looking for rics to connect to
|
|
71
|
+
* This is used from the Phone App only
|
|
72
|
+
*/
|
|
73
|
+
startDiscovery(ricSelectedCb: (raft: RAFT) => void, uuids: string[]): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Stοp discovery
|
|
76
|
+
* When the user cancels the discovery process without having first connected to a robot
|
|
77
|
+
*/
|
|
78
|
+
stopDiscovery(): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Stop verifying raft
|
|
81
|
+
*/
|
|
82
|
+
stopVerifyingRaft(raftId: string, isCorrectRIC: boolean): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Publishing events to observers
|
|
85
|
+
* It could be either events we get from RAFT, or custom events related to the app
|
|
86
|
+
*/
|
|
87
|
+
publish(eventType: string, eventEnum: RaftConnEvent | RaftUpdateEvent | RaftPublishEvent | RaftInfoEvents, eventName: string, eventData: any): void;
|
|
88
|
+
subscribe(observer: RaftObserver, topics: Array<string>): void;
|
|
89
|
+
unsubscribe(observer: RaftObserver): void;
|
|
90
|
+
receivedRICEvent(raftId: string, eventType: any, eventEnum: any, eventName: any, eventData: any): void;
|
|
91
|
+
/**
|
|
92
|
+
* Save the file on the device
|
|
93
|
+
*/
|
|
94
|
+
saveFileOnDevice(fileName: string, base64: string): void | Promise<unknown>;
|
|
95
|
+
/**
|
|
96
|
+
* Save the file on the device's local storage
|
|
97
|
+
*/
|
|
98
|
+
saveFileOnDeviceLocalStorage(dirname: string, fileName: string, base64: string): void | Promise<unknown>;
|
|
99
|
+
/**
|
|
100
|
+
* Load the file from the device's local storage
|
|
101
|
+
*/
|
|
102
|
+
loadFileFromDeviceLocalStorage(dirname: string, fileName: string): void | Promise<unknown>;
|
|
103
|
+
/**
|
|
104
|
+
* Delete the file from the device's local storage
|
|
105
|
+
*/
|
|
106
|
+
deleteFileFromDeviceLocalStorage(dirname: string, fileName: string): void | Promise<unknown>;
|
|
107
|
+
/**
|
|
108
|
+
* List the files from the device's local storage
|
|
109
|
+
*/
|
|
110
|
+
listFilesFromDeviceLocalStorage(dirname: string): Promise<unknown>;
|
|
111
|
+
/**
|
|
112
|
+
* Injects JS code to the phone app
|
|
113
|
+
* This is used to call native functions from the web app
|
|
114
|
+
*/
|
|
115
|
+
injectJS(jsCode: string): Promise<unknown>;
|
|
116
|
+
getTheCurrentlySelectedDeviceOrFirstOfItsKind(deviceType: RaftTypeE): RAFT | undefined;
|
|
117
|
+
}
|