incyclist-services 1.9.11 → 1.9.13

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 (48) hide show
  1. package/lib/cjs/apps/googleMaps/consts.js +10 -0
  2. package/lib/cjs/apps/googleMaps/index.js +1 -0
  3. package/lib/cjs/apps/googleMaps/service.js +46 -1
  4. package/lib/cjs/maps/MapArea/options.js +2 -3
  5. package/lib/cjs/ride/display/service.js +95 -0
  6. package/lib/cjs/ride/index.js +1 -0
  7. package/lib/cjs/ride/page/service.js +69 -1
  8. package/lib/cjs/ride/route/FreeRideDisplayService.js +36 -5
  9. package/lib/cjs/ride/route/GpxDisplayService.js +46 -1
  10. package/lib/cjs/ride/view-restriction/index.js +18 -0
  11. package/lib/cjs/ride/view-restriction/service.js +221 -0
  12. package/lib/cjs/ride/view-restriction/types.js +2 -0
  13. package/lib/cjs/routes/free-ride/option-labels.js +141 -0
  14. package/lib/cjs/routes/free-ride/service.js +217 -117
  15. package/lib/cjs/settings/display/ride/service.js +22 -4
  16. package/lib/esm/apps/googleMaps/consts.js +7 -0
  17. package/lib/esm/apps/googleMaps/index.js +1 -0
  18. package/lib/esm/apps/googleMaps/service.js +46 -1
  19. package/lib/esm/maps/MapArea/options.js +2 -3
  20. package/lib/esm/ride/display/service.js +95 -0
  21. package/lib/esm/ride/index.js +1 -0
  22. package/lib/esm/ride/page/service.js +69 -1
  23. package/lib/esm/ride/route/FreeRideDisplayService.js +36 -5
  24. package/lib/esm/ride/route/GpxDisplayService.js +46 -1
  25. package/lib/esm/ride/view-restriction/index.js +2 -0
  26. package/lib/esm/ride/view-restriction/service.js +217 -0
  27. package/lib/esm/ride/view-restriction/types.js +1 -0
  28. package/lib/esm/routes/free-ride/service.js +217 -117
  29. package/lib/esm/settings/display/ride/service.js +20 -2
  30. package/lib/types/apps/googleMaps/consts.d.ts +7 -0
  31. package/lib/types/apps/googleMaps/index.d.ts +1 -0
  32. package/lib/types/apps/googleMaps/service.d.ts +8 -0
  33. package/lib/types/maps/MapArea/types.d.ts +1 -0
  34. package/lib/types/ride/base/types.d.ts +5 -1
  35. package/lib/types/ride/display/service.d.ts +15 -0
  36. package/lib/types/ride/index.d.ts +1 -0
  37. package/lib/types/ride/page/service.d.ts +10 -0
  38. package/lib/types/ride/page/types.d.ts +10 -0
  39. package/lib/types/ride/route/FreeRideDisplayService.d.ts +4 -1
  40. package/lib/types/ride/route/GpxDisplayService.d.ts +5 -0
  41. package/lib/types/ride/view-restriction/index.d.ts +2 -0
  42. package/lib/types/ride/view-restriction/service.d.ts +30 -0
  43. package/lib/types/ride/view-restriction/types.d.ts +57 -0
  44. package/lib/types/routes/free-ride/service.d.ts +18 -2
  45. package/lib/types/routes/list/types.d.ts +11 -0
  46. package/lib/types/settings/display/ride/service.d.ts +1 -0
  47. package/lib/types/settings/display/ride/types.d.ts +4 -0
  48. package/package.json +3 -3
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAPS_KEY_TEXTS = exports.MAPS_KEY_HELP_URL = void 0;
4
+ exports.MAPS_KEY_HELP_URL = 'https://incyclist.com/maps-api-key/';
5
+ exports.MAPS_KEY_TEXTS = {
6
+ ownKey: 'your own Google Maps API key',
7
+ billing: 'Google then bills each ride that uses them to your own Google account.',
8
+ pendingRestart: 'Saved. Restart Incyclist to use it.',
9
+ helpLabel: 'How to create a key',
10
+ };
@@ -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("./consts"), exports);
@@ -50,20 +50,24 @@ let GoogleMapsService = (() => {
50
50
  let _instanceExtraInitializers = [];
51
51
  let _getSecretBindings_decorators;
52
52
  let _getUserSettings_decorators;
53
+ let _getBindings_decorators;
53
54
  var GoogleMapsService = class extends _classSuper {
54
55
  static { _classThis = this; }
55
56
  static {
56
57
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
57
58
  _getSecretBindings_decorators = [decorators_1.Injectable];
58
59
  _getUserSettings_decorators = [decorators_1.Injectable];
60
+ _getBindings_decorators = [decorators_1.Injectable];
59
61
  __esDecorate(this, null, _getSecretBindings_decorators, { kind: "method", name: "getSecretBindings", static: false, private: false, access: { has: obj => "getSecretBindings" in obj, get: obj => obj.getSecretBindings }, metadata: _metadata }, null, _instanceExtraInitializers);
60
62
  __esDecorate(this, null, _getUserSettings_decorators, { kind: "method", name: "getUserSettings", static: false, private: false, access: { has: obj => "getUserSettings" in obj, get: obj => obj.getUserSettings }, metadata: _metadata }, null, _instanceExtraInitializers);
63
+ __esDecorate(this, null, _getBindings_decorators, { kind: "method", name: "getBindings", static: false, private: false, access: { has: obj => "getBindings" in obj, get: obj => obj.getBindings }, metadata: _metadata }, null, _instanceExtraInitializers);
61
64
  __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
62
65
  GoogleMapsService = _classThis = _classDescriptor.value;
63
66
  if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
64
67
  __runInitializers(_classThis, _classExtraInitializers);
65
68
  }
66
69
  api = __runInitializers(this, _instanceExtraInitializers);
70
+ latchedKey;
67
71
  constructor() {
68
72
  super('GoogleMaps');
69
73
  const observer = this.getUserSettings().requestNotifyOnChange?.('maps', 'GOOGLE_MAPS_API_KEY');
@@ -84,6 +88,7 @@ let GoogleMapsService = (() => {
84
88
  const settings = this.getUserSettings();
85
89
  const personalKey = settings.getValue('GOOGLE_MAPS_API_KEY', undefined);
86
90
  const developmentMode = settings.get('mode', 'production') === 'development';
91
+ this.latchPersonalKey(personalKey);
87
92
  if (developmentMode)
88
93
  return personalKey ?? 'development';
89
94
  return personalKey;
@@ -93,8 +98,33 @@ let GoogleMapsService = (() => {
93
98
  const personalKey = settings.get('GOOGLE_MAPS_API_KEY', undefined);
94
99
  return personalKey !== undefined;
95
100
  }
101
+ hasActivePersonalApiKey() {
102
+ try {
103
+ if (this.isMobile())
104
+ return false;
105
+ this.latchPersonalKey(this.readPersonalKey());
106
+ return this.latchedKey !== '';
107
+ }
108
+ catch (err) {
109
+ this.logError(err, 'hasActivePersonalApiKey');
110
+ return false;
111
+ }
112
+ }
113
+ isPersonalApiKeyPendingRestart() {
114
+ try {
115
+ if (this.isMobile())
116
+ return false;
117
+ this.latchPersonalKey(this.readPersonalKey());
118
+ const current = this.normalizeKey(this.readPersonalKey());
119
+ return current !== '' && current !== this.latchedKey;
120
+ }
121
+ catch (err) {
122
+ this.logError(err, 'isPersonalApiKeyPendingRestart');
123
+ return false;
124
+ }
125
+ }
96
126
  onPersonalApiKeySet() {
97
- this.emit('reload');
127
+ this.reload();
98
128
  }
99
129
  hasDevelopmentApiKey() {
100
130
  const settings = this.getUserSettings();
@@ -110,6 +140,18 @@ let GoogleMapsService = (() => {
110
140
  this.emit('reload');
111
141
  }
112
142
  }
143
+ readPersonalKey() {
144
+ return this.getUserSettings().getValue('GOOGLE_MAPS_API_KEY', undefined);
145
+ }
146
+ normalizeKey(key) {
147
+ return typeof key === 'string' ? key.trim() : '';
148
+ }
149
+ latchPersonalKey(key) {
150
+ this.latchedKey ??= this.normalizeKey(key);
151
+ }
152
+ isMobile() {
153
+ return this.getBindings()?.appInfo?.getChannel() === 'mobile';
154
+ }
113
155
  getSecret(key) {
114
156
  return this.getSecretBindings()?.getSecret(key);
115
157
  }
@@ -119,6 +161,9 @@ let GoogleMapsService = (() => {
119
161
  getUserSettings() {
120
162
  return (0, settings_1.useUserSettings)();
121
163
  }
164
+ getBindings() {
165
+ return (0, api_1.getBindings)();
166
+ }
122
167
  };
123
168
  return GoogleMapsService = _classThis;
124
169
  })();
@@ -9,6 +9,7 @@ const clone_1 = __importDefault(require("../../utils/clone"));
9
9
  const utils_1 = require("./utils");
10
10
  const geo_1 = require("../../utils/geo");
11
11
  const utils_2 = require("../../utils");
12
+ const option_labels_1 = require("../../routes/free-ride/option-labels");
12
13
  class OptionManager {
13
14
  service;
14
15
  map;
@@ -108,9 +109,7 @@ class OptionManager {
108
109
  const currentDirection = this.map?.getHeading(way, 'end') ?? 0;
109
110
  options.forEach((option) => {
110
111
  const direction = this.map?.getHeading(option, 'start') ?? 0;
111
- option.direction = direction - currentDirection;
112
- if (option.direction > 180)
113
- option.direction = option.direction - 360;
112
+ option.direction = (0, option_labels_1.normalizeAngle)(direction - currentDirection);
114
113
  });
115
114
  if (props?.minDistance) {
116
115
  await this.checkMinDistance(options, props.minDistance);
@@ -54,6 +54,7 @@ const WorkoutDisplayService_1 = require("../workout/WorkoutDisplayService");
54
54
  const api_1 = require("../../api");
55
55
  const RLVDisplayService_1 = require("../route/RLVDisplayService");
56
56
  const coaches_1 = require("../../coaches");
57
+ const service_3 = require("../view-restriction/service");
57
58
  let RideDisplayService = (() => {
58
59
  let _classDecorators = [types_1.Singleton];
59
60
  let _classDescriptor;
@@ -70,6 +71,7 @@ let RideDisplayService = (() => {
70
71
  let _getDeviceConfiguration_decorators;
71
72
  let _getUIBinding_decorators;
72
73
  let _getCoaches_decorators;
74
+ let _getRideViewRestriction_decorators;
73
75
  let _getPairingVisitTracker_decorators;
74
76
  var RideDisplayService = class extends _classSuper {
75
77
  static { _classThis = this; }
@@ -84,6 +86,7 @@ let RideDisplayService = (() => {
84
86
  _getDeviceConfiguration_decorators = [decorators_1.Injectable];
85
87
  _getUIBinding_decorators = [decorators_1.Injectable];
86
88
  _getCoaches_decorators = [decorators_1.Injectable];
89
+ _getRideViewRestriction_decorators = [decorators_1.Injectable];
87
90
  _getPairingVisitTracker_decorators = [decorators_1.Injectable];
88
91
  __esDecorate(this, null, _getActivityRide_decorators, { kind: "method", name: "getActivityRide", static: false, private: false, access: { has: obj => "getActivityRide" in obj, get: obj => obj.getActivityRide }, metadata: _metadata }, null, _instanceExtraInitializers);
89
92
  __esDecorate(this, null, _getWorkoutRide_decorators, { kind: "method", name: "getWorkoutRide", static: false, private: false, access: { has: obj => "getWorkoutRide" in obj, get: obj => obj.getWorkoutRide }, metadata: _metadata }, null, _instanceExtraInitializers);
@@ -94,6 +97,7 @@ let RideDisplayService = (() => {
94
97
  __esDecorate(this, null, _getDeviceConfiguration_decorators, { kind: "method", name: "getDeviceConfiguration", static: false, private: false, access: { has: obj => "getDeviceConfiguration" in obj, get: obj => obj.getDeviceConfiguration }, metadata: _metadata }, null, _instanceExtraInitializers);
95
98
  __esDecorate(this, null, _getUIBinding_decorators, { kind: "method", name: "getUIBinding", static: false, private: false, access: { has: obj => "getUIBinding" in obj, get: obj => obj.getUIBinding }, metadata: _metadata }, null, _instanceExtraInitializers);
96
99
  __esDecorate(this, null, _getCoaches_decorators, { kind: "method", name: "getCoaches", static: false, private: false, access: { has: obj => "getCoaches" in obj, get: obj => obj.getCoaches }, metadata: _metadata }, null, _instanceExtraInitializers);
100
+ __esDecorate(this, null, _getRideViewRestriction_decorators, { kind: "method", name: "getRideViewRestriction", static: false, private: false, access: { has: obj => "getRideViewRestriction" in obj, get: obj => obj.getRideViewRestriction }, metadata: _metadata }, null, _instanceExtraInitializers);
97
101
  __esDecorate(this, null, _getPairingVisitTracker_decorators, { kind: "method", name: "getPairingVisitTracker", static: false, private: false, access: { has: obj => "getPairingVisitTracker" in obj, get: obj => obj.getPairingVisitTracker }, metadata: _metadata }, null, _instanceExtraInitializers);
98
102
  __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
99
103
  RideDisplayService = _classThis = _classDescriptor.value;
@@ -115,6 +119,7 @@ let RideDisplayService = (() => {
115
119
  startDeviceHandlers;
116
120
  isResuming;
117
121
  stateUpdateHandler = this.onStateUpdate.bind(this);
122
+ discarding = false;
118
123
  controlDevicesReadyNotified = false;
119
124
  constructor() {
120
125
  super('RideDisplay');
@@ -295,6 +300,60 @@ let RideDisplayService = (() => {
295
300
  this.getActivityRide().cleanup().catch(err => { this.logError(err, 'stop'); });
296
301
  this.getCoaches().stopRide().catch(err => { this.logError(err, 'stop'); });
297
302
  }
303
+ async discardSimulatedRide() {
304
+ if (this.discarding)
305
+ return false;
306
+ try {
307
+ if (!this.isSimulated()) {
308
+ this.logError(new Error('not a simulated ride'), 'discardSimulatedRide');
309
+ return false;
310
+ }
311
+ this.discarding = true;
312
+ const selection = this.getRideSelection();
313
+ await this.deleteActivityOnDiscard();
314
+ await this.stop();
315
+ const restored = this.restoreRideSelection(selection);
316
+ this.logEvent({ message: 'simulated ride discarded', restored });
317
+ return restored;
318
+ }
319
+ catch (err) {
320
+ this.logError(err, 'discardSimulatedRide');
321
+ return false;
322
+ }
323
+ finally {
324
+ this.discarding = false;
325
+ }
326
+ }
327
+ onRideViewNoticeAction(id) {
328
+ try {
329
+ this.getRideViewRestriction().onNoticeAction(id);
330
+ this.observer?.emit('overlay-update', this.getDisplayProperties());
331
+ }
332
+ catch (err) {
333
+ this.logError(err, 'onRideViewNoticeAction');
334
+ }
335
+ }
336
+ onRideViewNoticeClosed() {
337
+ try {
338
+ this.getRideViewRestriction().onNoticeClosed();
339
+ this.observer?.emit('overlay-update', this.getDisplayProperties());
340
+ }
341
+ catch (err) {
342
+ this.logError(err, 'onRideViewNoticeClosed');
343
+ }
344
+ }
345
+ setRideViewReminder(enabled) {
346
+ try {
347
+ this.getRideViewRestriction().setReminderEnabled(enabled);
348
+ }
349
+ catch (err) {
350
+ this.logError(err, 'setRideViewReminder');
351
+ }
352
+ }
353
+ getRideViewRestrictionDialogProps() {
354
+ const inRide = this.isSimulated() && (this.state === 'Started' || this.state === 'Active' || this.state === 'Paused');
355
+ return this.getRideViewRestriction().getDialogProps({ inRide });
356
+ }
298
357
  toggleCyclingMode() {
299
358
  try {
300
359
  if (!this.actualWorkout) {
@@ -523,6 +582,39 @@ let RideDisplayService = (() => {
523
582
  this.logError(err, 'init');
524
583
  }
525
584
  }
585
+ getRideSelection() {
586
+ const routeList = this.getRouteList();
587
+ return {
588
+ route: routeList.getSelected(),
589
+ startSettings: routeList.getStartSettings(),
590
+ workout: this.getWorkoutList().getSelected()
591
+ };
592
+ }
593
+ async deleteActivityOnDiscard() {
594
+ try {
595
+ await this.getActivityRide().delete();
596
+ }
597
+ catch (err) {
598
+ this.logError(err, 'discardSimulatedRide');
599
+ }
600
+ }
601
+ restoreRideSelection(selection) {
602
+ try {
603
+ const { route, startSettings, workout } = selection;
604
+ const routeList = this.getRouteList();
605
+ if (route)
606
+ routeList.select(route);
607
+ if (startSettings)
608
+ routeList.setStartSettings(startSettings);
609
+ if (workout)
610
+ this.getWorkoutList().select(workout);
611
+ return true;
612
+ }
613
+ catch (err) {
614
+ this.logError(err, 'discardSimulatedRide');
615
+ return false;
616
+ }
617
+ }
526
618
  setState(state) {
527
619
  this.state = state;
528
620
  this.observer?.emit('state-update', this.state);
@@ -1192,6 +1284,9 @@ let RideDisplayService = (() => {
1192
1284
  getCoaches() {
1193
1285
  return (0, coaches_1.getCoachesService)();
1194
1286
  }
1287
+ getRideViewRestriction() {
1288
+ return (0, service_3.useRideViewRestriction)();
1289
+ }
1195
1290
  getPairingVisitTracker() {
1196
1291
  return (0, visit_log_factory_1.usePairingVisitTracker)();
1197
1292
  }
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./base"), exports);
18
18
  __exportStar(require("./display"), exports);
19
19
  __exportStar(require("./page"), exports);
20
+ __exportStar(require("./view-restriction"), exports);
@@ -115,6 +115,7 @@ let RidePageService = (() => {
115
115
  prevRidesVisibleRows = DEFAULT_PREV_RIDES_VISIBLE_ROWS;
116
116
  prevRidesMode = 'list';
117
117
  gestureHintDismissed = false;
118
+ rideViewRestrictionDialog = null;
118
119
  prevRidesShown = false;
119
120
  nearbyRiders;
120
121
  nearbyRidersSubscribed = false;
@@ -160,6 +161,7 @@ let RidePageService = (() => {
160
161
  this.logEvent({ message: 'page shown', page: pageLogName });
161
162
  gd_eventlog_1.EventLogger.setGlobalConfig('page', pageLogName);
162
163
  this.gestureHintDismissed = false;
164
+ this.rideViewRestrictionDialog = null;
163
165
  this.prevRidesShown = false;
164
166
  this.nearbyRidersSubscribed = false;
165
167
  this.videoVisit = { started: false, routeIds: [], exitHandled: false };
@@ -210,6 +212,7 @@ let RidePageService = (() => {
210
212
  if (this.viewTransition)
211
213
  return;
212
214
  try {
215
+ this.rideViewRestrictionDialog = null;
213
216
  gd_eventlog_1.EventLogger.setGlobalConfig('page', null);
214
217
  this.logEvent({ message: 'page closed', page: this.getPageLogName() });
215
218
  this.handleVideoVisitExit();
@@ -465,10 +468,73 @@ let RidePageService = (() => {
465
468
  svInitAllowed: props.svInitAllowed,
466
469
  rideViewNotice: props.rideViewNotice,
467
470
  svCoverageNotice: props.svCoverageNotice,
468
- svHasCoverage: props.svHasCoverage
471
+ svHasCoverage: props.svHasCoverage,
472
+ rideViewRestriction: props.rideViewRestriction,
473
+ rideViewRestrictionNotice: this.canShowRideViewRestrictionNotice(base) ? props.rideViewRestrictionNotice : undefined,
474
+ rideViewRestrictionDialog: this.rideViewRestrictionDialog
469
475
  };
470
476
  return displayProps;
471
477
  }
478
+ canShowRideViewRestrictionNotice(base) {
479
+ return !base.startOverlayProps && !base.gestureHint;
480
+ }
481
+ onRideViewNoticeAction(id) {
482
+ try {
483
+ this.getRideDisplay().onRideViewNoticeAction(id);
484
+ if (id === 'how-to' || id === 'change-this')
485
+ this.openRideViewRestrictionDialog();
486
+ this.updatePageDisplay();
487
+ }
488
+ catch (err) {
489
+ this.logError(err, 'onRideViewNoticeAction');
490
+ }
491
+ }
492
+ onRideViewNoticeClosed() {
493
+ try {
494
+ this.getRideDisplay().onRideViewNoticeClosed();
495
+ this.updatePageDisplay();
496
+ }
497
+ catch (err) {
498
+ this.logError(err, 'onRideViewNoticeClosed');
499
+ }
500
+ }
501
+ onOpenRideViewRestrictionDialog() {
502
+ try {
503
+ this.openRideViewRestrictionDialog();
504
+ this.updatePageDisplay();
505
+ }
506
+ catch (err) {
507
+ this.logError(err, 'onOpenRideViewRestrictionDialog');
508
+ }
509
+ }
510
+ onCloseRideViewRestrictionDialog() {
511
+ this.rideViewRestrictionDialog = null;
512
+ this.updatePageDisplay();
513
+ }
514
+ onRideViewReminderChanged(enabled) {
515
+ try {
516
+ this.getRideDisplay().setRideViewReminder(enabled);
517
+ if (this.rideViewRestrictionDialog)
518
+ this.openRideViewRestrictionDialog();
519
+ this.updatePageDisplay();
520
+ }
521
+ catch (err) {
522
+ this.logError(err, 'onRideViewReminderChanged');
523
+ }
524
+ }
525
+ async onDiscardSimulatedRide() {
526
+ try {
527
+ this.rideViewRestrictionDialog = null;
528
+ const discarded = await this.getRideDisplay().discardSimulatedRide();
529
+ this.moveTo(discarded ? '/pairingStart' : '$contentPage');
530
+ }
531
+ catch (err) {
532
+ this.logError(err, 'onDiscardSimulatedRide');
533
+ }
534
+ }
535
+ openRideViewRestrictionDialog() {
536
+ this.rideViewRestrictionDialog = this.getRideDisplay().getRideViewRestrictionDialogProps();
537
+ }
472
538
  buildWorkoutOverlayProps(props) {
473
539
  const cornerWidget = this.getCornerWidget();
474
540
  if (!this.isWorkoutAttached() || !props?.showWorkout)
@@ -1166,6 +1232,8 @@ let RidePageService = (() => {
1166
1232
  }
1167
1233
  }
1168
1234
  onDisplayStateUpdate(state) {
1235
+ if (this.rideViewRestrictionDialog && state !== 'Started' && state !== 'Active' && state !== 'Paused')
1236
+ this.rideViewRestrictionDialog = null;
1169
1237
  this.subscribeToWorkoutObserver();
1170
1238
  this.subscribeToNearbyRiders();
1171
1239
  switch (state) {
@@ -72,6 +72,7 @@ let FreeRideDisplayService = (() => {
72
72
  prevViewport;
73
73
  tsLastOptionChange;
74
74
  optionsVisible;
75
+ lastLoggedButtons;
75
76
  mapProps;
76
77
  distanceRemaining;
77
78
  timeRemaining;
@@ -105,7 +106,7 @@ let FreeRideDisplayService = (() => {
105
106
  }
106
107
  selectOption(option) {
107
108
  try {
108
- this.getFreeRideService().selectOption(option);
109
+ this.getFreeRideService().selectOptionByUser(option);
109
110
  return this.getFreeRideService().buildUIOptions(this.currentOptions);
110
111
  }
111
112
  catch (err) {
@@ -226,7 +227,8 @@ let FreeRideDisplayService = (() => {
226
227
  optionsId: this.getOptionsId(),
227
228
  distance,
228
229
  isNearby: this.isNearbyOption && distance !== undefined,
229
- turn: this.isTurnEnabled
230
+ turn: this.isTurnEnabled,
231
+ optionsState: this.getOptionsState()
230
232
  };
231
233
  return {
232
234
  ...routeProps,
@@ -282,6 +284,7 @@ let FreeRideDisplayService = (() => {
282
284
  mode: 'free ride',
283
285
  rideView,
284
286
  lat, lng,
287
+ startSource: this.getFreeRideService().getStartSource(),
285
288
  ...bikeProps
286
289
  };
287
290
  return props;
@@ -291,6 +294,28 @@ let FreeRideDisplayService = (() => {
291
294
  return {};
292
295
  }
293
296
  }
297
+ getOptionsState() {
298
+ const options = this.getFreeRideService().getOptions();
299
+ if (this.isStarting || options === undefined)
300
+ return 'loading';
301
+ if (options.length > 0)
302
+ return 'ready';
303
+ return this.getFreeRideService().isLastQueryValid() ? 'none' : 'failed';
304
+ }
305
+ getButtonsLogInfo() {
306
+ try {
307
+ return this.getFreeRideService().buildUIOptions(this.currentOptions ?? []).map(o => {
308
+ let marker;
309
+ if (o.selected)
310
+ marker = o.selectedBy === 'user' ? 'NEXT' : 'AUTO';
311
+ return [o.index, o.maneuverText, o.roadLabel, marker].filter(v => v !== undefined).join('·');
312
+ }).join('|');
313
+ }
314
+ catch (err) {
315
+ this.logError(err, 'getButtonsLogInfo');
316
+ return '';
317
+ }
318
+ }
294
319
  getOptionsId() {
295
320
  if (!this.currentOptions?.length)
296
321
  return 'none';
@@ -479,11 +504,17 @@ let FreeRideDisplayService = (() => {
479
504
  const { lat, lng } = this.currentOptions[0].path[0];
480
505
  return { lat, lng };
481
506
  }
482
- onOptionsVisibleChanged(visible) {
483
- if (visible === this.optionsVisible) {
507
+ onOptionsVisibleChanged(visible, reason) {
508
+ const changed = visible !== this.optionsVisible;
509
+ const buttons = visible ? this.getButtonsLogInfo() : undefined;
510
+ if (!changed && (!visible || buttons === this.lastLoggedButtons))
484
511
  return;
485
- }
486
512
  this.optionsVisible = visible;
513
+ this.lastLoggedButtons = visible ? buttons : undefined;
514
+ const props = { visible, count: this.currentOptions?.length ?? 0, reason: reason ?? 'unknown', pinned: this.isNearbyOption };
515
+ if (buttons !== undefined)
516
+ props.buttons = buttons;
517
+ this.logEvent({ message: 'free ride options visibility', ...props });
487
518
  }
488
519
  emitRouteUpdate() {
489
520
  const options = this.getFreeRideService().buildUIOptions(this.currentOptions);
@@ -42,6 +42,7 @@ const decorators_1 = require("../../base/decorators");
42
42
  const types_1 = require("../../base/types");
43
43
  const routes_1 = require("../../routes");
44
44
  const display_1 = require("../../settings/display");
45
+ const service_1 = require("../view-restriction/service");
45
46
  const RouteDisplayService_1 = require("./RouteDisplayService");
46
47
  const SV_UPDATE_FREQ = 3000;
47
48
  const SV_MIN_READY = 1500;
@@ -57,6 +58,7 @@ let GpxDisplayService = (() => {
57
58
  let _getGoogleMaps_decorators;
58
59
  let _getBindings_decorators;
59
60
  let _getRideSettingsDisplay_decorators;
61
+ let _getRideViewRestriction_decorators;
60
62
  let _getAppState_decorators;
61
63
  return class GpxDisplayService extends _classSuper {
62
64
  static {
@@ -64,10 +66,12 @@ let GpxDisplayService = (() => {
64
66
  _getGoogleMaps_decorators = [decorators_1.Injectable];
65
67
  _getBindings_decorators = [decorators_1.Injectable];
66
68
  _getRideSettingsDisplay_decorators = [decorators_1.Injectable];
69
+ _getRideViewRestriction_decorators = [decorators_1.Injectable];
67
70
  _getAppState_decorators = [decorators_1.Injectable];
68
71
  __esDecorate(this, null, _getGoogleMaps_decorators, { kind: "method", name: "getGoogleMaps", static: false, private: false, access: { has: obj => "getGoogleMaps" in obj, get: obj => obj.getGoogleMaps }, metadata: _metadata }, null, _instanceExtraInitializers);
69
72
  __esDecorate(this, null, _getBindings_decorators, { kind: "method", name: "getBindings", static: false, private: false, access: { has: obj => "getBindings" in obj, get: obj => obj.getBindings }, metadata: _metadata }, null, _instanceExtraInitializers);
70
73
  __esDecorate(this, null, _getRideSettingsDisplay_decorators, { kind: "method", name: "getRideSettingsDisplay", static: false, private: false, access: { has: obj => "getRideSettingsDisplay" in obj, get: obj => obj.getRideSettingsDisplay }, metadata: _metadata }, null, _instanceExtraInitializers);
74
+ __esDecorate(this, null, _getRideViewRestriction_decorators, { kind: "method", name: "getRideViewRestriction", static: false, private: false, access: { has: obj => "getRideViewRestriction" in obj, get: obj => obj.getRideViewRestriction }, metadata: _metadata }, null, _instanceExtraInitializers);
71
75
  __esDecorate(this, null, _getAppState_decorators, { kind: "method", name: "getAppState", static: false, private: false, access: { has: obj => "getAppState" in obj, get: obj => obj.getAppState }, metadata: _metadata }, null, _instanceExtraInitializers);
72
76
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
73
77
  }
@@ -96,6 +100,7 @@ let GpxDisplayService = (() => {
96
100
  rideViewNotice;
97
101
  svCoverageNotice;
98
102
  svHasCoverage;
103
+ restrictionEvaluated = false;
99
104
  svPhaseDelayTimeout;
100
105
  svSlowTimeout;
101
106
  svStartTimeout;
@@ -106,6 +111,7 @@ let GpxDisplayService = (() => {
106
111
  initView() {
107
112
  try {
108
113
  this.tsInit = Date.now();
114
+ this.restrictionEvaluated = false;
109
115
  const rideView = this.getRideView();
110
116
  if (rideView === 'sv') {
111
117
  this.svFlowActive = true;
@@ -144,6 +150,33 @@ let GpxDisplayService = (() => {
144
150
  }
145
151
  return props;
146
152
  }
153
+ start() {
154
+ super.start();
155
+ this.startViewRestriction();
156
+ }
157
+ startViewRestriction() {
158
+ if (this.restrictionEvaluated)
159
+ return;
160
+ this.restrictionEvaluated = true;
161
+ try {
162
+ const restriction = this.getRideViewRestriction();
163
+ restriction.beginRide({
164
+ simulated: this.service?.isSimulated() === true,
165
+ preferredView: this.getRideSettingsDisplay().getRideView()
166
+ });
167
+ }
168
+ catch (err) {
169
+ this.logError(err, 'startViewRestriction');
170
+ }
171
+ }
172
+ endViewRestriction() {
173
+ try {
174
+ this.getRideViewRestriction().endRide();
175
+ }
176
+ catch (err) {
177
+ this.logError(err, 'endViewRestriction');
178
+ }
179
+ }
147
180
  isSideViewsSupported() {
148
181
  return this.getGoogleMaps().hasPersonalApiKey()
149
182
  || this.getGoogleMaps().hasDevelopmentApiKey();
@@ -239,17 +272,22 @@ let GpxDisplayService = (() => {
239
272
  const svCoverageNotice = this.svCoverageNotice;
240
273
  delete this.svCoverageNotice;
241
274
  const svHasCoverage = this.svHasCoverage;
275
+ const restriction = this.getRideViewRestriction();
276
+ const rideViewRestriction = restriction.getActiveRestriction();
277
+ const rideViewRestrictionNotice = restriction.getNotice();
242
278
  return {
243
279
  rideView,
244
280
  svInitAllowed: rideView === 'sv' && this.svReleased,
245
281
  rideViewNotice,
282
+ rideViewRestriction,
283
+ rideViewRestrictionNotice,
246
284
  svCoverageNotice,
247
285
  svHasCoverage,
248
286
  ...routeProps
249
287
  };
250
288
  }
251
289
  getRideView() {
252
- if (this.service?.isSimulated() && !this.getGoogleMaps().hasPersonalApiKey()) {
290
+ if (this.getRideViewRestriction().getActiveRestriction()) {
253
291
  this.rideViewOverride = 'map';
254
292
  this.abandonStreetViewFlow();
255
293
  }
@@ -264,6 +302,8 @@ let GpxDisplayService = (() => {
264
302
  }
265
303
  onRideSettingsChanged(settings = {}) {
266
304
  super.onRideSettingsChanged(settings);
305
+ if (this.getRideViewRestriction().getActiveRestriction())
306
+ return;
267
307
  if (this.rideViewOverride && settings?.rideView) {
268
308
  delete this.rideViewOverride;
269
309
  }
@@ -526,9 +566,11 @@ let GpxDisplayService = (() => {
526
566
  if (this.getRideView() === 'sv' && !this.svReleased)
527
567
  this.release('start-completed');
528
568
  this.clearSatelliteViewStartTimeout();
569
+ this.getRideViewRestriction().onRideStarted();
529
570
  super.onStarted();
530
571
  }
531
572
  async stop() {
573
+ this.endViewRestriction();
532
574
  this.clearStreetViewPhaseTimers();
533
575
  this.clearSatelliteViewStartTimeout();
534
576
  if (this.svFallbackHoldTimeout) {
@@ -615,6 +657,9 @@ let GpxDisplayService = (() => {
615
657
  getRideSettingsDisplay() {
616
658
  return (0, display_1.useRideSettingsDisplay)();
617
659
  }
660
+ getRideViewRestriction() {
661
+ return (0, service_1.useRideViewRestriction)();
662
+ }
618
663
  getAppState() {
619
664
  return (0, appstate_1.useAppState)();
620
665
  }
@@ -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("./types"), exports);
18
+ __exportStar(require("./service"), exports);