@sports-alliance/sports-lib 7.0.0 → 7.0.2
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/.github/workflows/test.yml +2 -2
- package/lib/cjs/activities/activity.types.d.ts +6 -3
- package/lib/cjs/activities/activity.types.js +9 -4
- package/lib/cjs/data/data.cycling-position.js +1 -1
- package/lib/cjs/data/data.feeling.js +1 -1
- package/lib/cjs/data/data.interface.js +1 -1
- package/lib/cjs/data/data.rpe.js +1 -1
- package/lib/cjs/data/data.store.export.spec.js +28 -14
- package/lib/cjs/data/data.store.js +1 -1
- package/lib/cjs/events/adapters/file-type.enum.js +1 -1
- package/lib/cjs/events/adapters/importers/fit/importer.fit.coros.device.names.js +2 -1
- package/lib/cjs/events/adapters/importers/fit/importer.fit.d.ts +2 -1
- package/lib/cjs/events/adapters/importers/fit/importer.fit.garmin.device.names.js +61 -2
- package/lib/cjs/events/adapters/importers/fit/importer.fit.garmin.profile.data.js +867 -855
- package/lib/cjs/events/adapters/importers/fit/importer.fit.garmin.profile.mapper.spec.d.ts +1 -0
- package/lib/cjs/events/adapters/importers/fit/importer.fit.garmin.profile.mapper.spec.js +34 -0
- package/lib/cjs/events/adapters/importers/fit/importer.fit.integration.spec.js +22 -8
- package/lib/cjs/events/adapters/importers/fit/importer.fit.js +24 -2
- package/lib/cjs/events/adapters/importers/fit/importer.fit.suunto.device.names.js +1 -0
- package/lib/cjs/events/adapters/importers/fit/importer.fit.wahoo.device.names.js +5 -1
- package/lib/cjs/events/adapters/importers/gpx/importer.gpx.integration.spec.js +22 -8
- package/lib/cjs/events/adapters/importers/gpx/importer.gpx.js +1 -1
- package/lib/cjs/events/adapters/importers/gpx/importer.gpx.spec.js +50 -0
- package/lib/cjs/events/adapters/importers/suunto/importer.suunto.activity.ids.js +1 -1
- package/lib/cjs/events/adapters/importers/suunto/importer.suunto.device.names.js +1 -0
- package/lib/cjs/events/adapters/importers/suunto/importer.suunto.integration.spec.js +22 -8
- package/lib/cjs/events/adapters/importers/tcx/importer.tcx.integration.spec.js +22 -8
- package/lib/cjs/events/utilities/activity.utilities.js +7 -7
- package/lib/cjs/events/utilities/grade-calculator/low-pass-filter.js +3 -3
- package/lib/cjs/events/utilities/helpers.d.ts +1 -1
- package/lib/cjs/events/utilities/helpers.js +19 -19
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/index.js +5 -1
- package/lib/cjs/laps/lap.types.js +1 -1
- package/lib/cjs/meta-data/event-meta-data.interface.js +1 -1
- package/lib/cjs/privacy/privacy.class.interface.js +1 -1
- package/lib/cjs/specs/activities-parsing.integration.spec.js +75 -61
- package/lib/cjs/specs/strava-streams-compliance.spec.js +22 -8
- package/lib/cjs/streams/compressed.stream.interface.js +2 -2
- package/lib/cjs/tiles/tile.settings.interface.js +5 -5
- package/lib/cjs/users/settings/dashboard/user.dashboard.settings.interface.js +1 -1
- package/lib/cjs/users/settings/user.app.settings.interface.js +1 -1
- package/lib/cjs/users/settings/user.chart.settings.interface.js +3 -3
- package/lib/cjs/users/settings/user.map.settings.interface.js +2 -2
- package/lib/cjs/users/settings/user.unit.settings.interface.js +9 -9
- package/lib/esm/activities/activity.types.d.ts +6 -3
- package/lib/esm/activities/activity.types.js +7 -2
- package/lib/esm/data/data.store.export.spec.js +6 -6
- package/lib/esm/data/data.store.js +1 -1
- package/lib/esm/events/adapters/importers/fit/importer.fit.coros.device.names.js +2 -1
- package/lib/esm/events/adapters/importers/fit/importer.fit.d.ts +2 -1
- package/lib/esm/events/adapters/importers/fit/importer.fit.garmin.device.names.js +61 -2
- package/lib/esm/events/adapters/importers/fit/importer.fit.garmin.profile.data.js +867 -855
- package/lib/esm/events/adapters/importers/fit/importer.fit.garmin.profile.mapper.spec.d.ts +1 -0
- package/lib/esm/events/adapters/importers/fit/importer.fit.garmin.profile.mapper.spec.js +32 -0
- package/lib/esm/events/adapters/importers/fit/importer.fit.js +24 -2
- package/lib/esm/events/adapters/importers/fit/importer.fit.suunto.device.names.js +1 -0
- package/lib/esm/events/adapters/importers/fit/importer.fit.wahoo.device.names.js +5 -1
- package/lib/esm/events/adapters/importers/gpx/importer.gpx.js +1 -1
- package/lib/esm/events/adapters/importers/gpx/importer.gpx.spec.js +17 -0
- package/lib/esm/events/adapters/importers/suunto/importer.suunto.device.names.js +1 -0
- package/lib/esm/events/utilities/activity.utilities.js +7 -7
- package/lib/esm/events/utilities/grade-calculator/low-pass-filter.js +3 -3
- package/lib/esm/events/utilities/helpers.d.ts +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/specs/activities-parsing.integration.spec.js +53 -53
- package/package.json +21 -21
- package/.editorconfig +0 -14
- package/.eslintignore +0 -4
- package/.eslintrc.js +0 -9
- package/.prettierignore +0 -24
- package/.prettierrc.json +0 -12
- package/.vscode/launch.json +0 -49
- package/.vscode/tasks.json +0 -34
- package/CODE_OF_CONDUCT.md +0 -76
- package/debug-fit-import.js +0 -10
- package/jest.config.js +0 -23
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/specs/fixtures/streams/strava/rides/3171472783.json +0 -52534
- package/lib/cjs/specs/fixtures/streams/strava/rides/3171487458.json +0 -78818
- package/lib/cjs/specs/fixtures/streams/strava/rides/343080886.json +0 -105090
- package/lib/cjs/specs/fixtures/streams/strava/rides/5910143591.json +0 -110711
- package/lib/cjs/specs/fixtures/streams/strava/runs/2451375851.json +0 -74846
- package/lib/cjs/specs/fixtures/streams/strava/runs/2709634581.json +0 -66817
- package/lib/cjs/specs/fixtures/streams/strava/runs/3156040843.json +0 -17594
- package/lib/cjs/specs/fixtures/streams/strava/runs/3182900697.json +0 -17322
- package/lib/cjs/specs/fixtures/streams/strava/runs/3183465494.json +0 -20463
- package/lib/cjs/specs/fixtures/streams/strava/runs/3183490558.json +0 -58202
- package/lib/esm/specs/fixtures/streams/strava/rides/3171472783.json +0 -52534
- package/lib/esm/specs/fixtures/streams/strava/rides/3171487458.json +0 -78818
- package/lib/esm/specs/fixtures/streams/strava/rides/343080886.json +0 -105090
- package/lib/esm/specs/fixtures/streams/strava/rides/5910143591.json +0 -110711
- package/lib/esm/specs/fixtures/streams/strava/runs/2451375851.json +0 -74846
- package/lib/esm/specs/fixtures/streams/strava/runs/2709634581.json +0 -66817
- package/lib/esm/specs/fixtures/streams/strava/runs/3156040843.json +0 -17594
- package/lib/esm/specs/fixtures/streams/strava/runs/3182900697.json +0 -17322
- package/lib/esm/specs/fixtures/streams/strava/runs/3183465494.json +0 -20463
- package/lib/esm/specs/fixtures/streams/strava/runs/3183490558.json +0 -58202
- package/test_output.log +0 -162
- package/test_output_2.log +0 -168
- package/test_output_3.log +0 -168
- package/tsconfig.cjs.json +0 -7
- package/tsconfig.esm.json +0 -8
- package/tsconfig.lib.json +0 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const importer_fit_garmin_profile_mapper_1 = require("./importer.fit.garmin.profile.mapper");
|
|
4
|
+
describe('GarminProfileMapper', () => {
|
|
5
|
+
describe('getSportName', () => {
|
|
6
|
+
it('should translate sport ID', () => {
|
|
7
|
+
// Assuming ID 1 is Running
|
|
8
|
+
expect(importer_fit_garmin_profile_mapper_1.GarminProfileMapper.getSportName(1)).toBe('running');
|
|
9
|
+
});
|
|
10
|
+
it('should return null for unknown sport', () => {
|
|
11
|
+
expect(importer_fit_garmin_profile_mapper_1.GarminProfileMapper.getSportName(99999)).toBeNull();
|
|
12
|
+
});
|
|
13
|
+
it('should return names in snake_case (regression check for extraction logic)', () => {
|
|
14
|
+
// Checking ID 4 which is 'fitness_equipment' (was 'fitnessEquipment' in raw SDK)
|
|
15
|
+
expect(importer_fit_garmin_profile_mapper_1.GarminProfileMapper.getSportName(4)).toBe('fitness_equipment');
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
describe('getSubSportName', () => {
|
|
19
|
+
it('should translate sub sport ID', () => {
|
|
20
|
+
// Assuming ID 1 is Treadmill
|
|
21
|
+
expect(importer_fit_garmin_profile_mapper_1.GarminProfileMapper.getSubSportName(1)).toBe('treadmill');
|
|
22
|
+
});
|
|
23
|
+
it('should return names in snake_case (regression check for extraction logic)', () => {
|
|
24
|
+
// Checking ID 6 which is 'indoor_cycling' (was 'indoorCycling' in raw SDK)
|
|
25
|
+
expect(importer_fit_garmin_profile_mapper_1.GarminProfileMapper.getSubSportName(6)).toBe('indoor_cycling');
|
|
26
|
+
});
|
|
27
|
+
it('should correctly map Enduro and Downhill MTB (IDs 153/154)', () => {
|
|
28
|
+
// ID 153 = mountain_enduro
|
|
29
|
+
expect(importer_fit_garmin_profile_mapper_1.GarminProfileMapper.getSubSportName(153)).toBe('mountain_enduro');
|
|
30
|
+
// ID 154 = mountain_downhill
|
|
31
|
+
expect(importer_fit_garmin_profile_mapper_1.GarminProfileMapper.getSubSportName(154)).toBe('mountain_downhill');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
15
|
}) : function(o, v) {
|
|
12
16
|
o["default"] = v;
|
|
13
17
|
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
21
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -122,8 +122,8 @@ const fit_file_parser_1 = __importDefault(require("fit-file-parser"));
|
|
|
122
122
|
// Threshold to detect that session.timestamp are not trustable (when exceeding 15% of session.total_elapsed_time)
|
|
123
123
|
const INVALID_DATES_ELAPSED_TIME_RATIO_THRESHOLD = 1.15;
|
|
124
124
|
class EventImporterFIT {
|
|
125
|
-
static getFromArrayBuffer(
|
|
126
|
-
return __awaiter(this,
|
|
125
|
+
static getFromArrayBuffer(arrayBuffer_1) {
|
|
126
|
+
return __awaiter(this, arguments, void 0, function* (arrayBuffer, options = activity_parsing_options_1.ActivityParsingOptions.DEFAULT, name = 'New Event') {
|
|
127
127
|
return new Promise((resolve, reject) => {
|
|
128
128
|
const fitFileParser = new fit_file_parser_1.default({
|
|
129
129
|
force: true,
|
|
@@ -134,6 +134,7 @@ class EventImporterFIT {
|
|
|
134
134
|
mode: 'both'
|
|
135
135
|
});
|
|
136
136
|
fitFileParser.parse(arrayBuffer, (error, fitDataObject) => {
|
|
137
|
+
var _a;
|
|
137
138
|
if (error) {
|
|
138
139
|
// For now, assume any error from parser on this file means it's broken/empty in a way we treat as EmptyEventLibError
|
|
139
140
|
// to satisfy existing tests. Or ideally we wrap in a generic EventLibError.
|
|
@@ -145,6 +146,27 @@ class EventImporterFIT {
|
|
|
145
146
|
reject(new empty_event_sports_libs_error_1.EmptyEventLibError());
|
|
146
147
|
return;
|
|
147
148
|
}
|
|
149
|
+
// Check if we have length data at the top level (new parser behavior or missing mapping)
|
|
150
|
+
if (fitDataObject.lengths && fitDataObject.lengths.length > 0) {
|
|
151
|
+
(_a = fitDataObject.sessions) === null || _a === void 0 ? void 0 : _a.forEach((session) => {
|
|
152
|
+
var _a;
|
|
153
|
+
const sessionStartTime = new Date(session.start_time).getTime();
|
|
154
|
+
const sessionEndTime = sessionStartTime + (session.total_elapsed_time || 0) * 1000;
|
|
155
|
+
session.lengths = fitDataObject.lengths.filter((length) => {
|
|
156
|
+
const lengthTime = new Date(length.timestamp || length.start_time).getTime();
|
|
157
|
+
return lengthTime >= sessionStartTime && lengthTime < sessionEndTime;
|
|
158
|
+
});
|
|
159
|
+
// Also distribute to laps
|
|
160
|
+
(_a = session.laps) === null || _a === void 0 ? void 0 : _a.forEach((lap) => {
|
|
161
|
+
const lapStartTime = new Date(lap.start_time).getTime();
|
|
162
|
+
const lapEndTime = lapStartTime + (lap.total_elapsed_time || 0) * 1000;
|
|
163
|
+
lap.lengths = fitDataObject.lengths.filter((length) => {
|
|
164
|
+
const lengthTime = new Date(length.timestamp || length.start_time).getTime();
|
|
165
|
+
return lengthTime >= lapStartTime && lengthTime < lapEndTime;
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
}
|
|
148
170
|
// Iterate over the sessions and create their activities
|
|
149
171
|
const activities = fitDataObject.sessions.map((sessionObject) => {
|
|
150
172
|
// Get the activity from the sessionObject
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ImporterFitSuuntoDeviceNames = void 0;
|
|
4
4
|
const importer_suunto_device_names_1 = require("../suunto/importer.suunto.device.names");
|
|
5
5
|
exports.ImporterFitSuuntoDeviceNames = {
|
|
6
|
+
19: importer_suunto_device_names_1.ImporterSuuntoDeviceNames.Ambit2,
|
|
6
7
|
28: importer_suunto_device_names_1.ImporterSuuntoDeviceNames.Brighton,
|
|
7
8
|
29: importer_suunto_device_names_1.ImporterSuuntoDeviceNames.Amsterdam,
|
|
8
9
|
34: importer_suunto_device_names_1.ImporterSuuntoDeviceNames.Ibiza,
|
|
@@ -3,7 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ImporterFitWahooDeviceNames = void 0;
|
|
4
4
|
exports.ImporterFitWahooDeviceNames = {
|
|
5
5
|
28: 'ELEMNT',
|
|
6
|
+
30: 'ELEMNT MINI',
|
|
6
7
|
31: 'ELEMNT BOLT',
|
|
8
|
+
33: 'ELEMNT RIVAL',
|
|
7
9
|
37: 'ELEMNT ROAM',
|
|
8
|
-
|
|
10
|
+
38: 'ELEMNT MINI',
|
|
11
|
+
43: 'ELEMNT BOLT',
|
|
12
|
+
47: 'ELEMNT ROAM'
|
|
9
13
|
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
15
|
}) : function(o, v) {
|
|
12
16
|
o["default"] = v;
|
|
13
17
|
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
21
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -57,7 +57,7 @@ class EventImporterGPX {
|
|
|
57
57
|
// @todo for routes add a separate parser
|
|
58
58
|
const endDate = isActivity
|
|
59
59
|
? new Date(samples[samples.length - 1].time[0])
|
|
60
|
-
: new Date(startDate.getTime() + samples.length * 1000);
|
|
60
|
+
: new Date(startDate.getTime() + (samples.length > 0 ? samples.length - 1 : 0) * 1000);
|
|
61
61
|
let activityType = isActivity ? activity_types_1.ActivityTypes.unknown : activity_types_1.ActivityTypes.route;
|
|
62
62
|
if (trackOrRoute.type && activity_types_1.ActivityTypes[trackOrRoute.type]) {
|
|
63
63
|
activityType = activity_types_1.ActivityTypes[trackOrRoute.type];
|
|
@@ -1,4 +1,37 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -56,4 +89,21 @@ describe('importer.gpx', () => {
|
|
|
56
89
|
const result = yield importer_gpx_1.EventImporterGPX.getFromString(gpxString, xmldom_1.default.DOMParser);
|
|
57
90
|
expect(result.getFirstActivity().name).toEqual('Meylan Road Cycling');
|
|
58
91
|
}));
|
|
92
|
+
it('parses route.gpx from samples', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
93
|
+
const fs = yield Promise.resolve().then(() => __importStar(require('fs')));
|
|
94
|
+
const path = yield Promise.resolve().then(() => __importStar(require('path')));
|
|
95
|
+
const samplesDir = path.resolve(__dirname, '../../../../../samples/gpx');
|
|
96
|
+
const filePath = path.join(samplesDir, 'route.gpx');
|
|
97
|
+
const fileString = fs.readFileSync(filePath, 'utf-8');
|
|
98
|
+
const result = yield importer_gpx_1.EventImporterGPX.getFromString(fileString, xmldom_1.default.DOMParser);
|
|
99
|
+
expect(result.getActivities().length).toBeGreaterThan(0);
|
|
100
|
+
const activity = result.getFirstActivity();
|
|
101
|
+
expect(activity.type).toEqual('Route');
|
|
102
|
+
const distance = activity.getStat('Distance');
|
|
103
|
+
expect(distance).toBeDefined();
|
|
104
|
+
expect(distance.getValue()).toBeGreaterThan(0);
|
|
105
|
+
// Check if the number of samples matches the number of points in the GPX
|
|
106
|
+
const latStream = activity.getStream('Latitude');
|
|
107
|
+
expect(latStream.getData().length).toBe(2987); // I counted 2987 rtept earlier
|
|
108
|
+
}));
|
|
59
109
|
});
|
|
@@ -85,4 +85,4 @@ var ImporterSuuntoActivityIds;
|
|
|
85
85
|
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Hiking"] = 96] = "Hiking";
|
|
86
86
|
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Fishing"] = 97] = "Fishing";
|
|
87
87
|
ImporterSuuntoActivityIds[ImporterSuuntoActivityIds["Hunting"] = 98] = "Hunting";
|
|
88
|
-
})(ImporterSuuntoActivityIds
|
|
88
|
+
})(ImporterSuuntoActivityIds || (exports.ImporterSuuntoActivityIds = ImporterSuuntoActivityIds = {}));
|
|
@@ -21,6 +21,7 @@ exports.ImporterSuuntoDeviceNames = {
|
|
|
21
21
|
Gdansk: 'Spartan WHR Baro',
|
|
22
22
|
'Spartan Sport Wrist HR Baro': 'Spartan WHR Baro',
|
|
23
23
|
Helsinki: '3 Fitness',
|
|
24
|
+
Ambit2: 'Ambit2',
|
|
24
25
|
'Ambit3 Sport': 'Ambit3 Sport',
|
|
25
26
|
'Ambit3 Peak': 'Ambit3 Peak',
|
|
26
27
|
'Ambit3 Run': 'Ambit3 Run',
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
15
|
}) : function(o, v) {
|
|
12
16
|
o["default"] = v;
|
|
13
17
|
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
21
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
15
|
}) : function(o, v) {
|
|
12
16
|
o["default"] = v;
|
|
13
17
|
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
21
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -111,8 +111,8 @@ const ALTITUDE_SPIKES_FILTER_WIN = 3;
|
|
|
111
111
|
// Fix abnormal streams
|
|
112
112
|
const SPEED_STREAM_STD_DEV_THRESHOLD_DEFAULT = 25 / 3.6; // Kph to mps
|
|
113
113
|
const SPEED_STREAM_STD_DEV_THRESHOLD_MAP = new Map([
|
|
114
|
-
[activity_types_1.ActivityTypeGroups.Running, 15 / 3.6],
|
|
115
|
-
[activity_types_1.ActivityTypeGroups.Cycling, 27 / 3.6],
|
|
114
|
+
[activity_types_1.ActivityTypeGroups.Running, 15 / 3.6], // kph to m/s
|
|
115
|
+
[activity_types_1.ActivityTypeGroups.Cycling, 27 / 3.6], // kph to m/s
|
|
116
116
|
[activity_types_1.ActivityTypeGroups.Swimming, 5 / 3.6] // kph to m/s
|
|
117
117
|
]);
|
|
118
118
|
class ActivityUtilities {
|
|
@@ -278,7 +278,7 @@ class ActivityUtilities {
|
|
|
278
278
|
this.shapeStream(data_speed_1.DataSpeed.type, activity, squashedSpeedData => {
|
|
279
279
|
// Grade stream
|
|
280
280
|
const SPEED_KALMAN_SMOOTHING = {
|
|
281
|
-
R: 0.01,
|
|
281
|
+
R: 0.01, // Speed model calculation is something stable
|
|
282
282
|
Q: speedStdDev * 2 // We intend to get a measurement error which can be under and over std dev (explaining the double factor)
|
|
283
283
|
};
|
|
284
284
|
// Apply kalman filter
|
|
@@ -294,7 +294,7 @@ class ActivityUtilities {
|
|
|
294
294
|
// Always include derived base streams (like Pace), but conditionally include unit variants
|
|
295
295
|
const includeUnitVariants = !activity.parseOptions || activity.parseOptions.generateUnitStreams;
|
|
296
296
|
activity.addStreams(this.createUnitStreamsFromStreams(activity.getAllStreams(), activity.type, undefined, {
|
|
297
|
-
includeDerivedTypes: true,
|
|
297
|
+
includeDerivedTypes: true, // Always include derived base types (Pace etc)
|
|
298
298
|
includeUnitVariants
|
|
299
299
|
}));
|
|
300
300
|
}
|
|
@@ -760,9 +760,9 @@ class ActivityUtilities {
|
|
|
760
760
|
return prevPosition;
|
|
761
761
|
}
|
|
762
762
|
if (prevPosition && position) {
|
|
763
|
-
distance += this.
|
|
763
|
+
distance += this.geoLibAdapter.getDistance([prevPosition, position]);
|
|
764
764
|
}
|
|
765
|
-
streamData[index] = distance;
|
|
765
|
+
streamData[index] = this.round(distance, 2);
|
|
766
766
|
return position;
|
|
767
767
|
});
|
|
768
768
|
if (!activity.hasStreamData(data_distance_1.DataDistance.type)) {
|
|
@@ -815,7 +815,7 @@ class ActivityUtilities {
|
|
|
815
815
|
this.shapeStream(data_grade_smooth_1.DataGradeSmooth.type, activity, squashedGradeData => {
|
|
816
816
|
// Grade stream
|
|
817
817
|
const GRADE_KALMAN_SMOOTHING = {
|
|
818
|
-
R: 0.01,
|
|
818
|
+
R: 0.01, // Grade model is stable
|
|
819
819
|
Q: 0.5 // Grade measurement error which can be expected
|
|
820
820
|
};
|
|
821
821
|
// Predict proper grade values
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LowPassFilter = void 0;
|
|
4
4
|
class LowPassFilter {
|
|
5
|
+
static smooth(values, smoothing = 0.5) {
|
|
6
|
+
return new LowPassFilter(smoothing).smoothArray(values);
|
|
7
|
+
}
|
|
5
8
|
constructor(smoothing) {
|
|
6
9
|
this._smoothing = smoothing || 0.5; // must be smaller than 1
|
|
7
10
|
this._buffer = []; // FIFO queue
|
|
8
11
|
this._bufferMaxSize = 10;
|
|
9
12
|
}
|
|
10
|
-
static smooth(values, smoothing = 0.5) {
|
|
11
|
-
return new LowPassFilter(smoothing).smoothArray(values);
|
|
12
|
-
}
|
|
13
13
|
/**
|
|
14
14
|
* Init buffer with array of values
|
|
15
15
|
* @param {number[]} values
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function isNumberOrString(property: any):
|
|
1
|
+
export declare function isNumberOrString(property: any): property is string | number;
|
|
2
2
|
export declare function isNumber(property: any): boolean;
|
|
3
3
|
/**
|
|
4
4
|
* Converts speed from m/s to pace as of seconds per km
|
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.standardDeviation = exports.medianFilter = exports.meanWindowSmoothing = exports.mean =
|
|
3
|
+
exports.standardDeviation = exports.medianFilter = exports.meanWindowSmoothing = exports.mean = void 0;
|
|
4
|
+
exports.isNumberOrString = isNumberOrString;
|
|
5
|
+
exports.isNumber = isNumber;
|
|
6
|
+
exports.convertSpeedToPace = convertSpeedToPace;
|
|
7
|
+
exports.convertSpeedToSwimPace = convertSpeedToSwimPace;
|
|
8
|
+
exports.convertSpeedToSpeedInKilometersPerHour = convertSpeedToSpeedInKilometersPerHour;
|
|
9
|
+
exports.convertSpeedToSpeedInMilesPerHour = convertSpeedToSpeedInMilesPerHour;
|
|
10
|
+
exports.convertSpeedToSpeedInFeetPerSecond = convertSpeedToSpeedInFeetPerSecond;
|
|
11
|
+
exports.convertSpeedToSpeedInMetersPerMinute = convertSpeedToSpeedInMetersPerMinute;
|
|
12
|
+
exports.convertSpeedToSpeedInFeetPerMinute = convertSpeedToSpeedInFeetPerMinute;
|
|
13
|
+
exports.convertSpeedToSpeedInFeetPerHour = convertSpeedToSpeedInFeetPerHour;
|
|
14
|
+
exports.convertSpeedToSpeedInMetersPerHour = convertSpeedToSpeedInMetersPerHour;
|
|
15
|
+
exports.convertSpeedToSpeedInKnots = convertSpeedToSpeedInKnots;
|
|
16
|
+
exports.convertPaceToPaceInMinutesPerMile = convertPaceToPaceInMinutesPerMile;
|
|
17
|
+
exports.convertMetersToMiles = convertMetersToMiles;
|
|
18
|
+
exports.convertSwimPaceToSwimPacePer100Yard = convertSwimPaceToSwimPacePer100Yard;
|
|
19
|
+
exports.getSize = getSize;
|
|
20
|
+
exports.getSizeFormated = getSizeFormated;
|
|
21
|
+
exports.fillMissingValuesLinear = fillMissingValuesLinear;
|
|
4
22
|
function isNumberOrString(property) {
|
|
5
23
|
return typeof property === 'number' || typeof property === 'string';
|
|
6
24
|
}
|
|
7
|
-
exports.isNumberOrString = isNumberOrString;
|
|
8
25
|
function isNumber(property) {
|
|
9
26
|
return typeof property === 'number' && !isNaN(property);
|
|
10
27
|
}
|
|
11
|
-
exports.isNumber = isNumber;
|
|
12
28
|
/**
|
|
13
29
|
* Converts speed from m/s to pace as of seconds per km
|
|
14
30
|
* @param {number} number
|
|
@@ -17,7 +33,6 @@ exports.isNumber = isNumber;
|
|
|
17
33
|
function convertSpeedToPace(number) {
|
|
18
34
|
return number === 0 ? Infinity : 1000 / number;
|
|
19
35
|
}
|
|
20
|
-
exports.convertSpeedToPace = convertSpeedToPace;
|
|
21
36
|
/**
|
|
22
37
|
* Converts m/s to seconds per 100m
|
|
23
38
|
* @param number
|
|
@@ -25,47 +40,36 @@ exports.convertSpeedToPace = convertSpeedToPace;
|
|
|
25
40
|
function convertSpeedToSwimPace(number) {
|
|
26
41
|
return number === 0 ? Infinity : 100 / number;
|
|
27
42
|
}
|
|
28
|
-
exports.convertSpeedToSwimPace = convertSpeedToSwimPace;
|
|
29
43
|
function convertSpeedToSpeedInKilometersPerHour(number) {
|
|
30
44
|
return number * 3.6;
|
|
31
45
|
}
|
|
32
|
-
exports.convertSpeedToSpeedInKilometersPerHour = convertSpeedToSpeedInKilometersPerHour;
|
|
33
46
|
function convertSpeedToSpeedInMilesPerHour(number) {
|
|
34
47
|
return number * 2.237;
|
|
35
48
|
}
|
|
36
|
-
exports.convertSpeedToSpeedInMilesPerHour = convertSpeedToSpeedInMilesPerHour;
|
|
37
49
|
function convertSpeedToSpeedInFeetPerSecond(number) {
|
|
38
50
|
return number * 3.28084;
|
|
39
51
|
}
|
|
40
|
-
exports.convertSpeedToSpeedInFeetPerSecond = convertSpeedToSpeedInFeetPerSecond;
|
|
41
52
|
function convertSpeedToSpeedInMetersPerMinute(number) {
|
|
42
53
|
return number * 60;
|
|
43
54
|
}
|
|
44
|
-
exports.convertSpeedToSpeedInMetersPerMinute = convertSpeedToSpeedInMetersPerMinute;
|
|
45
55
|
function convertSpeedToSpeedInFeetPerMinute(number) {
|
|
46
56
|
return number * 196.85;
|
|
47
57
|
}
|
|
48
|
-
exports.convertSpeedToSpeedInFeetPerMinute = convertSpeedToSpeedInFeetPerMinute;
|
|
49
58
|
function convertSpeedToSpeedInFeetPerHour(number) {
|
|
50
59
|
return number * 11811.024;
|
|
51
60
|
}
|
|
52
|
-
exports.convertSpeedToSpeedInFeetPerHour = convertSpeedToSpeedInFeetPerHour;
|
|
53
61
|
function convertSpeedToSpeedInMetersPerHour(number) {
|
|
54
62
|
return number * 3600;
|
|
55
63
|
}
|
|
56
|
-
exports.convertSpeedToSpeedInMetersPerHour = convertSpeedToSpeedInMetersPerHour;
|
|
57
64
|
function convertSpeedToSpeedInKnots(number) {
|
|
58
65
|
return number * 1.943844;
|
|
59
66
|
}
|
|
60
|
-
exports.convertSpeedToSpeedInKnots = convertSpeedToSpeedInKnots;
|
|
61
67
|
function convertPaceToPaceInMinutesPerMile(number) {
|
|
62
68
|
return number * 1.60934;
|
|
63
69
|
}
|
|
64
|
-
exports.convertPaceToPaceInMinutesPerMile = convertPaceToPaceInMinutesPerMile;
|
|
65
70
|
function convertMetersToMiles(number) {
|
|
66
71
|
return number === 0 ? 0 : number / 1609;
|
|
67
72
|
}
|
|
68
|
-
exports.convertMetersToMiles = convertMetersToMiles;
|
|
69
73
|
/**
|
|
70
74
|
* Converts m/s to seconds per 100m
|
|
71
75
|
* @param number
|
|
@@ -73,15 +77,12 @@ exports.convertMetersToMiles = convertMetersToMiles;
|
|
|
73
77
|
function convertSwimPaceToSwimPacePer100Yard(number) {
|
|
74
78
|
return number * 1.93613298;
|
|
75
79
|
}
|
|
76
|
-
exports.convertSwimPaceToSwimPacePer100Yard = convertSwimPaceToSwimPacePer100Yard;
|
|
77
80
|
function getSize(obj) {
|
|
78
81
|
return getSizeWithOptionalFormat(obj, false);
|
|
79
82
|
}
|
|
80
|
-
exports.getSize = getSize;
|
|
81
83
|
function getSizeFormated(obj) {
|
|
82
84
|
return getSizeWithOptionalFormat(obj, true);
|
|
83
85
|
}
|
|
84
|
-
exports.getSizeFormated = getSizeFormated;
|
|
85
86
|
function getSizeWithOptionalFormat(obj, format = true) {
|
|
86
87
|
let size;
|
|
87
88
|
try {
|
|
@@ -131,7 +132,6 @@ function fillMissingValuesLinear(array) {
|
|
|
131
132
|
}
|
|
132
133
|
return array;
|
|
133
134
|
}
|
|
134
|
-
exports.fillMissingValuesLinear = fillMissingValuesLinear;
|
|
135
135
|
const mean = (array) => {
|
|
136
136
|
return array.reduce((a, b) => a + b, 0) / array.length;
|
|
137
137
|
};
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare class SportsLib {
|
|
|
20
20
|
* @param arrayBuffer
|
|
21
21
|
* @param options
|
|
22
22
|
*/
|
|
23
|
-
static importFromFit(arrayBuffer: ArrayBuffer
|
|
23
|
+
static importFromFit(arrayBuffer: ArrayBuffer | Buffer<ArrayBuffer>, options?: ActivityParsingOptions): Promise<EventInterface>;
|
|
24
24
|
/**
|
|
25
25
|
* Parses and returns an event using Suunto format
|
|
26
26
|
* @param jsonString
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -53,4 +53,4 @@ var LapTypes;
|
|
|
53
53
|
LapTypes["fitness equipment"] = "Fitness equipment";
|
|
54
54
|
LapTypes["Fitness equipment"] = "Fitness equipment";
|
|
55
55
|
LapTypes["FitnessEquipment"] = "Fitness equipment";
|
|
56
|
-
})(LapTypes
|
|
56
|
+
})(LapTypes || (exports.LapTypes = LapTypes = {}));
|
|
@@ -6,4 +6,4 @@ var ServiceNames;
|
|
|
6
6
|
ServiceNames["SuuntoApp"] = "Suunto app";
|
|
7
7
|
ServiceNames["GarminAPI"] = "Garmin API";
|
|
8
8
|
ServiceNames["COROSAPI"] = "COROS API";
|
|
9
|
-
})(ServiceNames
|
|
9
|
+
})(ServiceNames || (exports.ServiceNames = ServiceNames = {}));
|