incyclist-services 1.7.21 → 1.7.23
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/activities/active-rides/mq.js +8 -3
- package/lib/cjs/activities/types.js +17 -0
- package/lib/cjs/apps/base/app/index.js +10 -1
- package/lib/cjs/apps/komoot/KomootAppConnection.js +13 -9
- package/lib/cjs/apps/velohero/VeloHeroAppConnection.js +0 -1
- package/lib/cjs/base/pages/service.js +26 -0
- package/lib/cjs/devices/page/service.js +23 -24
- package/lib/cjs/devices/pairing/service.js +0 -3
- package/lib/cjs/devices/ride/index.js +0 -1
- package/lib/cjs/devices/ride/types.js +2 -0
- package/lib/cjs/ride/display/service.js +2 -2
- package/lib/cjs/ride/index.js +1 -0
- package/lib/cjs/ride/page/index.js +17 -0
- package/lib/cjs/ride/page/service.js +225 -0
- package/lib/cjs/ride/page/types.js +2 -0
- package/lib/cjs/ride/route/RLVDisplayService.js +29 -26
- package/lib/cjs/ride/types.js +2 -0
- package/lib/cjs/routes/page/service.js +16 -0
- package/lib/esm/activities/active-rides/mq.js +8 -3
- package/lib/esm/activities/types.js +1 -0
- package/lib/esm/apps/base/app/index.js +10 -1
- package/lib/esm/apps/komoot/KomootAppConnection.js +13 -9
- package/lib/esm/apps/velohero/VeloHeroAppConnection.js +0 -1
- package/lib/esm/base/pages/service.js +26 -0
- package/lib/esm/devices/page/service.js +23 -24
- package/lib/esm/devices/pairing/service.js +0 -3
- package/lib/esm/devices/ride/index.js +0 -1
- package/lib/esm/devices/ride/types.js +1 -0
- package/lib/esm/ride/display/service.js +2 -2
- package/lib/esm/ride/index.js +1 -0
- package/lib/esm/ride/page/index.js +1 -0
- package/lib/esm/ride/page/service.js +221 -0
- package/lib/esm/ride/page/types.js +1 -0
- package/lib/esm/ride/route/RLVDisplayService.js +29 -26
- package/lib/esm/ride/types.js +1 -0
- package/lib/esm/routes/page/service.js +16 -0
- package/lib/types/activities/ride/service.d.ts +1 -1
- package/lib/types/activities/ride/types.d.ts +14 -0
- package/lib/types/activities/types.d.ts +1 -0
- package/lib/types/apps/base/app/index.d.ts +2 -0
- package/lib/types/apps/komoot/KomootAppConnection.d.ts +2 -2
- package/lib/types/apps/velohero/VeloHeroAppConnection.d.ts +0 -1
- package/lib/types/base/pages/service.d.ts +4 -0
- package/lib/types/devices/page/service.d.ts +2 -4
- package/lib/types/devices/ride/index.d.ts +1 -1
- package/lib/types/devices/ride/service.d.ts +1 -1
- package/lib/types/devices/ride/types.d.ts +54 -0
- package/lib/types/devices/types.d.ts +1 -0
- package/lib/types/ride/display/service.d.ts +1 -1
- package/lib/types/ride/index.d.ts +1 -0
- package/lib/types/ride/page/index.d.ts +1 -0
- package/lib/types/ride/page/service.d.ts +40 -0
- package/lib/types/ride/page/types.d.ts +34 -0
- package/lib/types/ride/route/types.d.ts +19 -0
- package/lib/types/ride/types.d.ts +3 -0
- package/lib/types/routes/page/service.d.ts +2 -0
- package/lib/types/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -135,12 +135,12 @@ let RLVDisplayService = (() => {
|
|
|
135
135
|
}
|
|
136
136
|
pause() {
|
|
137
137
|
super.pause();
|
|
138
|
-
this.currentVideo
|
|
138
|
+
this.currentVideo?.syncHelper.pause();
|
|
139
139
|
this.isVideoPaused = true;
|
|
140
140
|
}
|
|
141
141
|
resume() {
|
|
142
142
|
super.resume();
|
|
143
|
-
this.currentVideo
|
|
143
|
+
this.currentVideo?.syncHelper.resume();
|
|
144
144
|
this.isVideoPaused = false;
|
|
145
145
|
}
|
|
146
146
|
getDisplayProperties(props) {
|
|
@@ -157,14 +157,14 @@ let RLVDisplayService = (() => {
|
|
|
157
157
|
if (this.videos.length === 1) {
|
|
158
158
|
const autoConvert = this.currentVideo?.playback === 'converted';
|
|
159
159
|
const video = {
|
|
160
|
-
src: this.currentVideo
|
|
160
|
+
src: this.currentVideo?.source,
|
|
161
161
|
startTime,
|
|
162
162
|
autoConvert,
|
|
163
163
|
info: this.getInfotextDisplayProps(),
|
|
164
164
|
muted: true,
|
|
165
165
|
loop: this.isLoopEnabled() ? true : undefined,
|
|
166
|
-
playback: this.currentVideo
|
|
167
|
-
observer: this.currentVideo
|
|
166
|
+
playback: this.currentVideo?.playback,
|
|
167
|
+
observer: this.currentVideo?.observer,
|
|
168
168
|
onLoaded: this.onVideoLoaded.bind(this),
|
|
169
169
|
onLoadError: this.onVideoLoadError.bind(this),
|
|
170
170
|
onPlaybackError: this.onVideoPlaybackError.bind(this),
|
|
@@ -239,8 +239,8 @@ let RLVDisplayService = (() => {
|
|
|
239
239
|
}
|
|
240
240
|
onNextVideo() {
|
|
241
241
|
const old = this.currentVideo;
|
|
242
|
-
const next = this.currentVideo
|
|
243
|
-
if (!next)
|
|
242
|
+
const next = this.currentVideo?.next;
|
|
243
|
+
if (!next || !old)
|
|
244
244
|
return;
|
|
245
245
|
old.isCurrent = false;
|
|
246
246
|
old.isInitial = false;
|
|
@@ -261,13 +261,13 @@ let RLVDisplayService = (() => {
|
|
|
261
261
|
this.emit('route-updated', this.getCurrentRoute());
|
|
262
262
|
this.getCoaches().updateRoute(this.getCurrentRoute());
|
|
263
263
|
this.logEvent({ message: 'switching to next video', route: this.getCurrentRoute().details.title,
|
|
264
|
-
segment: this.currentVideo
|
|
264
|
+
segment: this.currentVideo?.route.description.title, offset: this.offset, segmentDistance: this.currentVideo?.route.description.distance,
|
|
265
265
|
totalDistance: this.getCurrentRoute().details.distance });
|
|
266
266
|
}
|
|
267
267
|
checkInfotextDisplayProps(time) {
|
|
268
268
|
if (!this.currentVideo?.info)
|
|
269
269
|
return;
|
|
270
|
-
const info = this.currentVideo
|
|
270
|
+
const info = this.currentVideo?.info.find(i => i.start <= time && i.stop > time);
|
|
271
271
|
if (info) {
|
|
272
272
|
this.infotext = info.props;
|
|
273
273
|
}
|
|
@@ -323,7 +323,7 @@ let RLVDisplayService = (() => {
|
|
|
323
323
|
}
|
|
324
324
|
async stop() {
|
|
325
325
|
try {
|
|
326
|
-
this.currentVideo
|
|
326
|
+
this.currentVideo?.syncHelper.stop();
|
|
327
327
|
delete this.startTime;
|
|
328
328
|
await super.stop();
|
|
329
329
|
}
|
|
@@ -339,7 +339,7 @@ let RLVDisplayService = (() => {
|
|
|
339
339
|
if (this.currentRoute?.description?.hasGpx && !this.currentRoute?.points?.length) {
|
|
340
340
|
state = 'Start:Failed';
|
|
341
341
|
const errMessage = 'Invalid route (GPX missing)';
|
|
342
|
-
if (!this.currentVideo
|
|
342
|
+
if (!this.currentVideo?.error) {
|
|
343
343
|
this.logError(new Error(errMessage), 'getVideoState', { route: this.currentVideo.route });
|
|
344
344
|
}
|
|
345
345
|
this.currentVideo.error = errMessage;
|
|
@@ -357,7 +357,7 @@ let RLVDisplayService = (() => {
|
|
|
357
357
|
return state;
|
|
358
358
|
}
|
|
359
359
|
getVideoLoadProgress() {
|
|
360
|
-
return { loaded: this.currentVideo?.loaded, bufferTime: this.currentVideo
|
|
360
|
+
return { loaded: this.currentVideo?.loaded, bufferTime: this.currentVideo?.bufferTime };
|
|
361
361
|
}
|
|
362
362
|
onConvertUpdate(progress, frames, time) {
|
|
363
363
|
if (!this.currentVideo || this.currentVideo.loaded)
|
|
@@ -433,7 +433,7 @@ let RLVDisplayService = (() => {
|
|
|
433
433
|
}
|
|
434
434
|
onVideoEnded(video = this.currentVideo) {
|
|
435
435
|
video.syncHelper.onVideoEnded();
|
|
436
|
-
if (this.currentVideo
|
|
436
|
+
if (this.currentVideo?.next) {
|
|
437
437
|
this.onNextVideo();
|
|
438
438
|
}
|
|
439
439
|
}
|
|
@@ -442,7 +442,7 @@ let RLVDisplayService = (() => {
|
|
|
442
442
|
const offset = this.offset ?? 0;
|
|
443
443
|
const { routeDistance, speed } = activityPos;
|
|
444
444
|
if (!this.isVideoPaused) {
|
|
445
|
-
this.currentVideo
|
|
445
|
+
this.currentVideo?.syncHelper.onActivityUpdate(routeDistance - offset, speed);
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
448
|
initVideoSource(video) {
|
|
@@ -468,18 +468,21 @@ let RLVDisplayService = (() => {
|
|
|
468
468
|
buildVideoError(error, video = this.currentVideo) {
|
|
469
469
|
const src = this.getVideoUrl(video);
|
|
470
470
|
const remote = src?.startsWith('http');
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
471
|
+
try {
|
|
472
|
+
switch (error.code) {
|
|
473
|
+
case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED:
|
|
474
|
+
if (error.message.includes('Format error'))
|
|
475
|
+
return remote ? 'Could not load video' : 'Could not open video file';
|
|
476
|
+
return 'Could not decode video';
|
|
477
|
+
case MediaError.MEDIA_ERR_NETWORK:
|
|
474
478
|
return remote ? 'Could not load video' : 'Could not open video file';
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
case MediaError.MEDIA_ERR_DECODE:
|
|
481
|
-
return 'Could not decode video';
|
|
479
|
+
case MediaError.MEDIA_ERR_ABORTED:
|
|
480
|
+
return 'The playback was canceled';
|
|
481
|
+
case MediaError.MEDIA_ERR_DECODE:
|
|
482
|
+
return 'Could not decode video';
|
|
483
|
+
}
|
|
482
484
|
}
|
|
485
|
+
catch { }
|
|
483
486
|
return error.message;
|
|
484
487
|
}
|
|
485
488
|
getVideoUrl(video) {
|
|
@@ -528,11 +531,11 @@ let RLVDisplayService = (() => {
|
|
|
528
531
|
let distance = startPos;
|
|
529
532
|
if (startPos === undefined) {
|
|
530
533
|
distance = this.isLoopEnabled() ? lapDistance : routeDistance - (this.offset ?? 0);
|
|
531
|
-
if (distance > this.currentVideo
|
|
534
|
+
if (distance > this.currentVideo?.route.details.distance) {
|
|
532
535
|
distance = 0;
|
|
533
536
|
}
|
|
534
537
|
}
|
|
535
|
-
const routeId = this.currentVideo
|
|
538
|
+
const routeId = this.currentVideo?.route.description.id;
|
|
536
539
|
this.getUserSettings().set(`routeSelection.video.prevSetting.${routeId}.startPos`, distance);
|
|
537
540
|
}
|
|
538
541
|
catch (err) {
|
package/lib/cjs/ride/types.js
CHANGED
|
@@ -43,6 +43,7 @@ const settings_1 = require("../../settings");
|
|
|
43
43
|
const types_1 = require("../../base/types");
|
|
44
44
|
const uuid_1 = require("uuid");
|
|
45
45
|
const sleep_1 = require("../../utils/sleep");
|
|
46
|
+
const devices_1 = require("../../devices");
|
|
46
47
|
let RoutesPageService = (() => {
|
|
47
48
|
let _classDecorators = [decorators_1.Singleton];
|
|
48
49
|
let _classDescriptor;
|
|
@@ -51,14 +52,17 @@ let RoutesPageService = (() => {
|
|
|
51
52
|
let _classSuper = pages_1.IncyclistPageService;
|
|
52
53
|
let _instanceExtraInitializers = [];
|
|
53
54
|
let _getRouteList_decorators;
|
|
55
|
+
let _getDevicePairing_decorators;
|
|
54
56
|
let _getUserSettings_decorators;
|
|
55
57
|
var RoutesPageService = class extends _classSuper {
|
|
56
58
|
static { _classThis = this; }
|
|
57
59
|
static {
|
|
58
60
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
59
61
|
_getRouteList_decorators = [decorators_1.Injectable];
|
|
62
|
+
_getDevicePairing_decorators = [decorators_1.Injectable];
|
|
60
63
|
_getUserSettings_decorators = [decorators_1.Injectable];
|
|
61
64
|
__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);
|
|
65
|
+
__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);
|
|
62
66
|
__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
67
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
64
68
|
RoutesPageService = _classThis = _classDescriptor.value;
|
|
@@ -144,6 +148,15 @@ let RoutesPageService = (() => {
|
|
|
144
148
|
if (card)
|
|
145
149
|
card.delete();
|
|
146
150
|
}
|
|
151
|
+
start() {
|
|
152
|
+
const service = this.getRouteList();
|
|
153
|
+
const pairing = this.getDevicePairing();
|
|
154
|
+
const { id, title, videoUrl } = service.getStartSettings() ?? {};
|
|
155
|
+
this.logEvent({ message: 'Attempting to start a ride', id, title, videoUrl, readyToStart: pairing.isReadyToStart(), });
|
|
156
|
+
service.close();
|
|
157
|
+
const next = pairing.isReadyToStart() ? '/rideDeviceOK' : '/pairingStart';
|
|
158
|
+
this.moveTo(next);
|
|
159
|
+
}
|
|
147
160
|
startImport(info) {
|
|
148
161
|
if (this.importObserver)
|
|
149
162
|
return this.importObserver;
|
|
@@ -251,6 +264,9 @@ let RoutesPageService = (() => {
|
|
|
251
264
|
getRouteList() {
|
|
252
265
|
return (0, list_1.useRouteList)();
|
|
253
266
|
}
|
|
267
|
+
getDevicePairing() {
|
|
268
|
+
return (0, devices_1.useDevicePairing)();
|
|
269
|
+
}
|
|
254
270
|
getUserSettings() {
|
|
255
271
|
return (0, settings_1.useUserSettings)();
|
|
256
272
|
}
|
|
@@ -82,9 +82,9 @@ let ActiveRideListMessageQueue = (() => {
|
|
|
82
82
|
if (existing.subscribed)
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
|
-
this.getMessageQueue().subscribe(topic);
|
|
86
85
|
if (!existing)
|
|
87
86
|
this.subscribed.push({ topic, filter, handler });
|
|
87
|
+
this.getMessageQueue().subscribe(topic);
|
|
88
88
|
}
|
|
89
89
|
unsubscribe(topic) {
|
|
90
90
|
const mq = this.getMessageQueue();
|
|
@@ -134,8 +134,13 @@ let ActiveRideListMessageQueue = (() => {
|
|
|
134
134
|
this.subscribeEnabled = false;
|
|
135
135
|
}
|
|
136
136
|
onTopicSubscribed(topic) {
|
|
137
|
-
const
|
|
138
|
-
existing
|
|
137
|
+
const subscribed = this.subscribed ?? [];
|
|
138
|
+
const existing = subscribed.find(s => s.topic === topic);
|
|
139
|
+
if (existing)
|
|
140
|
+
existing.subscribed = true;
|
|
141
|
+
else {
|
|
142
|
+
this.logEvent({ message: 'Warning: subscribe confirmation received but no existing record', topic, subscribed: subscribed.map(s => s.topic).join('') });
|
|
143
|
+
}
|
|
139
144
|
this.logEvent({ message: 'Subscribed to topic', topic });
|
|
140
145
|
}
|
|
141
146
|
onTopicMessage(topic, message) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ride/types';
|
|
@@ -51,6 +51,7 @@ let ConnectedAppService = (() => {
|
|
|
51
51
|
appKey;
|
|
52
52
|
isInitialized;
|
|
53
53
|
id;
|
|
54
|
+
credentials;
|
|
54
55
|
constructor(service, appKey) {
|
|
55
56
|
super(service);
|
|
56
57
|
this.service = service;
|
|
@@ -64,7 +65,12 @@ let ConnectedAppService = (() => {
|
|
|
64
65
|
return true;
|
|
65
66
|
if (!this.getUserSettings().isInitialized)
|
|
66
67
|
return false;
|
|
67
|
-
|
|
68
|
+
try {
|
|
69
|
+
this.isInitialized = this.checkAuth();
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
this.isInitialized = this.initAuth();
|
|
73
|
+
}
|
|
68
74
|
return this.isInitialized;
|
|
69
75
|
}
|
|
70
76
|
connect(credentials) {
|
|
@@ -82,6 +88,9 @@ let ConnectedAppService = (() => {
|
|
|
82
88
|
initAuth() {
|
|
83
89
|
throw new Error('method not implemented');
|
|
84
90
|
}
|
|
91
|
+
checkAuth() {
|
|
92
|
+
throw new Error('method not implemented');
|
|
93
|
+
}
|
|
85
94
|
ensureInitialized() {
|
|
86
95
|
if (!this.isInitialized)
|
|
87
96
|
this.init();
|
|
@@ -59,9 +59,10 @@ let KomootAppConnection = (() => {
|
|
|
59
59
|
}
|
|
60
60
|
_isConnecting = __runInitializers(this, _instanceExtraInitializers);
|
|
61
61
|
api;
|
|
62
|
-
credentials;
|
|
63
62
|
constructor() {
|
|
64
63
|
super('KomootAppConnection', 'komoot');
|
|
64
|
+
this.api = new KomootApi();
|
|
65
|
+
this.iniAuth();
|
|
65
66
|
}
|
|
66
67
|
async connect(credentials) {
|
|
67
68
|
this.ensureInitialized();
|
|
@@ -104,11 +105,17 @@ let KomootAppConnection = (() => {
|
|
|
104
105
|
return this.credentials;
|
|
105
106
|
}
|
|
106
107
|
getApi() {
|
|
107
|
-
if (!this.api)
|
|
108
|
-
this.api = new KomootApi();
|
|
109
108
|
return this.api;
|
|
110
109
|
}
|
|
111
|
-
|
|
110
|
+
iniAuth() {
|
|
111
|
+
const api = this.getApi();
|
|
112
|
+
if (this.credentials) {
|
|
113
|
+
api.setAuth(this.credentials);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
checkAuth() {
|
|
112
119
|
let isInitialized = false;
|
|
113
120
|
let credentials;
|
|
114
121
|
if (!this.getUserSettings().isInitialized) {
|
|
@@ -124,7 +131,7 @@ let KomootAppConnection = (() => {
|
|
|
124
131
|
credentials = this.decrypt(CRYPT_ALGO, auth);
|
|
125
132
|
}
|
|
126
133
|
}
|
|
127
|
-
this.logEvent({ message: 'Komoot init done', hasCredentials: (valid(
|
|
134
|
+
this.logEvent({ message: 'Komoot init done', hasCredentials: (valid(credentials?.username) && valid(credentials?.password)) });
|
|
128
135
|
isInitialized = true;
|
|
129
136
|
}
|
|
130
137
|
catch (err) {
|
|
@@ -132,10 +139,7 @@ let KomootAppConnection = (() => {
|
|
|
132
139
|
isInitialized = false;
|
|
133
140
|
}
|
|
134
141
|
this.setupEventListeners();
|
|
135
|
-
this.credentials = credentials;
|
|
136
|
-
if (credentials) {
|
|
137
|
-
this.getApi().setAuth(credentials);
|
|
138
|
-
}
|
|
142
|
+
this.credentials = { ...credentials };
|
|
139
143
|
return isInitialized;
|
|
140
144
|
}
|
|
141
145
|
getAuthConfig() {
|
|
@@ -36,14 +36,18 @@ import { IncyclistService } from "../service";
|
|
|
36
36
|
import { Observer } from "../types";
|
|
37
37
|
import { Injectable } from "../decorators";
|
|
38
38
|
import { useAppState } from "../../appstate";
|
|
39
|
+
import { getBindings } from "../../api";
|
|
39
40
|
let IncyclistPageService = (() => {
|
|
40
41
|
let _classSuper = IncyclistService;
|
|
41
42
|
let _instanceExtraInitializers = [];
|
|
43
|
+
let _getBindings_decorators;
|
|
42
44
|
let _getAppState_decorators;
|
|
43
45
|
return class IncyclistPageService extends _classSuper {
|
|
44
46
|
static {
|
|
45
47
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
48
|
+
_getBindings_decorators = [Injectable];
|
|
46
49
|
_getAppState_decorators = [Injectable];
|
|
50
|
+
__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);
|
|
47
51
|
__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);
|
|
48
52
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
49
53
|
}
|
|
@@ -90,6 +94,28 @@ let IncyclistPageService = (() => {
|
|
|
90
94
|
delete this.pageObserver;
|
|
91
95
|
}
|
|
92
96
|
}
|
|
97
|
+
getPrevContentPage() {
|
|
98
|
+
const contentPage = this.getAppState().getPersistedState('page');
|
|
99
|
+
return contentPage ?? 'routes';
|
|
100
|
+
}
|
|
101
|
+
moveTo(route, close = true) {
|
|
102
|
+
if (route === '$contentPage') {
|
|
103
|
+
const prevContentPage = this.getPrevContentPage();
|
|
104
|
+
this.getUIBinding().openPage(prevContentPage);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
this.getUIBinding().openPage(route);
|
|
108
|
+
}
|
|
109
|
+
if (close) {
|
|
110
|
+
this.closePage();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
getUIBinding() {
|
|
114
|
+
return this.getBindings().ui;
|
|
115
|
+
}
|
|
116
|
+
getBindings() {
|
|
117
|
+
return getBindings();
|
|
118
|
+
}
|
|
93
119
|
getAppState() {
|
|
94
120
|
return useAppState();
|
|
95
121
|
}
|
|
@@ -40,7 +40,6 @@ import { PairingPageStateMachine } from './statemachine';
|
|
|
40
40
|
import { PageLogObserver } from './logobserver';
|
|
41
41
|
import { useDeviceAccess } from '../access';
|
|
42
42
|
import { useDeviceConfiguration } from '../configuration';
|
|
43
|
-
import { getBindings } from '../../api';
|
|
44
43
|
import { useIncyclist } from '../../ui';
|
|
45
44
|
import { Observer } from '../../base/types';
|
|
46
45
|
let DevicesPageService = (() => {
|
|
@@ -52,7 +51,6 @@ let DevicesPageService = (() => {
|
|
|
52
51
|
let _instanceExtraInitializers = [];
|
|
53
52
|
let _getDevicePairing_decorators;
|
|
54
53
|
let _getDeviceConfiguration_decorators;
|
|
55
|
-
let _getBindings_decorators;
|
|
56
54
|
let _getIncyclist_decorators;
|
|
57
55
|
var DevicesPageService = class extends _classSuper {
|
|
58
56
|
static { _classThis = this; }
|
|
@@ -60,11 +58,9 @@ let DevicesPageService = (() => {
|
|
|
60
58
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
61
59
|
_getDevicePairing_decorators = [Injectable];
|
|
62
60
|
_getDeviceConfiguration_decorators = [Injectable];
|
|
63
|
-
_getBindings_decorators = [Injectable];
|
|
64
61
|
_getIncyclist_decorators = [Injectable];
|
|
65
62
|
__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);
|
|
66
63
|
__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
|
-
__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);
|
|
68
64
|
__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);
|
|
69
65
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
70
66
|
DevicesPageService = _classThis = _classDescriptor.value;
|
|
@@ -77,14 +73,16 @@ let DevicesPageService = (() => {
|
|
|
77
73
|
openedCapability;
|
|
78
74
|
openedInterfaceSettings;
|
|
79
75
|
interfaceSettingsObserver;
|
|
76
|
+
isPairingForRide = false;
|
|
80
77
|
constructor() {
|
|
81
|
-
super('
|
|
78
|
+
super('pairing');
|
|
82
79
|
this.stateMachine = new PairingPageStateMachine();
|
|
83
80
|
this.logObserver = new PageLogObserver('Pairing');
|
|
84
81
|
}
|
|
85
|
-
openPage() {
|
|
82
|
+
openPage(forRide) {
|
|
86
83
|
try {
|
|
87
|
-
this.logEvent({ message: 'page shown', page: 'Pairing' });
|
|
84
|
+
this.logEvent({ message: 'page shown', page: 'Pairing', forRide });
|
|
85
|
+
this.isPairingForRide = forRide ?? false;
|
|
88
86
|
EventLogger.setGlobalConfig('page', 'Pairing');
|
|
89
87
|
super.openPage();
|
|
90
88
|
if (this.promiseOpen !== undefined) {
|
|
@@ -109,6 +107,7 @@ let DevicesPageService = (() => {
|
|
|
109
107
|
try {
|
|
110
108
|
this.logEvent({ message: 'page closed', page: 'Pairing' });
|
|
111
109
|
EventLogger.setGlobalConfig('page', null);
|
|
110
|
+
this.isPairingForRide = false;
|
|
112
111
|
super.closePage();
|
|
113
112
|
this.stop();
|
|
114
113
|
this.stateMachine.stop();
|
|
@@ -356,26 +355,32 @@ let DevicesPageService = (() => {
|
|
|
356
355
|
this.getDevicePairing().prepareStart();
|
|
357
356
|
this.getDevicePairing().setReadyToStart();
|
|
358
357
|
this.getAppState().setState('paired', true);
|
|
359
|
-
this.
|
|
358
|
+
const prevContentPage = this.getPrevContentPage();
|
|
359
|
+
const prevPage = this.getAppState().getState('prevPage');
|
|
360
|
+
if (!prevPage) {
|
|
361
|
+
this.moveTo(prevContentPage);
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
if (this.isPairingForRide)
|
|
365
|
+
this.moveTo('/rideDeviceOK');
|
|
366
|
+
else
|
|
367
|
+
this.moveTo(prevContentPage);
|
|
368
|
+
}
|
|
360
369
|
}
|
|
361
370
|
onSimulate() {
|
|
362
371
|
const simulator = this.getDeviceConfiguration().getSimulatorAdapterId();
|
|
363
372
|
this.getDevicePairing().prepareStart([simulator]);
|
|
364
|
-
this.
|
|
373
|
+
const prevContentPage = this.getPrevContentPage();
|
|
374
|
+
const prevPage = this.getAppState().getState('prevPage');
|
|
375
|
+
if (this.isPairingForRide)
|
|
376
|
+
this.moveTo('/rideSimulate');
|
|
377
|
+
else
|
|
378
|
+
this.moveTo(prevContentPage);
|
|
365
379
|
}
|
|
366
380
|
onCancel() {
|
|
367
381
|
const nextPage = this.getAppState().getState('prevPage');
|
|
368
382
|
this.moveTo(`/${nextPage}`);
|
|
369
383
|
}
|
|
370
|
-
moveTo(route, close = true) {
|
|
371
|
-
if (!this.getUIBinding()) {
|
|
372
|
-
console.log('# navigate to ', route);
|
|
373
|
-
}
|
|
374
|
-
this.getUIBinding().openPage(route);
|
|
375
|
-
if (close) {
|
|
376
|
-
this.closePage();
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
384
|
async start() {
|
|
380
385
|
this.getDevicePairing().usage = 'page';
|
|
381
386
|
this.getDevicePairing().start(() => {
|
|
@@ -388,18 +393,12 @@ let DevicesPageService = (() => {
|
|
|
388
393
|
get state() {
|
|
389
394
|
return this.getDevicePairing().getState();
|
|
390
395
|
}
|
|
391
|
-
getUIBinding() {
|
|
392
|
-
return this.getBindings().ui;
|
|
393
|
-
}
|
|
394
396
|
getDevicePairing() {
|
|
395
397
|
return useDevicePairing();
|
|
396
398
|
}
|
|
397
399
|
getDeviceConfiguration() {
|
|
398
400
|
return useDeviceConfiguration();
|
|
399
401
|
}
|
|
400
|
-
getBindings() {
|
|
401
|
-
return getBindings();
|
|
402
|
-
}
|
|
403
402
|
getIncyclist() {
|
|
404
403
|
return useIncyclist();
|
|
405
404
|
}
|
|
@@ -912,7 +912,6 @@ let DevicePairingService = (() => {
|
|
|
912
912
|
return false;
|
|
913
913
|
const control = this.getCapability(IncyclistCapability.Control);
|
|
914
914
|
const power = this.getCapability(IncyclistCapability.Power);
|
|
915
|
-
console.log('# check pairing success', control?.connectState, power?.connectState);
|
|
916
915
|
const success = (control?.connectState === 'connected' || power?.connectState === 'connected');
|
|
917
916
|
this.state.canStartRide = success;
|
|
918
917
|
return success;
|
|
@@ -1002,7 +1001,6 @@ let DevicePairingService = (() => {
|
|
|
1002
1001
|
this.state.check = { preparing };
|
|
1003
1002
|
this.state.interfaces = this.access.enrichWithAccessState(this.state.interfaces);
|
|
1004
1003
|
this.emit('pairing-start');
|
|
1005
|
-
console.log('# start pairing', this.state.capabilities.map(c => `${c.capability}:${c.connectState}`));
|
|
1006
1004
|
const { isReady, busyRequired } = this.isReadyToPair();
|
|
1007
1005
|
if (!isReady) {
|
|
1008
1006
|
this.logEvent({ message: 'Pairing: waiting for interfaces', interfaces: busyRequired?.name });
|
|
@@ -1073,7 +1071,6 @@ let DevicePairingService = (() => {
|
|
|
1073
1071
|
this.state.capabilities.forEach(c => {
|
|
1074
1072
|
c.connectState = c.connectState === 'connected' ? 'connected' : 'waiting';
|
|
1075
1073
|
});
|
|
1076
|
-
console.log('# setPairingConnectState', this.state.capabilities.map(c => `${c.capability}:${c.connectState}`));
|
|
1077
1074
|
const all = adapters ?? [];
|
|
1078
1075
|
all.forEach(ai => {
|
|
1079
1076
|
if (ai.adapter.isStarted()) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -199,7 +199,7 @@ let RideDisplayService = (() => {
|
|
|
199
199
|
}
|
|
200
200
|
this.getWorkoutRide().pause();
|
|
201
201
|
this.displayService.pause();
|
|
202
|
-
this.observer?.emit('state-update', this.state);
|
|
202
|
+
this.observer?.emit('state-update', this.state, { pauseReason: requester });
|
|
203
203
|
this.pauseReason = requester;
|
|
204
204
|
}
|
|
205
205
|
catch (err) {
|
|
@@ -1011,7 +1011,7 @@ let RideDisplayService = (() => {
|
|
|
1011
1011
|
const readyToStart = this.isStartDeviceReadyToStart() && this.getRideModeService().isStartRideCompleted();
|
|
1012
1012
|
const devicesState = this.deviceInfo ?? [];
|
|
1013
1013
|
const displayOverlayProps = this.getRideModeService().getStartOverlayProps() ?? {};
|
|
1014
|
-
return { mode, rideState: this.state, devicesState, readyToStart, ...displayOverlayProps };
|
|
1014
|
+
return { mode, rideState: this.state, devicesState, devices: devicesState, readyToStart, ...displayOverlayProps };
|
|
1015
1015
|
};
|
|
1016
1016
|
getDeviceStartSettings() {
|
|
1017
1017
|
let forceErgMode = false;
|
package/lib/esm/ride/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './service';
|