incyclist-services 1.7.55 → 1.7.57

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 (63) hide show
  1. package/lib/cjs/devices/page/service.js +13 -1
  2. package/lib/cjs/i18n/countries/index.js +13 -118
  3. package/lib/cjs/i18n/countries/service.js +125 -0
  4. package/lib/cjs/maps/MapArea/options.js +3 -3
  5. package/lib/cjs/maps/MapArea/utils.js +1 -1
  6. package/lib/cjs/ride/route/RLVDisplayService.js +15 -3
  7. package/lib/cjs/routes/base/model/route.js +1 -4
  8. package/lib/cjs/routes/base/parsers/bikelab.js +1 -1
  9. package/lib/cjs/routes/base/parsers/epm.js +12 -15
  10. package/lib/cjs/routes/base/parsers/geometry.js +4 -5
  11. package/lib/cjs/routes/base/parsers/index.js +6 -2
  12. package/lib/cjs/routes/base/parsers/multixml.js +3 -1
  13. package/lib/cjs/routes/base/parsers/tacx/TacxParser.js +293 -223
  14. package/lib/cjs/routes/base/parsers/utils.js +118 -11
  15. package/lib/cjs/routes/base/parsers/xml.js +8 -2
  16. package/lib/cjs/routes/free-ride/service.js +42 -29
  17. package/lib/cjs/routes/library/service.js +104 -33
  18. package/lib/cjs/routes/list/service.js +35 -12
  19. package/lib/cjs/routes/page/service.js +5 -1
  20. package/lib/cjs/utils/fileinfo.js +1 -1
  21. package/lib/cjs/video/VideoSyncHelper.js +14 -3
  22. package/lib/cjs/workouts/base/parsers/incyclist/Json.js +3 -1
  23. package/lib/cjs/workouts/base/parsers/intervals/parser.js +3 -1
  24. package/lib/cjs/workouts/base/parsers/zwo/zwo.js +3 -1
  25. package/lib/esm/devices/page/service.js +13 -1
  26. package/lib/esm/i18n/countries/index.js +1 -115
  27. package/lib/esm/i18n/countries/service.js +118 -0
  28. package/lib/esm/maps/MapArea/options.js +3 -3
  29. package/lib/esm/maps/MapArea/utils.js +1 -1
  30. package/lib/esm/ride/route/RLVDisplayService.js +15 -3
  31. package/lib/esm/routes/base/model/route.js +1 -4
  32. package/lib/esm/routes/base/parsers/bikelab.js +1 -1
  33. package/lib/esm/routes/base/parsers/epm.js +13 -16
  34. package/lib/esm/routes/base/parsers/geometry.js +4 -5
  35. package/lib/esm/routes/base/parsers/index.js +6 -2
  36. package/lib/esm/routes/base/parsers/multixml.js +3 -1
  37. package/lib/esm/routes/base/parsers/tacx/TacxParser.js +300 -229
  38. package/lib/esm/routes/base/parsers/utils.js +113 -10
  39. package/lib/esm/routes/base/parsers/xml.js +9 -3
  40. package/lib/esm/routes/free-ride/service.js +42 -29
  41. package/lib/esm/routes/library/service.js +104 -33
  42. package/lib/esm/routes/list/service.js +35 -12
  43. package/lib/esm/routes/page/service.js +5 -1
  44. package/lib/esm/utils/fileinfo.js +1 -1
  45. package/lib/esm/video/VideoSyncHelper.js +14 -3
  46. package/lib/esm/workouts/base/parsers/incyclist/Json.js +3 -1
  47. package/lib/esm/workouts/base/parsers/intervals/parser.js +3 -1
  48. package/lib/esm/workouts/base/parsers/zwo/zwo.js +3 -1
  49. package/lib/types/api/fs/index.d.ts +1 -1
  50. package/lib/types/api/repository/types.d.ts +1 -2
  51. package/lib/types/devices/page/service.d.ts +1 -0
  52. package/lib/types/i18n/countries/index.d.ts +1 -17
  53. package/lib/types/i18n/countries/model.d.ts +6 -3
  54. package/lib/types/i18n/countries/service.d.ts +18 -0
  55. package/lib/types/ride/route/RLVDisplayService.d.ts +2 -0
  56. package/lib/types/routes/base/parsers/tacx/TacxParser.d.ts +7 -2
  57. package/lib/types/routes/base/parsers/utils.d.ts +4 -0
  58. package/lib/types/routes/free-ride/service.d.ts +3 -1
  59. package/lib/types/routes/library/service.d.ts +1 -0
  60. package/lib/types/routes/library/types.d.ts +1 -1
  61. package/lib/types/routes/list/service.d.ts +4 -0
  62. package/lib/types/routes/page/service.d.ts +1 -0
  63. package/package.json +1 -1
