@garmin/fitsdk 21.202.0 → 21.205.0
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/package.json +24 -22
- package/src/accumulator.js +2 -2
- package/src/bit-stream.js +56 -9
- package/src/crc-calculator.js +2 -2
- package/src/decoder.js +43 -81
- package/src/encoder.js +2 -39
- package/src/fit.js +5 -2
- package/src/index.d.ts +22 -0
- package/src/index.js +2 -2
- package/src/mesg-definition.js +2 -2
- package/src/output-stream.js +2 -2
- package/src/profile.js +8 -4
- package/src/stream.js +107 -90
- package/src/types/crc-calculator.d.ts +34 -0
- package/src/types/decoder.d.ts +140 -0
- package/src/types/encoder.d.ts +69 -0
- package/src/types/mesg.d.ts +35 -0
- package/src/types/mesgs.d.ts +2638 -0
- package/src/types/profile.d.ts +96 -0
- package/src/types/stream.d.ts +118 -0
- package/src/types/types.d.ts +4871 -0
- package/src/types/utils.d.ts +55 -0
- package/src/utils-hr-mesg.js +2 -2
- package/src/utils-internal.js +14 -6
- package/src/utils-memo-glob.js +2 -2
- package/src/utils.js +2 -16
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright 2026 Garmin International, Inc.
|
|
3
|
+
// Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
|
|
4
|
+
// may not use this file except in compliance with the Flexible and Interoperable Data
|
|
5
|
+
// Transfer (FIT) Protocol License.
|
|
6
|
+
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
7
|
+
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
|
|
8
|
+
// Profile Version = 21.205.0Release
|
|
9
|
+
// Tag = production/release/21.205.0-0-gb3c261eb
|
|
10
|
+
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export type FitBaseTypeString =
|
|
14
|
+
| 'enum'
|
|
15
|
+
| 'byte'
|
|
16
|
+
| 'sint8'
|
|
17
|
+
| 'uint8'
|
|
18
|
+
| 'uint8z'
|
|
19
|
+
| 'sint16'
|
|
20
|
+
| 'uint16'
|
|
21
|
+
| 'uint16z'
|
|
22
|
+
| 'sint32'
|
|
23
|
+
| 'uint32'
|
|
24
|
+
| 'uint32z'
|
|
25
|
+
| 'sint64'
|
|
26
|
+
| 'uint64'
|
|
27
|
+
| 'uint64z'
|
|
28
|
+
| 'float64'
|
|
29
|
+
| 'float32'
|
|
30
|
+
| 'string';
|
|
31
|
+
|
|
32
|
+
/** A reference mapping a subfield's activation value to its controlling field name */
|
|
33
|
+
export interface SubFieldMap {
|
|
34
|
+
name: string;
|
|
35
|
+
value: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** A subfield that is active when a controlling field matches a specific value */
|
|
39
|
+
export interface ProfileSubField {
|
|
40
|
+
name: string;
|
|
41
|
+
type: string;
|
|
42
|
+
baseType: FitBaseTypeString;
|
|
43
|
+
scale: number | number[];
|
|
44
|
+
offset: number | number[];
|
|
45
|
+
units: string | string[];
|
|
46
|
+
bits: number[];
|
|
47
|
+
components: string[];
|
|
48
|
+
hasComponents: boolean;
|
|
49
|
+
map: SubFieldMap[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A field definition within a profile message */
|
|
53
|
+
export interface ProfileField {
|
|
54
|
+
num: number;
|
|
55
|
+
name: string;
|
|
56
|
+
type: string;
|
|
57
|
+
baseType: FitBaseTypeString;
|
|
58
|
+
array: boolean;
|
|
59
|
+
scale: number | number[];
|
|
60
|
+
offset: number | number[];
|
|
61
|
+
units: string | string[];
|
|
62
|
+
bits: number[];
|
|
63
|
+
components: string[];
|
|
64
|
+
isAccumulated: boolean;
|
|
65
|
+
hasComponents: boolean;
|
|
66
|
+
subFields: ProfileSubField[];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** A message definition from the FIT profile */
|
|
70
|
+
export interface ProfileMesg {
|
|
71
|
+
num: number;
|
|
72
|
+
name: string;
|
|
73
|
+
messagesKey: string;
|
|
74
|
+
fields: Record<number, ProfileField>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export declare const Profile: {
|
|
78
|
+
/** The FIT profile version */
|
|
79
|
+
readonly version: {
|
|
80
|
+
major: number;
|
|
81
|
+
minor: number;
|
|
82
|
+
patch: number;
|
|
83
|
+
type: string;
|
|
84
|
+
};
|
|
85
|
+
readonly CommonFields: {
|
|
86
|
+
readonly PartIndex: number;
|
|
87
|
+
readonly Timestamp: number;
|
|
88
|
+
readonly MessageIndex: number;
|
|
89
|
+
};
|
|
90
|
+
/** All profile messages keyed by message number */
|
|
91
|
+
readonly messages: Record<number, ProfileMesg>;
|
|
92
|
+
/** All profile types keyed by type name, then value */
|
|
93
|
+
readonly types: Record<string, Record<number, string>>;
|
|
94
|
+
/** Message number constants keyed by message name */
|
|
95
|
+
readonly MesgNum: Record<string, number>;
|
|
96
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright 2026 Garmin International, Inc.
|
|
3
|
+
// Licensed under the Flexible and Interoperable Data Transfer (FIT) Protocol License; you
|
|
4
|
+
// may not use this file except in compliance with the Flexible and Interoperable Data
|
|
5
|
+
// Transfer (FIT) Protocol License.
|
|
6
|
+
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
7
|
+
// ****WARNING**** This file is auto-generated! Do NOT edit this file.
|
|
8
|
+
// Profile Version = 21.205.0Release
|
|
9
|
+
// Tag = production/release/21.205.0-0-gb3c261eb
|
|
10
|
+
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
import { CrcCalculator } from "./crc-calculator";
|
|
14
|
+
import { FieldValue } from "./mesg";
|
|
15
|
+
|
|
16
|
+
/** Represents a FIT file's bytes and provides sequential read access. */
|
|
17
|
+
export class Stream {
|
|
18
|
+
/**
|
|
19
|
+
* Creates a Stream containing a FIT file.
|
|
20
|
+
* @param buffer - `ArrayBuffer` containing the FIT file bytes.
|
|
21
|
+
*/
|
|
22
|
+
constructor(buffer: ArrayBuffer);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Convenience method for creating a Stream from a byte array.
|
|
26
|
+
* @param data - An array of bytes or a `Uint8Array`.
|
|
27
|
+
* @returns A new Stream object.
|
|
28
|
+
*/
|
|
29
|
+
static fromByteArray(data: number[] | Uint8Array): Stream;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Convenience method for creating a Stream from a Node Buffer.
|
|
33
|
+
* @param buffer - Node `Buffer` of bytes.
|
|
34
|
+
* @returns A new Stream object.
|
|
35
|
+
*/
|
|
36
|
+
static fromBuffer(buffer: Uint8Array): Stream;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Convenience method for creating a Stream from an `ArrayBuffer`.
|
|
40
|
+
* @param buffer - An `ArrayBuffer` of bytes.
|
|
41
|
+
* @returns A new Stream object.
|
|
42
|
+
*/
|
|
43
|
+
static fromArrayBuffer(buffer: ArrayBuffer): Stream;
|
|
44
|
+
|
|
45
|
+
/** Total length of the underlying buffer in bytes. */
|
|
46
|
+
readonly length: number;
|
|
47
|
+
/** Number of bytes read. */
|
|
48
|
+
readonly bytesRead: number;
|
|
49
|
+
/** Current read position. */
|
|
50
|
+
readonly position: number;
|
|
51
|
+
/** CRC calculator, updated as bytes are read. */
|
|
52
|
+
crcCalculator: CrcCalculator;
|
|
53
|
+
|
|
54
|
+
/** Resets the read position to 0. */
|
|
55
|
+
reset(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Seeks to an absolute byte offset.
|
|
58
|
+
* @param position - Byte offset to seek to.
|
|
59
|
+
*/
|
|
60
|
+
seek(position: number): void;
|
|
61
|
+
/**
|
|
62
|
+
* Returns a copy of the underlying buffer for the given range.
|
|
63
|
+
* @param begin - Start index (inclusive).
|
|
64
|
+
* @param end - End index (exclusive).
|
|
65
|
+
*/
|
|
66
|
+
slice(begin: number, end: number): ArrayBuffer;
|
|
67
|
+
/** Returns the byte at the current position without advancing. */
|
|
68
|
+
peekByte(): number;
|
|
69
|
+
/** Reads and returns one byte. */
|
|
70
|
+
readByte(): number;
|
|
71
|
+
/**
|
|
72
|
+
* Reads `size` bytes and returns them as a `Uint8Array`.
|
|
73
|
+
* @param size - Number of bytes to read.
|
|
74
|
+
*/
|
|
75
|
+
readBytes(size: number): Uint8Array;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Reads a value of the given FIT base type from the stream.
|
|
79
|
+
* @param baseType - FIT base type constant.
|
|
80
|
+
* @param size - Number of bytes to read.
|
|
81
|
+
* @param opts - Read options.
|
|
82
|
+
*/
|
|
83
|
+
readValue(baseType: number, size: number, opts?: ReadValueOptions): FieldValue;
|
|
84
|
+
|
|
85
|
+
/** Reads an unsigned 8-bit integer. */
|
|
86
|
+
readUInt8(opts?: ReadValueOptions): number;
|
|
87
|
+
/** Reads a signed 8-bit integer. */
|
|
88
|
+
readInt8(opts?: ReadValueOptions): number;
|
|
89
|
+
/** Reads an unsigned 16-bit integer. */
|
|
90
|
+
readUInt16(opts?: ReadValueOptions): number;
|
|
91
|
+
/** Reads a signed 16-bit integer. */
|
|
92
|
+
readInt16(opts?: ReadValueOptions): number;
|
|
93
|
+
/** Reads an unsigned 32-bit integer. */
|
|
94
|
+
readUInt32(opts?: ReadValueOptions): number;
|
|
95
|
+
/** Reads a signed 32-bit integer. */
|
|
96
|
+
readInt32(opts?: ReadValueOptions): number;
|
|
97
|
+
/** Reads an unsigned 64-bit integer as a `bigint`. */
|
|
98
|
+
readUInt64(opts?: ReadValueOptions): bigint;
|
|
99
|
+
/** Reads a signed 64-bit integer as a `bigint`. */
|
|
100
|
+
readInt64(opts?: ReadValueOptions): bigint;
|
|
101
|
+
/** Reads a 32-bit IEEE 754 float. */
|
|
102
|
+
readFloat32(opts?: ReadValueOptions): number;
|
|
103
|
+
/** Reads a 64-bit IEEE 754 float. */
|
|
104
|
+
readFloat64(opts?: ReadValueOptions): number;
|
|
105
|
+
/**
|
|
106
|
+
* Reads a null-terminated UTF-8 string of up to `strlen` bytes.
|
|
107
|
+
* @param strlen - Maximum number of bytes to read.
|
|
108
|
+
*/
|
|
109
|
+
readString(strlen: number): string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Options shared by the typed read methods on {@link Stream}. */
|
|
113
|
+
export type ReadValueOptions = {
|
|
114
|
+
/** Byte order for this read. Defaults to `true`. */
|
|
115
|
+
littleEndian?: boolean;
|
|
116
|
+
/** When `true`, invalid values are returned as `null`. Defaults to `true`. */
|
|
117
|
+
convertInvalidToNull?: boolean;
|
|
118
|
+
}
|