@robotical/webapp-types 3.19.1 → 3.19.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 +1 -0
- package/dist-types/src/application/ApplicationManager/ApplicationManager.js +70 -15
- package/dist-types/src/components/modals/WifiPhoneAppUpdateRequiredModal/index.d.ts +6 -0
- package/dist-types/src/components/modals/WifiPhoneAppUpdateRequiredModal/index.js +44 -0
- package/dist-types/src/utils/open-new-tab.d.ts +1 -0
- package/dist-types/src/utils/open-new-tab.js +5 -0
- package/dist-types/src/utils/phone-app-communication/wifi-connection-support.d.ts +2 -0
- package/dist-types/src/utils/phone-app-communication/wifi-connection-support.js +13 -0
- package/package.json +1 -1
|
@@ -58,6 +58,7 @@ export default class ApplicationManager {
|
|
|
58
58
|
isPhoneApp: () => boolean;
|
|
59
59
|
constructor();
|
|
60
60
|
getDeviceInfo(): Promise<void>;
|
|
61
|
+
ensureWifiConnectionSupported(): Promise<boolean>;
|
|
61
62
|
updateRaftNameInAllStates(raftId: string, name: string): Promise<boolean>;
|
|
62
63
|
private getConnectedRaftName;
|
|
63
64
|
/**
|
|
@@ -68,12 +68,14 @@ import draggableModalState from "../../state-observables/modal/DraggableModalSta
|
|
|
68
68
|
import SensorsDashboardModal from "../../components/modals/ SensorsDashboardModal";
|
|
69
69
|
import LEDLightsOrQRVerificationModal from "../../components/modals/LEDLightsOrQRVerificationModal";
|
|
70
70
|
import WifiConnectionModal from "../../components/modals/WifiConnectionModal";
|
|
71
|
+
import WifiPhoneAppUpdateRequiredModal from "../../components/modals/WifiPhoneAppUpdateRequiredModal";
|
|
71
72
|
import { CarouselNavigatorManager } from "../../utils/CarouselNavigatorManager";
|
|
72
73
|
import i18n from "../../i18n";
|
|
73
74
|
import InUnpluggedModalContent from "../../components/modals/InUnplugged";
|
|
74
75
|
import { cogKeepAwakeManager, } from "../../features/cog-keep-awake";
|
|
75
76
|
import { normalizeWifiLocator } from "../../utils/wifi-connection";
|
|
76
|
-
import { ConnectionMethodPreference, getConnectionMethodPreference, } from "../../store/ConnectionMethodPreference";
|
|
77
|
+
import { ConnectionMethodPreference, getConnectionMethodPreference, setConnectionMethodPreference, } from "../../store/ConnectionMethodPreference";
|
|
78
|
+
import { MINIMUM_PHONE_APP_WIFI_VERSION, isPhoneWrapperWifiSupported, } from "../../utils/phone-app-communication/wifi-connection-support";
|
|
77
79
|
var SHOW_LOGS = true;
|
|
78
80
|
var TAG = "ApplicationManager";
|
|
79
81
|
var UNSUPPORTED_WEB_BLUETOOTH_BROWSER_MESSAGE = "This browser can't connect to Marty or Cog over Bluetooth. Please use Chrome or Edge, or use the iPad app.";
|
|
@@ -188,6 +190,49 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
188
190
|
});
|
|
189
191
|
});
|
|
190
192
|
};
|
|
193
|
+
ApplicationManager.prototype.ensureWifiConnectionSupported = function () {
|
|
194
|
+
var _a, _b, _c, _d;
|
|
195
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
196
|
+
var error_1;
|
|
197
|
+
return __generator(this, function (_e) {
|
|
198
|
+
switch (_e.label) {
|
|
199
|
+
case 0:
|
|
200
|
+
if (!isPhoneApp()) {
|
|
201
|
+
return [2 /*return*/, true];
|
|
202
|
+
}
|
|
203
|
+
if (!!this.deviceInfo) return [3 /*break*/, 4];
|
|
204
|
+
_e.label = 1;
|
|
205
|
+
case 1:
|
|
206
|
+
_e.trys.push([1, 3, , 4]);
|
|
207
|
+
return [4 /*yield*/, this.getDeviceInfo()];
|
|
208
|
+
case 2:
|
|
209
|
+
_e.sent();
|
|
210
|
+
return [3 /*break*/, 4];
|
|
211
|
+
case 3:
|
|
212
|
+
error_1 = _e.sent();
|
|
213
|
+
Logger.warn(SHOW_LOGS, TAG, "Failed to determine phone app version for Wi-Fi: ".concat(error_1));
|
|
214
|
+
return [3 /*break*/, 4];
|
|
215
|
+
case 4:
|
|
216
|
+
if (isPhoneWrapperWifiSupported((_a = this.deviceInfo) === null || _a === void 0 ? void 0 : _a.appVersion)) {
|
|
217
|
+
return [2 /*return*/, true];
|
|
218
|
+
}
|
|
219
|
+
// Fail closed on old, missing, or malformed wrapper versions. Resetting
|
|
220
|
+
// the preference also covers a stale Wi-Fi choice left in localStorage.
|
|
221
|
+
setConnectionMethodPreference(ConnectionMethodPreference.BLUETOOTH);
|
|
222
|
+
return [4 /*yield*/, modalState.setModal(createElement(WifiPhoneAppUpdateRequiredModal, {
|
|
223
|
+
systemName: (_b = this.deviceInfo) === null || _b === void 0 ? void 0 : _b.systemName,
|
|
224
|
+
showUpdateAction: isPhoneWrapperWifiSupported((_c = this.deviceInfo) === null || _c === void 0 ? void 0 : _c.latestAppVersion),
|
|
225
|
+
}), i18n.t("connection.wifi_phone_update_title", {
|
|
226
|
+
defaultValue: "Update required for Wi-Fi",
|
|
227
|
+
}), "robotical", true, false)];
|
|
228
|
+
case 5:
|
|
229
|
+
_e.sent();
|
|
230
|
+
Logger.warn(SHOW_LOGS, TAG, "Wi-Fi requires phone app ".concat(MINIMUM_PHONE_APP_WIFI_VERSION, " or later; received ").concat(((_d = this.deviceInfo) === null || _d === void 0 ? void 0 : _d.appVersion) || "unknown"));
|
|
231
|
+
return [2 /*return*/, false];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
};
|
|
191
236
|
ApplicationManager.prototype.updateRaftNameInAllStates = function (raftId, name) {
|
|
192
237
|
return __awaiter(this, void 0, void 0, function () {
|
|
193
238
|
var raft, wasSuccessful;
|
|
@@ -224,7 +269,7 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
224
269
|
};
|
|
225
270
|
ApplicationManager.prototype.getConnectedRaftName = function (raft) {
|
|
226
271
|
return __awaiter(this, void 0, void 0, function () {
|
|
227
|
-
var cachedName,
|
|
272
|
+
var cachedName, error_2;
|
|
228
273
|
return __generator(this, function (_a) {
|
|
229
274
|
switch (_a.label) {
|
|
230
275
|
case 0:
|
|
@@ -238,8 +283,8 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
238
283
|
return [4 /*yield*/, raft.getRaftName()];
|
|
239
284
|
case 2: return [2 /*return*/, (_a.sent()) || ""];
|
|
240
285
|
case 3:
|
|
241
|
-
|
|
242
|
-
Logger.warn(SHOW_LOGS, TAG, "Failed to read RAFT name for ".concat(raft.id, ": ").concat(
|
|
286
|
+
error_2 = _a.sent();
|
|
287
|
+
Logger.warn(SHOW_LOGS, TAG, "Failed to read RAFT name for ".concat(raft.id, ": ").concat(error_2));
|
|
243
288
|
return [2 /*return*/, ""];
|
|
244
289
|
case 4: return [2 /*return*/];
|
|
245
290
|
}
|
|
@@ -282,7 +327,7 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
282
327
|
};
|
|
283
328
|
ApplicationManager.prototype.confirmQrVerifiedConnection = function (raft) {
|
|
284
329
|
return __awaiter(this, void 0, void 0, function () {
|
|
285
|
-
var didPublishVerifiedEvent,
|
|
330
|
+
var didPublishVerifiedEvent, error_3;
|
|
286
331
|
return __generator(this, function (_a) {
|
|
287
332
|
switch (_a.label) {
|
|
288
333
|
case 0: return [4 /*yield*/, Promise.resolve()];
|
|
@@ -303,8 +348,8 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
303
348
|
}
|
|
304
349
|
return [3 /*break*/, 5];
|
|
305
350
|
case 4:
|
|
306
|
-
|
|
307
|
-
Logger.warn(SHOW_LOGS, TAG, "Failed to publish QR verified event for ".concat(raft.id, ": ").concat(
|
|
351
|
+
error_3 = _a.sent();
|
|
352
|
+
Logger.warn(SHOW_LOGS, TAG, "Failed to publish QR verified event for ".concat(raft.id, ": ").concat(error_3));
|
|
308
353
|
this.publishLocalVerifiedConnection(raft);
|
|
309
354
|
return [3 /*break*/, 5];
|
|
310
355
|
case 5: return [2 /*return*/];
|
|
@@ -632,9 +677,9 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
632
677
|
};
|
|
633
678
|
ApplicationManager.prototype._resolveConnectOptions = function (options) {
|
|
634
679
|
return __awaiter(this, void 0, void 0, function () {
|
|
635
|
-
var method, expectedRaftType, bluetoothMethod, locator, modalLocator;
|
|
636
|
-
return __generator(this, function (
|
|
637
|
-
switch (
|
|
680
|
+
var method, expectedRaftType, bluetoothMethod, _a, locator, modalLocator;
|
|
681
|
+
return __generator(this, function (_b) {
|
|
682
|
+
switch (_b.label) {
|
|
638
683
|
case 0:
|
|
639
684
|
method = options.method;
|
|
640
685
|
expectedRaftType = options.expectedRaftType;
|
|
@@ -647,6 +692,16 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
647
692
|
? RaftConnectionMethod.WEB_SOCKET
|
|
648
693
|
: bluetoothMethod;
|
|
649
694
|
}
|
|
695
|
+
_a = method === RaftConnectionMethod.WEB_SOCKET;
|
|
696
|
+
if (!_a) return [3 /*break*/, 2];
|
|
697
|
+
return [4 /*yield*/, this.ensureWifiConnectionSupported()];
|
|
698
|
+
case 1:
|
|
699
|
+
_a = !(_b.sent());
|
|
700
|
+
_b.label = 2;
|
|
701
|
+
case 2:
|
|
702
|
+
if (_a) {
|
|
703
|
+
return [2 /*return*/, null];
|
|
704
|
+
}
|
|
650
705
|
if (expectedRaftType === RaftTypeE.COG &&
|
|
651
706
|
method === RaftConnectionMethod.WEB_SOCKET) {
|
|
652
707
|
this.toaster.error(i18n.t("connection.cog_wifi_unsupported", {
|
|
@@ -671,18 +726,18 @@ var ApplicationManager = /** @class */ (function () {
|
|
|
671
726
|
return [2 /*return*/, null];
|
|
672
727
|
}
|
|
673
728
|
locator = options.locator;
|
|
674
|
-
if (!!locator) return [3 /*break*/,
|
|
729
|
+
if (!!locator) return [3 /*break*/, 4];
|
|
675
730
|
return [4 /*yield*/, modalState.setModal(createElement(WifiConnectionModal, { raftType: expectedRaftType }), i18n.t("connection.wifi_connection_title", {
|
|
676
731
|
defaultValue: "Connect over Wi-Fi",
|
|
677
732
|
}), getModalLogoForRaftType(expectedRaftType), true, false)];
|
|
678
|
-
case
|
|
679
|
-
modalLocator =
|
|
733
|
+
case 3:
|
|
734
|
+
modalLocator = _b.sent();
|
|
680
735
|
if (!modalLocator) {
|
|
681
736
|
return [2 /*return*/, null];
|
|
682
737
|
}
|
|
683
738
|
locator = modalLocator;
|
|
684
|
-
|
|
685
|
-
case
|
|
739
|
+
_b.label = 4;
|
|
740
|
+
case 4:
|
|
686
741
|
if (!locator) {
|
|
687
742
|
return [2 /*return*/, null];
|
|
688
743
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type WifiPhoneAppUpdateRequiredModalProps = {
|
|
2
|
+
systemName?: string;
|
|
3
|
+
showUpdateAction?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export default function WifiPhoneAppUpdateRequiredModal({ systemName, showUpdateAction, }: WifiPhoneAppUpdateRequiredModalProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useTranslation } from "react-i18next";
|
|
14
|
+
import modalState from "../../../state-observables/modal/ModalState";
|
|
15
|
+
import { PALE_BLUE } from "../../../styles/colors";
|
|
16
|
+
import openNewTab from "../../../utils/open-new-tab";
|
|
17
|
+
import SimpleButton from "../../disposables/buttons/SimpleButton";
|
|
18
|
+
import styles from "./styles.module.css";
|
|
19
|
+
var IOS_APP_STORE_URL = "https://apps.apple.com/app/robotical/id6739531583";
|
|
20
|
+
var ANDROID_PLAY_STORE_URL = "https://play.google.com/store/apps/details?id=com.marty";
|
|
21
|
+
var getStoreUrl = function (systemName) {
|
|
22
|
+
var platform = "".concat(systemName || "", " ").concat(navigator.userAgent).toLowerCase();
|
|
23
|
+
return platform.includes("android")
|
|
24
|
+
? ANDROID_PLAY_STORE_URL
|
|
25
|
+
: IOS_APP_STORE_URL;
|
|
26
|
+
};
|
|
27
|
+
export default function WifiPhoneAppUpdateRequiredModal(_a) {
|
|
28
|
+
var systemName = _a.systemName, _b = _a.showUpdateAction, showUpdateAction = _b === void 0 ? false : _b;
|
|
29
|
+
var t = useTranslation().t;
|
|
30
|
+
var keepUsingBluetooth = function () {
|
|
31
|
+
modalState.closeModal(false);
|
|
32
|
+
};
|
|
33
|
+
var updateApp = function () {
|
|
34
|
+
openNewTab(getStoreUrl(systemName));
|
|
35
|
+
modalState.closeModal(false);
|
|
36
|
+
};
|
|
37
|
+
return (_jsxs("div", __assign({ className: styles.container }, { children: [_jsx("p", __assign({ className: styles.message }, { children: t("connection.wifi_phone_update_message", {
|
|
38
|
+
defaultValue: "Wi-Fi connections require Robotical app 2.4.4 or later. You can continue connecting with Bluetooth.",
|
|
39
|
+
}) })), _jsxs("div", __assign({ className: styles.actions }, { children: [_jsx(SimpleButton, { title: t("connection.keep_using_bluetooth", {
|
|
40
|
+
defaultValue: "Keep using Bluetooth",
|
|
41
|
+
}), onClick: keepUsingBluetooth, colour: PALE_BLUE }), showUpdateAction ? (_jsx(SimpleButton, { title: t("connection.update_phone_app", {
|
|
42
|
+
defaultValue: "Update app",
|
|
43
|
+
}), onClick: updateApp })) : null] }))] })));
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function openNewTab(url: string): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import semverGte from "semver/functions/gte";
|
|
2
|
+
export var MINIMUM_PHONE_APP_WIFI_VERSION = "2.4.4";
|
|
3
|
+
export var isPhoneWrapperWifiSupported = function (appVersion) {
|
|
4
|
+
if (typeof appVersion !== "string" || !appVersion.trim()) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
try {
|
|
8
|
+
return semverGte(appVersion.trim(), MINIMUM_PHONE_APP_WIFI_VERSION);
|
|
9
|
+
}
|
|
10
|
+
catch (_a) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
};
|