@@ -45,6 +45,7 @@ const access_1 = require("../access");
45
45
  const configuration_1 = require("../configuration");
46
46
  const ui_1 = require("../../ui");
47
47
  const types_1 = require("../../base/types");
48
+ const ride_1 = require("../ride");
48
49
  let DevicesPageService = (() => {
49
50
  let _classDecorators = [decorators_1.Singleton];
50
51
  let _classDescriptor;
@@ -53,6 +54,7 @@ let DevicesPageService = (() => {
53
54
  let _classSuper = pages_1.IncyclistPageService;
54
55
  let _instanceExtraInitializers = [];
55
56
  let _getDevicePairing_decorators;
57
+ let _getDeviceRide_decorators;
56
58
  let _getDeviceConfiguration_decorators;
57
59
  let _getIncyclist_decorators;
58
60
  var DevicesPageService = class extends _classSuper {
@@ -60,9 +62,11 @@ let DevicesPageService = (() => {
60
62
  static {
61
63
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
62
64
  _getDevicePairing_decorators = [decorators_1.Injectable];
65
+ _getDeviceRide_decorators = [decorators_1.Injectable];
63
66
  _getDeviceConfiguration_decorators = [decorators_1.Injectable];
64
67
  _getIncyclist_decorators = [decorators_1.Injectable];
65
68
  __esDecorate(this, null, _getDevicePairing_decorators, { kind: "method", name: "getDevicePairing", static: false, private: false, access: { has: obj => "getDevicePairing" in obj, get: obj => obj.getDevicePairing }, metadata: _metadata }, null, _instanceExtraInitializers);
69
+ __esDecorate(this, null, _getDeviceRide_decorators, { kind: "method", name: "getDeviceRide", static: false, private: false, access: { has: obj => "getDeviceRide" in obj, get: obj => obj.getDeviceRide }, metadata: _metadata }, null, _instanceExtraInitializers);
66
70
  __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);
67
71
  __esDecorate(this, null, _getIncyclist_decorators, { kind: "method", name: "getIncyclist", static: false, private: false, access: { has: obj => "getIncyclist" in obj, get: obj => obj.getIncyclist }, metadata: _metadata }, null, _instanceExtraInitializers);
68
72
  __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
@@ -325,6 +329,12 @@ let DevicesPageService = (() => {
325
329
  return [
326
330
  { label: 'OK', primary: true, onClick: this.onOK.bind(this) }
327
331
  ];
332
+ if (this.getDeviceRide().canEnforceSimulator()) {
333
+ return [
334
+ { label: 'Simulate', primary: true, onClick: this.onSimulate.bind(this) },
335
+ { label: 'Skip', primary: false, onClick: this.onSkip.bind(this) }
336
+ ];
337
+ }
328
338
  return [
329
339
  { label: 'Skip', primary: true, onClick: this.onSkip.bind(this) }
330
340
  ];
@@ -375,7 +385,6 @@ let DevicesPageService = (() => {
375
385
  const simulator = this.getDeviceConfiguration().getSimulatorAdapterId();
376
386
  this.getDevicePairing().prepareStart([simulator]);
377
387
  const prevContentPage = this.getPrevContentPage();
378
- const prevPage = this.getAppState().getState('prevPage');
379
388
  if (this.isPairingForRide)
380
389
  this.moveTo('/rideSimulate');
381
390
  else
@@ -400,6 +409,9 @@ let DevicesPageService = (() => {
400
409
  getDevicePairing() {
401
410
  return (0, pairing_1.useDevicePairing)();
402
411
  }
412
+ getDeviceRide() {
413
+ return (0, ride_1.useDeviceRide)();
414
+ }
403
415
  getDeviceConfiguration() {
404
416
  return (0, configuration_1.useDeviceConfiguration)();
405
417
  }
@@ -1,122 +1,17 @@
1
1
  "use strict";
2
- var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
- var _, done = false;
8
- for (var i = decorators.length - 1; i >= 0; i--) {
9
- var context = {};
10
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
- if (kind === "accessor") {
15
- if (result === void 0) continue;
16
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
- if (_ = accept(result.get)) descriptor.get = _;
18
- if (_ = accept(result.set)) descriptor.set = _;
19
- if (_ = accept(result.init)) initializers.unshift(_);
20
- }
21
- else if (_ = accept(result)) {
22
- if (kind === "field") initializers.unshift(_);
23
- else descriptor[key] = _;
24
- }
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]; } };
25
7
  }
26
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
- done = true;
28
- };
29
- var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
- var useValue = arguments.length > 2;
31
- for (var i = 0; i < initializers.length; i++) {
32
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
- }
34
- return useValue ? value : void 0;
35
- };
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
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);
38
15
  };
39
16
  Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.getCountries = exports.Countries = void 0;
41
- const service_1 = require("../../base/service");
42
- const types_1 = require("../../base/types");
43
- const countries_json_1 = __importDefault(require("./countries.json"));
44
- const services_1 = require("../../services");
45
- let Countries = (() => {
46
- let _classDecorators = [types_1.Singleton];
47
- let _classDescriptor;
48
- let _classExtraInitializers = [];
49
- let _classThis;
50
- let _classSuper = service_1.IncyclistService;
51
- var Countries = class extends _classSuper {
52
- static { _classThis = this; }
53
- static {
54
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
55
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
56
- Countries = _classThis = _classDescriptor.value;
57
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
58
- __runInitializers(_classThis, _classExtraInitializers);
59
- }
60
- language;
61
- countryLists;
62
- constructor() {
63
- super('Countries');
64
- this.language = countries_json_1.default.locale;
65
- this.countryLists = {};
66
- this.countryLists[this.language] = countries_json_1.default;
67
- }
68
- getList(locale = this.language) {
69
- return this.countryLists[locale] || this.countryLists.en;
70
- }
71
- getCountryFromIso(iso, locale) {
72
- const list = this.getList(locale);
73
- const info = list.countries[iso.toUpperCase()];
74
- return Array.isArray(info) ? info[0] : info;
75
- }
76
- getCountiesFromIsos(iso, locale) {
77
- return iso.map(i => this.getCountryFromIso(i, locale));
78
- }
79
- getIsoFromCountry(country, locale) {
80
- const list = this.getList(locale);
81
- const isos = Object.keys(list.countries);
82
- const iso = isos.find(i => {
83
- const c = list.countries[i];
84
- if (Array.isArray(c))
85
- return c.includes(country);
86
- return c === country;
87
- });
88
- return iso;
89
- }
90
- getIsosFromCountries(countries, locale) {
91
- return countries.map(c => this.getIsoFromCountry(c, locale));
92
- }
93
- async getIsoFromLatLng(point) {
94
- const { lat, lng } = point;
95
- const query = `[out:json][timeout:25];way['addr:country'](around:20000,${lat},${lng});out tags;`;
96
- try {
97
- const result = await (0, services_1.useOverpassApi)().query(query);
98
- if (!result?.elements)
99
- return;
100
- const isos = [];
101
- result.elements?.forEach(el => {
102
- const iso = el.tags['addr:country'];
103
- if (!iso)
104
- return;
105
- if (!isos.includes(iso.toUpperCase())) {
106
- isos.push(iso.toUpperCase());
107
- }
108
- });
109
- if (isos.length < 2)
110
- return isos[0];
111
- return isos.find(iso => this.getList().countries[iso] !== undefined);
112
- }
113
- catch {
114
- return undefined;
115
- }
116
- }
117
- };
118
- return Countries = _classThis;
119
- })();
120
- exports.Countries = Countries;
121
- const getCountries = () => new Countries();
122
- exports.getCountries = getCountries;
17
+ __exportStar(require("./service"), exports);
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
3
+ var useValue = arguments.length > 2;
4
+ for (var i = 0; i < initializers.length; i++) {
5
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
6
+ }
7
+ return useValue ? value : void 0;
8
+ };
9
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
10
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
11
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
12
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
13
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
14
+ var _, done = false;
15
+ for (var i = decorators.length - 1; i >= 0; i--) {
16
+ var context = {};
17
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
18
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
19
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
20
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
21
+ if (kind === "accessor") {
22
+ if (result === void 0) continue;
23
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
24
+ if (_ = accept(result.get)) descriptor.get = _;
25
+ if (_ = accept(result.set)) descriptor.set = _;
26
+ if (_ = accept(result.init)) initializers.unshift(_);
27
+ }
28
+ else if (_ = accept(result)) {
29
+ if (kind === "field") initializers.unshift(_);
30
+ else descriptor[key] = _;
31
+ }
32
+ }
33
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
34
+ done = true;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.getCountries = exports.Countries = void 0;
41
+ const service_1 = require("../../base/service");
42
+ const types_1 = require("../../base/types");
43
+ const countries_json_1 = __importDefault(require("./countries.json"));
44
+ const services_1 = require("../../services");
45
+ const decorators_1 = require("../../base/decorators");
46
+ let Countries = (() => {
47
+ let _classDecorators = [types_1.Singleton];
48
+ let _classDescriptor;
49
+ let _classExtraInitializers = [];
50
+ let _classThis;
51
+ let _classSuper = service_1.IncyclistService;
52
+ let _instanceExtraInitializers = [];
53
+ let _getOverpassApi_decorators;
54
+ var Countries = class extends _classSuper {
55
+ static { _classThis = this; }
56
+ static {
57
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
58
+ _getOverpassApi_decorators = [decorators_1.Injectable];
59
+ __esDecorate(this, null, _getOverpassApi_decorators, { kind: "method", name: "getOverpassApi", static: false, private: false, access: { has: obj => "getOverpassApi" in obj, get: obj => obj.getOverpassApi }, metadata: _metadata }, null, _instanceExtraInitializers);
60
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
61
+ Countries = _classThis = _classDescriptor.value;
62
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
63
+ __runInitializers(_classThis, _classExtraInitializers);
64
+ }
65
+ language = __runInitializers(this, _instanceExtraInitializers);
66
+ countryLists;
67
+ constructor() {
68
+ super('Countries');
69
+ this.language = countries_json_1.default.locale;
70
+ this.countryLists = {};
71
+ this.countryLists[this.language] = countries_json_1.default;
72
+ }
73
+ getList(locale = this.language) {
74
+ return this.countryLists[locale] || this.countryLists.en;
75
+ }
76
+ getCountryFromIso(iso, locale) {
77
+ const list = this.getList(locale);
78
+ const info = list.countries[iso.toUpperCase()];
79
+ return Array.isArray(info) ? info[0] : info;
80
+ }
81
+ getCountiesFromIsos(iso, locale) {
82
+ return iso.map(i => this.getCountryFromIso(i, locale));
83
+ }
84
+ getIsoFromCountry(country, locale) {
85
+ const list = this.getList(locale);
86
+ const isos = Object.keys(list.countries);
87
+ const iso = isos.find(i => {
88
+ const c = list.countries[i];
89
+ if (Array.isArray(c))
90
+ return c.includes(country);
91
+ return c === country;
92
+ });
93
+ return iso;
94
+ }
95
+ getIsosFromCountries(countries, locale) {
96
+ return countries.map(c => this.getIsoFromCountry(c, locale));
97
+ }
98
+ async getIsoFromLatLng(point) {
99
+ const { lat, lng } = point;
100
+ const query = `[out:json][timeout:10];is_in(${lat},${lng})->.a;rel(pivot.a)['admin_level'='2']['boundary'='administrative'];out tags;`;
101
+ try {
102
+ const result = await this.getOverpassApi().query(query);
103
+ if (!result?.elements)
104
+ return undefined;
105
+ const isos = result.elements
106
+ .map(el => el.tags['ISO3166-1:alpha2'])
107
+ .filter((iso) => !!iso)
108
+ .map(iso => iso.toUpperCase());
109
+ if (isos.length < 2)
110
+ return isos[0];
111
+ return isos.find(iso => this.getList().countries[iso] !== undefined);
112
+ }
113
+ catch {
114
+ return undefined;
115
+ }
116
+ }
117
+ getOverpassApi() {
118
+ return (0, services_1.useOverpassApi)();
119
+ }
120
+ };
121
+ return Countries = _classThis;
122
+ })();
123
+ exports.Countries = Countries;
124
+ const getCountries = () => new Countries();
125
+ exports.getCountries = getCountries;
@@ -30,12 +30,12 @@ class OptionManager {
30
30
  const path = segment.path;
31
31
  const opts = await this.getNextOptions(segment);
32
32
  if (opts?.length === 1) {
33
- if (opts[0].id !== segment.id) {
33
+ if (opts[0].id === segment.id) {
34
34
  (0, utils_1.concatPaths)(path, opts[0].path, 'after', opts[0].id);
35
35
  }
36
36
  else {
37
37
  let foundSameSegment = false;
38
- options[0].path.forEach((point, j) => {
38
+ opts[0].path.forEach((point, j) => {
39
39
  if (j === 0)
40
40
  return;
41
41
  foundSameSegment = points.some(pAll => pAll.id === point.id);
@@ -386,7 +386,7 @@ class OptionManager {
386
386
  const w = this.getWay(way);
387
387
  if (!w)
388
388
  return [];
389
- if (w.roundabout) {
389
+ if ((0, utils_1.isRoundabout)(w) && w.path[0].id !== w.path.at(-1).id) {
390
390
  const branches = (0, utils_1.splitAtPoint)(w, location);
391
391
  branches.forEach(b => {
392
392
  if (b.path.length > 1 && b.path[1].id !== prev.id) {
@@ -166,7 +166,7 @@ function splitAtPointInfo(way, split) {
166
166
  function isRoundabout(w, strictCheck = false) {
167
167
  if (!w)
168
168
  return;
169
- let roundabout = (w.tags !== undefined && (w.tags.roundabout === true || w.tags.junction === 'roundabout'));
169
+ let roundabout = (w.tags !== undefined && (w.tags.roundabout === true || w.tags.junction === 'roundabout' || w.tags.junction === 'circular'));
170
170
  if (roundabout)
171
171
  return true;
172
172
  if (strictCheck)
@@ -35,6 +35,7 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
35
35
  };
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.RLVDisplayService = void 0;
38
+ const api_1 = require("../../api");
38
39
  const decorators_1 = require("../../base/decorators");
39
40
  const types_1 = require("../../base/types");
40
41
  const coaches_1 = require("../../coaches");
@@ -47,15 +48,18 @@ const RouteDisplayService_1 = require("./RouteDisplayService");
47
48
  let RLVDisplayService = (() => {
48
49
  let _classSuper = RouteDisplayService_1.RouteDisplayService;
49
50
  let _instanceExtraInitializers = [];
51
+ let _getBindings_decorators;
50
52
  let _getRouteList_decorators;
51
53
  let _getLocalization_decorators;
52
54
  let _getCoaches_decorators;
53
55
  return class RLVDisplayService extends _classSuper {
54
56
  static {
55
57
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
58
+ _getBindings_decorators = [decorators_1.Injectable];
56
59
  _getRouteList_decorators = [decorators_1.Injectable];
57
60
  _getLocalization_decorators = [decorators_1.Injectable];
58
61
  _getCoaches_decorators = [decorators_1.Injectable];
62
+ __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);
59
63
  __esDecorate(this, null, _getRouteList_decorators, { kind: "method", name: "getRouteList", static: false, private: false, access: { has: obj => "getRouteList" in obj, get: obj => obj.getRouteList }, metadata: _metadata }, null, _instanceExtraInitializers);
60
64
  __esDecorate(this, null, _getLocalization_decorators, { kind: "method", name: "getLocalization", static: false, private: false, access: { has: obj => "getLocalization" in obj, get: obj => obj.getLocalization }, metadata: _metadata }, null, _instanceExtraInitializers);
61
65
  __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);
@@ -129,8 +133,8 @@ let RLVDisplayService = (() => {
129
133
  const nextId = (0, routes_1.getNextVideoId)(videoRoute);
130
134
  this.logEvent({ message: 'video added', id: videoRoute.description.id, title: videoRoute.description.title, segmentDistance: videoRoute.description.distance, next: nextId });
131
135
  }
132
- catch (error) {
133
- this.logError(error, 'addVideo');
136
+ catch (err) {
137
+ this.logError(err, 'addVideo');
134
138
  }
135
139
  }
136
140
  pause() {
@@ -515,12 +519,14 @@ let RLVDisplayService = (() => {
515
519
  fileName = fileName.replace('incyclist:', 'file:');
516
520
  if (fileName.startsWith('video:') && !lc.endsWith('.avi'))
517
521
  return fileName.replace('video:', 'file:');
518
- if (fileName.startsWith('file:') && !lc.endsWith('.avi'))
522
+ if (fileName.startsWith('file:') && !lc.endsWith('.avi') && !this.isMobile())
519
523
  return fileName.replace('file:', 'video:');
520
524
  if (fileName.startsWith('video:') && lc.endsWith('.avi'))
521
525
  return fileName;
522
526
  if (fileName.startsWith('file:') || fileName.startsWith('http:') || fileName.startsWith('https:') || fileName.startsWith('/'))
523
527
  return fileName;
528
+ if (fileName.startsWith('content:'))
529
+ return fileName;
524
530
  return `./${fileName}`;
525
531
  }
526
532
  isLoopEnabled() {
@@ -565,6 +571,12 @@ let RLVDisplayService = (() => {
565
571
  this.addVideo(nextRoute, false, current);
566
572
  return true;
567
573
  }
574
+ isMobile() {
575
+ return this.getBindings()?.appInfo?.getChannel() === 'mobile';
576
+ }
577
+ getBindings() {
578
+ return (0, api_1.getBindings)();
579
+ }
568
580
  getRouteList() {
569
581
  return (0, routes_1.useRouteList)();
570
582
  }
@@ -90,10 +90,7 @@ let Route = (() => {
90
90
  return this.getLocalizedTitle(language);
91
91
  }
92
92
  getLocalizedTitle(language) {
93
- if (this._details)
94
- return (0, localization_1.getLocalizedText)(this._details.localizedTitle, language) ?? this._details.title;
95
- else
96
- return (0, localization_1.getLocalizedText)(this._description.localizedTitle, language) ?? this._description.title;
93
+ return (0, localization_1.getLocalizedText)(this._description.localizedTitle, language) ?? this._description.title;
97
94
  }
98
95
  clone() {
99
96
  const description = (0, clone_1.default)(this._description);
@@ -47,7 +47,7 @@ class BikeLabParser extends xml_1.XMLParser {
47
47
  localizedTitle: value('Description') ?? value('Name'),
48
48
  country: value('CountryCode'),
49
49
  id: value('id'),
50
- previewUrl: value('previewURL'),
50
+ previewUrl: value('previewURL') ?? undefined,
51
51
  distance: 0,
52
52
  elevation: 0,
53
53
  points: [],
@@ -52,35 +52,32 @@ class EPMParser extends xml_1.XMLParser {
52
52
  }
53
53
  async loadEpp(context) {
54
54
  const { fileInfo } = context;
55
+ (0, utils_1.fixIncorrectFileInfo)(fileInfo);
55
56
  const file = { ...fileInfo, ext: 'epp', encoding: 'binary' };
56
- let fullName = fileInfo.base ?? fileInfo.name;
57
- if (!fullName.includes('.epm')) {
58
- fullName = fullName + '.epm';
59
- }
60
- const fileName = fullName.replace('epm', 'epp');
61
- if (fileName.startsWith('http') || fileName.startsWith('file') || fileName.startsWith('/') || fileName.startsWith('\\') || fileName.startsWith('.')) {
62
- file.type = 'file';
63
- file.filename = fileName;
64
- }
65
- else if (fileInfo.type === 'url') {
66
- file.url = file.url.replace(fileInfo.name, fileName);
67
- }
68
- else {
69
- file.filename = file.filename.replace(fullName, fileName);
57
+ let base = fileInfo.base;
58
+ if (!base.includes('.epm')) {
59
+ base = base + '.epm';
70
60
  }
61
+ file.base = base.replace('.epm', '.epp');
62
+ if (file.filename)
63
+ file.filename = fileInfo.filename.replace(base, file.base);
64
+ if (file.url)
65
+ file.url = fileInfo.url.replace(base, file.base);
71
66
  const onError = () => {
72
- const nameInfo = this.getChannel() === 'mobile' ? fileName : (0, utils_2.getFileName)(file);
67
+ const nameInfo = this.getChannel() === 'mobile' ? base : (0, utils_2.getFileName)(file);
73
68
  throw new Error('Could not open EPP file: ' + nameInfo);
74
69
  };
75
70
  const loader = (0, api_1.getBindings)().loader;
76
71
  try {
77
72
  const res = await loader.open(file);
78
73
  if (res.error) {
74
+ this.logger.logEvent({ message: 'could not load EPP file', file, reason: res.error });
79
75
  onError();
80
76
  }
81
77
  return res.data;
82
78
  }
83
79
  catch (err) {
80
+ this.logger.logEvent({ message: 'could not load EPP file', file, reason: err.message });
84
81
  onError();
85
82
  }
86
83
  }
@@ -38,6 +38,7 @@ exports.GeometryParser = void 0;
38
38
  const api_1 = require("../../../api");
39
39
  const decorators_1 = require("../../../base/decorators");
40
40
  const utils_1 = require("../../../utils");
41
+ const utils_2 = require("./utils");
41
42
  let GeometryParser = (() => {
42
43
  let _instanceExtraInitializers = [];
43
44
  let _getLoader_decorators;
@@ -53,7 +54,7 @@ let GeometryParser = (() => {
53
54
  return await this.parse(file, geometry);
54
55
  }
55
56
  getPrimaryExtension() {
56
- return 'xml';
57
+ return 'json';
57
58
  }
58
59
  getCompanionExtensions() {
59
60
  return [];
@@ -75,10 +76,8 @@ let GeometryParser = (() => {
75
76
  if (res.error) {
76
77
  onError();
77
78
  }
78
- if ((typeof res.data) === 'string') {
79
- return JSON.parse(res.data);
80
- }
81
- return res.data;
79
+ const cleaned = (0, utils_2.getUtf8Data)(res.data);
80
+ return JSON.parse(cleaned);
82
81
  }
83
82
  catch {
84
83
  onError();
@@ -24,6 +24,7 @@ const multixml_1 = require("./multixml");
24
24
  const bikelab_1 = require("./bikelab");
25
25
  const epm_1 = require("./epm");
26
26
  const TacxParser_1 = require("./tacx/TacxParser");
27
+ const utils_1 = require("./utils");
27
28
  const useParsers = () => {
28
29
  const parsers = factory_1.ParserFactory.getInstance();
29
30
  if (!parsers.isInitialized()) {
@@ -38,6 +39,7 @@ const useParsers = () => {
38
39
  exports.useParsers = useParsers;
39
40
  class RouteParser {
40
41
  static async parse(info) {
42
+ (0, utils_1.fixIncorrectFileInfo)(info);
41
43
  const parsers = (0, exports.useParsers)();
42
44
  const formatParsers = parsers.suppertsExtension(info.ext);
43
45
  const promises = [];
@@ -51,8 +53,10 @@ class RouteParser {
51
53
  });
52
54
  const res = await Promise.allSettled(promises);
53
55
  const matching = res.map(promise => promise.status === 'fulfilled' ? promise.value : undefined).find(p => p !== undefined);
54
- if (matching)
55
- return await matching.parser.import(info, matching.data);
56
+ if (matching) {
57
+ const res = await matching.parser.import(info, matching.data);
58
+ return res;
59
+ }
56
60
  if (formatParsers.length === 0)
57
61
  throw new Error('no matching parser found');
58
62
  else {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MultipleXMLParser = void 0;
4
4
  const api_1 = require("../../../api");
5
5
  const xml_1 = require("../../../utils/xml");
6
+ const utils_1 = require("./utils");
6
7
  class MultipleXMLParser {
7
8
  parsers;
8
9
  constructor(classes) {
@@ -37,7 +38,8 @@ class MultipleXMLParser {
37
38
  if (res.error) {
38
39
  throw new Error('Could not open file');
39
40
  }
40
- const xml = await (0, xml_1.parseXml)(res.data);
41
+ const cleaned = (0, utils_1.getUtf8Data)(res.data);
42
+ const xml = await (0, xml_1.parseXml)(cleaned);
41
43
  return xml;
42
44
  }
43
45
  }