incyclist-services 1.8.8 → 1.9.0
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/devices/page/index.js +6 -0
- package/lib/cjs/devices/page/service.js +69 -5
- package/lib/cjs/devices/page/visit-log-factory.js +41 -0
- package/lib/cjs/devices/page/visit-log.js +143 -0
- package/lib/cjs/devices/page/visit-tracker-factory.js +41 -0
- package/lib/cjs/devices/page/visit-tracker.js +142 -0
- package/lib/cjs/devices/pairing/guidance.js +152 -0
- package/lib/cjs/devices/pairing/index.js +2 -0
- package/lib/cjs/devices/pairing/status.js +54 -0
- package/lib/cjs/ride/display/service.js +15 -0
- package/lib/cjs/ui/service.js +39 -0
- package/lib/esm/devices/page/__tests__/desktop-matrix.js +23 -0
- package/lib/esm/devices/page/base/logobserver.js +15 -0
- package/lib/esm/devices/page/base/orchestrator.js +1 -0
- package/lib/esm/devices/page/base/service.js +380 -0
- package/lib/esm/devices/page/base/types.js +1 -0
- package/lib/esm/devices/page/base/visit-log-factory.js +33 -0
- package/lib/esm/devices/page/base/visit-log.js +138 -0
- package/lib/esm/devices/page/desktop/matrix.js +23 -0
- package/lib/esm/devices/page/desktop/orchestrator.js +17 -0
- package/lib/esm/devices/page/desktop/service.js +250 -0
- package/lib/esm/devices/page/desktop/types.js +1 -0
- package/lib/esm/devices/page/desktop-service.js +204 -0
- package/lib/esm/devices/page/index.js +11 -1
- package/lib/esm/devices/page/mobile/orchestrator.js +2 -0
- package/lib/esm/devices/page/mobile/service.js +194 -0
- package/lib/esm/devices/page/mobile/statemachine.js +345 -0
- package/lib/esm/devices/page/orchestrator.js +19 -0
- package/lib/esm/devices/page/pairing-page-service.js +385 -0
- package/lib/esm/devices/page/service.js +70 -6
- package/lib/esm/devices/page/visit-log-factory.js +33 -0
- package/lib/esm/devices/page/visit-log.js +138 -0
- package/lib/esm/devices/page/visit-tracker-factory.js +33 -0
- package/lib/esm/devices/page/visit-tracker.js +137 -0
- package/lib/esm/devices/pairing/guidance.js +141 -0
- package/lib/esm/devices/pairing/index.js +2 -0
- package/lib/esm/devices/pairing/service.js +54 -1
- package/lib/esm/devices/pairing/status.js +49 -0
- package/lib/esm/ride/display/service.js +16 -1
- package/lib/esm/ui/service.js +43 -1
- package/lib/types/activities/ride/service.d.ts +1 -1
- package/lib/types/devices/page/__tests__/desktop-matrix.d.ts +8 -0
- package/lib/types/devices/page/base/logobserver.d.ts +8 -0
- package/lib/types/devices/page/base/orchestrator.d.ts +11 -0
- package/lib/types/devices/page/base/service.d.ts +54 -0
- package/lib/types/devices/page/base/types.d.ts +130 -0
- package/lib/types/devices/page/base/visit-log-factory.d.ts +13 -0
- package/lib/types/devices/page/base/visit-log.d.ts +25 -0
- package/lib/types/devices/page/desktop/matrix.d.ts +8 -0
- package/lib/types/devices/page/desktop/orchestrator.d.ts +2 -0
- package/lib/types/devices/page/desktop/service.d.ts +32 -0
- package/lib/types/devices/page/desktop/types.d.ts +25 -0
- package/lib/types/devices/page/desktop-service.d.ts +28 -0
- package/lib/types/devices/page/index.d.ts +3 -1
- package/lib/types/devices/page/mobile/orchestrator.d.ts +2 -0
- package/lib/types/devices/page/mobile/service.d.ts +24 -0
- package/lib/types/devices/page/mobile/statemachine.d.ts +49 -0
- package/lib/types/devices/page/orchestrator.d.ts +13 -0
- package/lib/types/devices/page/pairing-page-service.d.ts +53 -0
- package/lib/types/devices/page/service.d.ts +9 -1
- package/lib/types/devices/page/types.d.ts +55 -0
- package/lib/types/devices/page/visit-log-factory.d.ts +13 -0
- package/lib/types/devices/page/visit-log.d.ts +25 -0
- package/lib/types/devices/page/visit-tracker-factory.d.ts +13 -0
- package/lib/types/devices/page/visit-tracker.d.ts +25 -0
- package/lib/types/devices/pairing/guidance.d.ts +55 -0
- package/lib/types/devices/pairing/index.d.ts +2 -0
- package/lib/types/devices/pairing/service.d.ts +8 -0
- package/lib/types/devices/pairing/status.d.ts +29 -0
- package/lib/types/ride/display/service.d.ts +3 -1
- package/lib/types/ui/service.d.ts +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEmptyTileFooterText = exports.getCapabilityHelpText = exports.getPairingRowLabelId = exports.getPairingGuidanceText = exports.derivePairingStatus = exports.getPairingHint = exports.getUnavailableInterfaces = exports.canScanWithInterfaces = exports.PAIRING_CAPABILITY_ROLES = void 0;
|
|
4
|
+
const incyclist_devices_1 = require("incyclist-devices");
|
|
5
|
+
exports.PAIRING_CAPABILITY_ROLES = [
|
|
6
|
+
{ capability: incyclist_devices_1.IncyclistCapability.Control, role: 'required', descriptor: 'control' },
|
|
7
|
+
{ capability: incyclist_devices_1.IncyclistCapability.Power, role: 'required', descriptor: 'power' },
|
|
8
|
+
{ capability: incyclist_devices_1.IncyclistCapability.Speed, role: 'required', descriptor: 'speed' },
|
|
9
|
+
{ capability: incyclist_devices_1.IncyclistCapability.HeartRate, role: 'optional', descriptor: 'heartrate' },
|
|
10
|
+
{ capability: incyclist_devices_1.IncyclistCapability.Cadence, role: 'optional', descriptor: 'cadence' },
|
|
11
|
+
{ capability: incyclist_devices_1.IncyclistCapability.AppControl, role: 'optional', descriptor: 'app_control' },
|
|
12
|
+
];
|
|
13
|
+
const INTERFACE_LABELS = {
|
|
14
|
+
ant: 'ANT+',
|
|
15
|
+
ble: 'Bluetooth',
|
|
16
|
+
serial: 'Serial',
|
|
17
|
+
tcpip: 'TCP/IP',
|
|
18
|
+
wifi: 'Wi-Fi',
|
|
19
|
+
};
|
|
20
|
+
const DESKTOP_SEARCH_INTERFACES = new Set(['ble', 'ant']);
|
|
21
|
+
const searchInterfaces = (interfaces, platform) => platform === 'desktop'
|
|
22
|
+
? interfaces.filter(i => DESKTOP_SEARCH_INTERFACES.has(i.id))
|
|
23
|
+
: interfaces;
|
|
24
|
+
const canScanWithInterfaces = (interfaces, platform) => searchInterfaces(interfaces, platform).some(i => i.enabled && i.available);
|
|
25
|
+
exports.canScanWithInterfaces = canScanWithInterfaces;
|
|
26
|
+
const getUnavailableInterfaces = (interfaces, platform) => searchInterfaces(interfaces, platform).filter(i => i.enabled && !i.available).map(i => i.id);
|
|
27
|
+
exports.getUnavailableInterfaces = getUnavailableInterfaces;
|
|
28
|
+
const isBrokenInterface = (interfaces, id) => interfaces.find(i => i.id === id && i.enabled && !i.available);
|
|
29
|
+
const getPairingHint = (input) => {
|
|
30
|
+
if (input.anyDeviceSelected)
|
|
31
|
+
return undefined;
|
|
32
|
+
if (input.platform === 'mobile') {
|
|
33
|
+
const ble = isBrokenInterface(input.interfaces, 'ble');
|
|
34
|
+
if (ble)
|
|
35
|
+
return ble.permissionDenied ? 'bluetooth-permission' : 'bluetooth-off';
|
|
36
|
+
if (isBrokenInterface(input.interfaces, 'wifi'))
|
|
37
|
+
return 'wifi-off';
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
if (isBrokenInterface(input.interfaces, 'ant'))
|
|
41
|
+
return 'ant';
|
|
42
|
+
return undefined;
|
|
43
|
+
};
|
|
44
|
+
exports.getPairingHint = getPairingHint;
|
|
45
|
+
const derivePairingStatus = (input) => {
|
|
46
|
+
if (!(0, exports.canScanWithInterfaces)(input.interfaces, input.platform))
|
|
47
|
+
return 'S1';
|
|
48
|
+
if (input.canStartRide)
|
|
49
|
+
return 'S2';
|
|
50
|
+
if (input.connectingDeviceName)
|
|
51
|
+
return 'S3';
|
|
52
|
+
if (input.initialising)
|
|
53
|
+
return 'S4';
|
|
54
|
+
if ((0, exports.getPairingHint)(input))
|
|
55
|
+
return 'S1b';
|
|
56
|
+
return 'S5';
|
|
57
|
+
};
|
|
58
|
+
exports.derivePairingStatus = derivePairingStatus;
|
|
59
|
+
const formatList = (names) => {
|
|
60
|
+
if (names.length <= 1)
|
|
61
|
+
return names.join('');
|
|
62
|
+
return `${names.slice(0, -1).join(', ')} and ${names.at(-1)}`;
|
|
63
|
+
};
|
|
64
|
+
const getNoSearchText = (params, isShort) => {
|
|
65
|
+
if (params.platform === 'mobile' && params.bluetoothDenied)
|
|
66
|
+
return isShort
|
|
67
|
+
? { text: 'Bluetooth not allowed.', link: 'Settings' }
|
|
68
|
+
: { text: "Can't search: Bluetooth is not allowed.", link: 'Open settings' };
|
|
69
|
+
const names = (params.unavailable ?? []).map(id => INTERFACE_LABELS[id]);
|
|
70
|
+
if (params.platform === 'mobile') {
|
|
71
|
+
const list = formatList(names);
|
|
72
|
+
const verb = names.length > 1 ? 'are' : 'is';
|
|
73
|
+
const link = names.length === 1 && names[0] === INTERFACE_LABELS.ble ? 'Bluetooth settings' : 'Settings';
|
|
74
|
+
if (isShort)
|
|
75
|
+
return { text: `${list} ${verb} off.`, link: 'Settings' };
|
|
76
|
+
return { text: `Can't search: ${list} ${verb} off.`, link };
|
|
77
|
+
}
|
|
78
|
+
const list = formatList(names);
|
|
79
|
+
if (names.length === 2)
|
|
80
|
+
return { text: `Can't search: ${list} are both unavailable.`, link: 'Check connections' };
|
|
81
|
+
return { text: `Can't search: ${list} unavailable.`, link: 'Check connections' };
|
|
82
|
+
};
|
|
83
|
+
const getHintText = (hint, isShort) => {
|
|
84
|
+
switch (hint) {
|
|
85
|
+
case 'bluetooth-permission':
|
|
86
|
+
return isShort
|
|
87
|
+
? { text: 'Bluetooth not allowed.', link: 'Settings' }
|
|
88
|
+
: { text: "Incyclist isn't allowed to use Bluetooth, so most trainers won't show up.", link: 'Open settings' };
|
|
89
|
+
case 'bluetooth-off':
|
|
90
|
+
return isShort
|
|
91
|
+
? { text: 'Bluetooth is off.', link: 'Settings' }
|
|
92
|
+
: { text: "Bluetooth is off, so most trainers won't show up.", link: 'Bluetooth settings' };
|
|
93
|
+
case 'wifi-off':
|
|
94
|
+
return isShort
|
|
95
|
+
? { text: 'Wi-Fi is off · needed for Wi-Fi trainers' }
|
|
96
|
+
: { text: 'Wi-Fi is off. If your trainer connects over Wi-Fi, turn Wi-Fi on.' };
|
|
97
|
+
case 'ant':
|
|
98
|
+
return { text: 'ANT+ stick not found. If you use one, plug it in, try another USB port, or close other apps that use it.' };
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const getPairingGuidanceText = (id, params = {}, variant = 'full') => {
|
|
102
|
+
const isShort = variant === 'short';
|
|
103
|
+
const device = params.deviceName ?? '';
|
|
104
|
+
switch (id) {
|
|
105
|
+
case 'S1':
|
|
106
|
+
return getNoSearchText(params, isShort);
|
|
107
|
+
case 'S1b':
|
|
108
|
+
return getHintText(params.hint, isShort);
|
|
109
|
+
case 'S2': {
|
|
110
|
+
if (isShort)
|
|
111
|
+
return { text: `Ready to ride with ${device}.` };
|
|
112
|
+
const tail = `You can add optional sensors, or press ${params.rideMode ? 'Start' : 'OK'}.`;
|
|
113
|
+
return { text: `Ready to ride with ${device}. ${tail}` };
|
|
114
|
+
}
|
|
115
|
+
case 'S3':
|
|
116
|
+
if (params.isTrainer)
|
|
117
|
+
return { text: isShort ? `Connecting to ${device}…` : `Connecting to your trainer ${device}…` };
|
|
118
|
+
return { text: `Connecting to ${device}…` };
|
|
119
|
+
case 'S4':
|
|
120
|
+
return { text: 'Getting ready to search…' };
|
|
121
|
+
case 'S5':
|
|
122
|
+
return isShort
|
|
123
|
+
? { text: 'Searching… Pedal to wake your trainer.' }
|
|
124
|
+
: { text: 'Searching for devices… Tip: pedal a few strokes to wake up your trainer.' };
|
|
125
|
+
case 'row-required':
|
|
126
|
+
return { text: 'TO RIDE', subtext: 'connect any one' };
|
|
127
|
+
case 'row-required-trainer':
|
|
128
|
+
return { text: 'TO RIDE', subtext: 'connecting to your trainer' };
|
|
129
|
+
case 'row-ready':
|
|
130
|
+
return { text: '✓ READY TO RIDE' };
|
|
131
|
+
case 'row-optional':
|
|
132
|
+
return { text: 'OPTIONAL', subtext: 'extras, not needed' };
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
exports.getPairingGuidanceText = getPairingGuidanceText;
|
|
136
|
+
const getPairingRowLabelId = (trainerSelected) => trainerSelected ? 'row-required-trainer' : 'row-required';
|
|
137
|
+
exports.getPairingRowLabelId = getPairingRowLabelId;
|
|
138
|
+
const getCapabilityHelpText = (capability, variant = 'full') => {
|
|
139
|
+
const isShort = variant === 'short';
|
|
140
|
+
switch (capability) {
|
|
141
|
+
case 'control': return 'Smart trainer';
|
|
142
|
+
case 'power': return 'Power meter';
|
|
143
|
+
case 'speed': return 'Speed sensor';
|
|
144
|
+
case 'heartrate': return 'Heart-rate monitor';
|
|
145
|
+
case 'cadence': return 'Cadence sensor';
|
|
146
|
+
case 'app_control': return isShort ? 'Remote buttons' : 'Remote buttons, e.g. Zwift Play';
|
|
147
|
+
default: return undefined;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
exports.getCapabilityHelpText = getCapabilityHelpText;
|
|
151
|
+
const getEmptyTileFooterText = (role) => role === 'required' ? 'Searching…' : 'Optional';
|
|
152
|
+
exports.getEmptyTileFooterText = getEmptyTileFooterText;
|
|
@@ -16,3 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./service"), exports);
|
|
18
18
|
__exportStar(require("./model"), exports);
|
|
19
|
+
__exportStar(require("./guidance"), exports);
|
|
20
|
+
__exportStar(require("./status"), exports);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPairingStatusDisplay = exports.toPairingInterfaceStates = void 0;
|
|
4
|
+
const guidance_1 = require("./guidance");
|
|
5
|
+
const REQUIRED_CAPABILITIES = ['control', 'power', 'speed'];
|
|
6
|
+
const toPairingInterfaceStates = (interfaces) => interfaces.map(i => ({
|
|
7
|
+
id: i.name,
|
|
8
|
+
enabled: i.enabled !== false,
|
|
9
|
+
available: i.state !== 'disconnected' && i.state !== 'unavailable',
|
|
10
|
+
}));
|
|
11
|
+
exports.toPairingInterfaceStates = toPairingInterfaceStates;
|
|
12
|
+
const DOT_BY_STATUS = { S1: 'red', S2: 'green' };
|
|
13
|
+
const statusDot = (id) => DOT_BY_STATUS[id] ?? 'amber';
|
|
14
|
+
const getPairingStatusDisplay = (src) => {
|
|
15
|
+
const find = (name) => src.capabilities.find(c => c.capability === name);
|
|
16
|
+
const readyCapability = REQUIRED_CAPABILITIES
|
|
17
|
+
.map(find)
|
|
18
|
+
.find(c => c?.selected && c.connectState === 'connected');
|
|
19
|
+
const connectingCapability = src.capabilities.find(c => c.selected && c.connectState === 'connecting');
|
|
20
|
+
const anyDeviceSelected = src.capabilities.some(c => Boolean(c.selected));
|
|
21
|
+
const derived = (0, guidance_1.derivePairingStatus)({
|
|
22
|
+
platform: src.platform,
|
|
23
|
+
interfaces: src.interfaces,
|
|
24
|
+
anyDeviceSelected,
|
|
25
|
+
initialising: src.loading,
|
|
26
|
+
searching: false,
|
|
27
|
+
canStartRide: src.canStartRide,
|
|
28
|
+
readyDeviceName: readyCapability?.deviceName,
|
|
29
|
+
connectingDeviceName: connectingCapability?.deviceName,
|
|
30
|
+
connectingIsTrainer: connectingCapability?.capability === 'control',
|
|
31
|
+
});
|
|
32
|
+
let id = derived === 'S1b' ? 'S5' : derived;
|
|
33
|
+
if (src.loading)
|
|
34
|
+
id = 'S4';
|
|
35
|
+
const deviceName = id === 'S3' ? connectingCapability?.deviceName : readyCapability?.deviceName;
|
|
36
|
+
const params = {
|
|
37
|
+
platform: src.platform,
|
|
38
|
+
unavailable: (0, guidance_1.getUnavailableInterfaces)(src.interfaces, src.platform),
|
|
39
|
+
deviceName,
|
|
40
|
+
isTrainer: connectingCapability?.capability === 'control',
|
|
41
|
+
rideMode: src.rideMode,
|
|
42
|
+
};
|
|
43
|
+
const full = (0, guidance_1.getPairingGuidanceText)(id, params, 'full');
|
|
44
|
+
const short = (0, guidance_1.getPairingGuidanceText)(id, params, 'short');
|
|
45
|
+
return {
|
|
46
|
+
id,
|
|
47
|
+
text: full.text,
|
|
48
|
+
shortText: short.text,
|
|
49
|
+
link: full.link,
|
|
50
|
+
shortLink: short.link,
|
|
51
|
+
dot: statusDot(id),
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
exports.getPairingStatusDisplay = getPairingStatusDisplay;
|
|
@@ -68,6 +68,7 @@ let RideDisplayService = (() => {
|
|
|
68
68
|
let _getDeviceConfiguration_decorators;
|
|
69
69
|
let _getUIBinding_decorators;
|
|
70
70
|
let _getCoaches_decorators;
|
|
71
|
+
let _getPairingVisitTracker_decorators;
|
|
71
72
|
var RideDisplayService = class extends _classSuper {
|
|
72
73
|
static { _classThis = this; }
|
|
73
74
|
static {
|
|
@@ -81,6 +82,7 @@ let RideDisplayService = (() => {
|
|
|
81
82
|
_getDeviceConfiguration_decorators = [decorators_1.Injectable];
|
|
82
83
|
_getUIBinding_decorators = [decorators_1.Injectable];
|
|
83
84
|
_getCoaches_decorators = [decorators_1.Injectable];
|
|
85
|
+
_getPairingVisitTracker_decorators = [decorators_1.Injectable];
|
|
84
86
|
__esDecorate(this, null, _getActivityRide_decorators, { kind: "method", name: "getActivityRide", static: false, private: false, access: { has: obj => "getActivityRide" in obj, get: obj => obj.getActivityRide }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
85
87
|
__esDecorate(this, null, _getWorkoutRide_decorators, { kind: "method", name: "getWorkoutRide", static: false, private: false, access: { has: obj => "getWorkoutRide" in obj, get: obj => obj.getWorkoutRide }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
86
88
|
__esDecorate(this, null, _getWorkoutList_decorators, { kind: "method", name: "getWorkoutList", static: false, private: false, access: { has: obj => "getWorkoutList" in obj, get: obj => obj.getWorkoutList }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
@@ -90,6 +92,7 @@ let RideDisplayService = (() => {
|
|
|
90
92
|
__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);
|
|
91
93
|
__esDecorate(this, null, _getUIBinding_decorators, { kind: "method", name: "getUIBinding", static: false, private: false, access: { has: obj => "getUIBinding" in obj, get: obj => obj.getUIBinding }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
92
94
|
__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);
|
|
95
|
+
__esDecorate(this, null, _getPairingVisitTracker_decorators, { kind: "method", name: "getPairingVisitTracker", static: false, private: false, access: { has: obj => "getPairingVisitTracker" in obj, get: obj => obj.getPairingVisitTracker }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
93
96
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
94
97
|
RideDisplayService = _classThis = _classDescriptor.value;
|
|
95
98
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
@@ -135,6 +138,7 @@ let RideDisplayService = (() => {
|
|
|
135
138
|
try {
|
|
136
139
|
if (simulate)
|
|
137
140
|
this.enforceSimulator();
|
|
141
|
+
this.notifyPairingVisitRideStarted(simulate);
|
|
138
142
|
const rideProps = this.getRideModeService().getLogProps();
|
|
139
143
|
this.logEvent({ message: 'Start ride', ...rideProps,
|
|
140
144
|
bike: this.getBike(),
|
|
@@ -154,6 +158,14 @@ let RideDisplayService = (() => {
|
|
|
154
158
|
this.logError(err, 'start');
|
|
155
159
|
}
|
|
156
160
|
}
|
|
161
|
+
notifyPairingVisitRideStarted(simulate) {
|
|
162
|
+
try {
|
|
163
|
+
this.getPairingVisitTracker().onRideStarted({ simulate: simulate === true });
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
this.logError(err, 'notifyPairingVisitRideStarted');
|
|
167
|
+
}
|
|
168
|
+
}
|
|
157
169
|
startWithMissingSensors() {
|
|
158
170
|
try {
|
|
159
171
|
const props = this.getStartOverlayProps();
|
|
@@ -1169,6 +1181,9 @@ let RideDisplayService = (() => {
|
|
|
1169
1181
|
getCoaches() {
|
|
1170
1182
|
return (0, coaches_1.getCoachesService)();
|
|
1171
1183
|
}
|
|
1184
|
+
getPairingVisitTracker() {
|
|
1185
|
+
return (0, devices_1.usePairingVisitTracker)();
|
|
1186
|
+
}
|
|
1172
1187
|
};
|
|
1173
1188
|
return RideDisplayService = _classThis;
|
|
1174
1189
|
})();
|
package/lib/cjs/ui/service.js
CHANGED
|
@@ -129,6 +129,7 @@ let UserInterfaceServcie = (() => {
|
|
|
129
129
|
this.initLogging();
|
|
130
130
|
this.logEvent({ message: 'App mounted', channel: platform });
|
|
131
131
|
this.createUserStats();
|
|
132
|
+
this.initPairingVisits();
|
|
132
133
|
await this.initDeviceServices();
|
|
133
134
|
this.preloadData();
|
|
134
135
|
this.onSessionStart();
|
|
@@ -147,6 +148,7 @@ let UserInterfaceServcie = (() => {
|
|
|
147
148
|
this.logEvent({ message: 'onAppExit called' });
|
|
148
149
|
this.stopHeartbeatWorker();
|
|
149
150
|
this.sendAppExitMessage();
|
|
151
|
+
this.closePairingVisitOnExit();
|
|
150
152
|
pages_1.IncyclistPageService.closePage();
|
|
151
153
|
const cleanup = async () => {
|
|
152
154
|
await (0, utils_1.waitNextTick)();
|
|
@@ -173,6 +175,7 @@ let UserInterfaceServcie = (() => {
|
|
|
173
175
|
this.appState = 'Background';
|
|
174
176
|
this.logEvent({ message: 'onAppPause called' });
|
|
175
177
|
this.stopHeartbeatWorker();
|
|
178
|
+
this.onPairingVisitBackground();
|
|
176
179
|
(0, devices_1.useDeviceAccess)().pauseBackgroundActivity()
|
|
177
180
|
.catch((err) => { this.logError(err, 'onAppPause:pauseBackgroundActivity'); });
|
|
178
181
|
this.backgroundTimer = setTimeout(() => {
|
|
@@ -199,6 +202,7 @@ let UserInterfaceServcie = (() => {
|
|
|
199
202
|
resumeRequired = false;
|
|
200
203
|
}
|
|
201
204
|
this.logEvent({ message: 'onAppResume called' });
|
|
205
|
+
this.onPairingVisitForeground();
|
|
202
206
|
this.startHeartbeatWorker();
|
|
203
207
|
this.backgroundPausedByService = false;
|
|
204
208
|
this.appState = 'Active';
|
|
@@ -536,6 +540,41 @@ let UserInterfaceServcie = (() => {
|
|
|
536
540
|
}
|
|
537
541
|
onNewUser() {
|
|
538
542
|
}
|
|
543
|
+
initPairingVisits() {
|
|
544
|
+
try {
|
|
545
|
+
const isNewUser = this.getUserSettings().isNewUser() ?? false;
|
|
546
|
+
(0, devices_1.initPairingVisitTracker)(this.platform).onAppLaunch(isNewUser);
|
|
547
|
+
}
|
|
548
|
+
catch (err) {
|
|
549
|
+
this.logError(err, 'initPairingVisits');
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
closePairingVisitOnExit() {
|
|
553
|
+
try {
|
|
554
|
+
const canStartRide = (0, devices_1.useDevicePairing)().getState()?.canStartRide ?? false;
|
|
555
|
+
(0, devices_1.usePairingVisitTracker)().onAppExit(canStartRide);
|
|
556
|
+
}
|
|
557
|
+
catch (err) {
|
|
558
|
+
this.logError(err, 'closePairingVisitOnExit');
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
onPairingVisitBackground() {
|
|
562
|
+
try {
|
|
563
|
+
const canStartRide = (0, devices_1.useDevicePairing)().getState()?.canStartRide;
|
|
564
|
+
(0, devices_1.usePairingVisitTracker)().onBackground({ canStartRide });
|
|
565
|
+
}
|
|
566
|
+
catch (err) {
|
|
567
|
+
this.logError(err, 'onPairingVisitBackground');
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
onPairingVisitForeground() {
|
|
571
|
+
try {
|
|
572
|
+
(0, devices_1.usePairingVisitTracker)().onForeground();
|
|
573
|
+
}
|
|
574
|
+
catch (err) {
|
|
575
|
+
this.logError(err, 'onPairingVisitForeground');
|
|
576
|
+
}
|
|
577
|
+
}
|
|
539
578
|
getMessageQueue() {
|
|
540
579
|
return (0, api_1.getBindings)().mq;
|
|
541
580
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const DESKTOP_MATRIX = [
|
|
2
|
+
{ area: 'buttons', name: 'ready, ride mode', given: 'canStartRide, mode=start', expected: 'primary "Start" (labelOK), secondary "Cancel" (labelSkip)' },
|
|
3
|
+
{ area: 'buttons', name: 'ready, normal mode', given: 'canStartRide, mode=normal', expected: 'primary "OK", secondary "Skip"' },
|
|
4
|
+
{ area: 'buttons', name: 'not ready, ride mode, simulator enforceable', given: '!canStartRide, mode=start, canEnforceSimulator at open', expected: 'primary "Simulate", secondary "Cancel"' },
|
|
5
|
+
{ area: 'buttons', name: 'not ready, ride mode, no simulator', given: '!canStartRide, mode=start, canEnforceSimulator false', expected: 'primary "Cancel"' },
|
|
6
|
+
{ area: 'buttons', name: 'not ready, normal mode', given: '!canStartRide, mode=normal', expected: 'primary "Skip", no Simulate (simulate is ride-mode only)' },
|
|
7
|
+
{ area: 'ok-navigation', name: 'OK in ride mode starts the ride', given: 'isPairingForRide', expected: 'navigate "/rideOK"' },
|
|
8
|
+
{ area: 'ok-navigation', name: 'OK outside ride mode returns to the content page', given: '!isPairingForRide', expected: 'navigate "/<persisted page ?? routes>"' },
|
|
9
|
+
{ area: 'ok-navigation', name: 'OK closes the visit as ok', given: 'any', expected: 'closeVisit("ok") then devicePairing.prepareStart() and setReadyToStart()' },
|
|
10
|
+
{ area: 'skip', name: 'Skip in normal mode returns to the source', given: 'mode=normal, location.state.source set', expected: 'navigate(source); closeVisit("skip")' },
|
|
11
|
+
{ area: 'skip', name: 'Skip in normal mode without a source', given: 'mode=normal, no source', expected: 'navigate("/<persisted page ?? routes>"); closeVisit("skip")' },
|
|
12
|
+
{ area: 'skip', name: 'Cancel in ride mode returns to the source', given: 'mode=start', expected: 'navigate(source); closeVisit("cancel")' },
|
|
13
|
+
{ area: 'simulate', name: 'Simulate in ride mode', given: 'isPairingForRide', expected: 'prepareStart([simulatorId]); navigate "/rideSimulate"; closeVisit("simulate")' },
|
|
14
|
+
{ area: 'simulator', name: 'Shift+S adds the simulator', given: 'Shift+S pressed', expected: 'deviceConfig.add({name:"Simulator", interface:"simulator"}); the key is disabled afterwards' },
|
|
15
|
+
{ area: 'tiles', name: 'Tile ✕ unselects the capability', given: 'a selected tile', expected: 'devicePairing.unselectDevices(capability)' },
|
|
16
|
+
{ area: 'device-list', name: 'Opening a tile opens its device list', given: 'tile clicked', expected: 'DeviceSelector opens for that capability' },
|
|
17
|
+
{ area: 'device-list', name: 'Select with changeForAll default for Resistance', given: 'capability=control, device clicked', expected: 'selectDevice(control, udid, true); the dialog closes' },
|
|
18
|
+
{ area: 'device-list', name: 'Select with changeForAll default for other capabilities', given: 'capability!=control, device clicked', expected: 'selectDevice(capability, udid, false); the dialog closes' },
|
|
19
|
+
{ area: 'device-list', name: 'Select-all is offered for Resistance only', given: 'capability=control', expected: 'canSelectAll true; other capabilities false' },
|
|
20
|
+
{ area: 'device-list', name: 'Delete a device in the list', given: 'delete clicked on a device', expected: 'devicePairing.deleteDevice(capability, udid); the list stays open' },
|
|
21
|
+
{ area: 'device-list', name: 'Cancel the device list keeps the selection', given: 'Cancel in the list', expected: 'stopDeviceSelection(); onCancel closes the dialog; no unselect', flag: 'Mobile has a "Don\'t use" tick that unselects. Desktop has no tick and uses the tile ✕. The product owner wants an alternative on mobile; a UX suggestion is pending.' },
|
|
22
|
+
{ area: 'interfaces', name: 'Interface settings change', given: 'OK in interface settings', expected: 'devicePairing.changeInterfaceSettings(ifName, settings); the dialog closes' },
|
|
23
|
+
];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EventLogger } from "gd-eventlog";
|
|
2
|
+
import { Observer } from "../../../base/types/observer";
|
|
3
|
+
export class PageLogObserver extends Observer {
|
|
4
|
+
loggerContext;
|
|
5
|
+
logger;
|
|
6
|
+
constructor(loggerContext) {
|
|
7
|
+
super();
|
|
8
|
+
this.loggerContext = loggerContext;
|
|
9
|
+
this.logger = new EventLogger(loggerContext);
|
|
10
|
+
}
|
|
11
|
+
emit(event, ...data) {
|
|
12
|
+
super.emit(event, ...data);
|
|
13
|
+
this.logger.logEvent({ message: 'Pairing page state event', event });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|