incyclist-services 1.9.14 → 1.9.15
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/cjs/routes/free-ride/service.js +13 -0
- package/lib/cjs/routes/list/service.js +3 -0
- package/lib/esm/routes/free-ride/service.js +13 -0
- package/lib/esm/routes/list/service.js +3 -0
- package/lib/types/routes/free-ride/service.d.ts +2 -0
- package/lib/types/routes/list/service.d.ts +1 -0
- package/package.json +1 -1
|
@@ -82,6 +82,7 @@ let FreeRideService = (() => {
|
|
|
82
82
|
initialized = false;
|
|
83
83
|
ivInit;
|
|
84
84
|
cntInitRetry = 0;
|
|
85
|
+
pendingEnsure;
|
|
85
86
|
rideSeq = 0;
|
|
86
87
|
selectedBy = 'auto';
|
|
87
88
|
startSource = 'default';
|
|
@@ -115,6 +116,18 @@ let FreeRideService = (() => {
|
|
|
115
116
|
isInitialized() {
|
|
116
117
|
return this.initialized;
|
|
117
118
|
}
|
|
119
|
+
async ensureInitialized() {
|
|
120
|
+
if (this.initialized)
|
|
121
|
+
return true;
|
|
122
|
+
if (!this.pendingEnsure) {
|
|
123
|
+
this.logEvent({ message: 'init free ride service on demand' });
|
|
124
|
+
this.pendingEnsure = this.selectStartPosition()
|
|
125
|
+
.catch(err => { this.logError(err, 'ensureInitialized'); })
|
|
126
|
+
.then(() => this.initialized)
|
|
127
|
+
.finally(() => { delete this.pendingEnsure; });
|
|
128
|
+
}
|
|
129
|
+
return this.pendingEnsure;
|
|
130
|
+
}
|
|
118
131
|
async selectStartPosition(position, opts) {
|
|
119
132
|
const rideSeq = this.rideSeq;
|
|
120
133
|
const keepSource = !position && (this.startSource === 'search' || this.startSource === 'map');
|
|
@@ -756,6 +756,9 @@ let RouteListService = (() => {
|
|
|
756
756
|
isFreeRideSupported() {
|
|
757
757
|
return this.getFreeRideService().isInitialized();
|
|
758
758
|
}
|
|
759
|
+
async ensureFreeRideSupported() {
|
|
760
|
+
return await this.getFreeRideService().ensureInitialized();
|
|
761
|
+
}
|
|
759
762
|
addRoute(route, source = 'system') {
|
|
760
763
|
const existing = source === 'system' ? this.getRoute(route.description.id) :
|
|
761
764
|
this.routes.find(r => r.description?.id === route.description.id);
|
|
@@ -76,6 +76,7 @@ let FreeRideService = (() => {
|
|
|
76
76
|
initialized = false;
|
|
77
77
|
ivInit;
|
|
78
78
|
cntInitRetry = 0;
|
|
79
|
+
pendingEnsure;
|
|
79
80
|
rideSeq = 0;
|
|
80
81
|
selectedBy = 'auto';
|
|
81
82
|
startSource = 'default';
|
|
@@ -109,6 +110,18 @@ let FreeRideService = (() => {
|
|
|
109
110
|
isInitialized() {
|
|
110
111
|
return this.initialized;
|
|
111
112
|
}
|
|
113
|
+
async ensureInitialized() {
|
|
114
|
+
if (this.initialized)
|
|
115
|
+
return true;
|
|
116
|
+
if (!this.pendingEnsure) {
|
|
117
|
+
this.logEvent({ message: 'init free ride service on demand' });
|
|
118
|
+
this.pendingEnsure = this.selectStartPosition()
|
|
119
|
+
.catch(err => { this.logError(err, 'ensureInitialized'); })
|
|
120
|
+
.then(() => this.initialized)
|
|
121
|
+
.finally(() => { delete this.pendingEnsure; });
|
|
122
|
+
}
|
|
123
|
+
return this.pendingEnsure;
|
|
124
|
+
}
|
|
112
125
|
async selectStartPosition(position, opts) {
|
|
113
126
|
const rideSeq = this.rideSeq;
|
|
114
127
|
const keepSource = !position && (this.startSource === 'search' || this.startSource === 'map');
|
|
@@ -750,6 +750,9 @@ let RouteListService = (() => {
|
|
|
750
750
|
isFreeRideSupported() {
|
|
751
751
|
return this.getFreeRideService().isInitialized();
|
|
752
752
|
}
|
|
753
|
+
async ensureFreeRideSupported() {
|
|
754
|
+
return await this.getFreeRideService().ensureInitialized();
|
|
755
|
+
}
|
|
753
756
|
addRoute(route, source = 'system') {
|
|
754
757
|
const existing = source === 'system' ? this.getRoute(route.description.id) :
|
|
755
758
|
this.routes.find(r => r.description?.id === route.description.id);
|
|
@@ -12,12 +12,14 @@ export declare class FreeRideService extends IncyclistService {
|
|
|
12
12
|
protected initialized: boolean;
|
|
13
13
|
protected ivInit?: NodeJS.Timeout;
|
|
14
14
|
protected cntInitRetry: number;
|
|
15
|
+
protected pendingEnsure?: Promise<boolean>;
|
|
15
16
|
protected rideSeq: number;
|
|
16
17
|
protected selectedBy: 'auto' | 'user';
|
|
17
18
|
protected startSource: 'default' | 'last' | 'search' | 'map';
|
|
18
19
|
constructor();
|
|
19
20
|
init(): void;
|
|
20
21
|
isInitialized(): boolean;
|
|
22
|
+
ensureInitialized(): Promise<boolean>;
|
|
21
23
|
selectStartPosition(position?: LatLng | undefined, opts?: {
|
|
22
24
|
source?: 'search' | 'map';
|
|
23
25
|
}): Promise<{
|
|
@@ -137,6 +137,7 @@ export declare class RouteListService extends IncyclistService implements IRoute
|
|
|
137
137
|
existsBySourceUri(uri: string): boolean;
|
|
138
138
|
getBySourceUri(uri: string): Route;
|
|
139
139
|
isFreeRideSupported(): boolean;
|
|
140
|
+
ensureFreeRideSupported(): Promise<boolean>;
|
|
140
141
|
addRoute(route: Route, source?: 'user' | 'system' | 'import'): void;
|
|
141
142
|
forgetRoute(target: Route | string): void;
|
|
142
143
|
createPreview(descr: RouteInfo): Promise<unknown>;
|