fit-file-parser 5.2.1 → 6.1.1
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/CHANGELOG.md +35 -191
- package/PROFILE.md +43 -0
- package/README.md +126 -82
- package/dist/binary.d.ts +2 -0
- package/dist/binary.js +23 -6
- package/dist/cjs/binary.d.ts +2 -0
- package/dist/cjs/binary.js +23 -6
- package/dist/cjs/fit-parser.d.ts +5 -0
- package/dist/cjs/fit-parser.js +42 -4
- package/dist/cjs/fit.d.ts +0 -6
- package/dist/cjs/fit.js +4 -114
- package/dist/cjs/fit_types.d.ts +2 -1
- package/dist/cjs/profile-lookup.d.ts +19 -0
- package/dist/cjs/profile-lookup.js +150 -0
- package/dist/cjs/profile.d.ts +9 -0
- package/dist/{garmin_profile.generated.js → cjs/profile.js} +287 -8
- package/dist/cjs/raw-message-reader.d.ts +60 -0
- package/dist/cjs/raw-message-reader.js +377 -0
- package/dist/cjs/type_generator.js +1 -0
- package/dist/fit-parser.d.ts +5 -0
- package/dist/fit-parser.js +27 -3
- package/dist/fit.d.ts +0 -6
- package/dist/fit.js +3 -113
- package/dist/fit_types.d.ts +2 -1
- package/dist/profile-lookup.d.ts +19 -0
- package/dist/profile-lookup.js +140 -0
- package/dist/profile.d.ts +9 -0
- package/dist/{cjs/garmin_profile.generated.js → profile.js} +284 -11
- package/dist/raw-message-reader.d.ts +60 -0
- package/dist/raw-message-reader.js +368 -0
- package/dist/type_generator.js +1 -0
- package/package.json +38 -9
- package/dist/cjs/garmin_profile.generated.d.ts +0 -9
- package/dist/garmin_profile.generated.d.ts +0 -9
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PROFILE_TYPES = exports.PROFILE_MESSAGES = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Static, community-maintained FIT interoperability profile.
|
|
6
|
+
*
|
|
7
|
+
* This table is ordinary project source maintained under the repository's MIT
|
|
8
|
+
* license. See PROFILE.md for the maintenance and verification policy.
|
|
9
|
+
*/
|
|
10
|
+
exports.PROFILE_MESSAGES = {
|
|
8
11
|
0: {
|
|
9
12
|
0: {
|
|
10
13
|
field: 'type',
|
|
@@ -2586,6 +2589,13 @@ export const GARMIN_MESSAGES = {
|
|
|
2586
2589
|
offset: 0,
|
|
2587
2590
|
units: 'Breaths/min',
|
|
2588
2591
|
},
|
|
2592
|
+
178: {
|
|
2593
|
+
field: 'est_sweat_loss',
|
|
2594
|
+
type: 'uint16',
|
|
2595
|
+
scale: 1,
|
|
2596
|
+
offset: 0,
|
|
2597
|
+
units: 'ml',
|
|
2598
|
+
},
|
|
2589
2599
|
180: {
|
|
2590
2600
|
field: 'enhanced_min_respiration_rate',
|
|
2591
2601
|
type: 'uint16',
|
|
@@ -2640,6 +2650,13 @@ export const GARMIN_MESSAGES = {
|
|
|
2640
2650
|
offset: 0,
|
|
2641
2651
|
units: 'Flow',
|
|
2642
2652
|
},
|
|
2653
|
+
188: {
|
|
2654
|
+
field: 'primary_benefit',
|
|
2655
|
+
type: 'uint8',
|
|
2656
|
+
scale: 1,
|
|
2657
|
+
offset: 0,
|
|
2658
|
+
units: '',
|
|
2659
|
+
},
|
|
2643
2660
|
192: {
|
|
2644
2661
|
field: 'workout_feel',
|
|
2645
2662
|
type: 'uint8',
|
|
@@ -2721,6 +2738,27 @@ export const GARMIN_MESSAGES = {
|
|
|
2721
2738
|
offset: 0,
|
|
2722
2739
|
units: 'm',
|
|
2723
2740
|
},
|
|
2741
|
+
205: {
|
|
2742
|
+
field: 'beginning_potential_stamina',
|
|
2743
|
+
type: 'uint8',
|
|
2744
|
+
scale: 1,
|
|
2745
|
+
offset: 0,
|
|
2746
|
+
units: 'percent',
|
|
2747
|
+
},
|
|
2748
|
+
206: {
|
|
2749
|
+
field: 'ending_potential_stamina',
|
|
2750
|
+
type: 'uint8',
|
|
2751
|
+
scale: 1,
|
|
2752
|
+
offset: 0,
|
|
2753
|
+
units: 'percent',
|
|
2754
|
+
},
|
|
2755
|
+
207: {
|
|
2756
|
+
field: 'min_stamina',
|
|
2757
|
+
type: 'uint8',
|
|
2758
|
+
scale: 1,
|
|
2759
|
+
offset: 0,
|
|
2760
|
+
units: 'percent',
|
|
2761
|
+
},
|
|
2724
2762
|
208: {
|
|
2725
2763
|
field: 'avg_core_temperature',
|
|
2726
2764
|
type: 'uint16',
|
|
@@ -4419,6 +4457,13 @@ export const GARMIN_MESSAGES = {
|
|
|
4419
4457
|
offset: 0,
|
|
4420
4458
|
units: 'm',
|
|
4421
4459
|
},
|
|
4460
|
+
90: {
|
|
4461
|
+
field: 'garmin_performance_condition',
|
|
4462
|
+
type: 'sint8',
|
|
4463
|
+
scale: 1,
|
|
4464
|
+
offset: 0,
|
|
4465
|
+
units: '',
|
|
4466
|
+
},
|
|
4422
4467
|
91: {
|
|
4423
4468
|
field: 'absolute_pressure',
|
|
4424
4469
|
type: 'uint32',
|
|
@@ -4626,6 +4671,20 @@ export const GARMIN_MESSAGES = {
|
|
|
4626
4671
|
offset: 0,
|
|
4627
4672
|
units: 'percent',
|
|
4628
4673
|
},
|
|
4674
|
+
137: {
|
|
4675
|
+
field: 'potential_stamina',
|
|
4676
|
+
type: 'uint8',
|
|
4677
|
+
scale: 1,
|
|
4678
|
+
offset: 0,
|
|
4679
|
+
units: 'percent',
|
|
4680
|
+
},
|
|
4681
|
+
138: {
|
|
4682
|
+
field: 'stamina',
|
|
4683
|
+
type: 'uint8',
|
|
4684
|
+
scale: 1,
|
|
4685
|
+
offset: 0,
|
|
4686
|
+
units: 'percent',
|
|
4687
|
+
},
|
|
4629
4688
|
139: {
|
|
4630
4689
|
field: 'core_temperature',
|
|
4631
4690
|
type: 'uint16',
|
|
@@ -4956,6 +5015,13 @@ export const GARMIN_MESSAGES = {
|
|
|
4956
5015
|
offset: 0,
|
|
4957
5016
|
units: '',
|
|
4958
5017
|
},
|
|
5018
|
+
24: {
|
|
5019
|
+
field: 'ant_id',
|
|
5020
|
+
type: 'uint32z',
|
|
5021
|
+
scale: 1,
|
|
5022
|
+
offset: 0,
|
|
5023
|
+
units: '',
|
|
5024
|
+
},
|
|
4959
5025
|
25: {
|
|
4960
5026
|
field: 'source_type',
|
|
4961
5027
|
type: 'source_type',
|
|
@@ -6398,6 +6464,107 @@ export const GARMIN_MESSAGES = {
|
|
|
6398
6464
|
},
|
|
6399
6465
|
name: 'hrv',
|
|
6400
6466
|
},
|
|
6467
|
+
79: {
|
|
6468
|
+
0: {
|
|
6469
|
+
field: 'vo2_max',
|
|
6470
|
+
type: 'uint16',
|
|
6471
|
+
scale: 292.57142857142856,
|
|
6472
|
+
offset: 0,
|
|
6473
|
+
units: 'ml/kg/min',
|
|
6474
|
+
},
|
|
6475
|
+
1: {
|
|
6476
|
+
field: 'age',
|
|
6477
|
+
type: 'uint8',
|
|
6478
|
+
scale: 1,
|
|
6479
|
+
offset: 0,
|
|
6480
|
+
units: 'years',
|
|
6481
|
+
},
|
|
6482
|
+
2: {
|
|
6483
|
+
field: 'height',
|
|
6484
|
+
type: 'uint8',
|
|
6485
|
+
scale: 100,
|
|
6486
|
+
offset: 0,
|
|
6487
|
+
units: 'm',
|
|
6488
|
+
},
|
|
6489
|
+
3: {
|
|
6490
|
+
field: 'weight',
|
|
6491
|
+
type: 'uint16',
|
|
6492
|
+
scale: 10,
|
|
6493
|
+
offset: 0,
|
|
6494
|
+
units: 'kg',
|
|
6495
|
+
},
|
|
6496
|
+
4: {
|
|
6497
|
+
field: 'gender',
|
|
6498
|
+
type: 'gender',
|
|
6499
|
+
scale: 1,
|
|
6500
|
+
offset: 0,
|
|
6501
|
+
units: '',
|
|
6502
|
+
},
|
|
6503
|
+
6: {
|
|
6504
|
+
field: 'max_heart_rate',
|
|
6505
|
+
type: 'uint8',
|
|
6506
|
+
scale: 1,
|
|
6507
|
+
offset: 0,
|
|
6508
|
+
units: 'bpm',
|
|
6509
|
+
},
|
|
6510
|
+
8: {
|
|
6511
|
+
field: 'remaining_recovery_time',
|
|
6512
|
+
type: 'uint16',
|
|
6513
|
+
scale: 1,
|
|
6514
|
+
offset: 0,
|
|
6515
|
+
units: '',
|
|
6516
|
+
},
|
|
6517
|
+
11: {
|
|
6518
|
+
field: 'lthr',
|
|
6519
|
+
type: 'uint16',
|
|
6520
|
+
scale: 1,
|
|
6521
|
+
offset: 0,
|
|
6522
|
+
units: 'bpm',
|
|
6523
|
+
},
|
|
6524
|
+
12: {
|
|
6525
|
+
field: 'ltpower',
|
|
6526
|
+
type: 'uint16',
|
|
6527
|
+
scale: 1,
|
|
6528
|
+
offset: 0,
|
|
6529
|
+
units: 'watts',
|
|
6530
|
+
},
|
|
6531
|
+
13: {
|
|
6532
|
+
field: 'ltspeed',
|
|
6533
|
+
type: 'uint16',
|
|
6534
|
+
scale: 1000,
|
|
6535
|
+
offset: 0,
|
|
6536
|
+
units: 'm/s',
|
|
6537
|
+
},
|
|
6538
|
+
16: {
|
|
6539
|
+
field: 'start_of_activity',
|
|
6540
|
+
type: 'date_time',
|
|
6541
|
+
scale: 1,
|
|
6542
|
+
offset: 0,
|
|
6543
|
+
units: '',
|
|
6544
|
+
},
|
|
6545
|
+
19: {
|
|
6546
|
+
field: 'first_vo2_max',
|
|
6547
|
+
type: 'uint32',
|
|
6548
|
+
scale: 18724.571428571428,
|
|
6549
|
+
offset: 0,
|
|
6550
|
+
units: 'ml/kg/min',
|
|
6551
|
+
},
|
|
6552
|
+
35: {
|
|
6553
|
+
field: 'end_of_previous_activity',
|
|
6554
|
+
type: 'date_time',
|
|
6555
|
+
scale: 1,
|
|
6556
|
+
offset: 0,
|
|
6557
|
+
units: '',
|
|
6558
|
+
},
|
|
6559
|
+
253: {
|
|
6560
|
+
field: 'timestamp',
|
|
6561
|
+
type: 'date_time',
|
|
6562
|
+
scale: 1,
|
|
6563
|
+
offset: 0,
|
|
6564
|
+
units: '',
|
|
6565
|
+
},
|
|
6566
|
+
name: 'user_metrics',
|
|
6567
|
+
},
|
|
6401
6568
|
80: {
|
|
6402
6569
|
0: {
|
|
6403
6570
|
field: 'fractional_timestamp',
|
|
@@ -7253,6 +7420,93 @@ export const GARMIN_MESSAGES = {
|
|
|
7253
7420
|
},
|
|
7254
7421
|
name: 'hr',
|
|
7255
7422
|
},
|
|
7423
|
+
140: {
|
|
7424
|
+
1: {
|
|
7425
|
+
field: 'new_max_heart_rate',
|
|
7426
|
+
type: 'uint8',
|
|
7427
|
+
scale: 1,
|
|
7428
|
+
offset: 0,
|
|
7429
|
+
units: 'bpm',
|
|
7430
|
+
},
|
|
7431
|
+
4: {
|
|
7432
|
+
field: 'aerobic_training_effect',
|
|
7433
|
+
type: 'uint8',
|
|
7434
|
+
scale: 10,
|
|
7435
|
+
offset: 0,
|
|
7436
|
+
units: '',
|
|
7437
|
+
},
|
|
7438
|
+
7: {
|
|
7439
|
+
field: 'vo2_max',
|
|
7440
|
+
type: 'uint32',
|
|
7441
|
+
scale: 18724.571428571428,
|
|
7442
|
+
offset: 0,
|
|
7443
|
+
units: 'ml/kg/min',
|
|
7444
|
+
},
|
|
7445
|
+
9: {
|
|
7446
|
+
field: 'recovery_time',
|
|
7447
|
+
type: 'uint16',
|
|
7448
|
+
scale: 1,
|
|
7449
|
+
offset: 0,
|
|
7450
|
+
units: 'min',
|
|
7451
|
+
},
|
|
7452
|
+
11: {
|
|
7453
|
+
field: 'sport',
|
|
7454
|
+
type: 'sport',
|
|
7455
|
+
scale: 1,
|
|
7456
|
+
offset: 0,
|
|
7457
|
+
units: '',
|
|
7458
|
+
},
|
|
7459
|
+
20: {
|
|
7460
|
+
field: 'anaerobic_training_effect',
|
|
7461
|
+
type: 'uint8',
|
|
7462
|
+
scale: 10,
|
|
7463
|
+
offset: 0,
|
|
7464
|
+
units: '',
|
|
7465
|
+
},
|
|
7466
|
+
29: {
|
|
7467
|
+
field: 'first_vo2_max',
|
|
7468
|
+
type: 'uint32',
|
|
7469
|
+
scale: 18724.571428571428,
|
|
7470
|
+
offset: 0,
|
|
7471
|
+
units: 'ml/kg/min',
|
|
7472
|
+
},
|
|
7473
|
+
41: {
|
|
7474
|
+
field: 'primary_benefit',
|
|
7475
|
+
type: 'uint8',
|
|
7476
|
+
scale: 1,
|
|
7477
|
+
offset: 0,
|
|
7478
|
+
units: '',
|
|
7479
|
+
},
|
|
7480
|
+
60: {
|
|
7481
|
+
field: 'total_ascent',
|
|
7482
|
+
type: 'uint16',
|
|
7483
|
+
scale: 1,
|
|
7484
|
+
offset: 0,
|
|
7485
|
+
units: 'm',
|
|
7486
|
+
},
|
|
7487
|
+
61: {
|
|
7488
|
+
field: 'total_descent',
|
|
7489
|
+
type: 'uint16',
|
|
7490
|
+
scale: 1,
|
|
7491
|
+
offset: 0,
|
|
7492
|
+
units: 'm',
|
|
7493
|
+
},
|
|
7494
|
+
62: {
|
|
7495
|
+
field: 'avg_power',
|
|
7496
|
+
type: 'uint16',
|
|
7497
|
+
scale: 1,
|
|
7498
|
+
offset: 0,
|
|
7499
|
+
units: 'watts',
|
|
7500
|
+
},
|
|
7501
|
+
63: {
|
|
7502
|
+
field: 'avg_heart_rate',
|
|
7503
|
+
type: 'uint8',
|
|
7504
|
+
scale: 1,
|
|
7505
|
+
offset: 0,
|
|
7506
|
+
units: 'bpm',
|
|
7507
|
+
},
|
|
7508
|
+
name: 'activity_metrics',
|
|
7509
|
+
},
|
|
7256
7510
|
142: {
|
|
7257
7511
|
0: {
|
|
7258
7512
|
field: 'event',
|
|
@@ -11787,6 +12041,27 @@ export const GARMIN_MESSAGES = {
|
|
|
11787
12041
|
offset: 0,
|
|
11788
12042
|
units: 's',
|
|
11789
12043
|
},
|
|
12044
|
+
107: {
|
|
12045
|
+
field: 'beginning_potential_stamina',
|
|
12046
|
+
type: 'uint8',
|
|
12047
|
+
scale: 1,
|
|
12048
|
+
offset: 0,
|
|
12049
|
+
units: 'percent',
|
|
12050
|
+
},
|
|
12051
|
+
108: {
|
|
12052
|
+
field: 'ending_potential_stamina',
|
|
12053
|
+
type: 'uint8',
|
|
12054
|
+
scale: 1,
|
|
12055
|
+
offset: 0,
|
|
12056
|
+
units: 'percent',
|
|
12057
|
+
},
|
|
12058
|
+
109: {
|
|
12059
|
+
field: 'min_stamina',
|
|
12060
|
+
type: 'uint8',
|
|
12061
|
+
scale: 1,
|
|
12062
|
+
offset: 0,
|
|
12063
|
+
units: 'percent',
|
|
12064
|
+
},
|
|
11790
12065
|
110: {
|
|
11791
12066
|
field: 'total_moving_time',
|
|
11792
12067
|
type: 'uint32',
|
|
@@ -13032,7 +13307,7 @@ export const GARMIN_MESSAGES = {
|
|
|
13032
13307
|
name: 'sleep_disruption_overnight_severity',
|
|
13033
13308
|
},
|
|
13034
13309
|
};
|
|
13035
|
-
|
|
13310
|
+
exports.PROFILE_TYPES = {
|
|
13036
13311
|
activity: {
|
|
13037
13312
|
0: 'manual',
|
|
13038
13313
|
1: 'auto_multi_sport',
|
|
@@ -15762,6 +16037,7 @@ export const GARMIN_TYPES = {
|
|
|
15762
16037
|
55: 'monitoring',
|
|
15763
16038
|
72: 'training_file',
|
|
15764
16039
|
78: 'hrv',
|
|
16040
|
+
79: 'user_metrics',
|
|
15765
16041
|
80: 'ant_rx',
|
|
15766
16042
|
81: 'ant_tx',
|
|
15767
16043
|
82: 'ant_channel_id',
|
|
@@ -15774,6 +16050,7 @@ export const GARMIN_TYPES = {
|
|
|
15774
16050
|
129: 'weather_alert',
|
|
15775
16051
|
131: 'cadence_zone',
|
|
15776
16052
|
132: 'hr',
|
|
16053
|
+
140: 'activity_metrics',
|
|
15777
16054
|
142: 'segment_lap',
|
|
15778
16055
|
145: 'memo_glob',
|
|
15779
16056
|
148: 'segment_id',
|
|
@@ -17202,6 +17479,8 @@ export const GARMIN_TYPES = {
|
|
|
17202
17479
|
125: 'rally',
|
|
17203
17480
|
126: 'pool_triathlon',
|
|
17204
17481
|
127: 'e_bike_enduro',
|
|
17482
|
+
153: 'mountain_enduro',
|
|
17483
|
+
154: 'mountain_downhill',
|
|
17205
17484
|
254: 'all',
|
|
17206
17485
|
},
|
|
17207
17486
|
supported_exd_screen_layouts: {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export type FitMessageReaderErrorCode = 'invalid_input' | 'input_limit' | 'invalid_header' | 'invalid_crc' | 'invalid_structure';
|
|
2
|
+
export type FitMessageReaderIssueCode = 'invalid_timestamp';
|
|
3
|
+
export interface FitRawField {
|
|
4
|
+
fieldNumber: number;
|
|
5
|
+
size: number;
|
|
6
|
+
baseType: number;
|
|
7
|
+
bytes: Uint8Array;
|
|
8
|
+
}
|
|
9
|
+
export interface FitRawDeveloperField {
|
|
10
|
+
fieldNumber: number;
|
|
11
|
+
size: number;
|
|
12
|
+
developerDataIndex: number;
|
|
13
|
+
bytes: Uint8Array;
|
|
14
|
+
}
|
|
15
|
+
export interface FitRawMessage {
|
|
16
|
+
globalMessageNumber: number;
|
|
17
|
+
messageIndex: number;
|
|
18
|
+
littleEndian: boolean;
|
|
19
|
+
/** Native FIT timestamp in seconds since the FIT epoch, when available. */
|
|
20
|
+
timestamp?: number;
|
|
21
|
+
/** Reconstructed native timestamp when the record used a compressed header. */
|
|
22
|
+
compressedTimestamp?: number;
|
|
23
|
+
fields: FitRawField[];
|
|
24
|
+
developerFields: FitRawDeveloperField[];
|
|
25
|
+
}
|
|
26
|
+
export interface FitMessageReaderIssue {
|
|
27
|
+
code: FitMessageReaderIssueCode;
|
|
28
|
+
globalMessageNumber: number;
|
|
29
|
+
messageIndex: number;
|
|
30
|
+
}
|
|
31
|
+
export interface FitMessageReaderResult {
|
|
32
|
+
protocolVersion: number;
|
|
33
|
+
profileVersion: number;
|
|
34
|
+
messages: FitRawMessage[];
|
|
35
|
+
issues: FitMessageReaderIssue[];
|
|
36
|
+
}
|
|
37
|
+
export interface FitMessageReaderOptions {
|
|
38
|
+
/** Retain only these global message numbers. Omit to retain every message. */
|
|
39
|
+
messageNumbers?: readonly number[];
|
|
40
|
+
/** Reject larger inputs before allocating retained message data. */
|
|
41
|
+
maxInputBytes?: number;
|
|
42
|
+
}
|
|
43
|
+
/** Error thrown when the strict raw-message reader rejects a FIT input. */
|
|
44
|
+
export declare class FitMessageReaderError extends Error {
|
|
45
|
+
readonly code: FitMessageReaderErrorCode;
|
|
46
|
+
constructor(code: FitMessageReaderErrorCode);
|
|
47
|
+
}
|
|
48
|
+
/** Returns the five-bit FIT base-type identifier, or null for reserved/unknown values. */
|
|
49
|
+
export declare function getFitBaseTypeId(baseType: number): number | null;
|
|
50
|
+
/** Reads an unsigned one-, two-, or four-byte raw FIT field. */
|
|
51
|
+
export declare function readFitUnsignedField(field: FitRawField | undefined, expectedBaseType: number, size: 1 | 2 | 4, littleEndian: boolean): number | undefined;
|
|
52
|
+
/** Reads UTF-8 bytes, removes trailing NUL padding, and preserves interior NUL separators. */
|
|
53
|
+
export declare function readFitStringField(field: FitRawField | undefined): string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Strictly validates a FIT file and retains raw fields for selected messages.
|
|
56
|
+
* This entry point does not load the semantic FIT profile or format field values.
|
|
57
|
+
*/
|
|
58
|
+
export declare function readFitMessages(input: ArrayBuffer | Uint8Array, options?: FitMessageReaderOptions): FitMessageReaderResult;
|
|
59
|
+
/** Converts a native FIT timestamp to a JavaScript epoch millisecond value. */
|
|
60
|
+
export declare function fitTimestampToUnixMilliseconds(timestamp: number): number;
|