incyclist-services 1.7.75 → 1.7.77

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.
Files changed (68) hide show
  1. package/lib/cjs/activities/list/service.js +1 -1
  2. package/lib/cjs/activities/ride/service.js +2 -1
  3. package/lib/cjs/services/overpass/overpass.js +25 -23
  4. package/lib/cjs/workouts/base/graph/index.js +18 -0
  5. package/lib/cjs/workouts/base/graph/series.js +162 -0
  6. package/lib/cjs/workouts/base/graph/types.js +2 -0
  7. package/lib/cjs/workouts/base/model/index.js +0 -1
  8. package/lib/cjs/workouts/calendar/service.js +14 -0
  9. package/lib/cjs/workouts/index.js +2 -0
  10. package/lib/cjs/workouts/list/cards/index.js +0 -1
  11. package/lib/cjs/workouts/list/index.js +0 -1
  12. package/lib/cjs/workouts/list/pageService.js +362 -5
  13. package/lib/cjs/workouts/list/service.js +39 -12
  14. package/lib/cjs/workouts/page/index.js +17 -0
  15. package/lib/cjs/workouts/page/service.js +455 -0
  16. package/lib/cjs/workouts/page/types.js +2 -0
  17. package/lib/cjs/workouts/ride/index.js +1 -0
  18. package/lib/cjs/workouts/ride/page/index.js +18 -0
  19. package/lib/cjs/workouts/ride/page/service.js +500 -0
  20. package/lib/cjs/workouts/ride/page/types.js +2 -0
  21. package/lib/cjs/workouts/types.js +2 -0
  22. package/lib/esm/activities/list/service.js +1 -1
  23. package/lib/esm/activities/ride/service.js +2 -1
  24. package/lib/esm/services/overpass/overpass.js +25 -23
  25. package/lib/esm/workouts/base/graph/index.js +2 -0
  26. package/lib/esm/workouts/base/graph/series.js +156 -0
  27. package/lib/esm/workouts/base/graph/types.js +1 -0
  28. package/lib/esm/workouts/base/model/index.js +0 -1
  29. package/lib/esm/workouts/calendar/service.js +14 -0
  30. package/lib/esm/workouts/index.js +2 -0
  31. package/lib/esm/workouts/list/cards/index.js +0 -1
  32. package/lib/esm/workouts/list/index.js +0 -1
  33. package/lib/esm/workouts/list/pageService.js +362 -5
  34. package/lib/esm/workouts/list/service.js +39 -12
  35. package/lib/esm/workouts/page/index.js +1 -0
  36. package/lib/esm/workouts/page/service.js +451 -0
  37. package/lib/esm/workouts/page/types.js +1 -0
  38. package/lib/esm/workouts/ride/index.js +1 -0
  39. package/lib/esm/workouts/ride/page/index.js +2 -0
  40. package/lib/esm/workouts/ride/page/service.js +496 -0
  41. package/lib/esm/workouts/ride/page/types.js +1 -0
  42. package/lib/esm/workouts/types.js +1 -0
  43. package/lib/types/appstate/types.d.ts +1 -1
  44. package/lib/types/services/overpass/overpass.d.ts +1 -1
  45. package/lib/types/types.d.ts +1 -0
  46. package/lib/types/workouts/base/graph/index.d.ts +2 -0
  47. package/lib/types/workouts/base/graph/series.d.ts +7 -0
  48. package/lib/types/workouts/base/graph/types.d.ts +11 -0
  49. package/lib/types/workouts/base/model/index.d.ts +0 -1
  50. package/lib/types/workouts/base/parsers/intervals/parser.d.ts +2 -1
  51. package/lib/types/workouts/calendar/service.d.ts +1 -0
  52. package/lib/types/workouts/index.d.ts +2 -0
  53. package/lib/types/workouts/list/cards/index.d.ts +0 -1
  54. package/lib/types/workouts/list/index.d.ts +0 -1
  55. package/lib/types/workouts/list/pageService.d.ts +136 -4
  56. package/lib/types/workouts/list/service.d.ts +4 -0
  57. package/lib/types/workouts/list/types.d.ts +1 -1
  58. package/lib/types/workouts/page/index.d.ts +1 -0
  59. package/lib/types/workouts/page/service.d.ts +57 -0
  60. package/lib/types/workouts/page/types.d.ts +95 -0
  61. package/lib/types/workouts/ride/index.d.ts +1 -0
  62. package/lib/types/workouts/ride/page/index.d.ts +2 -0
  63. package/lib/types/workouts/ride/page/service.d.ts +71 -0
  64. package/lib/types/workouts/ride/page/types.d.ts +72 -0
  65. package/lib/types/workouts/ride/service.d.ts +2 -1
  66. package/lib/types/workouts/ride/types.d.ts +1 -0
  67. package/lib/types/workouts/types.d.ts +8 -0
  68. 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: true,
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 });
@@ -46,10 +46,10 @@ const gd_eventlog_1 = require("gd-eventlog");
46
46
  const decorators_1 = require("../../base/decorators");
