incyclist-services 1.9.33 → 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/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/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 +7 -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/list/loaders/api.js +33 -24
- package/lib/cjs/routes/servers/validator.js +2 -2
- 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/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/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/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/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/workouts/calendar/sync/base/provider.js +6 -1
- package/lib/esm/workouts/calendar/sync/intervals/provider.js +5 -2
- 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 +54 -2
- 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/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/sync/base/provider.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
|
@@ -79,9 +79,16 @@ let ActivityUploadFactory = (() => {
|
|
|
79
79
|
this.uploaders.forEach(ui => {
|
|
80
80
|
const { service, uploader } = ui;
|
|
81
81
|
if (uploader.isConnected() && this.getAppsService().isEnabled(service, 'ActivityUpload')) {
|
|
82
|
+
this.getAppsService().logEvent({ message: 'start activity upload', externalApp: service });
|
|
82
83
|
const promise = uploader.upload(activity, format)
|
|
83
|
-
.then(success =>
|
|
84
|
-
.
|
|
84
|
+
.then(success => {
|
|
85
|
+
this.getAppsService().logEvent({ message: 'activity upload finished', externalApp: service });
|
|
86
|
+
return { service, success };
|
|
87
|
+
})
|
|
88
|
+
.catch(err => {
|
|
89
|
+
this.getAppsService().logEvent({ message: 'activity upload failed', externalApp: service, reason: err.message });
|
|
90
|
+
return { service, success: false, error: err.message };
|
|
91
|
+
});
|
|
85
92
|
uploads.push({ service, promise, status: undefined });
|
|
86
93
|
}
|
|
87
94
|
});
|
|
@@ -79,7 +79,6 @@ let IntervalsUpload = (() => {
|
|
|
79
79
|
try {
|
|
80
80
|
const ok = this.ensureInitialized();
|
|
81
81
|
if (!ok) {
|
|
82
|
-
this.logEvent({ message: 'Intervals.icu Upload skipped', reason: 'not initialized' });
|
|
83
82
|
return false;
|
|
84
83
|
}
|
|
85
84
|
if (!this.isConnected())
|
|
@@ -103,7 +102,6 @@ let IntervalsUpload = (() => {
|
|
|
103
102
|
return true;
|
|
104
103
|
}
|
|
105
104
|
catch (err) {
|
|
106
|
-
this.logEvent({ message: 'Intervals.icu Upload failure', error: err.message });
|
|
107
105
|
activity.links.intervals = {
|
|
108
106
|
error: err.message
|
|
109
107
|
};
|
|
@@ -80,7 +80,6 @@ let KomootUpload = (() => {
|
|
|
80
80
|
try {
|
|
81
81
|
const ok = this.ensureInitialized();
|
|
82
82
|
if (!ok) {
|
|
83
|
-
this.logEvent({ message: 'Komoot Upload skipped', reason: 'not initialized' });
|
|
84
83
|
return false;
|
|
85
84
|
}
|
|
86
85
|
if (!this.isConnected())
|
|
@@ -109,7 +108,6 @@ let KomootUpload = (() => {
|
|
|
109
108
|
return true;
|
|
110
109
|
}
|
|
111
110
|
catch (err) {
|
|
112
|
-
this.logEvent({ message: 'Komoot Upload failure', error: err.message });
|
|
113
111
|
activity.links.komoot = {
|
|
114
112
|
error: err.message
|
|
115
113
|
};
|
|
@@ -80,7 +80,6 @@ let RideWithGpsUpload = (() => {
|
|
|
80
80
|
}
|
|
81
81
|
async upload(activity, format = 'TCX') {
|
|
82
82
|
if (!this.ensureInitialized()) {
|
|
83
|
-
this.logEvent({ message: 'RideWithGPS Upload skipped', reason: 'not initialized' });
|
|
84
83
|
return false;
|
|
85
84
|
}
|
|
86
85
|
if (!this.isConnected())
|
|
@@ -93,7 +92,6 @@ let RideWithGpsUpload = (() => {
|
|
|
93
92
|
}
|
|
94
93
|
catch (err) {
|
|
95
94
|
const error = err?.message ?? String(err);
|
|
96
|
-
this.logEvent({ message: 'RideWithGPS Upload failure', error });
|
|
97
95
|
this.setLink(activity, { error });
|
|
98
96
|
return false;
|
|
99
97
|
}
|
|
@@ -80,7 +80,6 @@ let StravaUpload = (() => {
|
|
|
80
80
|
try {
|
|
81
81
|
const ok = this.ensureInitialized();
|
|
82
82
|
if (!ok) {
|
|
83
|
-
this.logEvent({ message: 'Strava Upload skipped', reason: 'not initialized' });
|
|
84
83
|
return false;
|
|
85
84
|
}
|
|
86
85
|
if (!this.isConnected())
|
|
@@ -105,14 +104,12 @@ let StravaUpload = (() => {
|
|
|
105
104
|
}
|
|
106
105
|
catch (err) {
|
|
107
106
|
if (err instanceof strava_1.DuplicateError) {
|
|
108
|
-
this.logEvent({ message: 'Strava Upload failure', error: 'duplicate', activityId: err.stravaId });
|
|
109
107
|
activity.links.strava = {
|
|
110
108
|
activity_id: err.stravaId,
|
|
111
109
|
url: this.getUrl(err.stravaId)
|
|
112
110
|
};
|
|
113
111
|
}
|
|
114
112
|
else {
|
|
115
|
-
this.logEvent({ message: 'Strava Upload failure', error: err.message });
|
|
116
113
|
activity.links.strava = {
|
|
117
114
|
error: err.message
|
|
118
115
|
};
|
|
@@ -85,7 +85,6 @@ let TrainerDayUpload = (() => {
|
|
|
85
85
|
}
|
|
86
86
|
async upload(activity, format = 'TCX') {
|
|
87
87
|
if (!this.ensureInitialized()) {
|
|
88
|
-
this.logEvent({ message: 'TrainerDay Upload skipped', reason: 'not initialized' });
|
|
89
88
|
return false;
|
|
90
89
|
}
|
|
91
90
|
if (!this.isConnected())
|
|
@@ -112,7 +111,6 @@ let TrainerDayUpload = (() => {
|
|
|
112
111
|
}
|
|
113
112
|
catch (err) {
|
|
114
113
|
const error = err?.message ?? String(err);
|
|
115
|
-
this.logEvent({ message: 'TrainerDay Upload failure', error });
|
|
116
114
|
this.setLink(activity, { error });
|
|
117
115
|
return false;
|
|
118
116
|
}
|
|
@@ -85,7 +85,6 @@ let TrainingPeaksUpload = (() => {
|
|
|
85
85
|
}
|
|
86
86
|
async upload(activity, format = 'TCX') {
|
|
87
87
|
if (!this.ensureInitialized()) {
|
|
88
|
-
this.logEvent({ message: 'TrainingPeaks Upload skipped', reason: 'not initialized' });
|
|
89
88
|
return false;
|
|
90
89
|
}
|
|
91
90
|
if (!this.isConnected())
|
|
@@ -108,7 +107,6 @@ let TrainingPeaksUpload = (() => {
|
|
|
108
107
|
catch (err) {
|
|
109
108
|
if (err instanceof trainingpeaks_1.TrainingPeaksDuplicateError)
|
|
110
109
|
return await this.onDuplicate(activity);
|
|
111
|
-
this.logEvent({ message: 'TrainingPeaks Upload failure', error: err.message });
|
|
112
110
|
this.setLink(activity, { error: err.message });
|
|
113
111
|
return false;
|
|
114
112
|
}
|
|
@@ -85,6 +85,10 @@ let DeviceRideService = (() => {
|
|
|
85
85
|
rideAdapters;
|
|
86
86
|
healthChecks = new Set();
|
|
87
87
|
startPromises;
|
|
88
|
+
startAttempts = new Map();
|
|
89
|
+
inFlightStarts = new Set();
|
|
90
|
+
retryPromises = new Map();
|
|
91
|
+
retryCounts = new Map();
|
|
88
92
|
startedCapabilities = new Map();
|
|
89
93
|
data = {};
|
|
90
94
|
simulatorEnforced;
|
|
@@ -596,8 +600,21 @@ let DeviceRideService = (() => {
|
|
|
596
600
|
ai.isStarted = false;
|
|
597
601
|
this.logEvent({ message: `${startType} ${sType} request`, ...logProps });
|
|
598
602
|
this.subscribeModeReplaced(ai.adapter);
|
|
603
|
+
const attempt = startType === 'start' ? this.beginStartAttempt(ai.udid) : undefined;
|
|
604
|
+
if (attempt !== undefined)
|
|
605
|
+
this.inFlightStarts.add(ai.udid);
|
|
606
|
+
const isSuperseded = () => attempt !== undefined && this.startAttempts.get(ai.udid) !== attempt;
|
|
607
|
+
const settle = () => {
|
|
608
|
+
if (attempt !== undefined && !isSuperseded())
|
|
609
|
+
this.inFlightStarts.delete(ai.udid);
|
|
610
|
+
};
|
|
599
611
|
return ai.adapter.start(startProps)
|
|
600
612
|
.then(async (success) => {
|
|
613
|
+
settle();
|
|
614
|
+
if (isSuperseded()) {
|
|
615
|
+
this.logEvent({ message: `${startType} ${sType} result dropped`, ...logProps, reason: 'superseded by a newer attempt' });
|
|
616
|
+
return success;
|
|
617
|
+
}
|
|
601
618
|
if (success) {
|
|
602
619
|
await this.handleStartSuccess(startType, ai, duplicates, sType, logProps);
|
|
603
620
|
return true;
|
|
@@ -606,10 +623,20 @@ let DeviceRideService = (() => {
|
|
|
606
623
|
return false;
|
|
607
624
|
})
|
|
608
625
|
.catch(async (err) => {
|
|
626
|
+
settle();
|
|
627
|
+
if (isSuperseded()) {
|
|
628
|
+
this.logEvent({ message: `${startType} ${sType} result dropped`, ...logProps, reason: 'superseded by a newer attempt' });
|
|
629
|
+
return false;
|
|
630
|
+
}
|
|
609
631
|
await this.handleStartRejection(startType, sType, logProps, err, ai, duplicates);
|
|
610
632
|
return false;
|
|
611
633
|
});
|
|
612
634
|
}
|
|
635
|
+
beginStartAttempt(udid) {
|
|
636
|
+
const attempt = (this.startAttempts.get(udid) ?? 0) + 1;
|
|
637
|
+
this.startAttempts.set(udid, attempt);
|
|
638
|
+
return attempt;
|
|
639
|
+
}
|
|
613
640
|
resumeLoggingForStart(ai) {
|
|
614
641
|
try {
|
|
615
642
|
ai.adapter.resumeLogging();
|
|
@@ -999,10 +1026,85 @@ let DeviceRideService = (() => {
|
|
|
999
1026
|
return;
|
|
1000
1027
|
return this.startAdapters(adapters, 'start', props);
|
|
1001
1028
|
}
|
|
1029
|
+
async retryStartDevice(udid, props) {
|
|
1030
|
+
await this.lazyInit();
|
|
1031
|
+
const ai = this.getRideAdapters()?.find(a => a.udid === udid);
|
|
1032
|
+
if (!ai) {
|
|
1033
|
+
this.logEvent({ message: 'start device retry skipped', udid, reason: 'unknown device' });
|
|
1034
|
+
return false;
|
|
1035
|
+
}
|
|
1036
|
+
const tsStart = Date.now();
|
|
1037
|
+
const retryAttempt = (this.retryCounts.get(udid) ?? 0) + 1;
|
|
1038
|
+
this.retryCounts.set(udid, retryAttempt);
|
|
1039
|
+
const token = this.beginStartAttempt(udid);
|
|
1040
|
+
const promise = this.runDeviceRetry(ai, props, token);
|
|
1041
|
+
this.retryPromises.set(udid, promise);
|
|
1042
|
+
let retryResult;
|
|
1043
|
+
try {
|
|
1044
|
+
retryResult = await promise;
|
|
1045
|
+
}
|
|
1046
|
+
finally {
|
|
1047
|
+
if (this.retryPromises.get(udid) === promise)
|
|
1048
|
+
this.retryPromises.delete(udid);
|
|
1049
|
+
}
|
|
1050
|
+
this.logEvent({
|
|
1051
|
+
message: 'start device retry result',
|
|
1052
|
+
device: ai.adapter.getUniqueName(),
|
|
1053
|
+
deviceRole: ai.isControl ? 'trainer' : 'sensor',
|
|
1054
|
+
retryResult,
|
|
1055
|
+
retryDurationMs: Date.now() - tsStart,
|
|
1056
|
+
retryAttempt
|
|
1057
|
+
});
|
|
1058
|
+
return retryResult === 'started';
|
|
1059
|
+
}
|
|
1060
|
+
async runDeviceRetry(ai, props, token) {
|
|
1061
|
+
const udid = ai.udid;
|
|
1062
|
+
try {
|
|
1063
|
+
if (ai.adapter.isStarted()) {
|
|
1064
|
+
this.emit('start-success', this.getAdapterStateInfo(ai));
|
|
1065
|
+
return 'started';
|
|
1066
|
+
}
|
|
1067
|
+
if (this.inFlightStarts.has(udid)) {
|
|
1068
|
+
const stopped = await this.stopWithTimeout(ai, timeouts_1.DEVICE_RETRY_STOP_TIMEOUT_MS);
|
|
1069
|
+
if (this.startAttempts.get(udid) !== token)
|
|
1070
|
+
return 'cancelled';
|
|
1071
|
+
if (!stopped) {
|
|
1072
|
+
this.emit('start-error', this.getAdapterStateInfo(ai), new Error('stop timeout'));
|
|
1073
|
+
return 'stop-timeout';
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
const success = await this.startSingleAdapter(ai, [], props, 'start');
|
|
1077
|
+
if (this.startAttempts.get(udid) !== token + 1)
|
|
1078
|
+
return 'cancelled';
|
|
1079
|
+
return success ? 'started' : 'failed';
|
|
1080
|
+
}
|
|
1081
|
+
catch (err) {
|
|
1082
|
+
this.logError(err, 'retryStartDevice');
|
|
1083
|
+
if (this.startAttempts.get(udid) === token || this.startAttempts.get(udid) === token + 1)
|
|
1084
|
+
this.emit('start-error', this.getAdapterStateInfo(ai), err);
|
|
1085
|
+
return 'failed';
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
stopWithTimeout(ai, timeout) {
|
|
1089
|
+
return new Promise(resolve => {
|
|
1090
|
+
const timer = setTimeout(() => { resolve(false); }, timeout);
|
|
1091
|
+
const done = () => { clearTimeout(timer); resolve(true); };
|
|
1092
|
+
try {
|
|
1093
|
+
ai.adapter.stop().then(done, done);
|
|
1094
|
+
}
|
|
1095
|
+
catch {
|
|
1096
|
+
done();
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1002
1100
|
async cancelStart() {
|
|
1003
|
-
if (!this.startPromises)
|
|
1101
|
+
if (!this.startPromises && this.retryPromises.size === 0)
|
|
1004
1102
|
return;
|
|
1005
1103
|
this.logEvent({ message: 'cancel start' });
|
|
1104
|
+
this.retryPromises.forEach((_p, udid) => {
|
|
1105
|
+
this.beginStartAttempt(udid);
|
|
1106
|
+
this.inFlightStarts.delete(udid);
|
|
1107
|
+
});
|
|
1006
1108
|
const adapters = this.getRideAdapters();
|
|
1007
1109
|
const promises = [];
|
|
1008
1110
|
adapters?.forEach(ai => {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPairingStartTimeout = void 0;
|
|
3
|
+
exports.DEVICE_RETRY_STOP_TIMEOUT_MS = exports.getPairingStartTimeout = void 0;
|
|
4
4
|
const PAIRING_START_TIMEOUT_MS = 10 * 1000;
|
|
5
5
|
const BLE_PAIRING_START_TIMEOUT_MS = 30 * 1000;
|
|
6
6
|
const getPairingStartTimeout = (adapter) => {
|
|
7
7
|
return adapter?.getSettings?.()?.interface === 'ble' ? BLE_PAIRING_START_TIMEOUT_MS : PAIRING_START_TIMEOUT_MS;
|
|
8
8
|
};
|
|
9
9
|
exports.getPairingStartTimeout = getPairingStartTimeout;
|
|
10
|
+
exports.DEVICE_RETRY_STOP_TIMEOUT_MS = 5 * 1000;
|