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
@@ -42,6 +42,7 @@ import { useUserSettings } from "../../settings";
42
42
  import { distanceBetween, calculateHeaderFromPoints as getHeadingBetween } from "../../utils/geo";
43
43
  import { waitNextTick } from "../../utils";
44
44
  import clone from "../../utils/clone";
45
+ import { buildOptionLabels, getCompassWord, getLayoutOrder, getRoadLabel } from "./option-labels";
45
46
  const INIT_RETRY = 15 * 1000;
46
47
  const MAX_RETRIES = 1;
47
48
  let FreeRideService = (() => {
@@ -75,6 +76,9 @@ let FreeRideService = (() => {
75
76
  initialized = false;
76
77
  ivInit;
77
78
  cntInitRetry = 0;
79
+ rideSeq = 0;
80
+ selectedBy = 'auto';
81
+ startSource = 'default';
78
82
  constructor() {
79
83
  super('FreeRide');
80
84
  this.options = [];
@@ -87,6 +91,8 @@ let FreeRideService = (() => {
87
91
  })
88
92
  .finally(() => {
89
93
  this.logEvent({ message: 'init free ride service result', success: this.initialized });
94
+ if (this.initialized)
95
+ return;
90
96
  this.ivInit = setInterval(() => {
91
97
  if (this.cntInitRetry < MAX_RETRIES) {
92
98
  this.cntInitRetry++;
@@ -103,15 +109,29 @@ let FreeRideService = (() => {
103
109
  isInitialized() {
104
110
  return this.initialized;
105
111
  }
106
- async selectStartPosition(position) {
112
+ async selectStartPosition(position, opts) {
113
+ const rideSeq = this.rideSeq;
114
+ const keepSource = !position && (this.startSource === 'search' || this.startSource === 'map');
115
+ this.startSource = opts?.source ?? (keepSource ? this.startSource : this.getDefaultSource(position));
107
116
  this.setStartPosition(position);
108
117
  const map = await this.getMapArea().load(this.startPosition);
109
118
  if (!this.initialized && map) {
110
119
  this.setInitialized();
111
120
  }
112
- await this.getStartOptions(map);
121
+ if (rideSeq !== this.rideSeq) {
122
+ this.logEvent({ message: 'start position update ignored', reason: 'ride started' });
123
+ return this.getRouteDefinitionDisplayProps();
124
+ }
125
+ await this.getStartOptions(map, rideSeq);
113
126
  return this.getRouteDefinitionDisplayProps();
114
127
  }
128
+ getStartSource() {
129
+ return this.startSource;
130
+ }
131
+ getDefaultSource(position) {
132
+ const { lat, lng } = position ?? this.getDefaultStartPosition();
133
+ return lat === DEFAULT_POSITION.lat && lng === DEFAULT_POSITION.lng ? 'default' : 'last';
134
+ }
115
135
  getStartPosition() {
116
136
  return this.startPosition ?? this.getDefaultStartPosition();
117
137
  }
@@ -141,7 +161,7 @@ let FreeRideService = (() => {
141
161
  this.options = await this.loadNextOptions(from, forStart);
142
162
  }
143
163
  const message = forStart ? 'start options updated' : 'free ride options updated';
144
- this.logEvent({ message, prepared, options: optionsInfo(this.options), from: this.buildId(from) });
164
+ this.logEvent({ message, prepared, options: optionsInfo(this.options), from: this.buildId(from), ...this.getOptionsLogProps() });
145
165
  if (this.options?.length > 0) {
146
166
  this.selectOption(this.options[0]);
147
167
  }
@@ -324,94 +344,100 @@ let FreeRideService = (() => {
324
344
  }
325
345
  async getNextLevelOptions(opts) {
326
346
  let segmentUpdated = false;
327
- this.once('segment-update', () => { segmentUpdated = true; });
347
+ const onSegmentUpdate = () => { segmentUpdated = true; };
348
+ this.once('segment-update', onSegmentUpdate);
328
349
  const optionManager = useMapArea().getOptionManager();
329
- for (const o of opts ?? []) {
330
- if (segmentUpdated)
331
- return;
332
- let segment = o;
333
- let done = false;
334
- let isSingle = false;
335
- let lastHandlerWasNoOption = false;
336
- do {
337
- const nextOptsResult = await optionManager.getNextOptions(segment);
338
- const nextOpts = nextOptsResult.options;
339
- const isValid = nextOptsResult.isValid;
340
- const handleSingleOption = () => {
341
- if (segmentUpdated)
342
- return;
343
- isSingle = true;
344
- try {
345
- segment = nextOpts[0];
346
- concatPaths(o.path, segment.path, 'after');
347
- const originatingPoint = segment.path[1];
348
- if (segment.options?.length > 0) {
349
- segment.options = segment.options.filter(o => o.path.at(-1).id !== originatingPoint.id);
350
+ try {
351
+ for (const o of opts ?? []) {
352
+ if (segmentUpdated)
353
+ return;
354
+ let segment = o;
355
+ let done = false;
356
+ let isSingle = false;
357
+ let lastHandlerWasNoOption = false;
358
+ do {
359
+ const nextOptsResult = await optionManager.getNextOptions(segment);
360
+ const nextOpts = nextOptsResult.options;
361
+ const isValid = nextOptsResult.isValid;
362
+ const handleSingleOption = () => {
363
+ if (segmentUpdated)
364
+ return;
365
+ isSingle = true;
366
+ try {
367
+ segment = nextOpts[0];
368
+ concatPaths(o.path, segment.path, 'after');
369
+ const originatingPoint = segment.path[1];
370
+ if (segment.options?.length > 0) {
371
+ segment.options = segment.options.filter(o => o.path.at(-1).id !== originatingPoint.id);
372
+ }
350
373
  }
351
- }
352
- catch (err) {
353
- this.logError(err, 'getNextLevelOptions#handleSingleOption');
354
- }
355
- };
356
- const handleNoOption = () => {
357
- if (segmentUpdated)
358
- return;
359
- if (isSingle) {
360
- o.options = [segment];
361
- done = true;
362
- return;
363
- }
364
- if (lastHandlerWasNoOption) {
365
- o.options = [];
366
- done = true;
367
- return;
368
- }
369
- try {
370
- const map = segment.map ?? this.getMapArea().getMap(segment.path[0]);
371
- const newPath = [];
372
- segment.path.forEach(p => {
373
- newPath.push(clone(p));
374
- });
375
- newPath.reverse();
376
- const way = map?.getWay(segment.id);
377
- if (!isOneWay(way) || isAllowed(way, newPath[0], newPath.at(-1))) {
378
- segment = {
379
- id: o.id,
380
- map: o.map,
381
- direction: 180,
382
- path: newPath
383
- };
384
- concatPaths(o.path, newPath, 'after');
374
+ catch (err) {
375
+ this.logError(err, 'getNextLevelOptions#handleSingleOption');
376
+ }
377
+ };
378
+ const handleNoOption = () => {
379
+ if (segmentUpdated)
380
+ return;
381
+ if (isSingle) {
382
+ o.options = [segment];
383
+ done = true;
384
+ return;
385
385
  }
386
- else {
386
+ if (lastHandlerWasNoOption) {
387
387
  o.options = [];
388
388
  done = true;
389
+ return;
390
+ }
391
+ try {
392
+ const map = segment.map ?? this.getMapArea().getMap(segment.path[0]);
393
+ const newPath = [];
394
+ segment.path.forEach(p => {
395
+ newPath.push(clone(p));
396
+ });
397
+ newPath.reverse();
398
+ const way = map?.getWay(segment.id);
399
+ if (!isOneWay(way) || isAllowed(way, newPath[0], newPath.at(-1))) {
400
+ segment = {
401
+ id: o.id,
402
+ map: o.map,
403
+ direction: 180,
404
+ path: newPath
405
+ };
406
+ concatPaths(o.path, newPath, 'after');
407
+ }
408
+ else {
409
+ o.options = [];
410
+ done = true;
411
+ }
389
412
  }
413
+ catch (err) {
414
+ this.logError(err, 'getNextLevelOptions#handleNoOption');
415
+ }
416
+ };
417
+ if (nextOpts?.length === 1) {
418
+ handleSingleOption();
419
+ lastHandlerWasNoOption = false;
390
420
  }
391
- catch (err) {
392
- this.logError(err, 'getNextLevelOptions#handleNoOption');
421
+ else if (!nextOpts?.length && isValid) {
422
+ handleNoOption();
423
+ lastHandlerWasNoOption = true;
393
424
  }
394
- };
395
- if (nextOpts?.length === 1) {
396
- handleSingleOption();
397
- lastHandlerWasNoOption = false;
398
- }
399
- else if (!nextOpts?.length && isValid) {
400
- handleNoOption();
401
- lastHandlerWasNoOption = true;
402
- }
403
- else if (!nextOpts?.length && !isValid) {
404
- o.options = [];
405
- done = true;
406
- lastHandlerWasNoOption = false;
407
- }
408
- else {
409
- o.options = nextOpts;
410
- done = true;
411
- lastHandlerWasNoOption = false;
412
- }
413
- await waitNextTick();
414
- } while (!done);
425
+ else if (!nextOpts?.length && !isValid) {
426
+ o.options = [];
427
+ done = true;
428
+ lastHandlerWasNoOption = false;
429
+ }
430
+ else {
431
+ o.options = nextOpts;
432
+ done = true;
433
+ lastHandlerWasNoOption = false;
434
+ }
435
+ await waitNextTick();
436
+ } while (!done);
437
+ }
438
+ }
439
+ finally {
440
+ this.off('segment-update', onSegmentUpdate);
415
441
  }
416
442
  }
417
443
  buildId(opt) {
@@ -426,6 +452,12 @@ let FreeRideService = (() => {
426
452
  isLastQueryValid() {
427
453
  return this.lastOptionsQueryValid;
428
454
  }
455
+ selectOptionByUser(option) {
456
+ const options = this.selectOption(option);
457
+ if (this.selectedOption)
458
+ this.selectedBy = 'user';
459
+ return options;
460
+ }
429
461
  selectOption(option) {
430
462
  const current = this.selectedOption;
431
463
  const options = this.options ?? [];
@@ -448,18 +480,26 @@ let FreeRideService = (() => {
448
480
  opt = option;
449
481
  }
450
482
  this.selectedOption = options?.find(o => this.buildId(o) === this.buildId(opt));
483
+ this.selectedBy = 'auto';
451
484
  if (!this.selectedOption) {
452
- this.logEvent({ message: 'free ride option selection failed', requested: option, type: typeof option, options: options ?? 'none', optionKeys: options.map(o => this.buildId(o)) });
485
+ const requested = typeof option === 'object' ? this.buildId(option) : option;
486
+ this.logEvent({ message: 'free ride option selection failed', requested, type: typeof option, count: options.length, optionKeys: options.map(o => this.buildId(o)).join('|') });
453
487
  }
454
488
  return this.options;
455
489
  }
456
490
  applyOption(option) {
457
- if (option)
491
+ if (option) {
492
+ const by = this.selectedBy;
493
+ const sameAsSelected = this.buildId(option) === this.buildId(this.selectedOption);
458
494
  this.selectOption(option);
459
- this.logEvent({ message: 'free ride option applied', option: this.buildId(this.selectedOption) });
495
+ if (sameAsSelected)
496
+ this.selectedBy = by;
497
+ }
498
+ this.logEvent({ message: 'free ride option applied', option: this.buildId(this.selectedOption), ...this.getSelectionLogProps() });
460
499
  this.currentSegment = this.selectedOption;
461
500
  }
462
501
  applyStartOption(startOption) {
502
+ this.rideSeq++;
463
503
  const option = this.options.find(o => this.buildId(o) === startOption?.id);
464
504
  this.applyOption(option);
465
505
  }
@@ -481,37 +521,98 @@ let FreeRideService = (() => {
481
521
  return path;
482
522
  }
483
523
  buildUIOptions(opts = this.options ?? []) {
484
- return opts.map((option, idx) => {
485
- const id = this.buildId(option);
486
- const selected = id === this.buildId(this.selectedOption);
487
- const text = this.getOptionText(option);
488
- const color = this.getOptionColor(idx, { isStartPos: false, selected });
489
- const uiOptions = { id, color, text, path: this.getPath(option), selected, direction: option.direction };
490
- option.ui = uiOptions;
491
- return uiOptions;
524
+ const seen = new Set();
525
+ const unique = opts.filter(o => {
526
+ const id = this.buildId(o);
527
+ if (seen.has(id))
528
+ return false;
529
+ seen.add(id);
530
+ return true;
531
+ });
532
+ const selectedId = this.buildId(this.selectedOption);
533
+ const infos = unique.map(option => ({
534
+ option,
535
+ id: this.buildId(option),
536
+ tags: this.getWayTags(option),
537
+ compass: this.getOptionText(option),
538
+ heading: this.getOptionHeading(option),
539
+ roundabout: !!option.roundabout
540
+ }));
541
+ const order = getLayoutOrder(infos.map(i => ({ direction: i.option.direction, roundabout: i.roundabout })));
542
+ const ordered = order.map(idx => ({ ...infos[idx], defaultIdx: idx }));
543
+ const labels = buildOptionLabels(ordered.map(i => ({ id: i.id, direction: i.option.direction, roundabout: i.roundabout, compass: i.compass, tags: i.tags })));
544
+ const result = ordered.map((info, pos) => {
545
+ const { option, id, compass, heading, defaultIdx } = info;
546
+ const selected = id === selectedId;
547
+ const color = this.getOptionColor(defaultIdx, { isStartPos: false, selected });
548
+ const label = labels[pos];
549
+ const uiOption = {
550
+ id, color, text: compass, path: this.getPath(option), selected, direction: option.direction,
551
+ index: pos + 1, maneuver: label.maneuver, maneuverText: label.maneuverText,
552
+ compass, heading, roadName: label.roadName, roadLabel: label.roadLabel,
553
+ isDefault: defaultIdx === 0, degraded: label.degraded
554
+ };
555
+ if (selected)
556
+ uiOption.selectedBy = this.selectedBy;
557
+ option.ui = uiOption;
558
+ return uiOption;
492
559
  });
560
+ return result;
493
561
  }
494
562
  buildStartOptions() {
495
563
  const opts = this.startOptions ?? [];
496
564
  if (opts.length < 1)
497
565
  return [];
498
- if (opts.length < 2) {
499
- const option = opts[0];
500
- const id = this.buildId(option);
501
- const uiOption = { id, color: 'blue', text: 'OK', path: this.getPath(option) };
502
- option.ui = uiOption;
503
- return [uiOption];
504
- }
505
- return opts.map((option, idx) => {
506
- const text = this.getOptionText(option);
507
- const color = this.getOptionColor(idx, { isStartPos: true });
566
+ const build = (option, color, text) => {
508
567
  const id = this.buildId(option);
509
- const uiOption = { id, color, text, path: this.getPath(option) };
568
+ const { roadName, roadLabel } = getRoadLabel(this.getWayTags(option));
569
+ const compass = this.getOptionText(option);
570
+ const uiOption = { id, color, text, path: this.getPath(option), compass, heading: this.getOptionHeading(option), roadName, roadLabel };
510
571
  option.ui = uiOption;
511
572
  return uiOption;
512
- });
573
+ };
574
+ if (opts.length < 2) {
575
+ return [build(opts[0], 'blue', 'OK')];
576
+ }
577
+ return opts.map((option, idx) => build(option, this.getOptionColor(idx, { isStartPos: true }), this.getOptionText(option)));
578
+ }
579
+ getWayTags(option) {
580
+ try {
581
+ const map = option?.map ?? (option?.path?.length ? this.getMapArea().getMap(option.path[0]) : undefined);
582
+ return map?.getWay(option?.id)?.tags;
583
+ }
584
+ catch {
585
+ return undefined;
586
+ }
587
+ }
588
+ getOptionHeading(option) {
589
+ const path = option?.path ?? [];
590
+ if (path.length < 2)
591
+ return undefined;
592
+ const heading = getHeadingBetween(path[0], path[1]);
593
+ return Number.isFinite(heading) ? ((heading % 360) + 360) % 360 : undefined;
594
+ }
595
+ getOptionsLogProps() {
596
+ const options = this.options ?? [];
597
+ const named = options.filter(o => { const t = this.getWayTags(o); return !!(t?.name || t?.ref); }).length;
598
+ const degraded = options.filter(o => !Number.isFinite(o.direction)).length;
599
+ return { count: options.length, named, degraded };
513
600
  }
514
- async getStartOptions(map) {
601
+ getSelectionLogProps() {
602
+ const options = this.options ?? [];
603
+ const selected = this.selectedOption;
604
+ const idx = selected ? options.findIndex(o => this.buildId(o) === this.buildId(selected)) : -1;
605
+ const tags = this.getWayTags(selected);
606
+ const props = { by: this.selectedBy, count: options.length };
607
+ if (idx >= 0) {
608
+ props.index = idx + 1;
609
+ props.named = !!(tags?.name || tags?.ref);
610
+ if (Number.isFinite(selected.direction))
611
+ props.direction = Math.round(selected.direction);
612
+ }
613
+ return props;
614
+ }
615
+ async getStartOptions(map, rideSeq = this.rideSeq) {
515
616
  this.startOptions = [];
516
617
  if (!map)
517
618
  return;
@@ -532,6 +633,10 @@ let FreeRideService = (() => {
532
633
  optionManager.setMap(map);
533
634
  const options = await optionManager.getStartOptions(way, crossing);
534
635
  this.startOptions.push(...options);
636
+ if (rideSeq !== this.rideSeq) {
637
+ this.logEvent({ message: 'start options update ignored', reason: 'ride started' });
638
+ return;
639
+ }
535
640
  this.options = this.startOptions;
536
641
  }
537
642
  setStartPosition(position) {
@@ -557,22 +662,17 @@ let FreeRideService = (() => {
557
662
  }
558
663
  }
559
664
  getOptionText(option) {
560
- const path = option?.path ?? [];
561
- if (path.length < 2)
562
- return;
563
- const heading = getHeadingBetween(path[0], path[1]) % 360;
564
- const idx = Number(heading / 45).toFixed(0);
565
- const texts = ['North', 'Northeast', 'East', 'Southeast', 'South', 'Southwest', 'West', 'Northwest', 'North'];
566
- return texts[idx];
665
+ const heading = this.getOptionHeading(option);
666
+ return heading === undefined ? undefined : getCompassWord(heading);
567
667
  }
568
668
  getOptionColor(idx, props) {
569
669
  if (props?.isStartPos) {
570
- const colors = ['red', 'green', 'blue', 'yellow', 'orange', 'gray', 'pink', 'brown'];
670
+ const colors = ['#e5484d', '#3e8ef7', '#d23fa0', '#14a3b8', '#8b5cf6', '#a0643c'];
571
671
  return colors[idx % colors.length];
572
672
  }
573
673
  if (props?.selected)
574
- return 'green';
575
- const colors = ['red', 'purple', 'black', 'magenta', 'orange', 'brown', 'royalblue', 'silver'];
674
+ return '#8dc100';
675
+ const colors = ['red', 'purple', 'magenta', 'orange', 'brown', 'royalblue', 'teal', 'deeppink'];
576
676
  return colors[idx % colors.length];
577
677
  }
578
678
  getMapArea() {
@@ -36,11 +36,13 @@ import { getBindings } from "../../../api";
36
36
  import { Injectable, Singleton } from "../../../base/decorators";
37
37
  import { IncyclistService } from "../../../base/service";
38
38
  import { Observer } from "../../../base/types";
39
+ import { useRideViewRestriction } from "../../../ride/view-restriction/service";
39
40
  import { useUserSettings } from "../../service";
40
41
  const UNAVAILABLE_MESSAGES = {
41
42
  'need.playservices': 'Install Google Play Services to use this view',
42
43
  };
43
44
  const DEFAULT_UNAVAILABLE_MESSAGE = 'This view is currently unavailable on your device';
45
+ const SIMULATION_MESSAGE = 'Not available in simulated rides';
44
46
  let RideSettingsDisplayService = (() => {
45
47
  let _classDecorators = [Singleton];
46
48
  let _classDescriptor;
@@ -48,14 +50,17 @@ let RideSettingsDisplayService = (() => {
48
50
  let _classThis;
49
51
  let _classSuper = IncyclistService;
50
52
  let _instanceExtraInitializers = [];
53
+ let _getRideViewRestriction_decorators;
51
54
  let _getUserSettings_decorators;
52
55
  let _getBindings_decorators;
53
56
  var RideSettingsDisplayService = class extends _classSuper {
54
57
  static { _classThis = this; }
55
58
  static {
56
59
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
60
+ _getRideViewRestriction_decorators = [Injectable];
57
61
  _getUserSettings_decorators = [Injectable];
58
62
  _getBindings_decorators = [Injectable];
63
+ __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);
59
64
  __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);
60
65
  __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
66
  __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
@@ -81,11 +86,17 @@ let RideSettingsDisplayService = (() => {
81
86
  delete this.observer;
82
87
  }
83
88
  getDisplayProps() {
84
- return {
85
- rideView: this.getRideView(),
89
+ const restriction = this.getRideViewRestriction().getActiveRestriction();
90
+ const props = {
91
+ rideView: restriction ? 'map' : this.getRideView(),
86
92
  rideViewOptions: this.getRideViewOptions(),
87
93
  ...this.getVideoOptions()
88
94
  };
95
+ if (restriction) {
96
+ const view = restriction.preferredView === 'sat' ? 'Satellite View' : 'Street View';
97
+ props.rideViewHelp = { label: `How to get ${view}` };
98
+ }
99
+ return props;
89
100
  }
90
101
  setRideView(rideView) {
91
102
  try {
@@ -134,6 +145,10 @@ let RideSettingsDisplayService = (() => {
134
145
  map.set(key, { label, disabled: true, message });
135
146
  return;
136
147
  }
148
+ if (this.getRideViewRestriction().getActiveRestriction()) {
149
+ map.set(key, { label, disabled: true, message: SIMULATION_MESSAGE, reason: 'simulation' });
150
+ return;
151
+ }
137
152
  map.set(key, { label });
138
153
  }
139
154
  isMobile() {
@@ -145,6 +160,9 @@ let RideSettingsDisplayService = (() => {
145
160
  isIOS() {
146
161
  return this.getBindings().appInfo?.getOS()?.platform === 'ios';
147
162
  }
163
+ getRideViewRestriction() {
164
+ return useRideViewRestriction();
165
+ }
148
166
  getUserSettings() {
149
167
  return useUserSettings();
150
168
  }
@@ -0,0 +1,7 @@
1
+ export declare const MAPS_KEY_HELP_URL = "https://incyclist.com/maps-api-key/";
2
+ export declare const MAPS_KEY_TEXTS: {
3
+ ownKey: string;
4
+ billing: string;
5
+ pendingRestart: string;
6
+ helpLabel: string;
7
+ };
@@ -1 +1,2 @@
1
1
  export * from './service';
2
+ export * from './consts';
@@ -1,18 +1,26 @@
1
1
  import { IncyclistService } from "../../base/service";
2
2
  export declare class GoogleMapsService extends IncyclistService {
3
3
  api: any;
4
+ protected latchedKey: string | undefined;
4
5
  constructor();
5
6
  setApi(api: any): void;
6
7
  getApi(): any;
7
8
  waitForApiKey(): Promise<boolean>;
8
9
  getApiKey(): Promise<string>;
9
10
  hasPersonalApiKey(): boolean;
11
+ hasActivePersonalApiKey(): boolean;
12
+ isPersonalApiKeyPendingRestart(): boolean;
10
13
  onPersonalApiKeySet(): void;
11
14
  hasDevelopmentApiKey(): boolean;
12
15
  getMapsDownloadUrl(): any;
13
16
  reload(): void;
17
+ protected readPersonalKey(): unknown;
18
+ protected normalizeKey(key: unknown): string;
19
+ protected latchPersonalKey(key: unknown): void;
20
+ protected isMobile(): boolean;
14
21
  protected getSecret(key: string): string;
15
22
  protected getSecretBindings(): import("../../api").ISecretBinding;
16
23
  protected getUserSettings(): import("../../settings").UserSettingsService;
24
+ protected getBindings(): import("../../api").IncyclistBindings;
17
25
  }
18
26
  export declare const useGoogleMaps: () => GoogleMapsService;
@@ -32,6 +32,7 @@ export type FreeRideContinuation = {
32
32
  id?: string;
33
33
  path: Array<IncyclistNode>;
34
34
  onewayReverse?: boolean;
35
+ roundabout?: boolean | string;
35
36
  direction?: number;
36
37
  options?: Array<FreeRideContinuation>;
37
38
  map?: IMapArea;
@@ -12,6 +12,7 @@ import { MapViewPort, StreetViewEvent, SvFallbackCause } from "../route/types";
12
12
  import { LatLng } from "../../utils/geo";
13
13
  import { Unit } from "../../i18n";
14
14
  import { IObserver } from "../../types";
15
+ import type { RideViewRestriction, RideViewRestrictionNoticeProps } from "../view-restriction/types";
15
16
  export type RideType = 'Free-Ride' | 'GPX' | 'Video' | 'Workout';
16
17
  export type CurrentRideState = 'Idle' | 'Starting' | 'Started' | 'Active' | 'Paused' | 'Error' | 'Finished' | 'Closing';
17
18
  export type CurrentRideDeviceState = 'Starting' | 'Started' | 'Error';
@@ -110,6 +111,8 @@ export interface GpxDisplayProps extends RouteDisplayProps {
110
111
  rideViewNotice?: {
111
112
  cause: SvFallbackCause;
112
113
  };
114
+ rideViewRestriction?: RideViewRestriction;
115
+ rideViewRestrictionNotice?: RideViewRestrictionNoticeProps;
113
116
  svCoverageNotice?: {
114
117
  ts: number;
115
118
  };
@@ -118,13 +121,14 @@ export interface GpxDisplayProps extends RouteDisplayProps {
118
121
  export interface RouteOptionDisplayProps {
119
122
  optionsDelay?: number;
120
123
  optionsId?: string;
121
- onOptionsVisibleChanged: (visible: boolean) => void;
124
+ onOptionsVisibleChanged: (visible: boolean, reason?: string) => void;
122
125
  isNearby?: boolean;
123
126
  distance?: {
124
127
  value: number;
125
128
  unit: Unit;
126
129
  };
127
130
  turn?: boolean;
131
+ optionsState?: 'loading' | 'ready' | 'none' | 'failed';
128
132
  }
129
133
  export interface FreeRideDisplayProps extends GpxDisplayProps {
130
134
  options?: FreeRideOption[];
@@ -10,6 +10,7 @@ import { INativeUI } from "../../api/ui";
10
10
  import { CurrentRideDisplayProps, ICurrentRideService, PrevRidesDisplayProps, StartOverlayProps } from "../base/types";
11
11
  import { PowerAdjustmentResult } from "../../workouts/ride/types";
12
12
  import { FreeRideOption } from "../../routes/list/types";
13
+ import { RideViewNoticeActionId, RideViewRestrictionDialogProps } from "../view-restriction/types";
13
14
  export declare class RideDisplayService extends IncyclistService implements ICurrentRideService {
14
15
  protected observer: Observer;
15
16
  protected type: RideType;
@@ -26,6 +27,7 @@ export declare class RideDisplayService extends IncyclistService implements ICur
26
27
  protected startDeviceHandlers: any;
27
28
  protected isResuming: boolean;
28
29
  protected stateUpdateHandler: any;
30
+ protected discarding: boolean;
29
31
  protected controlDevicesReadyNotified: boolean;
30
32
  constructor();
31
33
  init(): Promise<Observer>;
@@ -41,6 +43,11 @@ export declare class RideDisplayService extends IncyclistService implements ICur
41
43
  backward(): void;
42
44
  forward(): void;
43
45
  stop(exit?: boolean): Promise<void>;
46
+ discardSimulatedRide(): Promise<boolean>;
47
+ onRideViewNoticeAction(id: RideViewNoticeActionId): void;
48
+ onRideViewNoticeClosed(): void;
49
+ setRideViewReminder(enabled: boolean): void;
50
+ getRideViewRestrictionDialogProps(): RideViewRestrictionDialogProps;
44
51
  toggleCyclingMode(): void;
45
52
  takeScreenshot(): Promise<void>;
46
53
  toggleAllOverlays(): void;
@@ -69,6 +76,13 @@ export declare class RideDisplayService extends IncyclistService implements ICur
69
76
  noStateUpdates?: boolean;
70
77
  }): Promise<void>;
71
78
  protected closePrevRide(): Promise<void>;
79
+ protected getRideSelection(): {
80
+ route: Route;
81
+ startSettings: import("../../routes/list/types").RouteStartSettings;
82
+ workout: Workout;
83
+ };
84
+ protected deleteActivityOnDiscard(): Promise<void>;
85
+ protected restoreRideSelection(selection: ReturnType<RideDisplayService['getRideSelection']>): boolean;
72
86
  protected setState(state: CurrentRideState): void;
73
87
  protected detectRideType(): RideType;
74
88
  getRideModeService(overwrite?: boolean): IRideModeService;
@@ -144,6 +158,7 @@ export declare class RideDisplayService extends IncyclistService implements ICur
144
158
  protected getDeviceConfiguration(): import("../../devices/configuration").DeviceConfigurationService;
145
159
  protected getUIBinding(): INativeUI;
146
160
  protected getCoaches(): import("../../coaches").CoachesService;
161
+ protected getRideViewRestriction(): import("../view-restriction/service").RideViewRestrictionService;
147
162
  protected getPairingVisitTracker(): import("../..").PairingVisitTracker;
148
163
  }
149
164
  export declare const useRideDisplay: () => RideDisplayService;