Skip to content

Commit e0b16eb

Browse files
authored
Garmin FIT SDK 21.194.0
1 parent 128da39 commit e0b16eb

31 files changed

+828
-410
lines changed

README.md

Lines changed: 298 additions & 288 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@garmin/fitsdk",
3-
"version": "21.188.0",
3+
"version": "21.194.0",
44
"description": "FIT JavaScript SDK",
55
"main": "src/index.js",
66
"type": "module",

src/accumulator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/////////////////////////////////////////////////////////////////////////////////////////////
2-
// Copyright 2025 Garmin International, Inc.
2+
// Copyright 2026 Garmin International, Inc.
33
// Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
44
// may not use this file except in compliance with the Flexible and Interoperable Data
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.188.0Release
9-
// Tag = production/release/21.188.0-0-g55050f8
8+
// Profile Version = 21.194.0Release
9+
// Tag = production/release/21.194.0-0-g65135fc
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

src/bit-stream.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/////////////////////////////////////////////////////////////////////////////////////////////
2-
// Copyright 2025 Garmin International, Inc.
2+
// Copyright 2026 Garmin International, Inc.
33
// Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
44
// may not use this file except in compliance with the Flexible and Interoperable Data
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.188.0Release
9-
// Tag = production/release/21.188.0-0-g55050f8
8+
// Profile Version = 21.194.0Release
9+
// Tag = production/release/21.194.0-0-g65135fc
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

src/crc-calculator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/////////////////////////////////////////////////////////////////////////////////////////////
2-
// Copyright 2025 Garmin International, Inc.
2+
// Copyright 2026 Garmin International, Inc.
33
// Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
44
// may not use this file except in compliance with the Flexible and Interoperable Data
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.188.0Release
9-
// Tag = production/release/21.188.0-0-g55050f8
8+
// Profile Version = 21.194.0Release
9+
// Tag = production/release/21.194.0-0-g65135fc
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

src/decoder.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/////////////////////////////////////////////////////////////////////////////////////////////
2-
// Copyright 2025 Garmin International, Inc.
2+
// Copyright 2026 Garmin International, Inc.
33
// Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
44
// may not use this file except in compliance with the Flexible and Interoperable Data
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.188.0Release
9-
// Tag = production/release/21.188.0-0-g55050f8
8+
// Profile Version = 21.194.0Release
9+
// Tag = production/release/21.194.0-0-g65135fc
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

src/encoder.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/////////////////////////////////////////////////////////////////////////////////////////////
2-
// Copyright 2025 Garmin International, Inc.
2+
// Copyright 2026 Garmin International, Inc.
33
// Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
44
// may not use this file except in compliance with the Flexible and Interoperable Data
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.188.0Release
9-
// Tag = production/release/21.188.0-0-g55050f8
8+
// Profile Version = 21.194.0Release
9+
// Tag = production/release/21.194.0-0-g65135fc
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

@@ -212,12 +212,25 @@ class Encoder {
212212
throw new Error();
213213
}
214214

215+
// Convert valid numeric strings to the correct type
216+
if (FIT.isString(value)) {
217+
value = FIT.BigIntFieldTypes.includes(fieldDefinition.type)
218+
? BigInt(value)
219+
: Number(value);
220+
}
221+
215222
const hasScaleOrOffset = (fieldDefinition.scale != FIT.FIELD_DEFAULT_SCALE || fieldDefinition.offset != FIT.FIELD_DEFAULT_OFFSET);
216223

224+
if (!hasScaleOrOffset && !this.#isValidType(value, fieldDefinition.type)) {
225+
throw new Error();
226+
}
227+
217228
if (hasScaleOrOffset) {
218-
const scaledValue = (value + fieldDefinition.offset) * fieldDefinition.scale;
229+
const scaledValue = this.#unapplyScaleAndOffset(value, fieldDefinition.scale, fieldDefinition.offset);
230+
231+
const roundedValue = FIT.FloatingPointFieldTypes.includes(fieldDefinition.type) || FIT.isBigInt(scaledValue) ? scaledValue : Math.round(scaledValue);
219232

220-
return FIT.FloatingPointFieldTypes.includes(fieldDefinition.type) ? scaledValue : Math.round(scaledValue);
233+
return FIT.BigIntFieldTypes.includes(fieldDefinition.type) ? BigInt(roundedValue) : Number(roundedValue);
221234
}
222235

223236
return value;
@@ -265,6 +278,18 @@ class Encoder {
265278
}
266279
}
267280

