@sports-alliance/sports-lib 7.2.2 → 7.2.4

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/esm/index.js CHANGED
@@ -3488,6 +3488,9 @@ var DataStepsOld = class extends DataNumber {
3488
3488
 
3489
3489
  // src/data/data.event.ts
3490
3490
  var DataEvent = class extends DataNumber {
3491
+ get timestamp() {
3492
+ return this.getValue();
3493
+ }
3491
3494
  };
3492
3495
 
3493
3496
  // src/data/data.stop-event.ts
@@ -3692,9 +3695,14 @@ var DataRiderPositionChangeEvent = class extends DataEvent {
3692
3695
  static {
3693
3696
  this.type = "Rider Position Change Event";
3694
3697
  }
3695
- constructor(index, positionChange) {
3696
- super(index);
3697
- this.positionChange = positionChange;
3698
+ constructor(indexOrObj, positionChange) {
3699
+ if (typeof indexOrObj === "object") {
3700
+ super(indexOrObj.index);
3701
+ this.positionChange = indexOrObj.positionChange;
3702
+ } else {
3703
+ super(indexOrObj);
3704
+ this.positionChange = positionChange;
3705
+ }
3698
3706
  }
3699
3707
  };
3700
3708
 
@@ -3890,19 +3898,57 @@ var DataJumpCount = class extends DataNumber {
3890
3898
  };
3891
3899
 
3892
3900
  // src/data/data.jump-event.ts
3893
- var DataJumpEvent = class extends DataEvent {
3894
- constructor(timestamp, jumpData) {
3895
- super(timestamp);
3896
- this.jumpData = jumpData;
3901
+ var DataScore = class extends DataNumber {
3902
+ static {
3903
+ this.type = "Score";
3897
3904
  }
3905
+ };
3906
+ var DataRotations = class extends DataNumber {
3907
+ static {
3908
+ this.type = "Rotations";
3909
+ }
3910
+ };
3911
+ var DataJumpEvent = class _DataJumpEvent extends DataEvent {
3898
3912
  static {
3899
3913
  this.type = "Jump Event";
3900
3914
  }
3915
+ constructor(timestampOrObj, jumpData) {
3916
+ if (typeof timestampOrObj === "object") {
3917
+ super(timestampOrObj.timestamp);
3918
+ this.jumpData = this.hydrate(timestampOrObj.jumpData);
3919
+ } else {
3920
+ super(timestampOrObj);
3921
+ this.jumpData = this.hydrate(jumpData);
3922
+ }
3923
+ }
3924
+ hydrate(data) {
3925
+ return {
3926
+ distance: data.distance instanceof DataDistance ? data.distance : new DataDistance(data.distance),
3927
+ height: data.height ? data.height instanceof DataDistance ? data.height : new DataDistance(data.height) : void 0,
3928
+ score: data.score instanceof DataScore ? data.score : new DataScore(data.score),
3929
+ hang_time: data.hang_time ? data.hang_time instanceof DataDuration ? data.hang_time : new DataDuration(data.hang_time) : void 0,
3930
+ position_lat: data.position_lat ? data.position_lat instanceof DataLatitudeDegrees ? data.position_lat : new DataLatitudeDegrees(data.position_lat) : void 0,
3931
+ position_long: data.position_long ? data.position_long instanceof DataLongitudeDegrees ? data.position_long : new DataLongitudeDegrees(data.position_long) : void 0,
3932
+ speed: data.speed ? data.speed instanceof DataSpeed ? data.speed : new DataSpeed(data.speed) : void 0,
3933
+ rotations: data.rotations ? data.rotations instanceof DataRotations ? data.rotations : new DataRotations(data.rotations) : void 0
3934
+ };
3935
+ }
3901
3936
  toJSON() {
3902
3937
  const json = super.toJSON();
3903
3938
  return {
3904
- ...json,
3905
- jumpData: this.jumpData
3939
+ [_DataJumpEvent.type]: {
3940
+ timestamp: this.getValue(),
3941
+ jumpData: {
3942
+ distance: this.jumpData.distance.getValue(),
3943
+ height: this.jumpData.height?.getValue(),
3944
+ score: this.jumpData.score.getValue(),
3945
+ hang_time: this.jumpData.hang_time?.getValue(),
3946
+ position_lat: this.jumpData.position_lat?.getValue(),
3947
+ position_long: this.jumpData.position_long?.getValue(),
3948
+ speed: this.jumpData.speed?.getValue(),
3949
+ rotations: this.jumpData.rotations?.getValue()
3950
+ }
3951
+ }
3906
3952
  };
3907
3953
  }
3908
3954
  };
@@ -4142,6 +4188,206 @@ var DataDepthMax = class extends DataNumber {
4142
4188
  }
4143
4189
  };
4144
4190
 
4191
+ // src/data/data.jump-stats.ts
4192
+ var DataJumpHangTimeMin = class extends DataNumber {
4193
+ static {
4194
+ this.type = "Jump Hang Time Min";
4195
+ }
4196
+ static {
4197
+ this.unit = "s";
4198
+ }
4199
+ constructor(value) {
4200
+ super(value);
4201
+ }
4202
+ };
4203
+ var DataJumpHangTimeMax = class extends DataNumber {
4204
+ static {
4205
+ this.type = "Jump Hang Time Max";
4206
+ }
4207
+ static {
4208
+ this.unit = "s";
4209
+ }
4210
+ constructor(value) {
4211
+ super(value);
4212
+ }
4213
+ };
4214
+ var DataJumpHangTimeAvg = class extends DataNumber {
4215
+ static {
4216
+ this.type = "Jump Hang Time Avg";
4217
+ }
4218
+ static {
4219
+ this.unit = "s";
4220
+ }
4221
+ constructor(value) {
4222
+ super(value);
4223
+ }
4224
+ };
4225
+ var DataJumpDistanceMin = class extends DataNumber {
4226
+ static {
4227
+ this.type = "Jump Distance Min";
4228
+ }
4229
+ static {
4230
+ this.unit = "m";
4231
+ }
4232
+ constructor(value) {
4233
+ super(value);
4234
+ }
4235
+ };
4236
+ var DataJumpDistanceMax = class extends DataNumber {
4237
+ static {
4238
+ this.type = "Jump Distance Max";
4239
+ }
4240
+ static {
4241
+ this.unit = "m";
4242
+ }
4243
+ constructor(value) {
4244
+ super(value);
4245
+ }
4246
+ };
4247
+ var DataJumpDistanceAvg = class extends DataNumber {
4248
+ static {
4249
+ this.type = "Jump Distance Avg";
4250
+ }
4251
+ static {
4252
+ this.unit = "m";
4253
+ }
4254
+ constructor(value) {
4255
+ super(value);
4256
+ }
4257
+ };
4258
+ var DataJumpSpeedMin = class extends DataNumber {
4259
+ static {
4260
+ this.type = "Jump Speed Min";
4261
+ }
4262
+ static {
4263
+ this.unit = "m/s";
4264
+ }
4265
+ constructor(value) {
4266
+ super(value);
4267
+ }
4268
+ };
4269
+ var DataJumpSpeedMax = class extends DataNumber {
4270
+ static {
4271
+ this.type = "Jump Speed Max";
4272
+ }
4273
+ static {
4274
+ this.unit = "m/s";
4275
+ }
4276
+ constructor(value) {
4277
+ super(value);
4278
+ }
4279
+ };
4280
+ var DataJumpSpeedAvg = class extends DataNumber {
4281
+ static {
4282
+ this.type = "Jump Speed Avg";
4283
+ }
4284
+ static {
4285
+ this.unit = "m/s";
4286
+ }
4287
+ constructor(value) {
4288
+ super(value);
4289
+ }
4290
+ };
4291
+ var DataJumpRotationsMin = class extends DataNumber {
4292
+ static {
4293
+ this.type = "Jump Rotations Min";
4294
+ }
4295
+ static {
4296
+ this.unit = "";
4297
+ }
4298
+ constructor(value) {
4299
+ super(value);
4300
+ }
4301
+ };
4302
+ var DataJumpRotationsMax = class extends DataNumber {
4303
+ static {
4304
+ this.type = "Jump Rotations Max";
4305
+ }
4306
+ static {
4307
+ this.unit = "";
4308
+ }
4309
+ constructor(value) {
4310
+ super(value);
4311
+ }
4312
+ };
4313
+ var DataJumpRotationsAvg = class extends DataNumber {
4314
+ static {
4315
+ this.type = "Jump Rotations Avg";
4316
+ }
4317
+ static {
4318
+ this.unit = "";
4319
+ }
4320
+ constructor(value) {
4321
+ super(value);
4322
+ }
4323
+ };
4324
+ var DataJumpScoreMin = class extends DataNumber {
4325
+ static {
4326
+ this.type = "Jump Score Min";
4327
+ }
4328
+ static {
4329
+ this.unit = "";
4330
+ }
4331
+ constructor(value) {
4332
+ super(value);
4333
+ }
4334
+ };
4335
+ var DataJumpScoreMax = class extends DataNumber {
4336
+ static {
4337
+ this.type = "Jump Score Max";
4338
+ }
4339
+ static {
4340
+ this.unit = "";
4341
+ }
4342
+ constructor(value) {
4343
+ super(value);
4344
+ }
4345
+ };
4346
+ var DataJumpScoreAvg = class extends DataNumber {
4347
+ static {
4348
+ this.type = "Jump Score Avg";
4349
+ }
4350
+ static {
4351
+ this.unit = "";
4352
+ }
4353
+ constructor(value) {
4354
+ super(value);
4355
+ }
4356
+ };
4357
+ var DataJumpHeightMin = class extends DataNumber {
4358
+ static {
4359
+ this.type = "Jump Height Min";
4360
+ }
4361
+ static {
4362
+ this.unit = "m";
4363
+ }
4364
+ constructor(value) {
4365
+ super(value);
4366
+ }
4367
+ };
4368
+ var DataJumpHeightMax = class extends DataNumber {
4369
+ static {
4370
+ this.type = "Jump Height Max";
4371
+ }
4372
+ static {
4373
+ this.unit = "m";
4374
+ }
4375
+ constructor(value) {
4376
+ super(value);
4377
+ }
4378
+ };
4379
+ var DataJumpHeightAvg = class extends DataNumber {
4380
+ static {
4381
+ this.type = "Jump Height Avg";
4382
+ }
4383
+ static {
4384
+ this.unit = "m";
4385
+ }
4386
+ constructor(value) {
4387
+ super(value);
4388
+ }
4389
+ };
4390
+
4145
4391
  // src/data/data.store.ts
4146
4392
  var DataTotalTrainingEffectLegacy = class extends DataAerobicTrainingEffect {
4147
4393
  static {
@@ -4427,6 +4673,8 @@ var DataStore = {
4427
4673
  DataGrit,
4428
4674
  DataJumpCount,
4429
4675
  DataJumpEvent,
4676
+ DataScore,
4677
+ DataRotations,
4430
4678
  DataLeftPedalSmoothness,
4431
4679
  DataLeftTorqueEffectiveness,
4432
4680
  DataMaxRespirationRate,
@@ -4451,7 +4699,25 @@ var DataStore = {
4451
4699
  DataFitnessAge,
4452
4700
  DataMaxHRSetting,
4453
4701
  DataDepth,
4454
- DataDepthMax
4702
+ DataDepthMax,
4703
+ DataJumpHangTimeMin,
4704
+ DataJumpHangTimeMax,
4705
+ DataJumpHangTimeAvg,
4706
+ DataJumpDistanceMin,
4707
+ DataJumpDistanceMax,
4708
+ DataJumpDistanceAvg,
4709
+ DataJumpSpeedMin,
4710
+ DataJumpSpeedMax,
4711
+ DataJumpSpeedAvg,
4712
+ DataJumpRotationsMin,
4713
+ DataJumpRotationsMax,
4714
+ DataJumpRotationsAvg,
4715
+ DataJumpScoreMin,
4716
+ DataJumpScoreMax,
4717
+ DataJumpScoreAvg,
4718
+ DataJumpHeightMin,
4719
+ DataJumpHeightMax,
4720
+ DataJumpHeightAvg
4455
4721
  };
4456
4722
  var DynamicDataLoader = class _DynamicDataLoader {
4457
4723
  static {
@@ -10078,6 +10344,16 @@ var EventImporterFIT = class {
10078
10344
  });
10079
10345
  });
10080
10346
  }
10347
+ if (fitDataObject.jumps && fitDataObject.jumps.length > 0) {
10348
+ fitDataObject.sessions?.forEach((session) => {
10349
+ const sessionStartTime = new Date(session.start_time).getTime();
10350
+ const sessionEndTime = sessionStartTime + (session.total_elapsed_time || 0) * 1e3;
10351
+ session.jumps = fitDataObject.jumps.filter((jump) => {
10352
+ const jumpTime = new Date(jump.timestamp).getTime();
10353
+ return jumpTime >= sessionStartTime && jumpTime < sessionEndTime;
10354
+ });
10355
+ });
10356
+ }
10081
10357
  const activities = fitDataObject.sessions.map((sessionObject) => {
10082
10358
  const activity = this.getActivityFromSessionObject(sessionObject, fitDataObject, options);
10083
10359
  sessionObject.laps.forEach((sessionLapObject, index) => {
@@ -10195,7 +10471,12 @@ var EventImporterFIT = class {
10195
10471
  new DataJumpEvent(activity.getDateIndex(jump.timestamp), {
10196
10472
  distance: jump.distance,
10197
10473
  height: jump.height,
10198
- score: jump.score
10474
+ score: jump.score,
10475
+ hang_time: jump.hang_time,
10476
+ position_lat: jump.position_lat,
10477
+ position_long: jump.position_long,
10478
+ speed: jump.speed,
10479
+ rotations: jump.rotations
10199
10480
  })
10200
10481
  );
10201
10482
  });
@@ -10414,12 +10695,6 @@ var EventImporterFIT = class {
10414
10695
  options
10415
10696
  );
10416
10697
  this.getStatsFromObject(sessionObject, activity, false).forEach((stat) => activity.addStat(stat));
10417
- if (fitDataObject.jumps && fitDataObject.jumps.length) {
10418
- const jumpWithMets = fitDataObject.jumps.find((j) => j.enhanced_mets);
10419
- if (jumpWithMets) {
10420
- activity.addStat(new DataVO2Max(jumpWithMets.enhanced_mets * 3.5));
10421
- }
10422
- }
10423
10698
  if (fitDataObject.user_profile) {
10424
10699
  const userProfile = fitDataObject.user_profile;
10425
10700
  if (isNumberOrString(userProfile.weight)) {
@@ -10801,6 +11076,69 @@ var EventImporterFIT = class {
10801
11076
  if (isNumberOrString(object.avg_vam)) {
10802
11077
  stats.push(new DataAvgVAM(object.avg_vam));
10803
11078
  }
11079
+ if (object.jumps && object.jumps.length > 0) {
11080
+ const jumps = object.jumps;
11081
+ let count = 0;
11082
+ let hangTimeSum = 0, hangTimeMin = Number.MAX_VALUE, hangTimeMax = -Number.MAX_VALUE;
11083
+ let distanceSum = 0, distanceMin = Number.MAX_VALUE, distanceMax = -Number.MAX_VALUE;
11084
+ let speedSum = 0, speedMin = Number.MAX_VALUE, speedMax = -Number.MAX_VALUE;
11085
+ let rotationsSum = 0, rotationsMin = Number.MAX_VALUE, rotationsMax = -Number.MAX_VALUE;
11086
+ let scoreSum = 0, scoreMin = Number.MAX_VALUE, scoreMax = -Number.MAX_VALUE;
11087
+ let heightSum = 0, heightMin = Number.MAX_VALUE, heightMax = -Number.MAX_VALUE;
11088
+ jumps.forEach((j) => {
11089
+ count++;
11090
+ if (Number.isFinite(j.hang_time)) {
11091
+ hangTimeSum += j.hang_time;
11092
+ hangTimeMin = Math.min(hangTimeMin, j.hang_time);
11093
+ hangTimeMax = Math.max(hangTimeMax, j.hang_time);
11094
+ }
11095
+ if (Number.isFinite(j.distance)) {
11096
+ distanceSum += j.distance;
11097
+ distanceMin = Math.min(distanceMin, j.distance);
11098
+ distanceMax = Math.max(distanceMax, j.distance);
11099
+ }
11100
+ if (Number.isFinite(j.speed)) {
11101
+ speedSum += j.speed;
11102
+ speedMin = Math.min(speedMin, j.speed);
11103
+ speedMax = Math.max(speedMax, j.speed);
11104
+ }
11105
+ if (Number.isFinite(j.rotations)) {
11106
+ rotationsSum += j.rotations;
11107
+ rotationsMin = Math.min(rotationsMin, j.rotations);
11108
+ rotationsMax = Math.max(rotationsMax, j.rotations);
11109
+ }
11110
+ if (Number.isFinite(j.score)) {
11111
+ scoreSum += j.score;
11112
+ scoreMin = Math.min(scoreMin, j.score);
11113
+ scoreMax = Math.max(scoreMax, j.score);
11114
+ }
11115
+ if (Number.isFinite(j.height)) {
11116
+ heightSum += j.height;
11117
+ heightMin = Math.min(heightMin, j.height);
11118
+ heightMax = Math.max(heightMax, j.height);
11119
+ }
11120
+ });
11121
+ if (count > 0) {
11122
+ if (hangTimeMin !== Number.MAX_VALUE) stats.push(new DataJumpHangTimeMin(hangTimeMin));
11123
+ if (hangTimeMax !== -Number.MAX_VALUE) stats.push(new DataJumpHangTimeMax(hangTimeMax));
11124
+ if (hangTimeSum > 0) stats.push(new DataJumpHangTimeAvg(hangTimeSum / count));
11125
+ if (distanceMin !== Number.MAX_VALUE) stats.push(new DataJumpDistanceMin(distanceMin));
11126
+ if (distanceMax !== -Number.MAX_VALUE) stats.push(new DataJumpDistanceMax(distanceMax));
11127
+ if (distanceSum > 0) stats.push(new DataJumpDistanceAvg(distanceSum / count));
11128
+ if (speedMin !== Number.MAX_VALUE) stats.push(new DataJumpSpeedMin(speedMin));
11129
+ if (speedMax !== -Number.MAX_VALUE) stats.push(new DataJumpSpeedMax(speedMax));
11130
+ if (speedSum > 0) stats.push(new DataJumpSpeedAvg(speedSum / count));
11131
+ if (rotationsMin !== Number.MAX_VALUE) stats.push(new DataJumpRotationsMin(rotationsMin));
11132
+ if (rotationsMax !== -Number.MAX_VALUE) stats.push(new DataJumpRotationsMax(rotationsMax));
11133
+ if (rotationsSum > 0) stats.push(new DataJumpRotationsAvg(rotationsSum / count));
11134
+ if (scoreMin !== Number.MAX_VALUE) stats.push(new DataJumpScoreMin(scoreMin));
11135
+ if (scoreMax !== -Number.MAX_VALUE) stats.push(new DataJumpScoreMax(scoreMax));
11136
+ if (scoreSum > 0) stats.push(new DataJumpScoreAvg(scoreSum / count));
11137
+ if (heightMin !== Number.MAX_VALUE) stats.push(new DataJumpHeightMin(heightMin));
11138
+ if (heightMax !== -Number.MAX_VALUE) stats.push(new DataJumpHeightMax(heightMax));
11139
+ if (heightSum > 0) stats.push(new DataJumpHeightAvg(heightSum / count));
11140
+ }
11141
+ }
10804
11142
  return stats;
10805
11143
  }
10806
11144
  static getCreatorFromFitDataObject(fitDataObject) {
@@ -12620,6 +12958,7 @@ export {
12620
12958
  DataEPOC,
12621
12959
  DataEVPE,
12622
12960
  DataEnergy,
12961
+ DataEvent,
12623
12962
  DataFeeling,
12624
12963
  DataGPSAltitude,
12625
12964
  DataGradeAdjustedPace,
@@ -12645,6 +12984,7 @@ export {
12645
12984
  DataHeartRateMax,
12646
12985
  DataHeartRateMin,
12647
12986
  DataIBI,
12987
+ DataJumpEvent,
12648
12988
  DataLatitudeDegrees,
12649
12989
  DataLeftBalance,
12650
12990
  DataLeftPedalSmoothness,
@@ -12668,6 +13008,8 @@ export {
12668
13008
  DataRightBalance,
12669
13009
  DataRightPedalSmoothness,
12670
13010
  DataRightTorqueEffectiveness,
13011
+ DataRotations,
13012
+ DataScore,
12671
13013
  DataSeaLevelPressure,
12672
13014
  DataSpeed,
12673
13015
  DataSpeedAvg,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sports-alliance/sports-lib",
3
- "version": "7.2.2",
3
+ "version": "7.2.4",
4
4
  "description": "A Library to for importing / exporting and processing GPX, TCX, FIT and JSON files from services such as Strava, Movescount, Garmin, Polar etc",
5
5
  "keywords": [
6
6
  "gpx",
@@ -54,7 +54,7 @@
54
54
  "license": "SEE LICENSE IN LICENSE.md",
55
55
  "dependencies": {
56
56
  "fast-xml-parser": "^5.3.3",
57
- "fit-file-parser": "2.2.4",
57
+ "fit-file-parser": "2.2.5",
58
58
  "geolib": "^3.3.4",
59
59
  "gpx-builder": "^3.7.8",
60
60
  "kalmanjs": "^1.1.0",