incyclist-services 1.7.129 → 1.7.131
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/service.js +1 -1
- package/lib/cjs/devices/access/service.js +8 -0
- package/lib/cjs/ui/service.js +48 -10
- package/lib/esm/activities/active-rides/service.js +1 -1
- package/lib/esm/devices/access/service.js +8 -0
- package/lib/esm/ui/service.js +48 -10
- package/lib/types/devices/access/service.d.ts +2 -0
- package/package.json +2 -2
|
@@ -579,7 +579,7 @@ let ActiveRidesService = (() => {
|
|
|
579
579
|
this.isOnline = this.getOnlineStatusMonitoring().onlineStatus;
|
|
580
580
|
if (this.isOnline)
|
|
581
581
|
this.onConnect({ initial: true });
|
|
582
|
-
this.getOnlineStatusMonitoring().start('activeRides', this.
|
|
582
|
+
this.getOnlineStatusMonitoring().start('activeRides', this.onlineStatusHandler);
|
|
583
583
|
}
|
|
584
584
|
}
|
|
585
585
|
onOnlineStatusChange(online) {
|
|
@@ -271,6 +271,14 @@ let DeviceAccessService = (() => {
|
|
|
271
271
|
this.emit('interface-changed', ifaceName, { ...this.interfaces[ifaceName] });
|
|
272
272
|
return disconnected;
|
|
273
273
|
}
|
|
274
|
+
async pauseBackgroundActivity() {
|
|
275
|
+
const promises = Object.keys(this.interfaces).map((name) => this.getInterface(name)?.pauseBackgroundActivity?.());
|
|
276
|
+
await Promise.allSettled(promises);
|
|
277
|
+
}
|
|
278
|
+
async resumeBackgroundActivity() {
|
|
279
|
+
const promises = Object.keys(this.interfaces).map((name) => this.getInterface(name)?.resumeBackgroundActivity?.());
|
|
280
|
+
await Promise.allSettled(promises);
|
|
281
|
+
}
|
|
274
282
|
async terminate(ifaceName) {
|
|
275
283
|
await this.disconnect(ifaceName);
|
|
276
284
|
if (!ifaceName) {
|
package/lib/cjs/ui/service.js
CHANGED
|
@@ -173,9 +173,11 @@ let UserInterfaceServcie = (() => {
|
|
|
173
173
|
this.appState = 'Background';
|
|
174
174
|
this.logEvent({ message: 'onAppPause called' });
|
|
175
175
|
this.stopHeartbeatWorker();
|
|
176
|
+
(0, devices_1.useDeviceAccess)().pauseBackgroundActivity()
|
|
177
|
+
.catch((err) => { this.logError(err, 'onAppPause:pauseBackgroundActivity'); });
|
|
176
178
|
this.backgroundTimer = setTimeout(() => {
|
|
177
179
|
this.backgroundPausedByService = true;
|
|
178
|
-
this.pause();
|
|
180
|
+
this.pause().catch((err) => { this.logError(err, 'onAppPause:pause'); });
|
|
179
181
|
}, BACKGROUND_PAUSE_TIMEOUT_MS);
|
|
180
182
|
}
|
|
181
183
|
catch (err) {
|
|
@@ -200,8 +202,10 @@ let UserInterfaceServcie = (() => {
|
|
|
200
202
|
this.startHeartbeatWorker();
|
|
201
203
|
this.backgroundPausedByService = false;
|
|
202
204
|
this.appState = 'Active';
|
|
205
|
+
(0, devices_1.useDeviceAccess)().resumeBackgroundActivity()
|
|
206
|
+
.catch((err) => { this.logError(err, 'onAppResume:resumeBackgroundActivity'); });
|
|
203
207
|
if (resumeRequired) {
|
|
204
|
-
this.resume();
|
|
208
|
+
this.resume().catch((err) => { this.logError(err, 'onAppResume:resume'); });
|
|
205
209
|
}
|
|
206
210
|
}
|
|
207
211
|
catch (err) {
|
|
@@ -239,16 +243,50 @@ let UserInterfaceServcie = (() => {
|
|
|
239
243
|
}
|
|
240
244
|
}
|
|
241
245
|
async pause() {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
+
this.logEvent({ message: 'pause started' });
|
|
247
|
+
try {
|
|
248
|
+
await pages_1.IncyclistPageService.pausePage();
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
251
|
+
this.logError(err, 'pause:pausePage');
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
await (0, devices_1.useDeviceAccess)().disconnect();
|
|
255
|
+
}
|
|
256
|
+
catch (err) {
|
|
257
|
+
this.logError(err, 'pause:disconnect');
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
if (this.getMessageQueue().disconnect)
|
|
261
|
+
this.getMessageQueue().disconnect();
|
|
262
|
+
}
|
|
263
|
+
catch (err) {
|
|
264
|
+
this.logError(err, 'pause:mqDisconnect');
|
|
265
|
+
}
|
|
266
|
+
this.logEvent({ message: 'pause finished' });
|
|
246
267
|
}
|
|
247
268
|
async resume() {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
269
|
+
this.logEvent({ message: 'resume started' });
|
|
270
|
+
try {
|
|
271
|
+
if (this.getMessageQueue().connect)
|
|
272
|
+
this.getMessageQueue().connect();
|
|
273
|
+
}
|
|
274
|
+
catch (err) {
|
|
275
|
+
this.logError(err, 'resume:mqConnect');
|
|
276
|
+
}
|
|
277
|
+
try {
|
|
278
|
+
await (0, devices_1.useDeviceAccess)().connect();
|
|
279
|
+
}
|
|
280
|
+
catch (err) {
|
|
281
|
+
this.logError(err, 'resume:connect');
|
|
282
|
+
}
|
|
283
|
+
try {
|
|
284
|
+
await pages_1.IncyclistPageService.resumePage();
|
|
285
|
+
}
|
|
286
|
+
catch (err) {
|
|
287
|
+
this.logError(err, 'resume:resumePage');
|
|
288
|
+
}
|
|
289
|
+
this.logEvent({ message: 'resume finished' });
|
|
252
290
|
}
|
|
253
291
|
startHeartbeatWorker() {
|
|
254
292
|
if (this.heartbeatIv)
|
|
@@ -576,7 +576,7 @@ let ActiveRidesService = (() => {
|
|
|
576
576
|
this.isOnline = this.getOnlineStatusMonitoring().onlineStatus;
|
|
577
577
|
if (this.isOnline)
|
|
578
578
|
this.onConnect({ initial: true });
|
|
579
|
-
this.getOnlineStatusMonitoring().start('activeRides', this.
|
|
579
|
+
this.getOnlineStatusMonitoring().start('activeRides', this.onlineStatusHandler);
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
582
|
onOnlineStatusChange(online) {
|
|
@@ -265,6 +265,14 @@ let DeviceAccessService = (() => {
|
|
|
265
265
|
this.emit('interface-changed', ifaceName, { ...this.interfaces[ifaceName] });
|
|
266
266
|
return disconnected;
|
|
267
267
|
}
|
|
268
|
+
async pauseBackgroundActivity() {
|
|
269
|
+
const promises = Object.keys(this.interfaces).map((name) => this.getInterface(name)?.pauseBackgroundActivity?.());
|
|
270
|
+
await Promise.allSettled(promises);
|
|
271
|
+
}
|
|
272
|
+
async resumeBackgroundActivity() {
|
|
273
|
+
const promises = Object.keys(this.interfaces).map((name) => this.getInterface(name)?.resumeBackgroundActivity?.());
|
|
274
|
+
await Promise.allSettled(promises);
|
|
275
|
+
}
|
|
268
276
|
async terminate(ifaceName) {
|
|
269
277
|
await this.disconnect(ifaceName);
|
|
270
278
|
if (!ifaceName) {
|
package/lib/esm/ui/service.js
CHANGED
|
@@ -170,9 +170,11 @@ let UserInterfaceServcie = (() => {
|
|
|
170
170
|
this.appState = 'Background';
|
|
171
171
|
this.logEvent({ message: 'onAppPause called' });
|
|
172
172
|
this.stopHeartbeatWorker();
|
|
173
|
+
useDeviceAccess().pauseBackgroundActivity()
|
|
174
|
+
.catch((err) => { this.logError(err, 'onAppPause:pauseBackgroundActivity'); });
|
|
173
175
|
this.backgroundTimer = setTimeout(() => {
|
|
174
176
|
this.backgroundPausedByService = true;
|
|
175
|
-
this.pause();
|
|
177
|
+
this.pause().catch((err) => { this.logError(err, 'onAppPause:pause'); });
|
|
176
178
|
}, BACKGROUND_PAUSE_TIMEOUT_MS);
|
|
177
179
|
}
|
|
178
180
|
catch (err) {
|
|
@@ -197,8 +199,10 @@ let UserInterfaceServcie = (() => {
|
|
|
197
199
|
this.startHeartbeatWorker();
|
|
198
200
|
this.backgroundPausedByService = false;
|
|
199
201
|
this.appState = 'Active';
|
|
202
|
+
useDeviceAccess().resumeBackgroundActivity()
|
|
203
|
+
.catch((err) => { this.logError(err, 'onAppResume:resumeBackgroundActivity'); });
|
|
200
204
|
if (resumeRequired) {
|
|
201
|
-
this.resume();
|
|
205
|
+
this.resume().catch((err) => { this.logError(err, 'onAppResume:resume'); });
|
|
202
206
|
}
|
|
203
207
|
}
|
|
204
208
|
catch (err) {
|
|
@@ -236,16 +240,50 @@ let UserInterfaceServcie = (() => {
|
|
|
236
240
|
}
|
|
237
241
|
}
|
|
238
242
|
async pause() {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
+
this.logEvent({ message: 'pause started' });
|
|
244
|
+
try {
|
|
245
|
+
await IncyclistPageService.pausePage();
|
|
246
|
+
}
|
|
247
|
+
catch (err) {
|
|
248
|
+
this.logError(err, 'pause:pausePage');
|
|
249
|
+
}
|
|
250
|
+
try {
|
|
251
|
+
await useDeviceAccess().disconnect();
|
|
252
|
+
}
|
|
253
|
+
catch (err) {
|
|
254
|
+
this.logError(err, 'pause:disconnect');
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
if (this.getMessageQueue().disconnect)
|
|
258
|
+
this.getMessageQueue().disconnect();
|
|
259
|
+
}
|
|
260
|
+
catch (err) {
|
|
261
|
+
this.logError(err, 'pause:mqDisconnect');
|
|
262
|
+
}
|
|
263
|
+
this.logEvent({ message: 'pause finished' });
|
|
243
264
|
}
|
|
244
265
|
async resume() {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
266
|
+
this.logEvent({ message: 'resume started' });
|
|
267
|
+
try {
|
|
268
|
+
if (this.getMessageQueue().connect)
|
|
269
|
+
this.getMessageQueue().connect();
|
|
270
|
+
}
|
|
271
|
+
catch (err) {
|
|
272
|
+
this.logError(err, 'resume:mqConnect');
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
await useDeviceAccess().connect();
|
|
276
|
+
}
|
|
277
|
+
catch (err) {
|
|
278
|
+
this.logError(err, 'resume:connect');
|
|
279
|
+
}
|
|
280
|
+
try {
|
|
281
|
+
await IncyclistPageService.resumePage();
|
|
282
|
+
}
|
|
283
|
+
catch (err) {
|
|
284
|
+
this.logError(err, 'resume:resumePage');
|
|
285
|
+
}
|
|
286
|
+
this.logEvent({ message: 'resume finished' });
|
|
249
287
|
}
|
|
250
288
|
startHeartbeatWorker() {
|
|
251
289
|
if (this.heartbeatIv)
|
|
@@ -22,6 +22,8 @@ export declare class DeviceAccessService extends IncyclistService {
|
|
|
22
22
|
connect(ifaceName?: string): Promise<boolean>;
|
|
23
23
|
private getScanTimeout;
|
|
24
24
|
disconnect(ifaceName?: string): Promise<boolean>;
|
|
25
|
+
pauseBackgroundActivity(): Promise<void>;
|
|
26
|
+
resumeBackgroundActivity(): Promise<void>;
|
|
25
27
|
terminate(ifaceName?: string): Promise<void>;
|
|
26
28
|
scan(filter?: ScanFilter, props?: {
|
|
27
29
|
timeout?: number;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "incyclist-services",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.131",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"gd-eventlog": "^0.1.27"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@garmin/fitsdk": "^21.213.0",
|
|
9
9
|
"axios": "^1.19.0",
|
|
10
|
-
"incyclist-devices": "^3.0.
|
|
10
|
+
"incyclist-devices": "^3.0.35",
|
|
11
11
|
"promise.any": "^2.0.6",
|
|
12
12
|
"semver": "^7.7.4",
|
|
13
13
|
"tcx-builder": "^1.1.1",
|