281+
#isValidType = (value, type) => {
282+
const jsType = FIT.FieldTypeToJsType[type];
283+
284+
return typeof value === jsType
285+
}
286+
287+
#unapplyScaleAndOffset(value, scale, offset) {
288+
return FIT.isBigInt(value)
289+
? (value + BigInt(offset)) * BigInt(scale)
290+
: (value + offset) * scale;
291+
}
292+
268293
/**
269294
* Creates a MesgDefinition from the mesgNum and mesg.
270295
* @param {Number} mesgNum - The mesg number for this message

src/fit.js

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/////////////////////////////////////////////////////////////////////////////////////////////
2-
// Copyright 2025 Garmin International, Inc.
2+
// Copyright 2026 Garmin International, Inc.
33
// Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
44
// may not use this file except in compliance with the Flexible and Interoperable Data
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.188.0Release
9-
// Tag = production/release/21.188.0-0-g55050f8
8+
// Profile Version = 21.194.0Release
9+
// Tag = production/release/21.194.0-0-g65135fc
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

@@ -73,6 +73,32 @@ const NumericFieldTypes = [
7373
"uint64z"
7474
];
7575

76+
const FieldTypeToJsType = {
77+
"enum": "number",
78+
"sint8": "number",
79+
"uint8": "number",
80+
"sint16": "number",
81+
"uint16": "number",
82+
"sint32": "number",
83+
"uint32": "number",
84+
"string": "string",
85+
"float32": "number",
86+
"float64": "number",
87+
"uint8z": "number",
88+
"uint16z": "number",
89+
"uint32z": "number",
90+
"byte": "number",
91+
"sint64": "bigint",
92+
"uint64": "bigint",
93+
"uint64z": "bigint"
94+
}
95+
96+
const BigIntFieldTypes = [
97+
"sint64",
98+
"uint64",
99+
"uint64z"
100+
];
101+
76102
const FloatingPointFieldTypes = [
77103
"float32",
78104
"float64",
@@ -138,8 +164,21 @@ const isString = (obj) => {
138164
return typeof obj === "string";
139165
};
140166

167+
const isBigInt = (obj) => {
168+
return typeof obj === "bigint";
169+
};
170+
141171
const isNumeric = (obj) => {
142-
return !isNaN(parseFloat(obj)) && isFinite(obj);
172+
if (typeof obj === "number") {
173+
return !isNaN(obj) && isFinite(obj);
174+
}
175+
176+
if (typeof obj === "bigint") {
177+
return true;
178+
}
179+
180+
const num = parseFloat(obj);
181+
return !isNaN(num) && isFinite(num);
143182
};
144183

145184
const isNotNumberStringDateOrBoolean = (obj) => {
@@ -151,7 +190,7 @@ const isNumberStringDateOrBoolean = (obj) => {
151190
return false;
152191
}
153192

154-
if (!isDate(obj) && !isString(obj) && !isNumeric(obj) && !isBoolean(obj)) {
193+
if (!isNumeric(obj) && !isDate(obj) && !isString(obj) && !isBoolean(obj)) {
155194
return false;
156195
}
157196

@@ -163,14 +202,17 @@ export default {
163202
BaseTypeMask,
164203
BaseTypeDefinitions,
165204
NumericFieldTypes,
205+
BigIntFieldTypes,
166206
FloatingPointFieldTypes,
167207
FieldTypeToBaseType,
168208
BaseTypeToFieldType,
209+
FieldTypeToJsType,
169210
isNullOrUndefined,
170211
isObject,
171212
isBoolean,
172213
isDate,
173214
isString,
215+
isBigInt,
174216
isNumeric,
175217
isNumberStringDateOrBoolean,
176218
isNotNumberStringDateOrBoolean,

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/////////////////////////////////////////////////////////////////////////////////////////////
2-
// Copyright 2025 Garmin International, Inc.
2+
// Copyright 2026 Garmin International, Inc.
33
// Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
44
// may not use this file except in compliance with the Flexible and Interoperable Data
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.188.0Release
9-
// Tag = production/release/21.188.0-0-g55050f8
8+
// Profile Version = 21.194.0Release
9+
// Tag = production/release/21.194.0-0-g65135fc
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

src/mesg-definition.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/////////////////////////////////////////////////////////////////////////////////////////////
2-
// Copyright 2025 Garmin International, Inc.
2+
// Copyright 2026 Garmin International, Inc.
33
// Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
44
// may not use this file except in compliance with the Flexible and Interoperable Data
55
// Transfer (FIT) Protocol License.
66
/////////////////////////////////////////////////////////////////////////////////////////////
77
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
8-
// Profile Version = 21.188.0Release
9-
// Tag = production/release/21.188.0-0-g55050f8
8+
// Profile Version = 21.194.0Release
9+
// Tag = production/release/21.194.0-0-g65135fc
1010
/////////////////////////////////////////////////////////////////////////////////////////////
1111

1212

@@ -86,6 +86,10 @@ class MesgDefinition {
8686
fieldDefinitionNumber: fieldDescriptionMesg.fieldDefinitionNumber,
8787
size: this.#fieldSize(mesg.developerFields[key], baseTypeDef),
8888
developerDataIndex: developerDataIdMesg.developerDataIndex,
89+
type: FIT.BaseTypeToFieldType[baseTypeDef.type],
90+
scale: 1,
91+
offset: 0,
92+
components: [],
8993
});
9094
});
9195

0 commit comments

Comments
 (0)