47
47
  const api_1 = require("../../api");
48
48
  const settings_1 = require("../../settings");
49
+ const OVERPASS_URL_PRIMARY = 'https://overpass-api.de/api/interpreter';
49
50
  const OVERPASS_URL_ALT1 = 'https://overpass.kumi.systems/api/interpreter';
50
- const OVERPASS_URL_ALT2 = 'https://lz4.overpass-api.de/api/interpreter';
51
- const OVERPASS_URL_ALT3 = 'https://z.overpass-api.de/api/interpreter';
52
- exports.OVERPASS_URL_DEFAULT = OVERPASS_URL_ALT1;
51
+ const OVERPASS_URL_ALT2 = 'https://overpass.openstreetmap.fr/api/interpreter';
52
+ exports.OVERPASS_URL_DEFAULT = OVERPASS_URL_PRIMARY;
53
53
  let OverpassApi = (() => {
54
54
  let _classDecorators = [types_1.Singleton];
55
55
  let _classDescriptor;
@@ -77,7 +77,7 @@ let OverpassApi = (() => {
77
77
  logger;
78
78
  constructor(props) {
79
79
  super();
80
- this.mirrors = [OVERPASS_URL_ALT1, OVERPASS_URL_ALT2, OVERPASS_URL_ALT3];
80
+ this.mirrors = [OVERPASS_URL_PRIMARY, OVERPASS_URL_ALT1, OVERPASS_URL_ALT2];
81
81
  this.url = props?.url ?? this.mirrors[0];
82
82
  this.logger = new gd_eventlog_1.EventLogger('Overpass');
83
83
  if (props?.url) {
@@ -110,11 +110,7 @@ let OverpassApi = (() => {
110
110
  async post(url, data, conf) {
111
111
  const fetchBinding = this.getBindings()?.fetch;
112
112
  if (fetchBinding) {
113
- try {
114
- return await this.postViaFetchBinding(fetchBinding, url, data);
115
- }
116
- catch {
117
- }
113
+ return await this.postViaFetchBinding(fetchBinding, url, data);
118
114
  }
119
115
  try {
120
116
  const https = require('https');
@@ -132,19 +128,25 @@ let OverpassApi = (() => {
132
128
  async postViaFetchBinding(fetchBinding, url, data) {
133
129
  const headers = this.getOverpassHeaders();
134
130
  const body = typeof data === 'string' ? data : JSON.stringify(data);
135
- const res = await fetchBinding.fetch(url, {
136
- method: 'POST',
137
- headers,
138
- body,
139
- referrerPolicy: 'unsafe-url'
140
- });
141
- return {
142
- data: res.data,
143
- status: res.status,
144
- statusText: res.statusText,
145
- headers: res.headers,
146
- config: {}
147
- };
131
+ try {
132
+ const res = await fetchBinding.fetch(url, {
133
+ method: 'POST',
134
+ headers,
135
+ body,
136
+ referrerPolicy: 'unsafe-url'
137
+ });
138
+ return {
139
+ data: res.data,
140
+ status: res.status,
141
+ statusText: res.statusText,
142
+ headers: res.headers,
143
+ config: {}
144
+ };
145
+ }
146
+ catch (err) {
147
+ this.logger.logEvent({ message: 'fetch error', url, data, error: err.message });
148
+ throw err;
149
+ }
148
150
  }
149
151
  async postViaNodeHttps(https, url, data) {
150
152
  return new Promise((resolve, reject) => {
@@ -287,7 +289,7 @@ let OverpassApi = (() => {
287
289
  throw lastError;
288
290
  }
289
291
  reset() {
290
- this.mirrors = [OVERPASS_URL_ALT1, OVERPASS_URL_ALT2, OVERPASS_URL_ALT3];
292
+ this.mirrors = [OVERPASS_URL_PRIMARY, OVERPASS_URL_ALT1, OVERPASS_URL_ALT2];
291
293
  this.url = this.mirrors[0];
292
294
  }
293
295
  getAppVersion() {
@@ -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,162 @@
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.getWorkoutGraphSeries = getWorkoutGraphSeries;
7
+ const model_1 = require("../model");
8
+ exports.WORKOUT_ZONE_COLORS = [
9
+ 'white',
10
+ '#7f7f7f',
11
+ '#338cff',
12
+ '#59bf59',
13
+ '#ffcc3f',
14
+ '#ff6639',
15
+ '#ff330c',
16
+ '#ea39ff'
17
+ ];
18
+ function getMinPower(step, ftp) {
19
+ if (step?.power === undefined)
20
+ return undefined;
21
+ const p = step.power;
22
+ if (p.max !== undefined && p.min !== undefined && p.max === p.min)
23
+ return 0;
24
+ if (p.min === undefined)
25
+ return undefined;
26
+ let res = Math.round(p.min);
27
+ if (p.type === 'watt' && ftp !== undefined)
28
+ res = Math.round(p.min / ftp * 100);
29
+ return res;
30
+ }
31
+ function getMaxPower(step, ftp) {
32
+ if (step?.power === undefined)
33
+ return 0;
34
+ const p = step.power;
35
+ if (p.max === undefined)
36
+ return undefined;
37
+ let res = Math.round(p.max);
38
+ if (p.type === 'watt' && ftp !== undefined)
39
+ res = Math.round(p.max / ftp * 100);
40
+ return res;
41
+ }
42
+ function getZone(power, ftp) {
43
+ if (power === undefined)
44
+ return undefined;
45
+ if (ftp === undefined)
46
+ return 0;
47
+ if (power <= 55)
48
+ return 1;
49
+ if (power <= 75)
50
+ return 2;
51
+ if (power <= 90)
52
+ return 3;
53
+ if (power <= 105)
54
+ return 4;
55
+ if (power <= 120)
56
+ return 5;
57
+ if (power <= 150)
58
+ return 6;
59
+ return 7;
60
+ }
61
+ function getStepDuration(step) {
62
+ if (step.duration <= 60)
63
+ return `${step.duration}s`;
64
+ if (step.duration <= 3600)
65
+ return `${step.duration / 60}min`;
66
+ return `${step.duration / 3600}h`;
67
+ }
68
+ function formatPowerText(low, high, unit, rangePrefix) {
69
+ if (low !== undefined && high !== undefined && low !== high)
70
+ return `${rangePrefix}${Math.round(low)}-${Math.round(high)}${unit}`;
71
+ if (high !== undefined)
72
+ return `${Math.round(high)}${unit}`;
73
+ return '';
74
+ }
75
+ function appendConvertedSuffix(text, low, high, unit, ftp) {
76
+ if (text === '' || ftp === undefined)
77
+ return text;
78
+ const isPct = unit === '%';
79
+ const convert = (v) => isPct ? Math.round(v / 100 * ftp) : Math.round(v * 100 / ftp);
80
+ const suffixUnit = isPct ? 'W' : '%';
81
+ const range = (low !== undefined && high !== undefined && low !== high)
82
+ ? `${convert(low)}-${convert(high)}`
83
+ : `${convert(high)}`;
84
+ return `${text} (${range}${suffixUnit})`;
85
+ }
86
+ function getStepPower(step, ftp) {
87
+ if (step.power === undefined)
88
+ return '';
89
+ const { min, max, type } = step.power;
90
+ const unit = type === 'watt' ? 'W' : '%';
91
+ const ascending = step.steady || step.cooldown === false;
92
+ const low = ascending ? min : max;
93
+ const high = ascending ? max : min;
94
+ const rangePrefix = step.steady ? '' : 'Ramp ';
95
+ const stepText = formatPowerText(low, high, unit, rangePrefix);
96
+ return appendConvertedSuffix(stepText, low, high, unit, ftp);
97
+ }
98
+ function coerceToWorkout(workout) {
99
+ if (workout instanceof model_1.Workout)
100
+ return workout;
101
+ try {
102
+ return new model_1.Workout(workout);
103
+ }
104
+ catch {
105
+ return undefined;
106
+ }
107
+ }
108
+ function buildSteadyBar(step, stepStart, ftp, absValues) {
109
+ const x0 = stepStart;
110
+ const x = stepStart + step.getDuration();
111
+ let y = getMaxPower(step, ftp);
112
+ let y0 = getMinPower(step, ftp);
113
+ const zone = getZone(y, ftp);
114
+ if (absValues && ftp) {
115
+ y = ftp * y / 100;
116
+ y0 = ftp * y0 / 100;
117
+ }
118
+ if (y === undefined || Number.isNaN(y))
119
+ return undefined;
120
+ if (y0 !== undefined && !Number.isNaN(y0))
121
+ return { x, x0, y, y0, zone };
122
+ if (y0 === undefined)
123
+ return { x, x0, y, y0: 0, zone };
124
+ return undefined;
125
+ }
126
+ function buildRampBars(wo, step, stepStart, ftp, absValues) {
127
+ const bars = [];
128
+ const stepSize = step.getDuration() / 10;
129
+ for (let i = 0; i < 10; i++) {
130
+ const x0 = stepStart + i * stepSize;
131
+ const x = x0 + stepSize;
132
+ const limit = wo.getLimits(x0 + 0.01);
133
+ let y = getMaxPower(limit, ftp);
134
+ const zone = getZone(y, ftp);
135
+ if (absValues && ftp)
136
+ y = ftp * y / 100;
137
+ if (y !== undefined && !Number.isNaN(y))
138
+ bars.push({ x, x0, y, y0: 0, zone });
139
+ }
140
+ return bars;
141
+ }
142
+ function getWorkoutGraphSeries(workout, opts) {
143
+ const { ftp, absValues = false } = opts ?? {};
144
+ const wo = coerceToWorkout(workout);
145
+ if (!wo)
146
+ return [];
147
+ const bars = [];
148
+ let stepStart = 0;
149
+ for (let limits = wo.getLimits(0, true); limits !== undefined; limits = wo.getLimits(stepStart + 0.01, true)) {
150
+ const step = limits.step;
151
+ if (step.steady) {
152
+ const bar = buildSteadyBar(step, stepStart, ftp, absValues);
153
+ if (bar)
154
+ bars.push(bar);
155
+ }
156
+ else {
157
+ bars.push(...buildRampBars(wo, step, stepStart, ftp, absValues));
158
+ }
159
+ stepStart += step.getDuration();
160
+ }
161
+ return bars;
162
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -17,4 +17,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Workout"), exports);
18
18
  __exportStar(require("./Segment"), exports);
19
19
  __exportStar(require("./Step"), exports);
20
- __exportStar(require("./types"), exports);
@@ -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);