incyclist-services 1.5.1 → 1.5.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/lib/activities/active-rides/service.d.ts +1 -0
- package/lib/activities/active-rides/service.js +11 -0
- package/lib/activities/base/repo/db.js +1 -1
- package/lib/activities/ride/service.js +3 -3
- package/lib/api/overpass/index.js +2 -1
- package/lib/api/repository/json/index.js +2 -2
- package/lib/api/rest/api.js +5 -5
- package/lib/apps/base/api/strava/api.js +3 -3
- package/lib/apps/base/api/velohero/api.js +3 -3
- package/lib/base/service.js +1 -1
- package/lib/coaches/coach.js +3 -3
- package/lib/coaches/service.d.ts +1 -1
- package/lib/coaches/service.js +17 -13
- package/lib/devices/access/service.js +22 -14
- package/lib/devices/configuration/service.js +8 -7
- package/lib/devices/ride/service.d.ts +34 -3
- package/lib/devices/ride/service.js +201 -168
- package/lib/ride/display/service.d.ts +9 -6
- package/lib/ride/display/service.js +103 -86
- package/lib/ride/route/GpxDisplayService.js +2 -1
- package/lib/routes/base/api/index.js +5 -5
- package/lib/routes/base/model/route.d.ts +3 -1
- package/lib/routes/base/model/route.js +14 -2
- package/lib/routes/base/parsers/bikelab.js +7 -4
- package/lib/routes/base/parsers/gpx.js +4 -3
- package/lib/routes/base/parsers/incyclist.js +2 -1
- package/lib/routes/base/parsers/tacx/TacxReader.js +1 -1
- package/lib/routes/base/utils/localization.d.ts +2 -1
- package/lib/routes/base/utils/localization.js +23 -1
- package/lib/routes/list/cards/RouteCard.js +1 -9
- package/lib/routes/list/cards/base.js +2 -2
- package/lib/routes/list/loaders/LegacyDB.js +1 -1
- package/lib/routes/list/loaders/api.js +2 -1
- package/lib/routes/list/loaders/db.js +2 -4
- package/lib/settings/user/bindings/json.d.ts +1 -1
- package/lib/settings/user/bindings/json.js +11 -5
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/lib/utils/string.d.ts +1 -0
- package/lib/utils/string.js +8 -0
- package/lib/workouts/base/api/index.js +3 -3
- package/lib/workouts/base/parsers/zwo.js +6 -3
- package/lib/workouts/list/cards/base.js +1 -1
- package/package.json +1 -1
|
@@ -79,6 +79,7 @@ let ActiveRidesService = (() => {
|
|
|
79
79
|
this.session = __runInitializers(this, _instanceExtraInitializers);
|
|
80
80
|
this.apiState = { busy: false };
|
|
81
81
|
this.prevLogTS = 0;
|
|
82
|
+
this.isStarted = false;
|
|
82
83
|
this.activityEventHandlers = {
|
|
83
84
|
update: this.onActivityUpdateEvent.bind(this),
|
|
84
85
|
start: this.onActivityStartEvent.bind(this),
|
|
@@ -168,6 +169,7 @@ let ActiveRidesService = (() => {
|
|
|
168
169
|
const others = (_b = yield promise) !== null && _b !== void 0 ? _b : [];
|
|
169
170
|
this.others = this.current ? others.filter(e => { var _a, _b; return e.sessionId !== this.current.sessionId && ((_a = e.user) === null || _a === void 0 ? void 0 : _a.id) !== ((_b = this.current.user) === null || _b === void 0 ? void 0 : _b.id); }) : others;
|
|
170
171
|
if (this.current && ((_c = this.others) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
172
|
+
this.isStarted = true;
|
|
171
173
|
this.logEvent({ message: 'group ride started', active: this.others.length + 1, activityId: (_d = this.activity) === null || _d === void 0 ? void 0 : _d.id, routeHash: this.getRouteHash() });
|
|
172
174
|
}
|
|
173
175
|
}
|
|
@@ -219,6 +221,8 @@ let ActiveRidesService = (() => {
|
|
|
219
221
|
}
|
|
220
222
|
onActivityPaused() {
|
|
221
223
|
var _a;
|
|
224
|
+
if (!this.current)
|
|
225
|
+
return;
|
|
222
226
|
try {
|
|
223
227
|
this.current.currentSpeed = 0;
|
|
224
228
|
this.current.currentPower = 0;
|
|
@@ -496,9 +500,11 @@ let ActiveRidesService = (() => {
|
|
|
496
500
|
const entry = Object.assign(Object.assign({ id: Date.now().toString(), tsLastUpdate: Date.now() }, payload), { sessionId: session });
|
|
497
501
|
this.addActiveRide(entry);
|
|
498
502
|
if (prevActive === 0) {
|
|
503
|
+
this.isStarted = true;
|
|
499
504
|
this.logEvent({ message: 'group ride started', active: this.others.length + 1, activityId: (_c = this.activity) === null || _c === void 0 ? void 0 : _c.id, routeHash: this.getRouteHash() });
|
|
500
505
|
}
|
|
501
506
|
else {
|
|
507
|
+
this.isStarted = true;
|
|
502
508
|
this.logEvent({ message: 'group ride user joined', active: this.others.length + 1, activityId: (_d = this.activity) === null || _d === void 0 ? void 0 : _d.id, routeHash: this.getRouteHash() });
|
|
503
509
|
}
|
|
504
510
|
if (!payload.user) {
|
|
@@ -569,9 +575,11 @@ let ActiveRidesService = (() => {
|
|
|
569
575
|
this.addActiveRide(entry);
|
|
570
576
|
}
|
|
571
577
|
if (prevActive === 0) {
|
|
578
|
+
this.isStarted = true;
|
|
572
579
|
this.logEvent({ message: 'group ride started', active: this.others.length + 1, activityId: (_c = this.activity) === null || _c === void 0 ? void 0 : _c.id, routeHash: this.getRouteHash() });
|
|
573
580
|
}
|
|
574
581
|
else {
|
|
582
|
+
this.isStarted = true;
|
|
575
583
|
this.logEvent({ message: 'group ride user joined', active: this.others.length + 1, activityId: (_d = this.activity) === null || _d === void 0 ? void 0 : _d.id, routeHash: this.getRouteHash() });
|
|
576
584
|
}
|
|
577
585
|
}
|
|
@@ -601,6 +609,8 @@ let ActiveRidesService = (() => {
|
|
|
601
609
|
const idx = this.others.findIndex(ar => ar.sessionId === session);
|
|
602
610
|
if (idx !== -1)
|
|
603
611
|
this.others.splice(idx, 1);
|
|
612
|
+
if (!this.isStarted)
|
|
613
|
+
return;
|
|
604
614
|
if (this.others.length === 0) {
|
|
605
615
|
this.logEvent({ message: 'group ride finished', reason: 'all riders left', activityId: (_b = this.activity) === null || _b === void 0 ? void 0 : _b.id, routeHash: this.getRouteHash() });
|
|
606
616
|
}
|
|
@@ -640,6 +650,7 @@ let ActiveRidesService = (() => {
|
|
|
640
650
|
delete this.others;
|
|
641
651
|
delete this.coaches;
|
|
642
652
|
delete this.session;
|
|
653
|
+
this.isStarted = false;
|
|
643
654
|
this.getMessageQueue().unsubscribeAll();
|
|
644
655
|
this.isSubscribed = false;
|
|
645
656
|
this.observer.stop();
|
|
@@ -993,12 +993,12 @@ let ActivityRideService = (() => {
|
|
|
993
993
|
this.activity.time = this.activity.timeTotal - ((_a = this.activity.timePause) !== null && _a !== void 0 ? _a : 0);
|
|
994
994
|
}
|
|
995
995
|
getRideProps() {
|
|
996
|
-
var _a, _b
|
|
996
|
+
var _a, _b;
|
|
997
997
|
const { startPos, realityFactor, routeType } = this.activity;
|
|
998
|
-
const
|
|
998
|
+
const title = (_a = this.current.route) === null || _a === void 0 ? void 0 : _a.getLocalizedTitle('en');
|
|
999
999
|
let rideProps;
|
|
1000
1000
|
if (routeType === 'Free-Ride') {
|
|
1001
|
-
const { lat, lng } = (
|
|
1001
|
+
const { lat, lng } = (_b = this.current.position) !== null && _b !== void 0 ? _b : {};
|
|
1002
1002
|
rideProps = { route: 'Free Ride', lat, lng };
|
|
1003
1003
|
}
|
|
1004
1004
|
else if (routeType === 'None') {
|
|
@@ -66,7 +66,8 @@ let OverpassApi = (() => {
|
|
|
66
66
|
let _classThis;
|
|
67
67
|
var OverpassApi = _classThis = class {
|
|
68
68
|
constructor(props) {
|
|
69
|
-
|
|
69
|
+
var _a;
|
|
70
|
+
this.url = (_a = props === null || props === void 0 ? void 0 : props.url) !== null && _a !== void 0 ? _a : mirrors[0];
|
|
70
71
|
}
|
|
71
72
|
bulkQuery(queryOL) {
|
|
72
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -46,7 +46,7 @@ class JsonRepository {
|
|
|
46
46
|
if (str === '{}' || str.length < 2)
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
49
|
-
catch (
|
|
49
|
+
catch (_a) {
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
52
52
|
return data;
|
|
@@ -74,7 +74,7 @@ class JsonRepository {
|
|
|
74
74
|
this.access = access;
|
|
75
75
|
return true;
|
|
76
76
|
}
|
|
77
|
-
catch (
|
|
77
|
+
catch (_a) {
|
|
78
78
|
return false;
|
|
79
79
|
}
|
|
80
80
|
});
|
package/lib/api/rest/api.js
CHANGED
|
@@ -26,8 +26,8 @@ class ApiClient {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
client() {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
var _a;
|
|
30
|
+
this.axios = (_a = this.axios) !== null && _a !== void 0 ? _a : axios_1.default;
|
|
31
31
|
return this.axios;
|
|
32
32
|
}
|
|
33
33
|
onRequest(req) {
|
|
@@ -40,14 +40,14 @@ class ApiClient {
|
|
|
40
40
|
this.requests.push({ tid, ts });
|
|
41
41
|
}
|
|
42
42
|
catch (err) {
|
|
43
|
-
this.logger.logEvent({ message: 'error', fn: 'onRequest()', error: err.message
|
|
43
|
+
this.logger.logEvent({ message: 'error', fn: 'onRequest()', error: err.message, stack: err.stack });
|
|
44
44
|
}
|
|
45
45
|
return req;
|
|
46
46
|
}
|
|
47
47
|
onResponse(res) {
|
|
48
48
|
if (!res)
|
|
49
49
|
return;
|
|
50
|
-
const { config, status } = res
|
|
50
|
+
const { config, status } = res !== null && res !== void 0 ? res : {};
|
|
51
51
|
const { headers = {}, url, method, params } = config;
|
|
52
52
|
const tid = headers['x-transaction-id'];
|
|
53
53
|
if (!tid)
|
|
@@ -61,7 +61,7 @@ class ApiClient {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
catch (err) {
|
|
64
|
-
this.logger.logEvent({ message: 'error', fn: 'onResponse', error: err.message
|
|
64
|
+
this.logger.logEvent({ message: 'error', fn: 'onResponse', error: err.message, tid, stack: err.stack });
|
|
65
65
|
}
|
|
66
66
|
return res;
|
|
67
67
|
}
|
|
@@ -105,7 +105,7 @@ class StravaApi extends base_1.AppApiBase {
|
|
|
105
105
|
try {
|
|
106
106
|
yield this.refreshToken();
|
|
107
107
|
}
|
|
108
|
-
catch (
|
|
108
|
+
catch (_a) {
|
|
109
109
|
throw new Error('token refresh failed');
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -149,7 +149,7 @@ class StravaApi extends base_1.AppApiBase {
|
|
|
149
149
|
}
|
|
150
150
|
createUpload(request) {
|
|
151
151
|
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
var _a, _b, _c, _d, _e;
|
|
152
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
153
153
|
const reqOpts = {
|
|
154
154
|
headers: {
|
|
155
155
|
Authorization: 'Bearer ' + this.config.accessToken
|
|
@@ -161,7 +161,7 @@ class StravaApi extends base_1.AppApiBase {
|
|
|
161
161
|
return response.data;
|
|
162
162
|
}
|
|
163
163
|
else {
|
|
164
|
-
throw new Error(((_c = (_b = (_a = response.error) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error)
|
|
164
|
+
throw new Error((_h = (_g = (_d = (_c = (_b = (_a = response.error) === null || _a === void 0 ? void 0 : _a.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) !== null && _d !== void 0 ? _d : (_f = (_e = response.error) === null || _e === void 0 ? void 0 : _e.response) === null || _f === void 0 ? void 0 : _f.message) !== null && _g !== void 0 ? _g : response.error.message) !== null && _h !== void 0 ? _h : `HTTP error ${response.status}`);
|
|
165
165
|
}
|
|
166
166
|
});
|
|
167
167
|
}
|
|
@@ -60,7 +60,7 @@ class VeloHeroApi extends base_1.AppApiBase {
|
|
|
60
60
|
}
|
|
61
61
|
upload(fileName, props) {
|
|
62
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
63
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
64
64
|
if (!this.loginResponse && (!(props === null || props === void 0 ? void 0 : props.username) && !(props === null || props === void 0 ? void 0 : props.password))) {
|
|
65
65
|
throw new Error('not authenticated');
|
|
66
66
|
}
|
|
@@ -78,8 +78,8 @@ class VeloHeroApi extends base_1.AppApiBase {
|
|
|
78
78
|
return response.data;
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
|
-
const errMessage = ((_e = (_d = (_c = response.error) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.error)
|
|
82
|
-
throw new Error(errMessage
|
|
81
|
+
const errMessage = (_j = (_f = (_e = (_d = (_c = response.error) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.error) !== null && _f !== void 0 ? _f : (_h = (_g = response.error) === null || _g === void 0 ? void 0 : _g.response) === null || _h === void 0 ? void 0 : _h.message) !== null && _j !== void 0 ? _j : response.error.message;
|
|
82
|
+
throw new Error(errMessage !== null && errMessage !== void 0 ? errMessage : `HTTP error ${response.status}`);
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
}
|
package/lib/base/service.js
CHANGED
|
@@ -29,7 +29,7 @@ class IncyclistService extends events_1.default {
|
|
|
29
29
|
this.debug = enabled;
|
|
30
30
|
}
|
|
31
31
|
logError(err, fn, args) {
|
|
32
|
-
const logInfo = args
|
|
32
|
+
const logInfo = args !== null && args !== void 0 ? args : {};
|
|
33
33
|
this.logEvent(Object.assign(Object.assign({ message: 'Error', fn }, logInfo), { error: err.message, stack: err.stack }));
|
|
34
34
|
}
|
|
35
35
|
reset() {
|
package/lib/coaches/coach.js
CHANGED
|
@@ -74,14 +74,14 @@ class Coach {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
initSimulator(user, bikeType) {
|
|
77
|
+
var _a;
|
|
77
78
|
const { type, target } = this.settings;
|
|
78
79
|
const mode = type === 'power' ? 'Power' : 'Speed';
|
|
79
80
|
const power = type === 'power' ? target : undefined;
|
|
80
81
|
const speed = type === 'speed' ? target : undefined;
|
|
81
82
|
const deviceSettings = { name: this.settings.name, interface: incyclist_devices_1.INTERFACE.SIMULATOR };
|
|
82
83
|
const props = { port: '', isBot: true, user, settings: { bikeType, mode, power, speed } };
|
|
83
|
-
|
|
84
|
-
this.simulator = incyclist_devices_1.AdapterFactory.create(deviceSettings, props);
|
|
84
|
+
this.simulator = (_a = this.simulator) !== null && _a !== void 0 ? _a : incyclist_devices_1.AdapterFactory.create(deviceSettings, props);
|
|
85
85
|
}
|
|
86
86
|
start(onData) {
|
|
87
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -94,7 +94,7 @@ class Coach {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
catch (err) {
|
|
97
|
-
this.logger.logEvent({ message: 'error', fn: 'startCoach()', coach: this.settings.name, error: err.message
|
|
97
|
+
this.logger.logEvent({ message: 'error', fn: 'startCoach()', coach: this.settings.name, error: err.message });
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
}
|
package/lib/coaches/service.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare class CoachesService extends IncyclistService {
|
|
|
24
24
|
protected onCoachDataUpdate(coach: Coach, data: IncyclistAdapterData): void;
|
|
25
25
|
protected setCoachPosition(coach: Coach, distance: number): void;
|
|
26
26
|
protected get routesService(): RouteListService;
|
|
27
|
-
protected
|
|
27
|
+
protected getDeviceRide(): DeviceRideService;
|
|
28
28
|
protected get deviceConfig(): DeviceConfigurationService;
|
|
29
29
|
protected get pairingService(): DevicePairingService;
|
|
30
30
|
protected get userService(): UserSettingsService;
|
package/lib/coaches/service.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
2
9
|
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
10
|
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
11
|
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
@@ -26,13 +33,6 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
26
33
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
34
|
done = true;
|
|
28
35
|
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
36
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
37
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
38
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -48,7 +48,6 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
|
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
exports.getCoachesService = exports.CoachesService = void 0;
|
|
51
|
-
const incyclist_devices_1 = require("incyclist-devices");
|
|
52
51
|
const service_1 = require("../base/service");
|
|
53
52
|
const types_1 = require("../base/types");
|
|
54
53
|
const observer_1 = require("../base/types/observer");
|
|
@@ -59,16 +58,19 @@ const utils_1 = require("../utils");
|
|
|
59
58
|
const coach_1 = require("./coach");
|
|
60
59
|
const route_1 = require("../routes/base/utils/route");
|
|
61
60
|
const activities_1 = require("../activities");
|
|
61
|
+
const decorators_1 = require("../base/decorators");
|
|
62
62
|
let CoachesService = (() => {
|
|
63
63
|
let _classDecorators = [types_1.Singleton];
|
|
64
64
|
let _classDescriptor;
|
|
65
65
|
let _classExtraInitializers = [];
|
|
66
66
|
let _classThis;
|
|
67
67
|
let _classSuper = service_1.IncyclistService;
|
|
68
|
+
let _instanceExtraInitializers = [];
|
|
69
|
+
let _getDeviceRide_decorators;
|
|
68
70
|
var CoachesService = _classThis = class extends _classSuper {
|
|
69
71
|
constructor() {
|
|
70
72
|
super('Coaches');
|
|
71
|
-
this.coaches = [];
|
|
73
|
+
this.coaches = (__runInitializers(this, _instanceExtraInitializers), []);
|
|
72
74
|
this.isPaused = false;
|
|
73
75
|
}
|
|
74
76
|
getCoaches() {
|
|
@@ -117,7 +119,7 @@ let CoachesService = (() => {
|
|
|
117
119
|
this.isPaused = false;
|
|
118
120
|
const onDataUpdate = this.onCoachDataUpdate.bind(this);
|
|
119
121
|
this.coaches.forEach(c => {
|
|
120
|
-
var _a, _b, _c;
|
|
122
|
+
var _a, _b, _c, _d;
|
|
121
123
|
const startSettings = this.routesService.getStartSettings();
|
|
122
124
|
let pos = 0;
|
|
123
125
|
if (startSettings.type === 'Route') {
|
|
@@ -128,8 +130,8 @@ let CoachesService = (() => {
|
|
|
128
130
|
c.setRiderPosition(pos);
|
|
129
131
|
this.setCoachPosition(c, lead + pos);
|
|
130
132
|
const user = this.userService.get('user', {});
|
|
131
|
-
const
|
|
132
|
-
const bikeType =
|
|
133
|
+
const mode = this.getDeviceRide().getCyclingMode();
|
|
134
|
+
const bikeType = (_d = mode === null || mode === void 0 ? void 0 : mode.getSetting('bikeType')) !== null && _d !== void 0 ? _d : 'Race';
|
|
133
135
|
c.initSimulator(user, bikeType);
|
|
134
136
|
c.start(onDataUpdate);
|
|
135
137
|
});
|
|
@@ -222,7 +224,7 @@ let CoachesService = (() => {
|
|
|
222
224
|
get routesService() {
|
|
223
225
|
return (0, routes_1.useRouteList)();
|
|
224
226
|
}
|
|
225
|
-
|
|
227
|
+
getDeviceRide() {
|
|
226
228
|
return (0, devices_1.useDeviceRide)();
|
|
227
229
|
}
|
|
228
230
|
get deviceConfig() {
|
|
@@ -239,6 +241,8 @@ let CoachesService = (() => {
|
|
|
239
241
|
(() => {
|
|
240
242
|
var _a;
|
|
241
243
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
244
|
+
_getDeviceRide_decorators = [decorators_1.Injectable];
|
|
245
|
+
__esDecorate(_classThis, null, _getDeviceRide_decorators, { kind: "method", name: "getDeviceRide", static: false, private: false, access: { has: obj => "getDeviceRide" in obj, get: obj => obj.getDeviceRide }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
242
246
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
243
247
|
CoachesService = _classThis = _classDescriptor.value;
|
|
244
248
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
@@ -276,6 +276,21 @@ let DeviceAccessService = (() => {
|
|
|
276
276
|
const detected = [];
|
|
277
277
|
const onDataHandlers = {};
|
|
278
278
|
const { includeKnown = false } = props;
|
|
279
|
+
const isKnown = (adapters, deviceSettings) => {
|
|
280
|
+
if (adapters.find(a => a.isEqual(deviceSettings))) {
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
if (filter.profile && deviceSettings.profile !== filter.profile) {
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
if (filter.protocol && deviceSettings.protocol !== filter.protocol) {
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
if (filter.protocols && !filter.protocols.includes(deviceSettings.protocol)) {
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
return false;
|
|
293
|
+
};
|
|
279
294
|
if (!this.isScanning()) {
|
|
280
295
|
this.emitScanStateChange('start-requested');
|
|
281
296
|
this.scanState = {
|
|
@@ -298,22 +313,11 @@ let DeviceAccessService = (() => {
|
|
|
298
313
|
};
|
|
299
314
|
const onDevice = (deviceSettings) => __awaiter(this, void 0, void 0, function* () {
|
|
300
315
|
if (!includeKnown) {
|
|
301
|
-
if (adapters
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
if (filter.profile && deviceSettings.profile !== filter.profile) {
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
if (filter.protocol && deviceSettings.protocol !== filter.protocol) {
|
|
316
|
+
if (isKnown(adapters, deviceSettings))
|
|
308
317
|
return;
|
|
309
|
-
}
|
|
310
|
-
if (filter.protocols && !filter.protocols.includes(deviceSettings.protocol)) {
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
318
|
}
|
|
314
319
|
const adapter = incyclist_devices_1.AdapterFactory.create(deviceSettings);
|
|
315
320
|
if (!adapter) {
|
|
316
|
-
console.log('~~~ no adapter', deviceSettings);
|
|
317
321
|
return;
|
|
318
322
|
}
|
|
319
323
|
if (filter.capabilities) {
|
|
@@ -380,12 +384,16 @@ let DeviceAccessService = (() => {
|
|
|
380
384
|
});
|
|
381
385
|
}
|
|
382
386
|
let onDeviceHandler;
|
|
387
|
+
const checkIsNew = (detectedAdapters, deviceSettings) => {
|
|
388
|
+
const isKnown = knownAdapters.some(ai => ai.adapter.isEqual(deviceSettings));
|
|
389
|
+
const isAlreadyDetected = detectedAdapters.some(ai => ai.adapter.isEqual(deviceSettings));
|
|
390
|
+
return !isKnown && !isAlreadyDetected;
|
|
391
|
+
};
|
|
383
392
|
const waitForMaxDevices = () => {
|
|
384
393
|
const detectedAdapters = [];
|
|
385
394
|
return new Promise(resolve => {
|
|
386
395
|
onDeviceHandler = (deviceSettings) => {
|
|
387
|
-
const isNew =
|
|
388
|
-
detectedAdapters.find(ai => ai.adapter.isEqual(deviceSettings)) === undefined;
|
|
396
|
+
const isNew = checkIsNew(detectedAdapters, deviceSettings);
|
|
389
397
|
if (isNew) {
|
|
390
398
|
const adapter = incyclist_devices_1.AdapterFactory.create(deviceSettings);
|
|
391
399
|
detectedAdapters.push({ udid: `detected #${devices.length + 1}`, adapter, capabilities: adapter.getCapabilities() });
|
|
@@ -155,15 +155,15 @@ let DeviceConfigurationService = (() => {
|
|
|
155
155
|
this.emitCapabiltyChanged();
|
|
156
156
|
}
|
|
157
157
|
select(udid, capability, props) {
|
|
158
|
-
var _a, _b, _c;
|
|
158
|
+
var _a, _b, _c, _d;
|
|
159
159
|
this.logEvent({ message: 'select device', udid, capability, props });
|
|
160
|
-
const { emit = true } = props
|
|
160
|
+
const { emit = true } = props !== null && props !== void 0 ? props : {};
|
|
161
161
|
const deviceSettings = (_b = (_a = this.settings.devices) === null || _a === void 0 ? void 0 : _a.find(d => d.udid === udid)) === null || _b === void 0 ? void 0 : _b.settings;
|
|
162
162
|
if (!deviceSettings)
|
|
163
163
|
return;
|
|
164
|
-
const adapter = this.adapters[udid]
|
|
164
|
+
const adapter = (_c = this.adapters[udid]) !== null && _c !== void 0 ? _c : this.getAdapterFromSetting(deviceSettings);
|
|
165
165
|
if (!adapter) {
|
|
166
|
-
this.logEvent({ message: 'error: could not find adapter', fn: 'select', udid, capability, adapters: (
|
|
166
|
+
this.logEvent({ message: 'error: could not find adapter', fn: 'select', udid, capability, adapters: (_d = Object.keys(this.adapters)) === null || _d === void 0 ? void 0 : _d.join(',') });
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
169
169
|
if (capability === 'bike')
|
|
@@ -307,7 +307,7 @@ let DeviceConfigurationService = (() => {
|
|
|
307
307
|
return canStart;
|
|
308
308
|
}
|
|
309
309
|
getModeSettings(requestedUdid, requestedMode) {
|
|
310
|
-
var _a, _b, _c;
|
|
310
|
+
var _a, _b, _c, _d;
|
|
311
311
|
const { capabilities, devices } = this.settings;
|
|
312
312
|
if (!this.isInitialized())
|
|
313
313
|
return;
|
|
@@ -340,7 +340,7 @@ let DeviceConfigurationService = (() => {
|
|
|
340
340
|
else {
|
|
341
341
|
modeObj = options.find(m => m.getName() === mode);
|
|
342
342
|
}
|
|
343
|
-
settings = (device.modes ? device.modes[mode] : undefined)
|
|
343
|
+
settings = (_d = (device.modes ? device.modes[mode] : undefined)) !== null && _d !== void 0 ? _d : {};
|
|
344
344
|
if (!settings && modeObj) {
|
|
345
345
|
settings = modeObj.getSettings();
|
|
346
346
|
}
|
|
@@ -777,12 +777,13 @@ let DeviceConfigurationService = (() => {
|
|
|
777
777
|
capability: c.capability,
|
|
778
778
|
disabled: c.disabled || false,
|
|
779
779
|
devices: ((_a = c.devices) !== null && _a !== void 0 ? _a : []).filter(udid => devices.find(d => d.udid === udid)).map(udid => {
|
|
780
|
+
var _a, _b;
|
|
780
781
|
const adapter = adapters[udid];
|
|
781
782
|
const device = devices.find(d => d.udid === udid);
|
|
782
783
|
const mode = device.mode;
|
|
783
784
|
const modeSetting = device.modes ? device.modes[mode] : undefined;
|
|
784
785
|
const interfaceName = device.settings.interface;
|
|
785
|
-
const name = (device === null || device === void 0 ? void 0 : device.displayName)
|
|
786
|
+
const name = (_b = (_a = device === null || device === void 0 ? void 0 : device.displayName) !== null && _a !== void 0 ? _a : adapter === null || adapter === void 0 ? void 0 : adapter.getUniqueName()) !== null && _b !== void 0 ? _b : adapter === null || adapter === void 0 ? void 0 : adapter.getName();
|
|
786
787
|
return { udid, name, interface: interfaceName, selected: udid === c.selected, mode, modeSetting };
|
|
787
788
|
})
|
|
788
789
|
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { IncyclistDeviceSettings } from "../configuration";
|
|
2
|
-
import { AdapterRideInfo, AdapterStateInfo, PreparedRoute, RideServiceCheckFilter, RideServiceDeviceProperties } from "./model";
|
|
2
|
+
import { AdapterRideInfo, AdapterStateInfo, LegacyRoute, PreparedRoute, RideServiceCheckFilter, RideServiceDeviceProperties } from "./model";
|
|
3
3
|
import { EventLogger } from 'gd-eventlog';
|
|
4
|
-
import { CyclingMode, DeviceData, DeviceSettings, IncyclistCapability, IncyclistDeviceAdapter, UpdateRequest } from "incyclist-devices";
|
|
4
|
+
import { CyclingMode, DeviceData, DeviceSettings, ICyclingMode, IncyclistCapability, IncyclistDeviceAdapter, UpdateRequest } from "incyclist-devices";
|
|
5
5
|
import { IncyclistService } from "../../base/service";
|
|
6
|
+
import { Route } from "../../routes/base/model/route";
|
|
7
|
+
import { RouteApiDetail } from "../../routes/base/api/types";
|
|
8
|
+
import { DaumEppProgramEntry, RoutePoint } from "../../routes/base/types";
|
|
6
9
|
type DuplicateInfo = {
|
|
7
10
|
udid: string;
|
|
8
11
|
info: AdapterRideInfo;
|
|
@@ -30,6 +33,34 @@ export declare class DeviceRideService extends IncyclistService {
|
|
|
30
33
|
protected getAllAdapters(): AdapterRideInfo[];
|
|
31
34
|
protected getConfiguredAdapters(onlySelected?: boolean): AdapterRideInfo[];
|
|
32
35
|
prepareEppRoute(props: RideServiceDeviceProperties): PreparedRoute;
|
|
36
|
+
protected getRouteInfo(route: Route | LegacyRoute): {
|
|
37
|
+
routeData: RouteApiDetail;
|
|
38
|
+
title: string;
|
|
39
|
+
isLap: boolean;
|
|
40
|
+
};
|
|
41
|
+
protected incrementEppProgramId(): any;
|
|
42
|
+
protected parseEppData(routeData: RouteApiDetail, startPos: number, isLap: boolean, eppPreferences: any, rideMode: string, realityFactor: number): {
|
|
43
|
+
name: string;
|
|
44
|
+
description: string;
|
|
45
|
+
programId: any;
|
|
46
|
+
type: string;
|
|
47
|
+
totalDistance: number;
|
|
48
|
+
lapMode: boolean;
|
|
49
|
+
minElevation: number;
|
|
50
|
+
maxElevation: number;
|
|
51
|
+
sampleRate: number;
|
|
52
|
+
points: {
|
|
53
|
+
elevation: number;
|
|
54
|
+
distance: number;
|
|
55
|
+
}[];
|
|
56
|
+
};
|
|
57
|
+
protected updateEppFromStartPoint(originalPoints: DaumEppProgramEntry[], startPos: number, offset: number, isLap: boolean, routeData: RouteApiDetail): DaumEppProgramEntry[];
|
|
58
|
+
protected createEppDataFromPoints(routeData: RouteApiDetail, startPos: number, isLap: boolean, eppPreferences: any, rideMode: string, realityFactor: number): PreparedRoute;
|
|
59
|
+
protected addEppPoints(routeData: RouteApiDetail, points: RoutePoint[], eppRoute: PreparedRoute, startPos: number, realityFactor: number): void;
|
|
60
|
+
protected updatePointsFromStartPos(routeData: RouteApiDetail, startPos: number, isLap: boolean): {
|
|
61
|
+
points: any;
|
|
62
|
+
totalDistance: number;
|
|
63
|
+
};
|
|
33
64
|
waitForPreviousStartToFinish(): Promise<boolean>;
|
|
34
65
|
startCheck(filter: RideServiceCheckFilter): Promise<void>;
|
|
35
66
|
getAdapters(filter: RideServiceCheckFilter): AdapterRideInfo[];
|
|
@@ -73,7 +104,7 @@ export declare class DeviceRideService extends IncyclistService {
|
|
|
73
104
|
isUpdateBusy(): boolean;
|
|
74
105
|
waitForUpdateFinish(): Promise<void>;
|
|
75
106
|
sendUpdate(request: UpdateRequest): Promise<void>;
|
|
76
|
-
getCyclingMode(udid?: string):
|
|
107
|
+
getCyclingMode(udid?: string): ICyclingMode;
|
|
77
108
|
isToggleEnabled(): boolean;
|
|
78
109
|
toggleCyclingMode(): Promise<void>;
|
|
79
110
|
resetCyclingMode(sendInit?: boolean): Promise<{
|