incyclist-services 1.9.32 → 1.9.34
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/README.MD +72 -0
- package/lib/cjs/activities/upload/factory.js +9 -2
- package/lib/cjs/activities/upload/intervals.js +0 -2
- package/lib/cjs/activities/upload/komoot.js +0 -2
- package/lib/cjs/activities/upload/ridewithgps.js +0 -2
- package/lib/cjs/activities/upload/strava.js +0 -3
- package/lib/cjs/activities/upload/trainerday.js +0 -2
- package/lib/cjs/activities/upload/trainingpeaks.js +0 -2
- package/lib/cjs/api/rest/api.js +109 -4
- package/lib/cjs/api/rest/types.js +2 -0
- package/lib/cjs/apps/service.js +3 -0
- package/lib/cjs/devices/ride/service.js +103 -1
- package/lib/cjs/devices/ride/timeouts.js +2 -1
- package/lib/cjs/ride/base/base.js +3 -0
- package/lib/cjs/ride/display/service.js +333 -10
- package/lib/cjs/ride/page/service.js +16 -0
- package/lib/cjs/ride/route/FreeRideDisplayService.js +6 -0
- package/lib/cjs/ride/route/GpxDisplayService.js +22 -0
- package/lib/cjs/ride/route/MapillaryRide.js +551 -0
- package/lib/cjs/ride/route/RLVDisplayService.js +15 -0
- package/lib/cjs/routes/base/api/api.js +18 -3
- package/lib/cjs/routes/base/api/factory.js +12 -2
- package/lib/cjs/routes/base/api/unconfigured.js +24 -0
- package/lib/cjs/routes/base/parsers/utils.js +12 -1
- package/lib/cjs/routes/imagery/index.js +17 -0
- package/lib/cjs/routes/imagery/mapillary/api.js +113 -0
- package/lib/cjs/routes/imagery/mapillary/codec.js +123 -0
- package/lib/cjs/routes/imagery/mapillary/frame.js +165 -0
- package/lib/cjs/routes/imagery/mapillary/index.js +24 -0
- package/lib/cjs/routes/imagery/mapillary/resolve.js +16 -0
- package/lib/cjs/routes/imagery/mapillary/service.js +709 -0
- package/lib/cjs/routes/imagery/mapillary/source.js +48 -0
- package/lib/cjs/routes/imagery/mapillary/store.js +196 -0
- package/lib/cjs/routes/imagery/mapillary/types.js +2 -0
- package/lib/cjs/routes/index.js +1 -0
- package/lib/cjs/routes/list/cards/RouteCard.js +9 -10
- package/lib/cjs/routes/list/loaders/api.js +202 -39
- package/lib/cjs/routes/list/service.js +217 -26
- package/lib/cjs/routes/servers/errors.js +14 -0
- package/lib/cjs/routes/servers/index.js +15 -0
- package/lib/cjs/routes/servers/known-servers.json +1 -0
- package/lib/cjs/routes/servers/known.js +11 -0
- package/lib/cjs/routes/servers/messages.js +35 -0
- package/lib/cjs/routes/servers/page/base/service.js +708 -0
- package/lib/cjs/routes/servers/page/base/types.js +2 -0
- package/lib/cjs/routes/servers/page/base/utils.js +34 -0
- package/lib/cjs/routes/servers/page/desktop/service.js +10 -0
- package/lib/cjs/routes/servers/page/index.js +28 -0
- package/lib/cjs/routes/servers/page/mobile/service.js +69 -0
- package/lib/cjs/routes/servers/page/types.js +2 -0
- package/lib/cjs/routes/servers/probe.js +72 -0
- package/lib/cjs/routes/servers/status.js +97 -0
- package/lib/cjs/routes/servers/types.js +2 -0
- package/lib/cjs/routes/servers/validator.js +209 -0
- package/lib/cjs/routes/sync/base/provider.js +15 -5
- package/lib/cjs/routes/sync/komoot/provider.js +5 -4
- package/lib/cjs/routes/sync/ridewithgps/provider.js +9 -8
- package/lib/cjs/routes/sync/strava/provider.js +3 -3
- package/lib/cjs/settings/display/index.js +1 -0
- package/lib/cjs/settings/display/routeservers/index.js +21 -0
- package/lib/cjs/settings/display/routeservers/service.js +709 -0
- package/lib/cjs/settings/display/routeservers/types.js +2 -0
- package/lib/cjs/settings/display/routeservers/utils.js +34 -0
- package/lib/cjs/utils/string.js +8 -1
- package/lib/cjs/workouts/calendar/sync/base/provider.js +6 -1
- package/lib/cjs/workouts/calendar/sync/intervals/provider.js +5 -2
- package/lib/esm/activities/upload/factory.js +9 -2
- package/lib/esm/activities/upload/intervals.js +0 -2
- package/lib/esm/activities/upload/komoot.js +0 -2
- package/lib/esm/activities/upload/ridewithgps.js +0 -2
- package/lib/esm/activities/upload/strava.js +0 -3
- package/lib/esm/activities/upload/trainerday.js +0 -2
- package/lib/esm/activities/upload/trainingpeaks.js +0 -2
- package/lib/esm/api/rest/api.js +76 -1
- package/lib/esm/api/rest/types.js +1 -1
- package/lib/esm/apps/service.js +3 -0
- package/lib/esm/devices/ride/service.js +104 -2
- package/lib/esm/devices/ride/timeouts.js +1 -0
- package/lib/esm/ride/base/base.js +3 -0
- package/lib/esm/ride/display/service.js +333 -10
- package/lib/esm/ride/page/service.js +16 -0
- package/lib/esm/ride/route/FreeRideDisplayService.js +6 -0
- package/lib/esm/ride/route/GpxDisplayService.js +22 -0
- package/lib/esm/ride/route/MapillaryRide.js +682 -0
- package/lib/esm/ride/route/RLVDisplayService.js +15 -0
- package/lib/esm/routes/base/api/api.js +18 -3
- package/lib/esm/routes/base/api/factory.js +11 -1
- package/lib/esm/routes/base/api/unconfigured.js +20 -0
- package/lib/esm/routes/base/parsers/utils.js +10 -0
- package/lib/esm/routes/imagery/index.js +1 -0
- package/lib/esm/routes/imagery/mapillary/api.js +109 -0
- package/lib/esm/routes/imagery/mapillary/codec.js +114 -0
- package/lib/esm/routes/imagery/mapillary/frame.js +156 -0
- package/lib/esm/routes/imagery/mapillary/index.js +8 -0
- package/lib/esm/routes/imagery/mapillary/resolve.js +12 -0
- package/lib/esm/routes/imagery/mapillary/service.js +757 -0
- package/lib/esm/routes/imagery/mapillary/source.js +44 -0
- package/lib/esm/routes/imagery/mapillary/store.js +193 -0
- package/lib/esm/routes/imagery/mapillary/types.js +1 -0
- package/lib/esm/routes/imagery/mapillary/windows.js +152 -0
- package/lib/esm/routes/index.js +1 -0
- package/lib/esm/routes/list/cards/RouteCard.js +3 -4
- package/lib/esm/routes/list/loaders/api.js +202 -39
- package/lib/esm/routes/list/service.js +211 -20
- package/lib/esm/routes/servers/errors.js +10 -0
- package/lib/esm/routes/servers/index.js +4 -0
- package/lib/esm/routes/servers/known-servers.json +1 -0
- package/lib/esm/routes/servers/known.js +4 -0
- package/lib/esm/routes/servers/messages.js +32 -0
- package/lib/esm/routes/servers/page/base/service.js +705 -0
- package/lib/esm/routes/servers/page/base/types.js +1 -0
- package/lib/esm/routes/servers/page/base/utils.js +29 -0
- package/lib/esm/routes/servers/page/desktop/service.js +6 -0
- package/lib/esm/routes/servers/page/index.js +19 -0
- package/lib/esm/routes/servers/page/mobile/service.js +66 -0
- package/lib/esm/routes/servers/page/types.js +1 -0
- package/lib/esm/routes/servers/probe.js +63 -0
- package/lib/esm/routes/servers/status.js +93 -0
- package/lib/esm/routes/servers/types.js +1 -0
- package/lib/esm/routes/servers/validator.js +199 -0
- package/lib/esm/routes/sync/base/provider.js +15 -5
- package/lib/esm/routes/sync/komoot/provider.js +5 -4
- package/lib/esm/routes/sync/ridewithgps/provider.js +9 -8
- package/lib/esm/routes/sync/strava/provider.js +3 -3
- package/lib/esm/settings/display/index.js +1 -0
- package/lib/esm/settings/display/routeservers/index.js +2 -0
- package/lib/esm/settings/display/routeservers/service.js +705 -0
- package/lib/esm/settings/display/routeservers/types.js +1 -0
- package/lib/esm/settings/display/routeservers/utils.js +29 -0
- package/lib/esm/utils/string.js +6 -0
- package/lib/esm/workouts/calendar/sync/base/provider.js +6 -1
- package/lib/esm/workouts/calendar/sync/intervals/provider.js +5 -2
- package/lib/types/api/fs/index.d.ts +3 -0
- package/lib/types/api/rest/api.d.ts +6 -1
- package/lib/types/api/rest/types.d.ts +7 -0
- package/lib/types/apps/service.d.ts +4 -0
- package/lib/types/devices/ride/service.d.ts +9 -1
- package/lib/types/devices/ride/timeouts.d.ts +1 -0
- package/lib/types/devices/ride/types.d.ts +1 -0
- package/lib/types/ride/base/base.d.ts +2 -1
- package/lib/types/ride/base/types.d.ts +27 -0
- package/lib/types/ride/display/service.d.ts +53 -1
- package/lib/types/ride/page/service.d.ts +2 -0
- package/lib/types/ride/page/types.d.ts +2 -0
- package/lib/types/ride/route/FreeRideDisplayService.d.ts +2 -1
- package/lib/types/ride/route/GpxDisplayService.d.ts +3 -1
- package/lib/types/ride/route/MapillaryRide.d.ts +217 -0
- package/lib/types/ride/route/RLVDisplayService.d.ts +4 -1
- package/lib/types/routes/base/api/api.d.ts +9 -0
- package/lib/types/routes/base/api/factory.d.ts +2 -0
- package/lib/types/routes/base/api/unconfigured.d.ts +10 -0
- package/lib/types/routes/base/parsers/utils.d.ts +1 -0
- package/lib/types/routes/imagery/index.d.ts +1 -0
- package/lib/types/routes/imagery/mapillary/api.d.ts +17 -0
- package/lib/types/routes/imagery/mapillary/codec.d.ts +17 -0
- package/lib/types/routes/imagery/mapillary/frame.d.ts +16 -0
- package/lib/types/routes/imagery/mapillary/index.d.ts +8 -0
- package/lib/types/routes/imagery/mapillary/resolve.d.ts +12 -0
- package/lib/types/routes/imagery/mapillary/service.d.ts +130 -0
- package/lib/types/routes/imagery/mapillary/source.d.ts +26 -0
- package/lib/types/routes/imagery/mapillary/store.d.ts +36 -0
- package/lib/types/routes/imagery/mapillary/types.d.ts +175 -0
- package/lib/types/routes/imagery/mapillary/windows.d.ts +43 -0
- package/lib/types/routes/index.d.ts +1 -0
- package/lib/types/routes/list/loaders/api.d.ts +35 -3
- package/lib/types/routes/list/service.d.ts +43 -2
- package/lib/types/routes/list/types.d.ts +1 -0
- package/lib/types/routes/servers/errors.d.ts +6 -0
- package/lib/types/routes/servers/index.d.ts +5 -0
- package/lib/types/routes/servers/known.d.ts +2 -0
- package/lib/types/routes/servers/messages.d.ts +31 -0
- package/lib/types/routes/servers/page/base/service.d.ts +103 -0
- package/lib/types/routes/servers/page/base/types.d.ts +77 -0
- package/lib/types/routes/servers/page/base/utils.d.ts +2 -0
- package/lib/types/routes/servers/page/desktop/service.d.ts +4 -0
- package/lib/types/routes/servers/page/index.d.ts +9 -0
- package/lib/types/routes/servers/page/mobile/service.d.ts +6 -0
- package/lib/types/routes/servers/page/types.d.ts +1 -0
- package/lib/types/routes/servers/probe.d.ts +7 -0
- package/lib/types/routes/servers/status.d.ts +15 -0
- package/lib/types/routes/servers/types.d.ts +56 -0
- package/lib/types/routes/servers/validator.d.ts +8 -0
- package/lib/types/routes/sync/base/provider.d.ts +1 -0
- package/lib/types/settings/display/index.d.ts +1 -0
- package/lib/types/settings/display/routeservers/index.d.ts +3 -0
- package/lib/types/settings/display/routeservers/service.d.ts +102 -0
- package/lib/types/settings/display/routeservers/types.d.ts +76 -0
- package/lib/types/settings/display/routeservers/utils.d.ts +2 -0
- package/lib/types/utils/string.d.ts +1 -0
- package/lib/types/workouts/calendar/sync/base/provider.d.ts +4 -3
- package/lib/types/workouts/calendar/sync/trainerday/provider.d.ts +1 -1
- package/lib/types/workouts/calendar/sync/trainingpeaks/provider.d.ts +1 -1
- package/package.json +1 -1
|
@@ -55,6 +55,9 @@ const api_1 = require("../../api");
|
|
|
55
55
|
const RLVDisplayService_1 = require("../route/RLVDisplayService");
|
|
56
56
|
const coaches_1 = require("../../coaches");
|
|
57
57
|
const service_3 = require("../view-restriction/service");
|
|
58
|
+
const START_PHASE_DELAY = 400;
|
|
59
|
+
const START_SLOW_THRESHOLD = 10000;
|
|
60
|
+
const CANCEL_DEVICE_STOP_TIMEOUT = 5000;
|
|
58
61
|
let RideDisplayService = (() => {
|
|
59
62
|
let _classDecorators = [types_1.Singleton];
|
|
60
63
|
let _classDescriptor;
|
|
@@ -121,6 +124,19 @@ let RideDisplayService = (() => {
|
|
|
121
124
|
stateUpdateHandler = this.onStateUpdate.bind(this);
|
|
122
125
|
discarding = false;
|
|
123
126
|
controlDevicesReadyNotified = false;
|
|
127
|
+
tsStart;
|
|
128
|
+
reportedPhase;
|
|
129
|
+
pendingPhase;
|
|
130
|
+
startTimers = new Map();
|
|
131
|
+
slowFlags = { devices: false, content: false, stall: false };
|
|
132
|
+
slowLoggedPhases = new Set();
|
|
133
|
+
slowShown = false;
|
|
134
|
+
convertProgressKey;
|
|
135
|
+
deviceAttempts = new Map();
|
|
136
|
+
ignoredDevices = new Map();
|
|
137
|
+
deviceRetries = 0;
|
|
138
|
+
startTrigger = 'auto';
|
|
139
|
+
fullRetryPending = false;
|
|
124
140
|
constructor() {
|
|
125
141
|
super('RideDisplay');
|
|
126
142
|
this.debug = this.isDebug();
|
|
@@ -149,6 +165,7 @@ let RideDisplayService = (() => {
|
|
|
149
165
|
this.enforceSimulator();
|
|
150
166
|
}
|
|
151
167
|
this.notifyPairingVisitRideStarted(simulate);
|
|
168
|
+
this.resetStartTracking();
|
|
152
169
|
const rideProps = this.getRideModeService().getLogProps();
|
|
153
170
|
this.logEvent({ message: 'Start ride', ...rideProps,
|
|
154
171
|
bike: this.getBike(),
|
|
@@ -163,6 +180,7 @@ let RideDisplayService = (() => {
|
|
|
163
180
|
this.getCoaches().startRide(this.route).catch(err => { this.logError(err, 'start'); });
|
|
164
181
|
this.setState('Starting');
|
|
165
182
|
this.logEvent({ message: 'overlay shown', overlay: 'start overlay' });
|
|
183
|
+
this.updateStartTracking();
|
|
166
184
|
}
|
|
167
185
|
catch (err) {
|
|
168
186
|
this.logError(err, 'start');
|
|
@@ -184,6 +202,7 @@ let RideDisplayService = (() => {
|
|
|
184
202
|
const props = this.getStartOverlayProps();
|
|
185
203
|
this.logEvent({ message: 'button clicked', overlay: 'start overlay', button: 'Ignore', state: props, eventSource: 'user', });
|
|
186
204
|
this.logEvent({ message: 'overlay closed', overlay: 'start overlay' });
|
|
205
|
+
this.startTrigger = 'start-button';
|
|
187
206
|
this.onStartCompleted();
|
|
188
207
|
}
|
|
189
208
|
catch (err) {
|
|
@@ -209,6 +228,7 @@ let RideDisplayService = (() => {
|
|
|
209
228
|
bike: this.getBike(),
|
|
210
229
|
interface: this.getBikeInterface()
|
|
211
230
|
});
|
|
231
|
+
this.restartDeviceTracking();
|
|
212
232
|
this.startDevices(true);
|
|
213
233
|
this.startRide(true);
|
|
214
234
|
}
|
|
@@ -216,11 +236,51 @@ let RideDisplayService = (() => {
|
|
|
216
236
|
this.logError(err, 'retryStart');
|
|
217
237
|
}
|
|
218
238
|
}
|
|
239
|
+
retryStartDevice(udid) {
|
|
240
|
+
try {
|
|
241
|
+
const device = this.getStartingDevice(udid);
|
|
242
|
+
if (!device || device.status === 'Started')
|
|
243
|
+
return;
|
|
244
|
+
this.logDeviceButton('Retry device', device);
|
|
245
|
+
this.ignoredDevices.delete(udid);
|
|
246
|
+
this.deviceRetries++;
|
|
247
|
+
device.status = 'Starting';
|
|
248
|
+
delete device.stateText;
|
|
249
|
+
this.beginDeviceAttempt(udid);
|
|
250
|
+
this.checkStartStatus();
|
|
251
|
+
this.getDeviceRide().retryStartDevice(udid, this.getDeviceStartProps())
|
|
252
|
+
.catch(err => { this.logError(err, 'retryStartDevice'); });
|
|
253
|
+
}
|
|
254
|
+
catch (err) {
|
|
255
|
+
this.logError(err, 'retryStartDevice');
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
ignoreStartDevice(udid) {
|
|
259
|
+
try {
|
|
260
|
+
const device = this.getStartingDevice(udid);
|
|
261
|
+
if (!device || device.isControl || device.status === 'Started')
|
|
262
|
+
return;
|
|
263
|
+
this.logDeviceButton('Ignore device', device);
|
|
264
|
+
this.ignoredDevices.set(udid, Date.now());
|
|
265
|
+
this.clearStartTimer(this.getDeviceTimerKey(udid));
|
|
266
|
+
this.deviceAttempts.delete(udid);
|
|
267
|
+
this.checkStartStatus();
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
this.logError(err, 'ignoreStartDevice');
|
|
271
|
+
}
|
|
272
|
+
}
|
|
219
273
|
async cancelStart() {
|
|
220
274
|
try {
|
|
221
275
|
const props = this.getStartOverlayProps();
|
|
222
276
|
const rideProps = this.getRideModeService().getLogProps();
|
|
223
|
-
this.logEvent({ message: 'start ride cancel', reason: 'user cancel', ...rideProps, state: props
|
|
277
|
+
this.logEvent({ message: 'start ride cancel', reason: 'user cancel', ...rideProps, state: props,
|
|
278
|
+
startPhase: props.startPhase ?? this.derivePhase(),
|
|
279
|
+
startElapsedMs: this.getStartElapsed(),
|
|
280
|
+
slowShown: this.slowShown,
|
|
281
|
+
deviceRetries: this.deviceRetries
|
|
282
|
+
});
|
|
283
|
+
await this.cancelDeviceRetries();
|
|
224
284
|
await this.stopRide({ noStateUpdates: true });
|
|
225
285
|
}
|
|
226
286
|
catch (err) {
|
|
@@ -534,6 +594,7 @@ let RideDisplayService = (() => {
|
|
|
534
594
|
}
|
|
535
595
|
async stopRide(props = {}) {
|
|
536
596
|
try {
|
|
597
|
+
this.clearStartTimers();
|
|
537
598
|
const prevState = this.state;
|
|
538
599
|
const isRedundantCall = prevState === 'Finished' || prevState === 'Idle' || prevState === 'Closing';
|
|
539
600
|
if (!isRedundantCall && this.activity) {
|
|
@@ -659,6 +720,7 @@ let RideDisplayService = (() => {
|
|
|
659
720
|
this.getRideModeService().onStartDevicesReady();
|
|
660
721
|
}
|
|
661
722
|
const ride = this.getRideModeService().isStartRideCompleted();
|
|
723
|
+
this.updateStartTracking();
|
|
662
724
|
const props = this.getStartOverlayProps();
|
|
663
725
|
this.logEvent({ message: 'start overlay update', ...props });
|
|
664
726
|
if (devices && sensors && ride) {
|
|
@@ -925,7 +987,15 @@ let RideDisplayService = (() => {
|
|
|
925
987
|
return;
|
|
926
988
|
const logProps = this.getRideModeService().getLogProps();
|
|
927
989
|
this.logEvent({ message: 'overlay closed', overlay: 'start overlay' });
|
|
928
|
-
this.logEvent({ message: 'Start success', ...logProps
|
|
990
|
+
this.logEvent({ message: 'Start success', ...logProps,
|
|
991
|
+
startElapsedMs: this.getStartElapsed(),
|
|
992
|
+
startTrigger: this.startTrigger,
|
|
993
|
+
ignoredSensors: this.ignoredDevices.size,
|
|
994
|
+
missingSensors: this.getMissingSensors().length,
|
|
995
|
+
slowShown: this.slowShown,
|
|
996
|
+
deviceRetries: this.deviceRetries
|
|
997
|
+
});
|
|
998
|
+
this.clearStartTimers();
|
|
929
999
|
this.state = 'Started';
|
|
930
1000
|
this.displayService.off('state-update', this.stateUpdateHandler);
|
|
931
1001
|
this.disableScreensaver();
|
|
@@ -947,14 +1017,17 @@ let RideDisplayService = (() => {
|
|
|
947
1017
|
this.checkStartStatus();
|
|
948
1018
|
this.updateStartOverlay();
|
|
949
1019
|
}
|
|
950
|
-
|
|
951
|
-
const devices = this.getDeviceRide();
|
|
1020
|
+
getDeviceStartProps() {
|
|
952
1021
|
const startSettings = this.getDeviceStartSettings() ?? {};
|
|
953
|
-
|
|
1022
|
+
return {
|
|
954
1023
|
user: this.user,
|
|
955
1024
|
route: this.route,
|
|
956
1025
|
...startSettings,
|
|
957
1026
|
};
|
|
1027
|
+
}
|
|
1028
|
+
startDevices(retry) {
|
|
1029
|
+
const devices = this.getDeviceRide();
|
|
1030
|
+
const props = this.getDeviceStartProps();
|
|
958
1031
|
const logError = (err) => {
|
|
959
1032
|
this.logError(err, 'startDevices');
|
|
960
1033
|
};
|
|
@@ -1055,27 +1128,42 @@ let RideDisplayService = (() => {
|
|
|
1055
1128
|
this.getRideModeService().sendUpdate(request);
|
|
1056
1129
|
}
|
|
1057
1130
|
onDeviceStartRequest(devices) {
|
|
1131
|
+
const keepStarted = this.fullRetryPending;
|
|
1132
|
+
this.fullRetryPending = false;
|
|
1058
1133
|
this.deviceInfo = devices.map(d => ({
|
|
1059
1134
|
name: d.name,
|
|
1060
1135
|
udid: d.udid,
|
|
1061
1136
|
isControl: d.isControl,
|
|
1062
1137
|
capabilities: d.capabilities,
|
|
1063
|
-
status: 'Starting'
|
|
1138
|
+
status: keepStarted && d.isStarted ? 'Started' : 'Starting'
|
|
1064
1139
|
}));
|
|
1140
|
+
this.deviceInfo.forEach(d => {
|
|
1141
|
+
if (d.status === 'Starting')
|
|
1142
|
+
this.beginDeviceAttempt(d.udid);
|
|
1143
|
+
});
|
|
1065
1144
|
this.updateStartOverlay();
|
|
1066
1145
|
}
|
|
1067
1146
|
updateStartOverlay() {
|
|
1068
1147
|
this.observer?.emit('state-update', this.state);
|
|
1069
1148
|
}
|
|
1070
1149
|
async onDeviceStartOK(device) {
|
|
1150
|
+
this.onIgnoredDeviceStarted(device.udid);
|
|
1071
1151
|
if (this.state !== 'Starting')
|
|
1072
1152
|
return;
|
|
1073
|
-
const startDevice = this.deviceInfo
|
|
1153
|
+
const startDevice = this.deviceInfo?.find(d => d.udid === device.udid);
|
|
1074
1154
|
if (!startDevice)
|
|
1075
1155
|
return;
|
|
1156
|
+
this.endDeviceAttempt(startDevice.udid);
|
|
1076
1157
|
startDevice.status = 'Started';
|
|
1077
1158
|
this.checkStartStatus();
|
|
1078
1159
|
}
|
|
1160
|
+
onIgnoredDeviceStarted(udid) {
|
|
1161
|
+
const ts = this.ignoredDevices.get(udid);
|
|
1162
|
+
if (ts === undefined)
|
|
1163
|
+
return;
|
|
1164
|
+
const device = this.deviceInfo?.find(d => d.udid === udid);
|
|
1165
|
+
this.logEvent({ message: 'ignored sensor connected', device: device?.name, ignoredForMs: Date.now() - ts, afterStart: this.state !== 'Starting' });
|
|
1166
|
+
}
|
|
1079
1167
|
enforceSimulator() {
|
|
1080
1168
|
this.simulated = true;
|
|
1081
1169
|
this.getDeviceRide().enforceSimulator();
|
|
@@ -1128,6 +1216,7 @@ let RideDisplayService = (() => {
|
|
|
1128
1216
|
const key = startDevice.isControl ? 'Device' : 'Sensor';
|
|
1129
1217
|
this.logEvent({ message: `${key} start error shown`, overlay: 'start overlay', device: startDevice.name, });
|
|
1130
1218
|
}
|
|
1219
|
+
this.endDeviceAttempt(startDevice.udid);
|
|
1131
1220
|
startDevice.status = 'Error';
|
|
1132
1221
|
this.checkStartStatus();
|
|
1133
1222
|
}
|
|
@@ -1196,7 +1285,7 @@ let RideDisplayService = (() => {
|
|
|
1196
1285
|
}
|
|
1197
1286
|
isSensorsReadyToStart() {
|
|
1198
1287
|
const devices = this.deviceInfo ?? [];
|
|
1199
|
-
const mandatory = devices?.filter(d => !d.isControl) ?? [];
|
|
1288
|
+
const mandatory = devices?.filter(d => !d.isControl && !this.ignoredDevices.has(d.udid)) ?? [];
|
|
1200
1289
|
if (!mandatory.length)
|
|
1201
1290
|
return true;
|
|
1202
1291
|
return mandatory.filter(d => d.status === 'Started').length == mandatory.length;
|
|
@@ -1204,10 +1293,244 @@ let RideDisplayService = (() => {
|
|
|
1204
1293
|
getStartOverlayProps = () => {
|
|
1205
1294
|
const mode = this.getRideType();
|
|
1206
1295
|
const readyToStart = this.isStartDeviceReadyToStart() && this.getRideModeService().isStartRideCompleted();
|
|
1207
|
-
const devicesState = this.deviceInfo ?? [];
|
|
1208
1296
|
const displayOverlayProps = this.getRideModeService().getStartOverlayProps() ?? {};
|
|
1209
|
-
return
|
|
1297
|
+
return this.buildStartOverlayProps(mode, readyToStart, displayOverlayProps);
|
|
1210
1298
|
};
|
|
1299
|
+
buildStartOverlayProps(mode, readyToStart, displayOverlayProps) {
|
|
1300
|
+
const startPhase = this.reportedPhase ?? this.derivePhase();
|
|
1301
|
+
const devices = (this.deviceInfo ?? []).map(d => ({ ...d, ...this.getDeviceStartFields(d) }));
|
|
1302
|
+
const startContent = this.getRideModeService().getStartContentInfo?.();
|
|
1303
|
+
const { slow: startSlow } = this.getStartSlow(startPhase, startContent, displayOverlayProps);
|
|
1304
|
+
const props = {
|
|
1305
|
+
mode, rideState: this.state, devicesState: devices, devices, readyToStart, ...displayOverlayProps,
|
|
1306
|
+
startPhase, startSlow
|
|
1307
|
+
};
|
|
1308
|
+
if (startContent)
|
|
1309
|
+
props.startContent = startContent;
|
|
1310
|
+
if (startPhase === 'ready')
|
|
1311
|
+
props.startReadyInfo = this.getStartReadyInfo(displayOverlayProps);
|
|
1312
|
+
return props;
|
|
1313
|
+
}
|
|
1314
|
+
getStartReadyInfo(displayOverlayProps) {
|
|
1315
|
+
const sensors = (this.deviceInfo ?? []).filter(d => !d.isControl && !this.ignoredDevices.has(d.udid));
|
|
1316
|
+
return {
|
|
1317
|
+
pendingSensors: sensors.filter(d => d.status === 'Starting').map(d => d.name),
|
|
1318
|
+
notConnectedSensors: sensors.filter(d => d.status === 'Error').map(d => d.name),
|
|
1319
|
+
viewFallback: displayOverlayProps.viewState === 'unavailable'
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
getDeviceStartFields(d) {
|
|
1323
|
+
const ignored = !d.isControl && this.ignoredDevices.has(d.udid);
|
|
1324
|
+
const starting = d.status === 'Starting';
|
|
1325
|
+
const slow = starting && !ignored && this.deviceAttempts.get(d.udid)?.slow === true;
|
|
1326
|
+
let startState = 'starting';
|
|
1327
|
+
if (d.status === 'Started')
|
|
1328
|
+
startState = 'started';
|
|
1329
|
+
else if (ignored)
|
|
1330
|
+
startState = 'ignored';
|
|
1331
|
+
else if (d.stateText)
|
|
1332
|
+
startState = 'uploading';
|
|
1333
|
+
else if (d.status === 'Error')
|
|
1334
|
+
startState = d.isControl ? 'failed' : 'not-connected';
|
|
1335
|
+
if (d.isControl) {
|
|
1336
|
+
return { startState, slow, canRetry: starting && slow && !d.stateText, canIgnore: false };
|
|
1337
|
+
}
|
|
1338
|
+
const stuck = d.status === 'Error' || (starting && slow);
|
|
1339
|
+
return {
|
|
1340
|
+
startState, slow,
|
|
1341
|
+
canRetry: stuck || (ignored && d.status !== 'Started'),
|
|
1342
|
+
canIgnore: stuck && !ignored
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
derivePhase() {
|
|
1346
|
+
if (!this.isStartDeviceReadyToStart())
|
|
1347
|
+
return 'devices';
|
|
1348
|
+
if (!this.getRideModeService().isStartRideCompleted())
|
|
1349
|
+
return 'content';
|
|
1350
|
+
return 'ready';
|
|
1351
|
+
}
|
|
1352
|
+
getStartSlow(phase, content, displayOverlayProps) {
|
|
1353
|
+
if (phase === 'devices') {
|
|
1354
|
+
const controls = (this.deviceInfo ?? []).filter(d => d.isControl);
|
|
1355
|
+
const slow = this.slowFlags.devices && controls.some(d => d.status === 'Starting') && !controls.some(d => d.stateText);
|
|
1356
|
+
return { slow, cause: 'devices' };
|
|
1357
|
+
}
|
|
1358
|
+
if (phase === 'content') {
|
|
1359
|
+
if (content?.kind === 'streetview')
|
|
1360
|
+
return { slow: displayOverlayProps.viewState === 'slow', cause: 'streetview' };
|
|
1361
|
+
if (content?.progress)
|
|
1362
|
+
return { slow: this.slowFlags.stall, cause: 'convert-stall' };
|
|
1363
|
+
return { slow: this.slowFlags.content, cause: 'content' };
|
|
1364
|
+
}
|
|
1365
|
+
return { slow: false };
|
|
1366
|
+
}
|
|
1367
|
+
getSlowThreshold() {
|
|
1368
|
+
try {
|
|
1369
|
+
const val = Number(this.getUserSettings().get('START_SLOW_THRESHOLD', undefined));
|
|
1370
|
+
return (val > 0 && !Number.isNaN(val)) ? val : START_SLOW_THRESHOLD;
|
|
1371
|
+
}
|
|
1372
|
+
catch {
|
|
1373
|
+
return START_SLOW_THRESHOLD;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
getStartElapsed() {
|
|
1377
|
+
return Date.now() - (this.tsStart ?? Date.now());
|
|
1378
|
+
}
|
|
1379
|
+
getMissingSensors() {
|
|
1380
|
+
return (this.deviceInfo ?? []).filter(d => !d.isControl && !this.ignoredDevices.has(d.udid) && d.status !== 'Started');
|
|
1381
|
+
}
|
|
1382
|
+
resetStartTracking() {
|
|
1383
|
+
this.clearStartTimers();
|
|
1384
|
+
this.tsStart = Date.now();
|
|
1385
|
+
this.reportedPhase = undefined;
|
|
1386
|
+
this.pendingPhase = undefined;
|
|
1387
|
+
this.slowFlags = { devices: false, content: false, stall: false };
|
|
1388
|
+
this.slowLoggedPhases.clear();
|
|
1389
|
+
this.slowShown = false;
|
|
1390
|
+
this.convertProgressKey = undefined;
|
|
1391
|
+
this.deviceAttempts.clear();
|
|
1392
|
+
this.ignoredDevices.clear();
|
|
1393
|
+
this.deviceRetries = 0;
|
|
1394
|
+
this.startTrigger = 'auto';
|
|
1395
|
+
this.fullRetryPending = false;
|
|
1396
|
+
this.armStartTimer('devices-slow', this.getSlowThreshold(), () => { this.slowFlags.devices = true; });
|
|
1397
|
+
}
|
|
1398
|
+
restartDeviceTracking() {
|
|
1399
|
+
this.fullRetryPending = true;
|
|
1400
|
+
this.slowFlags.devices = false;
|
|
1401
|
+
this.armStartTimer('devices-slow', this.getSlowThreshold(), () => { this.slowFlags.devices = true; });
|
|
1402
|
+
}
|
|
1403
|
+
armStartTimer(key, ms, handler) {
|
|
1404
|
+
this.clearStartTimer(key);
|
|
1405
|
+
const timer = setTimeout(() => {
|
|
1406
|
+
this.startTimers.delete(key);
|
|
1407
|
+
try {
|
|
1408
|
+
if (this.state !== 'Starting')
|
|
1409
|
+
return;
|
|
1410
|
+
handler();
|
|
1411
|
+
this.checkStartStatus();
|
|
1412
|
+
}
|
|
1413
|
+
catch (err) {
|
|
1414
|
+
this.logError(err, 'startTimer', { key });
|
|
1415
|
+
}
|
|
1416
|
+
}, ms);
|
|
1417
|
+
this.startTimers.set(key, timer);
|
|
1418
|
+
}
|
|
1419
|
+
clearStartTimer(key) {
|
|
1420
|
+
const timer = this.startTimers.get(key);
|
|
1421
|
+
if (timer) {
|
|
1422
|
+
clearTimeout(timer);
|
|
1423
|
+
this.startTimers.delete(key);
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
clearStartTimers() {
|
|
1427
|
+
this.startTimers.forEach(t => clearTimeout(t));
|
|
1428
|
+
this.startTimers.clear();
|
|
1429
|
+
}
|
|
1430
|
+
getDeviceTimerKey(udid) {
|
|
1431
|
+
return `device:${udid}`;
|
|
1432
|
+
}
|
|
1433
|
+
beginDeviceAttempt(udid) {
|
|
1434
|
+
const attempt = { slow: false };
|
|
1435
|
+
this.deviceAttempts.set(udid, attempt);
|
|
1436
|
+
this.armStartTimer(this.getDeviceTimerKey(udid), this.getSlowThreshold(), () => { attempt.slow = true; });
|
|
1437
|
+
}
|
|
1438
|
+
endDeviceAttempt(udid) {
|
|
1439
|
+
this.clearStartTimer(this.getDeviceTimerKey(udid));
|
|
1440
|
+
this.deviceAttempts.delete(udid);
|
|
1441
|
+
}
|
|
1442
|
+
updateStartTracking() {
|
|
1443
|
+
if (this.state !== 'Starting' || !this.displayService)
|
|
1444
|
+
return;
|
|
1445
|
+
try {
|
|
1446
|
+
this.trackPhase();
|
|
1447
|
+
const content = this.getRideModeService().getStartContentInfo?.();
|
|
1448
|
+
this.trackConvertProgress(content);
|
|
1449
|
+
this.trackSlowShown(content);
|
|
1450
|
+
}
|
|
1451
|
+
catch (err) {
|
|
1452
|
+
this.logError(err, 'updateStartTracking');
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
trackPhase() {
|
|
1456
|
+
const phase = this.derivePhase();
|
|
1457
|
+
if (this.reportedPhase === undefined) {
|
|
1458
|
+
this.enterPhase(phase);
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
if (phase === this.pendingPhase)
|
|
1462
|
+
return;
|
|
1463
|
+
this.pendingPhase = phase;
|
|
1464
|
+
this.clearStartTimer('phase');
|
|
1465
|
+
if (phase !== this.reportedPhase) {
|
|
1466
|
+
this.armStartTimer('phase', START_PHASE_DELAY, () => { this.enterPhase(this.pendingPhase); });
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
enterPhase(phase) {
|
|
1470
|
+
this.reportedPhase = phase;
|
|
1471
|
+
this.pendingPhase = phase;
|
|
1472
|
+
if (phase === 'content') {
|
|
1473
|
+
this.slowFlags.content = false;
|
|
1474
|
+
this.armStartTimer('content-slow', this.getSlowThreshold(), () => { this.slowFlags.content = true; });
|
|
1475
|
+
}
|
|
1476
|
+
this.logEvent({ message: 'start phase entered', mode: this.getLogRideMode(), startPhase: phase, startElapsedMs: this.getStartElapsed() });
|
|
1477
|
+
}
|
|
1478
|
+
trackConvertProgress(content) {
|
|
1479
|
+
if (!content?.progress || content.state !== 'loading') {
|
|
1480
|
+
this.clearStartTimer('stall');
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
const key = `${content.progress.convertPct}|${content.progress.convertSeconds}`;
|
|
1484
|
+
if (key === this.convertProgressKey)
|
|
1485
|
+
return;
|
|
1486
|
+
this.convertProgressKey = key;
|
|
1487
|
+
this.slowFlags.stall = false;
|
|
1488
|
+
this.armStartTimer('stall', this.getSlowThreshold(), () => { this.slowFlags.stall = true; });
|
|
1489
|
+
}
|
|
1490
|
+
trackSlowShown(content) {
|
|
1491
|
+
const phase = this.reportedPhase;
|
|
1492
|
+
if (!phase || this.slowLoggedPhases.has(phase))
|
|
1493
|
+
return;
|
|
1494
|
+
const { slow, cause } = this.getStartSlow(phase, content, this.getRideModeService().getStartOverlayProps() ?? {});
|
|
1495
|
+
if (!slow)
|
|
1496
|
+
return;
|
|
1497
|
+
this.slowLoggedPhases.add(phase);
|
|
1498
|
+
this.slowShown = true;
|
|
1499
|
+
this.logEvent({ message: 'start slow shown', startPhase: phase, slowCause: cause, startElapsedMs: this.getStartElapsed() });
|
|
1500
|
+
}
|
|
1501
|
+
getStartingDevice(udid) {
|
|
1502
|
+
if (this.state !== 'Starting')
|
|
1503
|
+
return undefined;
|
|
1504
|
+
return this.deviceInfo?.find(d => d.udid === udid);
|
|
1505
|
+
}
|
|
1506
|
+
logDeviceButton(button, device) {
|
|
1507
|
+
const props = this.getStartOverlayProps();
|
|
1508
|
+
const info = props.devices?.find(d => d.udid === device.udid);
|
|
1509
|
+
this.logEvent({
|
|
1510
|
+
message: 'button clicked', overlay: 'start overlay', button,
|
|
1511
|
+
device: device.name,
|
|
1512
|
+
deviceRole: device.isControl ? 'trainer' : 'sensor',
|
|
1513
|
+
deviceStartState: info?.startState ?? this.getDeviceStartFields(device).startState,
|
|
1514
|
+
startPhase: props.startPhase ?? this.derivePhase(),
|
|
1515
|
+
eventSource: 'user',
|
|
1516
|
+
state: props
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
async cancelDeviceRetries() {
|
|
1520
|
+
if (this.deviceRetries === 0)
|
|
1521
|
+
return;
|
|
1522
|
+
let timer;
|
|
1523
|
+
try {
|
|
1524
|
+
const timeout = new Promise(resolve => { timer = setTimeout(resolve, CANCEL_DEVICE_STOP_TIMEOUT); });
|
|
1525
|
+
await Promise.race([this.getDeviceRide().cancelStart(), timeout]);
|
|
1526
|
+
}
|
|
1527
|
+
catch (err) {
|
|
1528
|
+
this.logError(err, 'cancelDeviceRetries');
|
|
1529
|
+
}
|
|
1530
|
+
finally {
|
|
1531
|
+
clearTimeout(timer);
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1211
1534
|
getDeviceStartSettings() {
|
|
1212
1535
|
let forceErgMode = false;
|
|
1213
1536
|
if (this.getWorkoutList().getSelected()) {
|
|
@@ -299,6 +299,22 @@ let RidePageService = (() => {
|
|
|
299
299
|
this.logError(err, 'onIgnoreStart');
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
|
+
onRetryStartDevice(udid) {
|
|
303
|
+
try {
|
|
304
|
+
this.getRideDisplay().retryStartDevice(udid);
|
|
305
|
+
}
|
|
306
|
+
catch (err) {
|
|
307
|
+
this.logError(err, 'onRetryStartDevice');
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
onIgnoreStartDevice(udid) {
|
|
311
|
+
try {
|
|
312
|
+
this.getRideDisplay().ignoreStartDevice(udid);
|
|
313
|
+
}
|
|
314
|
+
catch (err) {
|
|
315
|
+
this.logError(err, 'onIgnoreStartDevice');
|
|
316
|
+
}
|
|
317
|
+
}
|
|
302
318
|
onStartWithMap() {
|
|
303
319
|
try {
|
|
304
320
|
this.getRideDisplay().startWithMapFallback();
|
|
@@ -104,6 +104,12 @@ let FreeRideDisplayService = (() => {
|
|
|
104
104
|
isStartRideCompleted() {
|
|
105
105
|
return this.currentOptions !== undefined && super.isStartRideCompleted();
|
|
106
106
|
}
|
|
107
|
+
getStartContentInfo() {
|
|
108
|
+
const info = super.getStartContentInfo();
|
|
109
|
+
if (this.currentOptions === undefined && info.state === 'ready')
|
|
110
|
+
return { ...info, state: 'loading' };
|
|
111
|
+
return info;
|
|
112
|
+
}
|
|
107
113
|
selectOption(option) {
|
|
108
114
|
try {
|
|
109
115
|
this.getFreeRideService().selectOptionByUser(option);
|
|
@@ -242,6 +242,28 @@ let GpxDisplayService = (() => {
|
|
|
242
242
|
mapStateError: this.mapError
|
|
243
243
|
};
|
|
244
244
|
}
|
|
245
|
+
getStartContentInfo() {
|
|
246
|
+
const props = this.getStartOverlayProps();
|
|
247
|
+
const label = props.mapType;
|
|
248
|
+
const kind = this.getContentKind();
|
|
249
|
+
if (kind === 'streetview') {
|
|
250
|
+
const map = {
|
|
251
|
+
waiting: 'waiting', loading: 'loading', slow: 'loading', loaded: 'ready', unavailable: 'unavailable'
|
|
252
|
+
};
|
|
253
|
+
return { kind, label, state: map[props.viewState] ?? 'loading' };
|
|
254
|
+
}
|
|
255
|
+
if (props.mapStateError)
|
|
256
|
+
return { kind, label, state: 'failed' };
|
|
257
|
+
return { kind, label, state: this.isStartRideCompleted() ? 'ready' : 'loading' };
|
|
258
|
+
}
|
|
259
|
+
getContentKind() {
|
|
260
|
+
if (this.svFlowActive)
|
|
261
|
+
return 'streetview';
|
|
262
|
+
const rideView = this.getRideView();
|
|
263
|
+
if (rideView === 'sat')
|
|
264
|
+
return 'satellite';
|
|
265
|
+
return 'map';
|
|
266
|
+
}
|
|
245
267
|
isStartRideCompleted() {
|
|
246
268
|
const rideView = this.getRideView();
|
|
247
269
|
if (this.svFlowActive) {
|