incyclist-services 1.9.2 → 1.9.3
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/base/utils/activity.js +1 -1
- package/lib/cjs/activities/list/service.js +14 -1
- package/lib/cjs/activities/ride/service.js +3 -2
- package/lib/cjs/ride/page/service.js +8 -4
- package/lib/cjs/routes/base/model/route.js +3 -1
- package/lib/cjs/ui/service.js +9 -0
- package/lib/cjs/workouts/base/model/Workout.js +8 -0
- package/lib/esm/activities/base/utils/activity.js +1 -1
- package/lib/esm/activities/list/service.js +14 -1
- package/lib/esm/activities/ride/service.js +3 -2
- package/lib/esm/ride/page/service.js +8 -4
- package/lib/esm/routes/base/model/route.js +3 -1
- package/lib/esm/ui/service.js +9 -0
- package/lib/esm/workouts/base/model/Workout.js +8 -0
- package/lib/types/ui/service.d.ts +1 -0
- package/package.json +2 -2
|
@@ -117,7 +117,7 @@ let Activity = (() => {
|
|
|
117
117
|
return !!this.info.details;
|
|
118
118
|
}
|
|
119
119
|
getTitle() {
|
|
120
|
-
let title = this.info.summary.title;
|
|
120
|
+
let title = this.info.details?.title ?? this.info.summary.title;
|
|
121
121
|
const sport = this.details?.sport ?? 'cycling';
|
|
122
122
|
if (title === model_1.DEFAULT_ACTIVITY_TITLE || title === model_1.DEFAULT_SPORT_ACTIVITY_TITLE[sport]) {
|
|
123
123
|
if (this.details?.route?.title) {
|
|
@@ -332,8 +332,21 @@ let ActivityListService = (() => {
|
|
|
332
332
|
}
|
|
333
333
|
getPastActivities() {
|
|
334
334
|
try {
|
|
335
|
+
const prefixes = ['Incyclist Ride:', 'Incyclist Run:', 'Incyclist Row:', 'Incyclist:'];
|
|
336
|
+
const fixTitle = (ai) => {
|
|
337
|
+
const prefix = prefixes.find(p => ai.summary.title.startsWith(p));
|
|
338
|
+
if (prefix) {
|
|
339
|
+
const updated = { ...ai.summary };
|
|
340
|
+
updated.title = ai.summary.title.slice(prefix.length).trim();
|
|
341
|
+
ai.summary = updated;
|
|
342
|
+
}
|
|
343
|
+
};
|
|
335
344
|
const activities = this.getRepo().search(this.filter) ?? [];
|
|
336
|
-
|
|
345
|
+
const sorted = activities.toSorted((a, b) => b.summary?.startTime - a.summary?.startTime);
|
|
346
|
+
if (!sorted?.length)
|
|
347
|
+
return sorted;
|
|
348
|
+
sorted.forEach(fixTitle);
|
|
349
|
+
return sorted;
|
|
337
350
|
}
|
|
338
351
|
catch (err) {
|
|
339
352
|
this.logError(err, 'getPastActivities');
|
|
@@ -1099,10 +1099,11 @@ let ActivityRideService = (() => {
|
|
|
1099
1099
|
}
|
|
1100
1100
|
}
|
|
1101
1101
|
const sport = this.getDeviceRide().getSport() ?? 'cycling';
|
|
1102
|
-
const
|
|
1102
|
+
const prefix = `${base_1.DEFAULT_SPORT_ACTIVITY_TITLE[sport] ?? 'Incyclist'}`;
|
|
1103
|
+
const title = `${prefix}: ${routeName}`;
|
|
1103
1104
|
const id = requestedId ?? (0, uuid_1.v4)();
|
|
1104
1105
|
const date = (0, utils_1.formatDateTime)(new Date(), "%Y%m%d%H%M%S", false);
|
|
1105
|
-
const name = `${
|
|
1106
|
+
const name = `${prefix}-${date}`;
|
|
1106
1107
|
const fileName = this.getRepo().getFilename(name);
|
|
1107
1108
|
const route = { name: routeName, hash: routeHash, title: routeTitle };
|
|
1108
1109
|
if (routeId)
|
|
@@ -227,10 +227,13 @@ let RidePageService = (() => {
|
|
|
227
227
|
}
|
|
228
228
|
async pausePage() {
|
|
229
229
|
try {
|
|
230
|
-
this.backgroundTimer
|
|
231
|
-
this.
|
|
232
|
-
|
|
233
|
-
|
|
230
|
+
if (!this.backgroundTimer) {
|
|
231
|
+
this.backgroundTimer = setTimeout(() => {
|
|
232
|
+
this.backgroundTimer = undefined;
|
|
233
|
+
this.getRideDisplay().pause(this.getBackgroundPauseRequester());
|
|
234
|
+
this.backgroundPausedByService = true;
|
|
235
|
+
}, BACKGROUND_PAUSE_TIMEOUT_MS);
|
|
236
|
+
}
|
|
234
237
|
this.isInitialized = false;
|
|
235
238
|
return super.pausePage();
|
|
236
239
|
}
|
|
@@ -242,6 +245,7 @@ let RidePageService = (() => {
|
|
|
242
245
|
try {
|
|
243
246
|
if (this.backgroundTimer) {
|
|
244
247
|
clearTimeout(this.backgroundTimer);
|
|
248
|
+
this.backgroundTimer = undefined;
|
|
245
249
|
}
|
|
246
250
|
await this.getRouteVideoAvailability().onForeground();
|
|
247
251
|
return super.resumePage();
|
|
@@ -68,7 +68,9 @@ let Route = (() => {
|
|
|
68
68
|
}
|
|
69
69
|
replace(update) {
|
|
70
70
|
this._description = { ...update._description };
|
|
71
|
-
|
|
71
|
+
if (update._details) {
|
|
72
|
+
this._details = { ...update._details };
|
|
73
|
+
}
|
|
72
74
|
}
|
|
73
75
|
addDetails(details) {
|
|
74
76
|
this._details = details;
|
package/lib/cjs/ui/service.js
CHANGED
|
@@ -102,6 +102,7 @@ let UserInterfaceServcie = (() => {
|
|
|
102
102
|
appState = 'Inactive';
|
|
103
103
|
backgroundTimer;
|
|
104
104
|
backgroundPausedByService = false;
|
|
105
|
+
isLaunched = false;
|
|
105
106
|
constructor() {
|
|
106
107
|
super('Incyclist');
|
|
107
108
|
this.bindings = this.getBindings();
|
|
@@ -117,6 +118,10 @@ let UserInterfaceServcie = (() => {
|
|
|
117
118
|
};
|
|
118
119
|
}
|
|
119
120
|
async onAppLaunch(platform, version, appFeatures) {
|
|
121
|
+
if (this.isLaunched) {
|
|
122
|
+
this.logEvent({ message: 'onAppLaunch skipped', reason: 'already-launched' });
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
120
125
|
this.isTerminated = false;
|
|
121
126
|
this.isTerminating = false;
|
|
122
127
|
try {
|
|
@@ -137,6 +142,7 @@ let UserInterfaceServcie = (() => {
|
|
|
137
142
|
this.preloadData();
|
|
138
143
|
this.onSessionStart();
|
|
139
144
|
this.appState = 'Active';
|
|
145
|
+
this.isLaunched = true;
|
|
140
146
|
}
|
|
141
147
|
catch (err) {
|
|
142
148
|
this.logError(err, 'onAppLaunch');
|
|
@@ -162,6 +168,7 @@ let UserInterfaceServcie = (() => {
|
|
|
162
168
|
this.appState = 'Stopped';
|
|
163
169
|
this.logEvent({ message: 'onAppExit finished' });
|
|
164
170
|
this.isTerminated = true;
|
|
171
|
+
this.isLaunched = false;
|
|
165
172
|
return true;
|
|
166
173
|
}
|
|
167
174
|
return false;
|
|
@@ -182,6 +189,7 @@ let UserInterfaceServcie = (() => {
|
|
|
182
189
|
(0, access_1.useDeviceAccess)().pauseBackgroundActivity()
|
|
183
190
|
.catch((err) => { this.logError(err, 'onAppPause:pauseBackgroundActivity'); });
|
|
184
191
|
this.backgroundTimer = setTimeout(() => {
|
|
192
|
+
this.backgroundTimer = undefined;
|
|
185
193
|
this.backgroundPausedByService = true;
|
|
186
194
|
this.pause().catch((err) => { this.logError(err, 'onAppPause:pause'); });
|
|
187
195
|
}, BACKGROUND_PAUSE_TIMEOUT_MS);
|
|
@@ -202,6 +210,7 @@ let UserInterfaceServcie = (() => {
|
|
|
202
210
|
let resumeRequired = true;
|
|
203
211
|
if (this.backgroundTimer) {
|
|
204
212
|
clearTimeout(this.backgroundTimer);
|
|
213
|
+
this.backgroundTimer = undefined;
|
|
205
214
|
resumeRequired = false;
|
|
206
215
|
}
|
|
207
216
|
this.logEvent({ message: 'onAppResume called' });
|
|
@@ -61,6 +61,10 @@ class Workout extends Segment_1.Segment {
|
|
|
61
61
|
return s;
|
|
62
62
|
}
|
|
63
63
|
addStep(step) {
|
|
64
|
+
if (step.duration) {
|
|
65
|
+
delete step.start;
|
|
66
|
+
delete step.end;
|
|
67
|
+
}
|
|
64
68
|
if ((0, valid_1.valid)(step)) {
|
|
65
69
|
if (step.duration === undefined && step.start === undefined && step.end === undefined)
|
|
66
70
|
throw new Error(`Invalid Step description, start&end or duration needs to be provided `);
|
|
@@ -75,6 +79,10 @@ class Workout extends Segment_1.Segment {
|
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
81
|
addSegment(segment) {
|
|
82
|
+
if (segment.duration) {
|
|
83
|
+
delete segment.start;
|
|
84
|
+
delete segment.end;
|
|
85
|
+
}
|
|
78
86
|
if ((0, valid_1.valid)(segment)) {
|
|
79
87
|
this.prepareNext(segment);
|
|
80
88
|
if (segment instanceof Segment_1.Segment)
|
|
@@ -114,7 +114,7 @@ let Activity = (() => {
|
|
|
114
114
|
return !!this.info.details;
|
|
115
115
|
}
|
|
116
116
|
getTitle() {
|
|
117
|
-
let title = this.info.summary.title;
|
|
117
|
+
let title = this.info.details?.title ?? this.info.summary.title;
|
|
118
118
|
const sport = this.details?.sport ?? 'cycling';
|
|
119
119
|
if (title === DEFAULT_ACTIVITY_TITLE || title === DEFAULT_SPORT_ACTIVITY_TITLE[sport]) {
|
|
120
120
|
if (this.details?.route?.title) {
|
|
@@ -329,8 +329,21 @@ let ActivityListService = (() => {
|
|
|
329
329
|
}
|
|
330
330
|
getPastActivities() {
|
|
331
331
|
try {
|
|
332
|
+
const prefixes = ['Incyclist Ride:', 'Incyclist Run:', 'Incyclist Row:', 'Incyclist:'];
|
|
333
|
+
const fixTitle = (ai) => {
|
|
334
|
+
const prefix = prefixes.find(p => ai.summary.title.startsWith(p));
|
|
335
|
+
if (prefix) {
|
|
336
|
+
const updated = { ...ai.summary };
|
|
337
|
+
updated.title = ai.summary.title.slice(prefix.length).trim();
|
|
338
|
+
ai.summary = updated;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
332
341
|
const activities = this.getRepo().search(this.filter) ?? [];
|
|
333
|
-
|
|
342
|
+
const sorted = activities.toSorted((a, b) => b.summary?.startTime - a.summary?.startTime);
|
|
343
|
+
if (!sorted?.length)
|
|
344
|
+
return sorted;
|
|
345
|
+
sorted.forEach(fixTitle);
|
|
346
|
+
return sorted;
|
|
334
347
|
}
|
|
335
348
|
catch (err) {
|
|
336
349
|
this.logError(err, 'getPastActivities');
|
|
@@ -1093,10 +1093,11 @@ let ActivityRideService = (() => {
|
|
|
1093
1093
|
}
|
|
1094
1094
|
}
|
|
1095
1095
|
const sport = this.getDeviceRide().getSport() ?? 'cycling';
|
|
1096
|
-
const
|
|
1096
|
+
const prefix = `${DEFAULT_SPORT_ACTIVITY_TITLE[sport] ?? 'Incyclist'}`;
|
|
1097
|
+
const title = `${prefix}: ${routeName}`;
|
|
1097
1098
|
const id = requestedId ?? generateUUID();
|
|
1098
1099
|
const date = formatDateTime(new Date(), "%Y%m%d%H%M%S", false);
|
|
1099
|
-
const name = `${
|
|
1100
|
+
const name = `${prefix}-${date}`;
|
|
1100
1101
|
const fileName = this.getRepo().getFilename(name);
|
|
1101
1102
|
const route = { name: routeName, hash: routeHash, title: routeTitle };
|
|
1102
1103
|
if (routeId)
|
|
@@ -224,10 +224,13 @@ let RidePageService = (() => {
|
|
|
224
224
|
}
|
|
225
225
|
async pausePage() {
|
|
226
226
|
try {
|
|
227
|
-
this.backgroundTimer
|
|
228
|
-
this.
|
|
229
|
-
|
|
230
|
-
|
|
227
|
+
if (!this.backgroundTimer) {
|
|
228
|
+
this.backgroundTimer = setTimeout(() => {
|
|
229
|
+
this.backgroundTimer = undefined;
|
|
230
|
+
this.getRideDisplay().pause(this.getBackgroundPauseRequester());
|
|
231
|
+
this.backgroundPausedByService = true;
|
|
232
|
+
}, BACKGROUND_PAUSE_TIMEOUT_MS);
|
|
233
|
+
}
|
|
231
234
|
this.isInitialized = false;
|
|
232
235
|
return super.pausePage();
|
|
233
236
|
}
|
|
@@ -239,6 +242,7 @@ let RidePageService = (() => {
|
|
|
239
242
|
try {
|
|
240
243
|
if (this.backgroundTimer) {
|
|
241
244
|
clearTimeout(this.backgroundTimer);
|
|
245
|
+
this.backgroundTimer = undefined;
|
|
242
246
|
}
|
|
243
247
|
await this.getRouteVideoAvailability().onForeground();
|
|
244
248
|
return super.resumePage();
|
|
@@ -62,7 +62,9 @@ let Route = (() => {
|
|
|
62
62
|
}
|
|
63
63
|
replace(update) {
|
|
64
64
|
this._description = { ...update._description };
|
|
65
|
-
|
|
65
|
+
if (update._details) {
|
|
66
|
+
this._details = { ...update._details };
|
|
67
|
+
}
|
|
66
68
|
}
|
|
67
69
|
addDetails(details) {
|
|
68
70
|
this._details = details;
|
package/lib/esm/ui/service.js
CHANGED
|
@@ -99,6 +99,7 @@ let UserInterfaceServcie = (() => {
|
|
|
99
99
|
appState = 'Inactive';
|
|
100
100
|
backgroundTimer;
|
|
101
101
|
backgroundPausedByService = false;
|
|
102
|
+
isLaunched = false;
|
|
102
103
|
constructor() {
|
|
103
104
|
super('Incyclist');
|
|
104
105
|
this.bindings = this.getBindings();
|
|
@@ -114,6 +115,10 @@ let UserInterfaceServcie = (() => {
|
|
|
114
115
|
};
|
|
115
116
|
}
|
|
116
117
|
async onAppLaunch(platform, version, appFeatures) {
|
|
118
|
+
if (this.isLaunched) {
|
|
119
|
+
this.logEvent({ message: 'onAppLaunch skipped', reason: 'already-launched' });
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
117
122
|
this.isTerminated = false;
|
|
118
123
|
this.isTerminating = false;
|
|
119
124
|
try {
|
|
@@ -134,6 +139,7 @@ let UserInterfaceServcie = (() => {
|
|
|
134
139
|
this.preloadData();
|
|
135
140
|
this.onSessionStart();
|
|
136
141
|
this.appState = 'Active';
|
|
142
|
+
this.isLaunched = true;
|
|
137
143
|
}
|
|
138
144
|
catch (err) {
|
|
139
145
|
this.logError(err, 'onAppLaunch');
|
|
@@ -159,6 +165,7 @@ let UserInterfaceServcie = (() => {
|
|
|
159
165
|
this.appState = 'Stopped';
|
|
160
166
|
this.logEvent({ message: 'onAppExit finished' });
|
|
161
167
|
this.isTerminated = true;
|
|
168
|
+
this.isLaunched = false;
|
|
162
169
|
return true;
|
|
163
170
|
}
|
|
164
171
|
return false;
|
|
@@ -179,6 +186,7 @@ let UserInterfaceServcie = (() => {
|
|
|
179
186
|
useDeviceAccess().pauseBackgroundActivity()
|
|
180
187
|
.catch((err) => { this.logError(err, 'onAppPause:pauseBackgroundActivity'); });
|
|
181
188
|
this.backgroundTimer = setTimeout(() => {
|
|
189
|
+
this.backgroundTimer = undefined;
|
|
182
190
|
this.backgroundPausedByService = true;
|
|
183
191
|
this.pause().catch((err) => { this.logError(err, 'onAppPause:pause'); });
|
|
184
192
|
}, BACKGROUND_PAUSE_TIMEOUT_MS);
|
|
@@ -199,6 +207,7 @@ let UserInterfaceServcie = (() => {
|
|
|
199
207
|
let resumeRequired = true;
|
|
200
208
|
if (this.backgroundTimer) {
|
|
201
209
|
clearTimeout(this.backgroundTimer);
|
|
210
|
+
this.backgroundTimer = undefined;
|
|
202
211
|
resumeRequired = false;
|
|
203
212
|
}
|
|
204
213
|
this.logEvent({ message: 'onAppResume called' });
|
|
@@ -58,6 +58,10 @@ export class Workout extends Segment {
|
|
|
58
58
|
return s;
|
|
59
59
|
}
|
|
60
60
|
addStep(step) {
|
|
61
|
+
if (step.duration) {
|
|
62
|
+
delete step.start;
|
|
63
|
+
delete step.end;
|
|
64
|
+
}
|
|
61
65
|
if (valid(step)) {
|
|
62
66
|
if (step.duration === undefined && step.start === undefined && step.end === undefined)
|
|
63
67
|
throw new Error(`Invalid Step description, start&end or duration needs to be provided `);
|
|
@@ -72,6 +76,10 @@ export class Workout extends Segment {
|
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
addSegment(segment) {
|
|
79
|
+
if (segment.duration) {
|
|
80
|
+
delete segment.start;
|
|
81
|
+
delete segment.end;
|
|
82
|
+
}
|
|
75
83
|
if (valid(segment)) {
|
|
76
84
|
this.prepareNext(segment);
|
|
77
85
|
if (segment instanceof Segment)
|
|
@@ -20,6 +20,7 @@ export declare class UserInterfaceServcie extends IncyclistService {
|
|
|
20
20
|
protected appState: 'Inactive' | 'Active' | 'Background' | 'Stopped';
|
|
21
21
|
protected backgroundTimer: NodeJS.Timeout | undefined;
|
|
22
22
|
protected backgroundPausedByService: boolean;
|
|
23
|
+
protected isLaunched: boolean;
|
|
23
24
|
constructor();
|
|
24
25
|
getBindings(): IncyclistBindings;
|
|
25
26
|
setBindings(bindings: IncyclistBindings): void;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-services",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"gd-eventlog": "^0.1.27"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@garmin/fitsdk": "^21.
|
|
8
|
+
"@garmin/fitsdk": "^21.217.0",
|
|
9
9
|
"axios": "^1.20.0",
|
|
10
10
|
"incyclist-devices": "^3.0.40",
|
|
11
11
|
"promise.any": "^2.0.6",
|