incyclist-services 1.7.94 → 1.7.96

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 (77) hide show
  1. package/lib/cjs/activities/upload/index.js +0 -1
  2. package/lib/cjs/apps/index.js +0 -1
  3. package/lib/cjs/apps/service.js +1 -3
  4. package/lib/cjs/devices/page/service.js +9 -3
  5. package/lib/cjs/devices/page/statemachine.js +14 -4
  6. package/lib/cjs/devices/ride/cyclingMode.js +29 -0
  7. package/lib/cjs/devices/ride/index.js +1 -0
  8. package/lib/cjs/ride/display/service.js +7 -13
  9. package/lib/cjs/ride/page/index.js +1 -0
  10. package/lib/cjs/ride/page/service.js +458 -124
  11. package/lib/cjs/ride/workout/WorkoutDisplayService.js +6 -2
  12. package/lib/cjs/workouts/ride/index.js +0 -1
  13. package/lib/cjs/workouts/ride/service.js +80 -11
  14. package/lib/esm/activities/upload/index.js +0 -1
  15. package/lib/esm/apps/index.js +0 -1
  16. package/lib/esm/apps/service.js +1 -3
  17. package/lib/esm/devices/page/service.js +9 -3
  18. package/lib/esm/devices/page/statemachine.js +14 -4
  19. package/lib/esm/devices/ride/cyclingMode.js +25 -0
  20. package/lib/esm/devices/ride/index.js +1 -0
  21. package/lib/esm/ride/display/service.js +8 -14
  22. package/lib/esm/ride/page/index.js +1 -0
  23. package/lib/esm/ride/page/service.js +458 -124
  24. package/lib/esm/ride/workout/WorkoutDisplayService.js +6 -2
  25. package/lib/esm/workouts/ride/index.js +0 -1
  26. package/lib/esm/workouts/ride/page/service.js +13 -2
  27. package/lib/esm/workouts/ride/service.js +81 -12
  28. package/lib/types/activities/ride/service.d.ts +1 -1
  29. package/lib/types/activities/ride/types.d.ts +1 -1
  30. package/lib/types/activities/upload/index.d.ts +0 -1
  31. package/lib/types/apps/index.d.ts +0 -1
  32. package/lib/types/appstate/types.d.ts +1 -1
  33. package/lib/types/devices/page/statemachine.d.ts +2 -0
  34. package/lib/types/devices/ride/cyclingMode.d.ts +4 -0
  35. package/lib/types/devices/ride/index.d.ts +1 -0
  36. package/lib/types/ride/page/index.d.ts +1 -0
  37. package/lib/types/ride/page/service.d.ts +69 -17
  38. package/lib/types/ride/page/types.d.ts +84 -8
  39. package/lib/types/workouts/ride/index.d.ts +0 -1
  40. package/lib/types/workouts/ride/page/service.d.ts +2 -1
  41. package/lib/types/workouts/ride/page/types.d.ts +3 -0
  42. package/lib/types/workouts/ride/service.d.ts +10 -1
  43. package/lib/types/workouts/ride/types.d.ts +10 -1
  44. package/lib/types/workouts/types.d.ts +0 -1
  45. package/package.json +1 -1
  46. package/lib/cjs/activities/upload/velohero.js +0 -136
  47. package/lib/cjs/apps/velohero/VeloHeroAppConnection.js +0 -232
  48. package/lib/cjs/apps/velohero/index.js +0 -18
  49. package/lib/cjs/apps/velohero/types.js +0 -2
  50. package/lib/cjs/workouts/list/pageService.js +0 -455
  51. package/lib/cjs/workouts/ride/page/index.js +0 -18
  52. package/lib/cjs/workouts/ride/page/service.js +0 -553
  53. package/lib/cjs/workouts/ride/page/types.js +0 -2
  54. package/lib/esm/activities/upload/trainingpeaks.js +0 -123
  55. package/lib/esm/activities/upload/velohero.js +0 -133
  56. package/lib/esm/apps/base/api/trainingpeaks/api.js +0 -143
  57. package/lib/esm/apps/base/api/trainingpeaks/index.js +0 -1
  58. package/lib/esm/apps/base/api/trainingpeaks/types.js +0 -1
  59. package/lib/esm/apps/trainingpeaks/TrainingPeaksAppConnection.js +0 -189
  60. package/lib/esm/apps/trainingpeaks/types.js +0 -1
  61. package/lib/esm/apps/velohero/VeloHeroAppConnection.js +0 -229
  62. package/lib/esm/apps/velohero/index.js +0 -2
  63. package/lib/esm/apps/velohero/types.js +0 -1
  64. package/lib/esm/workouts/calendar/sync/trainingpeaks/provider.js +0 -201
  65. package/lib/esm/workouts/list/pageService.js +0 -451
  66. package/lib/types/activities/upload/trainingpeaks.d.ts +0 -16
  67. package/lib/types/activities/upload/velohero.d.ts +0 -18
  68. package/lib/types/apps/base/api/trainingpeaks/api.d.ts +0 -30
  69. package/lib/types/apps/base/api/trainingpeaks/index.d.ts +0 -2
  70. package/lib/types/apps/base/api/trainingpeaks/types.d.ts +0 -55
  71. package/lib/types/apps/trainingpeaks/TrainingPeaksAppConnection.d.ts +0 -22
  72. package/lib/types/apps/trainingpeaks/types.d.ts +0 -6
  73. package/lib/types/apps/velohero/VeloHeroAppConnection.d.ts +0 -24
  74. package/lib/types/apps/velohero/index.d.ts +0 -2
  75. package/lib/types/apps/velohero/types.d.ts +0 -9
  76. package/lib/types/workouts/calendar/sync/trainingpeaks/provider.d.ts +0 -22
  77. package/lib/types/workouts/list/pageService.d.ts +0 -150
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./velohero"), exports);
18
17
  __exportStar(require("./strava"), exports);
