incyclist-services 1.5.71 → 1.6.1
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.
- package/lib/appstate/index.d.ts +1 -0
- package/lib/appstate/index.js +1 -0
- package/lib/appstate/service.d.ts +2 -0
- package/lib/appstate/service.js +3 -0
- package/lib/ride/display/service.js +4 -11
- package/lib/routes/base/utils/route.d.ts +2 -2
- package/lib/routes/base/utils/route.js +20 -12
- package/package.json +1 -1
package/lib/appstate/index.d.ts
CHANGED
package/lib/appstate/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { IncyclistService } from "../base/service";
|
|
2
|
+
import { AppFeature } from "./types";
|
|
2
3
|
export declare class AppStateService extends IncyclistService {
|
|
3
4
|
protected state: Record<string, any>;
|
|
4
5
|
constructor();
|
|
6
|
+
hasFeature(feature: AppFeature): any;
|
|
5
7
|
getPersistedState(key: string): any;
|
|
6
8
|
setPersistedState(key: string, value: any): void;
|
|
7
9
|
getState(key: string): any;
|
package/lib/appstate/service.js
CHANGED
|
@@ -56,6 +56,9 @@ let AppStateService = (() => {
|
|
|
56
56
|
super('AppState');
|
|
57
57
|
this.state = (__runInitializers(this, _instanceExtraInitializers), {});
|
|
58
58
|
}
|
|
59
|
+
hasFeature(feature) {
|
|
60
|
+
return this.getSetting(feature, false);
|
|
61
|
+
}
|
|
59
62
|
getPersistedState(key) {
|
|
60
63
|
return this.getSetting(`state.${key}`, undefined);
|
|
61
64
|
}
|
|
@@ -99,21 +99,14 @@ let RideDisplayService = (() => {
|
|
|
99
99
|
}
|
|
100
100
|
init() {
|
|
101
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
var _a, _b, _c;
|
|
103
102
|
yield this.closePrevRide();
|
|
104
103
|
this.observer = new types_1.Observer();
|
|
105
104
|
try {
|
|
106
105
|
this.displayService = this.getRideModeService(true);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (!showLegacy) {
|
|
112
|
-
this.displayService.init(this);
|
|
113
|
-
this.displayService.on('lap-completed', this.onLapCompleted.bind(this));
|
|
114
|
-
this.displayService.on('route-completed', this.onRouteCompleted.bind(this));
|
|
115
|
-
this.hideAll = false;
|
|
116
|
-
}
|
|
106
|
+
this.displayService.init(this);
|
|
107
|
+
this.displayService.on('lap-completed', this.onLapCompleted.bind(this));
|
|
108
|
+
this.displayService.on('route-completed', this.onRouteCompleted.bind(this));
|
|
109
|
+
this.hideAll = false;
|
|
117
110
|
}
|
|
118
111
|
catch (err) {
|
|
119
112
|
this.logError(err, 'init');
|
|
@@ -31,9 +31,9 @@ export interface GetPositionProps {
|
|
|
31
31
|
nearest?: boolean;
|
|
32
32
|
latlng?: LatLng;
|
|
33
33
|
}
|
|
34
|
-
export declare const getPosition: (
|
|
34
|
+
export declare const getPosition: (src: Route | Array<RoutePoint>, props: GetPositionProps) => RoutePoint;
|
|
35
35
|
export declare const getHeading: (route: Route, point: RoutePoint) => number;
|
|
36
|
-
export declare const getPointAtDistance: (
|
|
36
|
+
export declare const getPointAtDistance: (src: Route | RouteApiDetail | Array<RoutePoint>, routeDistance: number, nearest?: boolean) => RoutePoint;
|
|
37
37
|
interface LegacyRouteApiDetail extends RouteApiDetail {
|
|
38
38
|
decoded?: Array<RoutePoint>;
|
|
39
39
|
}
|
|
@@ -359,18 +359,26 @@ const getNextPosition = (route, props) => {
|
|
|
359
359
|
return lapPoint;
|
|
360
360
|
};
|
|
361
361
|
exports.getNextPosition = getNextPosition;
|
|
362
|
-
const getPosition = (
|
|
363
|
-
|
|
362
|
+
const getPosition = (src, props) => {
|
|
363
|
+
let route;
|
|
364
|
+
let points;
|
|
365
|
+
if (Array.isArray(src)) {
|
|
366
|
+
points = src;
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
route = src;
|
|
370
|
+
}
|
|
371
|
+
if (props === undefined || ((route === null || route === void 0 ? void 0 : route.points) === undefined && !(points === null || points === void 0 ? void 0 : points.length)))
|
|
364
372
|
return;
|
|
365
373
|
const { cnt, distance, nearest = true, latlng } = props;
|
|
366
374
|
if (props.cnt !== undefined) {
|
|
367
|
-
return getPointAtIndex(
|
|
375
|
+
return getPointAtIndex(src, cnt);
|
|
368
376
|
}
|
|
369
377
|
if (props.distance !== undefined) {
|
|
370
|
-
return (0, exports.getPointAtDistance)(
|
|
378
|
+
return (0, exports.getPointAtDistance)(src, distance, nearest);
|
|
371
379
|
}
|
|
372
380
|
if (props.latlng !== undefined) {
|
|
373
|
-
return getPointAtLatLng(
|
|
381
|
+
return getPointAtLatLng(src, latlng, nearest);
|
|
374
382
|
}
|
|
375
383
|
};
|
|
376
384
|
exports.getPosition = getPosition;
|
|
@@ -394,16 +402,16 @@ const getHeading = (route, point) => {
|
|
|
394
402
|
return (0, geo_1.calculateHeaderFromPoints)(p1, p2);
|
|
395
403
|
};
|
|
396
404
|
exports.getHeading = getHeading;
|
|
397
|
-
const getPointAtIndex = (
|
|
398
|
-
const points =
|
|
405
|
+
const getPointAtIndex = (src, idx) => {
|
|
406
|
+
const points = Array.isArray(src) ? src : src.points;
|
|
399
407
|
if (idx >= points.length || idx < 0)
|
|
400
408
|
return;
|
|
401
409
|
const point = Object.assign({}, points[idx]);
|
|
402
410
|
point.cnt = idx;
|
|
403
411
|
return point;
|
|
404
412
|
};
|
|
405
|
-
const getPointAtDistance = (
|
|
406
|
-
const points =
|
|
413
|
+
const getPointAtDistance = (src, routeDistance, nearest = true) => {
|
|
414
|
+
const points = Array.isArray(src) ? src : src.points;
|
|
407
415
|
if (!points)
|
|
408
416
|
return;
|
|
409
417
|
const exact = !nearest;
|
|
@@ -432,9 +440,9 @@ const getPointAtDistance = (route, routeDistance, nearest = true) => {
|
|
|
432
440
|
return point;
|
|
433
441
|
};
|
|
434
442
|
exports.getPointAtDistance = getPointAtDistance;
|
|
435
|
-
const getPointAtLatLng = (
|
|
436
|
-
const points =
|
|
437
|
-
if (!points
|
|
443
|
+
const getPointAtLatLng = (src, latlng, nearest = true) => {
|
|
444
|
+
const points = Array.isArray(src) ? src : src.points;
|
|
445
|
+
if (!points)
|
|
438
446
|
return;
|
|
439
447
|
const exact = !nearest;
|
|
440
448
|
let cnt = 0;
|