incyclist-services 1.7.76 → 1.7.78
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/list/service.js +1 -1
- package/lib/cjs/activities/ride/service.js +2 -1
- package/lib/cjs/workouts/base/graph/index.js +18 -0
- package/lib/cjs/workouts/base/graph/series.js +205 -0
- package/lib/cjs/workouts/base/graph/types.js +2 -0
- package/lib/cjs/workouts/base/model/index.js +0 -1
- package/lib/cjs/workouts/calendar/service.js +14 -0
- package/lib/cjs/workouts/index.js +2 -0
- package/lib/cjs/workouts/list/cards/index.js +0 -1
- package/lib/cjs/workouts/list/index.js +0 -1
- package/lib/cjs/workouts/list/pageService.js +362 -5
- package/lib/cjs/workouts/list/service.js +39 -12
- package/lib/cjs/workouts/page/index.js +17 -0
- package/lib/cjs/workouts/page/service.js +455 -0
- package/lib/cjs/workouts/page/types.js +2 -0
- package/lib/cjs/workouts/ride/index.js +1 -0
- package/lib/cjs/workouts/ride/page/index.js +18 -0
- package/lib/cjs/workouts/ride/page/service.js +498 -0
- package/lib/cjs/workouts/ride/page/types.js +2 -0
- package/lib/cjs/workouts/ride/service.js +1 -1
- package/lib/cjs/workouts/types.js +2 -0
- package/lib/esm/activities/list/service.js +1 -1
- package/lib/esm/activities/ride/service.js +2 -1
- package/lib/esm/workouts/base/graph/index.js +2 -0
- package/lib/esm/workouts/base/graph/series.js +197 -0
- package/lib/esm/workouts/base/graph/types.js +1 -0
- package/lib/esm/workouts/base/model/index.js +0 -1
- package/lib/esm/workouts/calendar/service.js +14 -0
- package/lib/esm/workouts/index.js +2 -0
- package/lib/esm/workouts/list/cards/index.js +0 -1
- package/lib/esm/workouts/list/index.js +0 -1
- package/lib/esm/workouts/list/pageService.js +362 -5
- package/lib/esm/workouts/list/service.js +39 -12
- package/lib/esm/workouts/page/index.js +1 -0
- package/lib/esm/workouts/page/service.js +451 -0
- package/lib/esm/workouts/page/types.js +1 -0
- package/lib/esm/workouts/ride/index.js +1 -0
- package/lib/esm/workouts/ride/page/index.js +2 -0
- package/lib/esm/workouts/ride/page/service.js +494 -0
- package/lib/esm/workouts/ride/page/types.js +1 -0
- package/lib/esm/workouts/ride/service.js +1 -1
- package/lib/esm/workouts/types.js +1 -0
- package/lib/types/types.d.ts +1 -0
- package/lib/types/workouts/base/graph/index.d.ts +2 -0
- package/lib/types/workouts/base/graph/series.d.ts +18 -0
- package/lib/types/workouts/base/graph/types.d.ts +11 -0
- package/lib/types/workouts/base/model/index.d.ts +0 -1
- package/lib/types/workouts/base/parsers/intervals/parser.d.ts +2 -1
- package/lib/types/workouts/calendar/service.d.ts +1 -0
- package/lib/types/workouts/index.d.ts +2 -0
- package/lib/types/workouts/list/cards/index.d.ts +0 -1
- package/lib/types/workouts/list/index.d.ts +0 -1
- package/lib/types/workouts/list/pageService.d.ts +136 -4
- package/lib/types/workouts/list/service.d.ts +4 -0
- package/lib/types/workouts/list/types.d.ts +1 -1
- package/lib/types/workouts/page/index.d.ts +1 -0
- package/lib/types/workouts/page/service.d.ts +57 -0
- package/lib/types/workouts/page/types.d.ts +95 -0
- package/lib/types/workouts/ride/index.d.ts +1 -0
- package/lib/types/workouts/ride/page/index.d.ts +2 -0
- package/lib/types/workouts/ride/page/service.d.ts +70 -0
- package/lib/types/workouts/ride/page/types.d.ts +71 -0
- package/lib/types/workouts/ride/service.d.ts +2 -1
- package/lib/types/workouts/ride/types.d.ts +3 -0
- package/lib/types/workouts/types.d.ts +8 -0
- package/package.json +1 -1
|
@@ -404,7 +404,7 @@ let ActivityListService = (() => {
|
|
|
404
404
|
startPos,
|
|
405
405
|
segment: activity?.segment,
|
|
406
406
|
started: activity ? new Date(activity.startTime) : undefined,
|
|
407
|
-
showMap:
|
|
407
|
+
showMap: activity?.routeType !== 'None',
|
|
408
408
|
points,
|
|
409
409
|
activity,
|
|
410
410
|
exports: this.exports,
|
|
@@ -425,10 +425,11 @@ let ActivityRideService = (() => {
|
|
|
425
425
|
const route = this.getRouteList().getSelected();
|
|
426
426
|
const startSettings = this.getRouteList().getStartSettings();
|
|
427
427
|
const isFreeRide = startSettings?.type === 'Free-Ride';
|
|
428
|
+
const isWorkout = this.activity?.routeType === 'None';
|
|
428
429
|
const showSave = this.activity !== undefined && !this.isSaveDone;
|
|
429
430
|
const showContinue = this.state !== 'completed';
|
|
430
431
|
const hasGPX = this.activity?.logs?.some((log) => !!log.lat && !!log.lng);
|
|
431
|
-
const showMap = hasGPX || isFreeRide || (route?.description?.hasGpx);
|
|
432
|
+
const showMap = hasGPX || isFreeRide || isWorkout || (route?.description?.hasGpx);
|
|
432
433
|
const preview = showMap ? undefined : route?.description?.previewUrl;
|
|
433
434
|
if (!this.isSummaryShown) {
|
|
434
435
|
this.logEvent({ message: 'activity summary shown', showSave, showContinue, showMap, fileLink: this.activity?.fitFileName });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./series"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WORKOUT_ZONE_COLORS = void 0;
|
|
4
|
+
exports.getStepDuration = getStepDuration;
|
|
5
|
+
exports.getStepPower = getStepPower;
|
|
6
|
+
exports.getStepTargetText = getStepTargetText;
|
|
7
|
+
exports.getFlattenedSteps = getFlattenedSteps;
|
|
8
|
+
exports.getWorkoutGraphSeries = getWorkoutGraphSeries;
|
|
9
|
+
const model_1 = require("../model");
|
|
10
|
+
exports.WORKOUT_ZONE_COLORS = [
|
|
11
|
+
'white',
|
|
12
|
+
'#7f7f7f',
|
|
13
|
+
'#338cff',
|
|
14
|
+
'#59bf59',
|
|
15
|
+
'#ffcc3f',
|
|
16
|
+
'#ff6639',
|
|
17
|
+
'#ff330c',
|
|
18
|
+
'#ea39ff'
|
|
19
|
+
];
|
|
20
|
+
function getMinPower(step, ftp) {
|
|
21
|
+
if (step?.power === undefined)
|
|
22
|
+
return undefined;
|
|
23
|
+
const p = step.power;
|
|
24
|
+
if (p.max !== undefined && p.min !== undefined && p.max === p.min)
|
|
25
|
+
return 0;
|
|
26
|
+
if (p.min === undefined)
|
|
27
|
+
return undefined;
|
|
28
|
+
let res = Math.round(p.min);
|
|
29
|
+
if (p.type === 'watt' && ftp !== undefined)
|
|
30
|
+
res = Math.round(p.min / ftp * 100);
|
|
31
|
+
return res;
|
|
32
|
+
}
|
|
33
|
+
function getMaxPower(step, ftp) {
|
|
34
|
+
if (step?.power === undefined)
|
|
35
|
+
return 0;
|
|
36
|
+
const p = step.power;
|
|
37
|
+
if (p.max === undefined)
|
|
38
|
+
return undefined;
|
|
39
|
+
let res = Math.round(p.max);
|
|
40
|
+
if (p.type === 'watt' && ftp !== undefined)
|
|
41
|
+
res = Math.round(p.max / ftp * 100);
|
|
42
|
+
return res;
|
|
43
|
+
}
|
|
44
|
+
function getZone(power, ftp) {
|
|
45
|
+
if (power === undefined)
|
|
46
|
+
return undefined;
|
|
47
|
+
if (ftp === undefined)
|
|
48
|
+
return 0;
|
|
49
|
+
if (power <= 55)
|
|
50
|
+
return 1;
|
|
51
|
+
if (power <= 75)
|
|
52
|
+
return 2;
|
|
53
|
+
if (power <= 90)
|
|
54
|
+
return 3;
|
|
55
|
+
if (power <= 105)
|
|
56
|
+
return 4;
|
|
57
|
+
if (power <= 120)
|
|
58
|
+
return 5;
|
|
59
|
+
if (power <= 150)
|
|
60
|
+
return 6;
|
|
61
|
+
return 7;
|
|
62
|
+
}
|
|
63
|
+
function getStepDuration(step) {
|
|
64
|
+
if (step.duration <= 60)
|
|
65
|
+
return `${step.duration}s`;
|
|
66
|
+
if (step.duration <= 3600)
|
|
67
|
+
return `${step.duration / 60}min`;
|
|
68
|
+
return `${step.duration / 3600}h`;
|
|
69
|
+
}
|
|
70
|
+
function formatPowerText(low, high, unit, rangePrefix) {
|
|
71
|
+
if (low !== undefined && high !== undefined && low !== high)
|
|
72
|
+
return `${rangePrefix}${Math.round(low)}-${Math.round(high)}${unit}`;
|
|
73
|
+
if (high !== undefined)
|
|
74
|
+
return `${Math.round(high)}${unit}`;
|
|
75
|
+
return '';
|
|
76
|
+
}
|
|
77
|
+
function appendConvertedSuffix(text, low, high, unit, ftp) {
|
|
78
|
+
if (text === '' || ftp === undefined)
|
|
79
|
+
return text;
|
|
80
|
+
const isPct = unit === '%';
|
|
81
|
+
const convert = (v) => isPct ? Math.round(v / 100 * ftp) : Math.round(v * 100 / ftp);
|
|
82
|
+
const suffixUnit = isPct ? 'W' : '%';
|
|
83
|
+
const range = (low !== undefined && high !== undefined && low !== high)
|
|
84
|
+
? `${convert(low)}-${convert(high)}`
|
|
85
|
+
: `${convert(high)}`;
|
|
86
|
+
return `${text} (${range}${suffixUnit})`;
|
|
87
|
+
}
|
|
88
|
+
function getStepPower(step, ftp) {
|
|
89
|
+
if (step.power === undefined)
|
|
90
|
+
return '';
|
|
91
|
+
const { min, max, type } = step.power;
|
|
92
|
+
const unit = type === 'watt' ? 'W' : '%';
|
|
93
|
+
const ascending = step.steady || step.cooldown === false;
|
|
94
|
+
const low = ascending ? min : max;
|
|
95
|
+
const high = ascending ? max : min;
|
|
96
|
+
const rangePrefix = step.steady ? '' : 'Ramp ';
|
|
97
|
+
const stepText = formatPowerText(low, high, unit, rangePrefix);
|
|
98
|
+
return appendConvertedSuffix(stepText, low, high, unit, ftp);
|
|
99
|
+
}
|
|
100
|
+
function resolvePowerWatts(power, ftp) {
|
|
101
|
+
if (!power)
|
|
102
|
+
return {};
|
|
103
|
+
const toWatts = (v) => {
|
|
104
|
+
if (v === undefined)
|
|
105
|
+
return undefined;
|
|
106
|
+
if (power.type === 'watt')
|
|
107
|
+
return Math.round(v);
|
|
108
|
+
return ftp === undefined ? undefined : Math.round(v / 100 * ftp);
|
|
109
|
+
};
|
|
110
|
+
return { min: toWatts(power.min), max: toWatts(power.max) };
|
|
111
|
+
}
|
|
112
|
+
function formatRange(low, high, unit, rangePrefix = '') {
|
|
113
|
+
if (low !== undefined && high !== undefined && Math.round(low) !== Math.round(high))
|
|
114
|
+
return `${rangePrefix}${Math.round(low)}-${Math.round(high)}${unit}`;
|
|
115
|
+
const v = high ?? low;
|
|
116
|
+
return v === undefined ? '' : `${Math.round(v)}${unit}`;
|
|
117
|
+
}
|
|
118
|
+
function getStepTargetText(step, ftp, powerOverrideWatts) {
|
|
119
|
+
const { min: minPower, max: maxPower } = powerOverrideWatts ?? resolvePowerWatts(step.power, ftp);
|
|
120
|
+
const ascending = step.steady || step.cooldown === false;
|
|
121
|
+
const lowPower = ascending ? minPower : maxPower;
|
|
122
|
+
const highPower = ascending ? maxPower : minPower;
|
|
123
|
+
const rangePrefix = step.steady ? '' : 'Ramp ';
|
|
124
|
+
const powerText = formatRange(lowPower, highPower, 'W', rangePrefix);
|
|
125
|
+
const hrText = formatRange(step.hrm?.min, step.hrm?.max, 'HR');
|
|
126
|
+
const cadenceText = formatRange(step.cadence?.min, step.cadence?.max, ' rpm');
|
|
127
|
+
const parts = [powerText, hrText, cadenceText].filter(Boolean);
|
|
128
|
+
return parts.length ? parts.join(' at ') : 'free';
|
|
129
|
+
}
|
|
130
|
+
function coerceToWorkout(workout) {
|
|
131
|
+
if (workout instanceof model_1.Workout)
|
|
132
|
+
return workout;
|
|
133
|
+
try {
|
|
134
|
+
return new model_1.Workout(workout);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function buildSteadyBar(step, stepStart, ftp, absValues) {
|
|
141
|
+
const x0 = stepStart;
|
|
142
|
+
const x = stepStart + step.getDuration();
|
|
143
|
+
let y = getMaxPower(step, ftp);
|
|
144
|
+
let y0 = getMinPower(step, ftp);
|
|
145
|
+
const zone = getZone(y, ftp);
|
|
146
|
+
if (absValues && ftp) {
|
|
147
|
+
y = ftp * y / 100;
|
|
148
|
+
y0 = ftp * y0 / 100;
|
|
149
|
+
}
|
|
150
|
+
if (y === undefined || Number.isNaN(y))
|
|
151
|
+
return undefined;
|
|
152
|
+
if (y0 !== undefined && !Number.isNaN(y0))
|
|
153
|
+
return { x, x0, y, y0, zone };
|
|
154
|
+
if (y0 === undefined)
|
|
155
|
+
return { x, x0, y, y0: 0, zone };
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
function buildRampBars(wo, step, stepStart, ftp, absValues) {
|
|
159
|
+
const bars = [];
|
|
160
|
+
const stepSize = step.getDuration() / 10;
|
|
161
|
+
for (let i = 0; i < 10; i++) {
|
|
162
|
+
const x0 = stepStart + i * stepSize;
|
|
163
|
+
const x = x0 + stepSize;
|
|
164
|
+
const limit = wo.getLimits(x0 + 0.01);
|
|
165
|
+
let y = getMaxPower(limit, ftp);
|
|
166
|
+
const zone = getZone(y, ftp);
|
|
167
|
+
if (absValues && ftp)
|
|
168
|
+
y = ftp * y / 100;
|
|
169
|
+
if (y !== undefined && !Number.isNaN(y))
|
|
170
|
+
bars.push({ x, x0, y, y0: 0, zone });
|
|
171
|
+
}
|
|
172
|
+
return bars;
|
|
173
|
+
}
|
|
174
|
+
function getFlattenedSteps(workout) {
|
|
175
|
+
const wo = coerceToWorkout(workout);
|
|
176
|
+
if (!wo)
|
|
177
|
+
return [];
|
|
178
|
+
const result = [];
|
|
179
|
+
let stepStart = 0;
|
|
180
|
+
for (let limits = wo.getLimits(0, true); limits !== undefined; limits = wo.getLimits(stepStart + 0.01, true)) {
|
|
181
|
+
const step = limits.step;
|
|
182
|
+
const duration = step.getDuration();
|
|
183
|
+
result.push({ step, start: stepStart, end: stepStart + duration, duration });
|
|
184
|
+
stepStart += duration;
|
|
185
|
+
}
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
188
|
+
function getWorkoutGraphSeries(workout, opts) {
|
|
189
|
+
const { ftp, absValues = false } = opts ?? {};
|
|
190
|
+
const wo = coerceToWorkout(workout);
|
|
191
|
+
if (!wo)
|
|
192
|
+
return [];
|
|
193
|
+
const bars = [];
|
|
194
|
+
getFlattenedSteps(wo).forEach(({ step, start: stepStart }) => {
|
|
195
|
+
if (step.steady) {
|
|
196
|
+
const bar = buildSteadyBar(step, stepStart, ftp, absValues);
|
|
197
|
+
if (bar)
|
|
198
|
+
bars.push(bar);
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
bars.push(...buildRampBars(wo, step, stepStart, ftp, absValues));
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
return bars;
|
|
205
|
+
}
|
|
@@ -136,6 +136,20 @@ let WorkoutCalendarService = (() => {
|
|
|
136
136
|
}
|
|
137
137
|
return [];
|
|
138
138
|
}
|
|
139
|
+
getScheduledToday() {
|
|
140
|
+
try {
|
|
141
|
+
if (!this.workouts)
|
|
142
|
+
return undefined;
|
|
143
|
+
const now = new Date();
|
|
144
|
+
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
145
|
+
const entry = this.workouts.find(w => w.day?.toLocaleDateString() === today.toLocaleDateString());
|
|
146
|
+
return entry ? this.getScheduledWorkout(entry) : undefined;
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
this.logError(err, 'getScheduledToday');
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
139
153
|
setActive(active) {
|
|
140
154
|
try {
|
|
141
155
|
this.listActive = active;
|
|
@@ -17,3 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./list"), exports);
|
|
18
18
|
__exportStar(require("./ride"), exports);
|
|
19
19
|
__exportStar(require("./base/model"), exports);
|
|
20
|
+
__exportStar(require("./base/graph"), exports);
|
|
21
|
+
__exportStar(require("./page"), exports);
|
|
@@ -17,4 +17,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./WorkoutCreateCard"), exports);
|
|
18
18
|
__exportStar(require("./WorkoutImportCard"), exports);
|
|
19
19
|
__exportStar(require("./WorkoutCard"), exports);
|
|
20
|
-
__exportStar(require("./types"), exports);
|
|
@@ -16,4 +16,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./service"), exports);
|
|
18
18
|
__exportStar(require("./cards"), exports);
|
|
19
|
-
__exportStar(require("./pageService"), exports);
|