19
18
  __exportStar(require("./intervals"), exports);
20
19
  __exportStar(require("./types"), exports);
@@ -18,4 +18,3 @@ __exportStar(require("./base"), exports);
18
18
  __exportStar(require("./googleMaps"), exports);
19
19
  __exportStar(require("./service"), exports);
20
20
  __exportStar(require("./strava"), exports);
21
- __exportStar(require("./velohero"), exports);
@@ -43,7 +43,6 @@ const settings_1 = require("../settings");
43
43
  const base_1 = require("./base");
44
44
  const IntervalsAppConnection_1 = require("./intervals/IntervalsAppConnection");
45
45
  const komoot_1 = require("./komoot");
46
- const VeloHeroAppConnection_1 = require("./velohero/VeloHeroAppConnection");
47
46
  let AppsService = (() => {
48
47
  let _classDecorators = [types_1.Singleton];
49
48
  let _classDescriptor;
@@ -67,7 +66,7 @@ let AppsService = (() => {
67
66
  __runInitializers(_classThis, _classExtraInitializers);
68
67
  }
69
68
  services = (__runInitializers(this, _instanceExtraInitializers), {
70
- ActivityUpload: ['strava', 'velohero', 'intervals'],
69
+ ActivityUpload: ['strava', 'intervals'],
71
70
  WorkoutUpload: [],
72
71
  WorkoutDownload: ['intervals'],
73
72
  ActivityDownload: [],
@@ -75,7 +74,6 @@ let AppsService = (() => {
75
74
  });
76
75
  serviceMap = [
77
76
  { name: 'Strava', key: 'strava', iconUrl: 'https://static.cdnlogo.com/logos/s/42/strava-wordmark.svg', connection: new base_1.StravaAppConnection() },
78
- { name: 'VeloHero', key: 'velohero', iconUrl: 'images/velo-white.png', connection: new VeloHeroAppConnection_1.VeloHeroAppConnection() },
79
77
  { name: 'Komoot', key: 'komoot', iconUrl: 'https://www.komoot.com/assets/4d8ae313eec53e6e.svg', connection: new komoot_1.KomootAppConnection() },
80
78
  { name: 'Intervals.icu', key: 'intervals', iconUrl: 'images/intervals.png', connection: new IntervalsAppConnection_1.IntervalsAppConnection() },
81
79
  ];
@@ -95,9 +95,15 @@ let DevicesPageService = (() => {
95
95
  if (this.promiseOpen !== undefined) {
96
96
  return this.getPageObserver();
97
97
  }
98
- this.stateMachine.start(() => {
98
+ const onStateMachineUpdate = () => {
99
99
  this.getPageObserver().emit('page-update');
100
- });
100
+ };
101
+ this.stateMachine.start(onStateMachineUpdate);
102
+ if (this.stateMachine.state !== 'Idle') {
103
+ this.logEvent({ message: 'state machine was not in expected state on open, resetting', page: 'Pairing', state: this.stateMachine.state });
104
+ this.stateMachine.stop();
105
+ this.stateMachine.start(onStateMachineUpdate);
106
+ }
101
107
  this.promiseOpen = new Promise((done) => {
102
108
  this.start()
103
109
  .catch((err) => { this.logError(err, 'openPage'); })
@@ -321,7 +327,7 @@ let DevicesPageService = (() => {
321
327
  this.updatePage();
322
328
  }
323
329
  async closeDeviceSelection(enabled) {
324
- this.logEvent({ message: 'capability closed', capability: this.openedCapability });
330
+ this.logEvent({ message: 'capability closed', capability: this.openedCapability, enabled, caller: new Error().stack });
325
331
  if (!enabled) {
326
332
  const all = this.state.capabilities ?? [];
327
333
  const requested = all.find(c => c.capability === this.openedCapability);
@@ -68,6 +68,8 @@ let PairingPageStateMachine = (() => {
68
68
  selectStateChangeCallback;
69
69
  retryTimeout;
70
70
  selectionTimeout;
71
+ pairingPromise;
72
+ scanningPromise;
71
73
  constructor() {
72
74
  this.logger = new gd_eventlog_1.EventLogger('PairingPageState');
73
75
  }
@@ -99,6 +101,8 @@ let PairingPageStateMachine = (() => {
99
101
  this.unregisterServiceEventHandlers();
100
102
  delete this.stateChangeCallback;
101
103
  this.resetTimeouts();
104
+ delete this.pairingPromise;
105
+ delete this.scanningPromise;
102
106
  this.setState('Closed');
103
107
  this.logIncomingEvent('stop', prev, 'Closed');
104
108
  }
@@ -199,14 +203,20 @@ let PairingPageStateMachine = (() => {
199
203
  this.resetTimeouts();
200
204
  this.setState('Done');
201
205
  }
202
- else {
206
+ else if (!this.pairingPromise) {
203
207
  this.setState('Pairing');
204
- service.startPairing(adapters, {});
208
+ this.pairingPromise = Promise.resolve(service.startPairing(adapters, {}))
209
+ .catch(err => { this.logError(err, 'startPairing'); })
210
+ .finally(() => { delete this.pairingPromise; });
205
211
  }
206
212
  }
207
213
  else if (this.selectState === 'Closed' || this.selectState === 'Active') {
208
- this.setState('Scanning');
209
- service.startScanning(adapters, {});
214
+ if (!this.scanningPromise) {
215
+ this.setState('Scanning');
216
+ this.scanningPromise = Promise.resolve(service.startScanning(adapters, {}))
217
+ .catch(err => { this.logError(err, 'startScanning'); })
218
+ .finally(() => { delete this.scanningPromise; });
219
+ }
210
220
  }
211
221
  if (this.state !== oldState)
212
222
  this.logger.logEvent({ message: 'state changed', stateTransition: { from: oldState, to: this.state } });
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isVirtualShiftingEnabled = isVirtualShiftingEnabled;
4
+ exports.getLoadButtonMode = getLoadButtonMode;
5
+ function isVirtualShiftingEnabled(mode) {
6
+ try {
7
+ if (!mode)
8
+ return false;
9
+ if (mode.isSIM()) {
10
+ const virtshiftMode = mode.getSetting('virtshift');
11
+ return (virtshiftMode === 'Mixed' || virtshiftMode === 'Incyclist' || virtshiftMode === 'SmartTrainer' || virtshiftMode === 'Enabled');
12
+ }
13
+ if (mode.isResistance()) {
14
+ return true;
15
+ }
16
+ return false;
17
+ }
18
+ catch {
19
+ return false;
20
+ }
21
+ }
22
+ function getLoadButtonMode(mode) {
23
+ if (!mode)
24
+ return 'power';
25
+ if (mode.isSIM() || mode.isResistance()) {
26
+ return isVirtualShiftingEnabled(mode) ? 'gear' : 'hidden';
27
+ }
28
+ return 'power';
29
+ }
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./service"), exports);
18
+ __exportStar(require("./cyclingMode"), exports);
@@ -432,8 +432,11 @@ let RideDisplayService = (() => {
432
432
  this.observer?.stop({ immediately: props.noStateUpdates });
433
433
  if (props.noStateUpdates)
434
434
  delete this.observer;
435
- else
436
- (0, utils_1.waitNextTick)().then(() => delete this.observer);
435
+ else {
436
+ const observerToClear = this.observer;
437
+ (0, utils_1.waitNextTick)().then(() => { if (this.observer === observerToClear)
438
+ delete this.observer; });
439
+ }
437
440
  if (prevState === 'Finished' || prevState === 'Idle' || prevState === 'Closing') {
438
441
  this.state = 'Idle';
439
442
  return;
@@ -553,7 +556,7 @@ let RideDisplayService = (() => {
553
556
  const { time, speed, routeDistance, distance } = currentValues;
554
557
  const data = { time, speed, routeDistance, distance };
555
558
  this.getRideModeService().onActivityUpdate(data, currentValues);
556
- this.observer.emit('data-update', data, currentValues);
559
+ this.observer?.emit('data-update', data, currentValues);
557
560
  }
558
561
  }
559
562
  onWorkoutStopped() {
@@ -1085,16 +1088,7 @@ let RideDisplayService = (() => {
1085
1088
  isVirtualShiftingEnabled() {
1086
1089
  try {
1087
1090
  const mode = this.getDeviceRide().getCyclingMode();
1088
- if (!mode)
1089
- return false;
1090
- if (mode.isSIM()) {
1091
- const virtshiftMode = mode.getSetting('virtshift');
1092
- return (virtshiftMode === 'Mixed' || virtshiftMode === 'Incyclist' || virtshiftMode === 'SmartTrainer' || virtshiftMode === 'Enabled');
1093
- }
1094
- if (mode.isResistance()) {
1095
- return true;
1096
- }
1097
- return false;
1091
+ return (0, devices_1.isVirtualShiftingEnabled)(mode);
1098
1092
  }
1099
1093
  catch (err) {
1100
1094
  this.logError(err, 'isVirtualShiftingEnabled');
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./service"), exports);
18
+ __exportStar(require("./types"), exports);