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
|
@@ -85,9 +85,9 @@ let ActiveRideListMessageQueue = (() => {
|
|
|
85
85
|
if (existing.subscribed)
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
this.getMessageQueue().subscribe(topic);
|
|
89
88
|
if (!existing)
|
|
90
89
|
this.subscribed.push({ topic, filter, handler });
|
|
90
|
+
this.getMessageQueue().subscribe(topic);
|
|
91
91
|
}
|
|
92
92
|
unsubscribe(topic) {
|
|
93
93
|
const mq = this.getMessageQueue();
|
|
@@ -137,8 +137,13 @@ let ActiveRideListMessageQueue = (() => {
|
|
|
137
137
|
this.subscribeEnabled = false;
|
|
138
138
|
}
|
|
139
139
|
onTopicSubscribed(topic) {
|
|
140
|
-
const
|
|
141
|
-
existing
|
|
140
|
+
const subscribed = this.subscribed ?? [];
|
|
141
|
+
const existing = subscribed.find(s => s.topic === topic);
|
|
142
|
+
if (existing)
|
|
143
|
+
existing.subscribed = true;
|
|
144
|
+
else {
|
|
145
|
+
this.logEvent({ message: 'Warning: subscribe confirmation received but no existing record', topic, subscribed: subscribed.map(s => s.topic).join('') });
|
|
146
|
+
}
|
|
142
147
|
this.logEvent({ message: 'Subscribed to topic', topic });
|
|
143
148
|
}
|
|
144
149
|
onTopicMessage(topic, message) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
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]; } };
|
|
7
|
+
}
|
|
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);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ride/types"), exports);
|
|
@@ -54,6 +54,7 @@ let ConnectedAppService = (() => {
|
|
|
54
54
|
appKey;
|
|
55
55
|
isInitialized;
|
|
56
56
|
id;
|
|
57
|
+
credentials;
|
|
57
58
|
constructor(service, appKey) {
|
|
58
59
|
super(service);
|
|
59
60
|
this.service = service;
|
|
@@ -67,7 +68,12 @@ let ConnectedAppService = (() => {
|
|
|
67
68
|
return true;
|
|
68
69
|
if (!this.getUserSettings().isInitialized)
|
|
69
70
|
return false;
|
|
70
|
-
|
|
71
|
+
try {
|
|
72
|
+
this.isInitialized = this.checkAuth();
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
this.isInitialized = this.initAuth();
|
|
76
|
+
}
|
|
71
77
|
return this.isInitialized;
|
|
72
78
|
}
|
|
73
79
|
connect(credentials) {
|
|
@@ -85,6 +91,9 @@ let ConnectedAppService = (() => {
|
|
|
85
91
|
initAuth() {
|
|
86
92
|
throw new Error('method not implemented');
|
|
87
93
|
}
|
|
94
|
+
checkAuth() {
|
|
95
|
+
throw new Error('method not implemented');
|
|
96
|
+
}
|
|
88
97
|
ensureInitialized() {
|
|
89
98
|
if (!this.isInitialized)
|
|
90
99
|
this.init();
|
|
@@ -62,9 +62,10 @@ let KomootAppConnection = (() => {
|
|
|
62
62
|
}
|
|
63
63
|
_isConnecting = __runInitializers(this, _instanceExtraInitializers);
|
|
64
64
|
api;
|
|
65
|
-
credentials;
|
|
66
65
|
constructor() {
|
|
67
66
|
super('KomootAppConnection', 'komoot');
|
|
67
|
+
this.api = new api_2.KomootApi();
|
|
68
|
+
this.iniAuth();
|
|
68
69
|
}
|
|
69
70
|
async connect(credentials) {
|
|
70
71
|
this.ensureInitialized();
|
|
@@ -107,11 +108,17 @@ let KomootAppConnection = (() => {
|
|
|
107
108
|
return this.credentials;
|
|
108
109
|
}
|
|
109
110
|
getApi() {
|
|
110
|
-
if (!this.api)
|
|
111
|
-
this.api = new api_2.KomootApi();
|
|
112
111
|
return this.api;
|
|
113
112
|
}
|
|
114
|
-
|
|
113
|
+
iniAuth() {
|
|
114
|
+
const api = this.getApi();
|
|
115
|
+
if (this.credentials) {
|
|
116
|
+
api.setAuth(this.credentials);
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
checkAuth() {
|
|
115
122
|
let isInitialized = false;
|
|
116
123
|
let credentials;
|
|
117
124
|
if (!this.getUserSettings().isInitialized) {
|
|
@@ -127,7 +134,7 @@ let KomootAppConnection = (() => {
|
|
|
127
134
|
credentials = this.decrypt(CRYPT_ALGO, auth);
|
|
128
135
|
}
|
|
129
136
|
}
|
|
130
|
-
this.logEvent({ message: 'Komoot init done', hasCredentials: ((0, valid_1.valid)(
|
|
137
|
+
this.logEvent({ message: 'Komoot init done', hasCredentials: ((0, valid_1.valid)(credentials?.username) && (0, valid_1.valid)(credentials?.password)) });
|
|
131
138
|
isInitialized = true;
|
|
132
139
|
}
|
|
133
140
|
catch (err) {
|
|
@@ -135,10 +142,7 @@ let KomootAppConnection = (() => {
|
|
|
135
142
|
isInitialized = false;
|
|
136
143
|
}
|
|
137
144
|
this.setupEventListeners();
|
|
138
|
-
this.credentials = credentials;
|
|
139
|
-
if (credentials) {
|
|
140
|
-
this.getApi().setAuth(credentials);
|
|
141
|
-
}
|
|
145
|
+
this.credentials = { ...credentials };
|
|
142
146
|
return isInitialized;
|
|
143
147
|
}
|
|
144
148
|
getAuthConfig() {
|
|
@@ -39,14 +39,18 @@ const service_1 = require("../service");
|
|
|
39
39
|
const types_1 = require("../types");
|
|
40
40
|
const decorators_1 = require("../decorators");
|
|
41
41
|
const appstate_1 = require("../../appstate");
|
|
42
|
+
const api_1 = require("../../api");
|
|
42
43
|
let IncyclistPageService = (() => {
|
|
43
44
|
let _classSuper = service_1.IncyclistService;
|
|
44
45
|
let _instanceExtraInitializers = [];
|
|
46
|
+
let _getBindings_decorators;
|
|
45
47
|
let _getAppState_decorators;
|
|
46
48
|
return class IncyclistPageService extends _classSuper {
|
|
47
49
|
static {
|
|
48
50
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
51
|
+
_getBindings_decorators = [decorators_1.Injectable];
|
|
49
52
|
_getAppState_decorators = [decorators_1.Injectable];
|
|
53
|
+
__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);
|
|
50
54
|
__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);
|
|
51
55
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
52
56
|
}
|
|
@@ -93,6 +97,28 @@ let IncyclistPageService = (() => {
|
|
|
93
97
|
delete this.pageObserver;
|
|
94
98
|
}
|
|
95
99
|
}
|
|
100
|
+
getPrevContentPage() {
|
|
101
|
+
const contentPage = this.getAppState().getPersistedState('page');
|
|
102
|
+
return contentPage ?? 'routes';
|
|
103
|
+
}
|
|
104
|
+
moveTo(route, close = true) {
|
|
105
|
+
if (route === '$contentPage') {
|
|
106
|
+
const prevContentPage = this.getPrevContentPage();
|
|
107
|
+
this.getUIBinding().openPage(prevContentPage);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
this.getUIBinding().openPage(route);
|
|
111
|
+
}
|
|
112
|
+
if (close) {
|
|
113
|
+
this.closePage();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
getUIBinding() {
|
|
117
|
+
return this.getBindings().ui;
|
|
118
|
+
}
|
|
119
|
+
getBindings() {
|
|
120
|
+
return (0, api_1.getBindings)();
|
|
121
|
+
}
|
|
96
122
|
getAppState() {
|
|
97
123
|
return (0, appstate_1.useAppState)();
|
|
98
124
|
}
|
|
@@ -43,7 +43,6 @@ const statemachine_1 = require("./statemachine");
|
|
|
43
43
|
const logobserver_1 = require("./logobserver");
|
|
44
44
|
const access_1 = require("../access");
|
|
45
45
|
const configuration_1 = require("../configuration");
|
|
46
|
-
const api_1 = require("../../api");
|
|
47
46
|
const ui_1 = require("../../ui");
|
|
48
47
|
const types_1 = require("../../base/types");
|
|
49
48
|
let DevicesPageService = (() => {
|
|
@@ -55,7 +54,6 @@ let DevicesPageService = (() => {
|
|
|
55
54
|
let _instanceExtraInitializers = [];
|
|
56
55
|
let _getDevicePairing_decorators;
|
|
57
56
|
let _getDeviceConfiguration_decorators;
|
|
58
|
-
let _getBindings_decorators;
|
|
59
57
|
let _getIncyclist_decorators;
|
|
60
58
|
var DevicesPageService = class extends _classSuper {
|
|
61
59
|
static { _classThis = this; }
|
|
@@ -63,11 +61,9 @@ let DevicesPageService = (() => {
|
|
|
63
61
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
64
62
|
_getDevicePairing_decorators = [decorators_1.Injectable];
|
|
65
63
|
_getDeviceConfiguration_decorators = [decorators_1.Injectable];
|
|
66
|
-
_getBindings_decorators = [decorators_1.Injectable];
|
|
67
64
|
_getIncyclist_decorators = [decorators_1.Injectable];
|
|
68
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);
|
|
69
66
|
__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);
|
|
70
|
-
__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);
|
|
71
67
|
__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);
|
|
72
68
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
73
69
|
DevicesPageService = _classThis = _classDescriptor.value;
|
|
@@ -80,14 +76,16 @@ let DevicesPageService = (() => {
|
|
|
80
76
|
openedCapability;
|
|
81
77
|
openedInterfaceSettings;
|
|
82
78
|
interfaceSettingsObserver;
|
|
79
|
+
isPairingForRide = false;
|
|
83
80
|
constructor() {
|
|
84
|
-
super('
|
|
81
|
+
super('pairing');
|
|
85
82
|
this.stateMachine = new statemachine_1.PairingPageStateMachine();
|
|
86
83
|
this.logObserver = new logobserver_1.PageLogObserver('Pairing');
|
|
87
84
|
}
|
|
88
|
-
openPage() {
|
|
85
|
+
openPage(forRide) {
|
|
89
86
|
try {
|
|
90
|
-
this.logEvent({ message: 'page shown', page: 'Pairing' });
|
|
87
|
+
this.logEvent({ message: 'page shown', page: 'Pairing', forRide });
|
|
88
|
+
this.isPairingForRide = forRide ?? false;
|
|
91
89
|
gd_eventlog_1.EventLogger.setGlobalConfig('page', 'Pairing');
|
|
92
90
|
super.openPage();
|
|
93
91
|
if (this.promiseOpen !== undefined) {
|
|
@@ -112,6 +110,7 @@ let DevicesPageService = (() => {
|
|
|
112
110
|
try {
|
|
113
111
|
this.logEvent({ message: 'page closed', page: 'Pairing' });
|
|
114
112
|
gd_eventlog_1.EventLogger.setGlobalConfig('page', null);
|
|
113
|
+
this.isPairingForRide = false;
|
|
115
114
|
super.closePage();
|
|
116
115
|
this.stop();
|
|
117
116
|
this.stateMachine.stop();
|
|
@@ -359,26 +358,32 @@ let DevicesPageService = (() => {
|
|
|
359
358
|
this.getDevicePairing().prepareStart();
|
|
360
359
|
this.getDevicePairing().setReadyToStart();
|
|
361
360
|
this.getAppState().setState('paired', true);
|
|
362
|
-
this.
|
|
361
|
+
const prevContentPage = this.getPrevContentPage();
|
|
362
|
+
const prevPage = this.getAppState().getState('prevPage');
|
|
363
|
+
if (!prevPage) {
|
|
364
|
+
this.moveTo(prevContentPage);
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
if (this.isPairingForRide)
|
|
368
|
+
this.moveTo('/rideDeviceOK');
|
|
369
|
+
else
|
|
370
|
+
this.moveTo(prevContentPage);
|
|
371
|
+
}
|
|
363
372
|
}
|
|
364
373
|
onSimulate() {
|
|
365
374
|
const simulator = this.getDeviceConfiguration().getSimulatorAdapterId();
|
|
366
375
|
this.getDevicePairing().prepareStart([simulator]);
|
|
367
|
-
this.
|
|
376
|
+
const prevContentPage = this.getPrevContentPage();
|
|
377
|
+
const prevPage = this.getAppState().getState('prevPage');
|
|
378
|
+
if (this.isPairingForRide)
|
|
379
|
+
this.moveTo('/rideSimulate');
|
|
380
|
+
else
|
|
381
|
+
this.moveTo(prevContentPage);
|
|
368
382
|
}
|
|
369
383
|
onCancel() {
|
|
370
384
|
const nextPage = this.getAppState().getState('prevPage');
|
|
371
385
|
this.moveTo(`/${nextPage}`);
|
|
372
386
|
}
|
|
373
|
-
moveTo(route, close = true) {
|
|
374
|
-
if (!this.getUIBinding()) {
|
|
375
|
-
console.log('# navigate to ', route);
|
|
376
|
-
}
|
|
377
|
-
this.getUIBinding().openPage(route);
|
|
378
|
-
if (close) {
|
|
379
|
-
this.closePage();
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
387
|
async start() {
|
|
383
388
|
this.getDevicePairing().usage = 'page';
|
|
384
389
|
this.getDevicePairing().start(() => {
|
|
@@ -391,18 +396,12 @@ let DevicesPageService = (() => {
|
|
|
391
396
|
get state() {
|
|
392
397
|
return this.getDevicePairing().getState();
|
|
393
398
|
}
|
|
394
|
-
getUIBinding() {
|
|
395
|
-
return this.getBindings().ui;
|
|
396
|
-
}
|
|
397
399
|
getDevicePairing() {
|
|
398
400
|
return (0, pairing_1.useDevicePairing)();
|
|
399
401
|
}
|
|
400
402
|
getDeviceConfiguration() {
|
|
401
403
|
return (0, configuration_1.useDeviceConfiguration)();
|
|
402
404
|
}
|
|
403
|
-
getBindings() {
|
|
404
|
-
return (0, api_1.getBindings)();
|
|
405
|
-
}
|
|
406
405
|
getIncyclist() {
|
|
407
406
|
return (0, ui_1.useIncyclist)();
|
|
408
407
|
}
|
|
@@ -918,7 +918,6 @@ let DevicePairingService = (() => {
|
|
|
918
918
|
return false;
|
|
919
919
|
const control = this.getCapability(incyclist_devices_1.IncyclistCapability.Control);
|
|
920
920
|
const power = this.getCapability(incyclist_devices_1.IncyclistCapability.Power);
|
|
921
|
-
console.log('# check pairing success', control?.connectState, power?.connectState);
|
|
922
921
|
const success = (control?.connectState === 'connected' || power?.connectState === 'connected');
|
|
923
922
|
this.state.canStartRide = success;
|
|
924
923
|
return success;
|
|
@@ -1008,7 +1007,6 @@ let DevicePairingService = (() => {
|
|
|
1008
1007
|
this.state.check = { preparing };
|
|
1009
1008
|
this.state.interfaces = this.access.enrichWithAccessState(this.state.interfaces);
|
|
1010
1009
|
this.emit('pairing-start');
|
|
1011
|
-
console.log('# start pairing', this.state.capabilities.map(c => `${c.capability}:${c.connectState}`));
|
|
1012
1010
|
const { isReady, busyRequired } = this.isReadyToPair();
|
|
1013
1011
|
if (!isReady) {
|
|
1014
1012
|
this.logEvent({ message: 'Pairing: waiting for interfaces', interfaces: busyRequired?.name });
|
|
@@ -1079,7 +1077,6 @@ let DevicePairingService = (() => {
|
|
|
1079
1077
|
this.state.capabilities.forEach(c => {
|
|
1080
1078
|
c.connectState = c.connectState === 'connected' ? 'connected' : 'waiting';
|
|
1081
1079
|
});
|
|
1082
|
-
console.log('# setPairingConnectState', this.state.capabilities.map(c => `${c.capability}:${c.connectState}`));
|
|
1083
1080
|
const all = adapters ?? [];
|
|
1084
1081
|
all.forEach(ai => {
|
|
1085
1082
|
if (ai.adapter.isStarted()) {
|
|
@@ -202,7 +202,7 @@ let RideDisplayService = (() => {
|
|
|
202
202
|
}
|
|
203
203
|
this.getWorkoutRide().pause();
|
|
204
204
|
this.displayService.pause();
|
|
205
|
-
this.observer?.emit('state-update', this.state);
|
|
205
|
+
this.observer?.emit('state-update', this.state, { pauseReason: requester });
|
|
206
206
|
this.pauseReason = requester;
|
|
207
207
|
}
|
|
208
208
|
catch (err) {
|
|
@@ -1014,7 +1014,7 @@ let RideDisplayService = (() => {
|
|
|
1014
1014
|
const readyToStart = this.isStartDeviceReadyToStart() && this.getRideModeService().isStartRideCompleted();
|
|
1015
1015
|
const devicesState = this.deviceInfo ?? [];
|
|
1016
1016
|
const displayOverlayProps = this.getRideModeService().getStartOverlayProps() ?? {};
|
|
1017
|
-
return { mode, rideState: this.state, devicesState, readyToStart, ...displayOverlayProps };
|
|
1017
|
+
return { mode, rideState: this.state, devicesState, devices: devicesState, readyToStart, ...displayOverlayProps };
|
|
1018
1018
|
};
|
|
1019
1019
|
getDeviceStartSettings() {
|
|
1020
1020
|
let forceErgMode = false;
|
package/lib/cjs/ride/index.js
CHANGED
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./base"), exports);
|
|
18
18
|
__exportStar(require("./display"), exports);
|
|
19
|
+
__exportStar(require("./page"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
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]; } };
|
|
7
|
+
}
|
|
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);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./service"), exports);
|
|
@@ -0,0 +1,225 @@
|
|
|
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
|
+
}
|
|
25
|
+
}
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.getRidePageService = exports.RidePageService = void 0;
|
|
38
|
+
const gd_eventlog_1 = require("gd-eventlog");
|
|
39
|
+
const decorators_1 = require("../../base/decorators");
|
|
40
|
+
const pages_1 = require("../../base/pages");
|
|
41
|
+
const display_1 = require("../display");
|
|
42
|
+
const sleep_1 = require("../../utils/sleep");
|
|
43
|
+
const BACKGROUND_PAUSE_TIMEOUT_MS = 60000;
|
|
44
|
+
let RidePageService = (() => {
|
|
45
|
+
let _classDecorators = [decorators_1.Singleton];
|
|
46
|
+
let _classDescriptor;
|
|
47
|
+
let _classExtraInitializers = [];
|
|
48
|
+
let _classThis;
|
|
49
|
+
let _classSuper = pages_1.IncyclistPageService;
|
|
50
|
+
var RidePageService = class extends _classSuper {
|
|
51
|
+
static { _classThis = this; }
|
|
52
|
+
static {
|
|
53
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
54
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
55
|
+
RidePageService = _classThis = _classDescriptor.value;
|
|
56
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
57
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
58
|
+
}
|
|
59
|
+
eventHandler = {};
|
|
60
|
+
backgroundTimer;
|
|
61
|
+
backgroundPausedByService = false;
|
|
62
|
+
menuProps = null;
|
|
63
|
+
isInitialized = false;
|
|
64
|
+
constructor() {
|
|
65
|
+
super('RidePage');
|
|
66
|
+
this.eventHandler['state-update'] = this.onDisplayStateUpdate.bind(this);
|
|
67
|
+
this.eventHandler['route-update'] = this.onRouteUpdate.bind(this);
|
|
68
|
+
}
|
|
69
|
+
async initPage() {
|
|
70
|
+
const service = this.getRideDisplay();
|
|
71
|
+
await service.init();
|
|
72
|
+
this.isInitialized = true;
|
|
73
|
+
return service.getRideType();
|
|
74
|
+
}
|
|
75
|
+
openPage(simulate) {
|
|
76
|
+
this.logEvent({ message: 'page shown', page: 'Rides' });
|
|
77
|
+
gd_eventlog_1.EventLogger.setGlobalConfig('page', 'Rides');
|
|
78
|
+
super.openPage();
|
|
79
|
+
try {
|
|
80
|
+
const service = this.getRideDisplay();
|
|
81
|
+
if (!this.isInitialized) {
|
|
82
|
+
service.init();
|
|
83
|
+
}
|
|
84
|
+
this.registerEventHandlers();
|
|
85
|
+
service.start(simulate);
|
|
86
|
+
(0, sleep_1.sleep)(5).then(() => {
|
|
87
|
+
this.updatePageDisplay();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
this.logError(err, 'openPage');
|
|
92
|
+
}
|
|
93
|
+
return this.getPageObserver();
|
|
94
|
+
}
|
|
95
|
+
closePage() {
|
|
96
|
+
gd_eventlog_1.EventLogger.setGlobalConfig('page', null);
|
|
97
|
+
this.logEvent({ message: 'page closed', page: 'Rides' });
|
|
98
|
+
this.getRideDisplay().stop();
|
|
99
|
+
this.menuProps = null;
|
|
100
|
+
this.isInitialized = false;
|
|
101
|
+
super.closePage();
|
|
102
|
+
}
|
|
103
|
+
pausePage() {
|
|
104
|
+
this.backgroundTimer = setTimeout(() => {
|
|
105
|
+
this.getRideDisplay().pause('user');
|
|
106
|
+
this.backgroundPausedByService = true;
|
|
107
|
+
}, BACKGROUND_PAUSE_TIMEOUT_MS);
|
|
108
|
+
this.isInitialized = false;
|
|
109
|
+
return super.pausePage();
|
|
110
|
+
}
|
|
111
|
+
resumePage() {
|
|
112
|
+
if (this.backgroundTimer) {
|
|
113
|
+
clearTimeout(this.backgroundTimer);
|
|
114
|
+
}
|
|
115
|
+
return super.resumePage();
|
|
116
|
+
}
|
|
117
|
+
getRideObserver() {
|
|
118
|
+
return this.rideObserver;
|
|
119
|
+
}
|
|
120
|
+
getPageDisplayProps() {
|
|
121
|
+
const rideType = this.getRideDisplay().getRideType();
|
|
122
|
+
switch (rideType) {
|
|
123
|
+
case 'Video': return this.getVideoRideDisplayProps();
|
|
124
|
+
default:
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
onMenuOpen() {
|
|
129
|
+
const state = this.getRideDisplay().getState();
|
|
130
|
+
this.menuProps = { showResume: state === 'Paused' };
|
|
131
|
+
this.updatePageDisplay();
|
|
132
|
+
}
|
|
133
|
+
onMenuClose() {
|
|
134
|
+
this.menuProps = null;
|
|
135
|
+
this.updatePageDisplay();
|
|
136
|
+
}
|
|
137
|
+
onPause() {
|
|
138
|
+
this.getRideDisplay().pause('user');
|
|
139
|
+
this.menuProps = { showResume: false };
|
|
140
|
+
this.updatePageDisplay();
|
|
141
|
+
}
|
|
142
|
+
onResume() {
|
|
143
|
+
this.getRideDisplay().resume();
|
|
144
|
+
this.menuProps = null;
|
|
145
|
+
this.updatePageDisplay();
|
|
146
|
+
}
|
|
147
|
+
onEndRide() {
|
|
148
|
+
this.getRideDisplay().stop();
|
|
149
|
+
this.moveToPreviousPage();
|
|
150
|
+
this.closePage();
|
|
151
|
+
}
|
|
152
|
+
onRetryStart() {
|
|
153
|
+
this.getRideDisplay().retryStart();
|
|
154
|
+
}
|
|
155
|
+
onIgnoreStart() {
|
|
156
|
+
this.getRideDisplay().startWithMissingSensors();
|
|
157
|
+
}
|
|
158
|
+
async onCancelStart() {
|
|
159
|
+
this.rideObserver?.stop();
|
|
160
|
+
await this.getRideDisplay().cancelStart();
|
|
161
|
+
this.moveToPreviousPage();
|
|
162
|
+
this.closePage();
|
|
163
|
+
}
|
|
164
|
+
getVideoRideDisplayProps() {
|
|
165
|
+
const props = this.rideDisplayProps;
|
|
166
|
+
const state = this.getRideDisplay().getState();
|
|
167
|
+
const rideType = this.getRideDisplay().getRideType();
|
|
168
|
+
const isStarting = state === 'Idle' || state === 'Starting' || state === 'Error';
|
|
169
|
+
const displayProps = {
|
|
170
|
+
rideState: state,
|
|
171
|
+
rideType,
|
|
172
|
+
startOverlayProps: isStarting ? this.getRideDisplay().getStartOverlayProps() : null,
|
|
173
|
+
menuProps: this.menuProps,
|
|
174
|
+
video: props.video,
|
|
175
|
+
videos: props.videos,
|
|
176
|
+
route: props.route
|
|
177
|
+
};
|
|
178
|
+
return displayProps;
|
|
179
|
+
}
|
|
180
|
+
getRideType() {
|
|
181
|
+
return this.getRideDisplay().getRideType();
|
|
182
|
+
}
|
|
183
|
+
updatePageDisplay() {
|
|
184
|
+
this.getPageObserver().emit('page-update');
|
|
185
|
+
}
|
|
186
|
+
registerEventHandlers() {
|
|
187
|
+
const events = Object.keys(this.eventHandler);
|
|
188
|
+
events.forEach(event => { this.rideObserver.on(event, this.eventHandler[event]); });
|
|
189
|
+
}
|
|
190
|
+
unregisterEventHandlers() {
|
|
191
|
+
const events = Object.keys(this.eventHandler);
|
|
192
|
+
events.forEach(event => { this.rideObserver.off(event, this.eventHandler[event]); });
|
|
193
|
+
}
|
|
194
|
+
onDisplayStateUpdate(state, props) {
|
|
195
|
+
switch (state) {
|
|
196
|
+
case 'Paused':
|
|
197
|
+
this.menuProps = { showResume: true };
|
|
198
|
+
break;
|
|
199
|
+
case 'Active':
|
|
200
|
+
this.menuProps = null;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
this.updatePageDisplay();
|
|
204
|
+
}
|
|
205
|
+
onRouteUpdate() {
|
|
206
|
+
this.updatePageDisplay();
|
|
207
|
+
}
|
|
208
|
+
moveToPreviousPage() {
|
|
209
|
+
this.moveTo('$contentPage');
|
|
210
|
+
}
|
|
211
|
+
get rideObserver() {
|
|
212
|
+
return this.getRideDisplay().getObserver();
|
|
213
|
+
}
|
|
214
|
+
get rideDisplayProps() {
|
|
215
|
+
return this.getRideDisplay().getDisplayProperties();
|
|
216
|
+
}
|
|
217
|
+
getRideDisplay() {
|
|
218
|
+
return (0, display_1.useRideDisplay)();
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
return RidePageService = _classThis;
|
|
222
|
+
})();
|
|
223
|
+
exports.RidePageService = RidePageService;
|
|
224
|
+
const getRidePageService = () => new RidePageService();
|
|
225
|
+
exports.getRidePageService = getRidePageService;
|