trackswap 0.2.3 → 0.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.
Files changed (53) hide show
  1. package/README.md +20 -0
  2. package/dist/FIT/base.d.ts +30 -0
  3. package/dist/FIT/decoder.d.ts +48 -0
  4. package/dist/FIT/encoder.d.ts +96 -0
  5. package/dist/FIT/encoderCourse.d.ts +45 -0
  6. package/dist/FIT/encoderWorkout.d.ts +45 -0
  7. package/dist/FIT/health.d.ts +195 -7
  8. package/dist/FIT/index.d.ts +1 -1
  9. package/dist/FIT/mesg.d.ts +3 -0
  10. package/dist/FIT/middleware.d.ts +15 -0
  11. package/dist/FIT/plugins.d.ts +9 -0
  12. package/dist/FIT/processor.d.ts +24 -0
  13. package/dist/FIT/types/checksum_type.d.ts +6 -0
  14. package/dist/FIT/types/date_time_type.d.ts +3 -0
  15. package/dist/FIT/types/file.d.ts +63 -0
  16. package/dist/FIT/types/file_flags_type.d.ts +9 -0
  17. package/dist/FIT/types/local_date_time_type.d.ts +3 -0
  18. package/dist/FIT/types/mesg_count_type.d.ts +6 -0
  19. package/dist/FIT/types/mesg_num.d.ts +369 -0
  20. package/dist/FIT/types/message_index_type.d.ts +6591 -0
  21. package/dist/FIT/types/sport.d.ts +44 -44
  22. package/dist/FIT/types.d.ts +509 -0
  23. package/dist/GPX/base.d.ts +24 -0
  24. package/dist/GPX/converters.d.ts +44 -0
  25. package/dist/GPX/decoder.d.ts +66 -0
  26. package/dist/GPX/encoder.d.ts +109 -0
  27. package/dist/GPX/middleware.d.ts +9 -0
  28. package/dist/GPX/processor.d.ts +18 -0
  29. package/dist/GPX/types.d.ts +138 -0
  30. package/dist/TCX/base.d.ts +33 -0
  31. package/dist/TCX/converters.d.ts +33 -0
  32. package/dist/TCX/decoder.d.ts +54 -0
  33. package/dist/TCX/encoder.d.ts +116 -0
  34. package/dist/TCX/middleware.d.ts +12 -0
  35. package/dist/TCX/processor.d.ts +30 -0
  36. package/dist/TCX/types.d.ts +13 -0
  37. package/dist/TrackSwap.d.ts +4 -0
  38. package/dist/activity/base.d.ts +54 -0
  39. package/dist/activity/converters.d.ts +57 -0
  40. package/dist/activity/encoders.d.ts +34 -0
  41. package/dist/activity/metrics/MetricsCalculator.d.ts +30 -0
  42. package/dist/activity/processor.d.ts +31 -0
  43. package/dist/core/base.d.ts +46 -0
  44. package/dist/core/builtin-adapters.d.ts +1 -0
  45. package/dist/core/xml-utils.d.ts +24 -0
  46. package/dist/errors.d.ts +1 -1
  47. package/dist/fit-debug.d.ts +3 -0
  48. package/dist/index.cjs +4 -4
  49. package/dist/index.d.ts +2 -2
  50. package/dist/index.js +29 -29
  51. package/dist/types.d.ts +102 -1
  52. package/dist/util.d.ts +9 -0
  53. package/package.json +4 -3
@@ -1,19 +1,52 @@
1
1
  import { IPlugin, IConverterPlugin, IMiddlewarePlugin, BaseConverter, BaseMiddleware } from "../core/base.js";
2
2
  import { TCXContext, TCXFileType } from "./types.js";
3
+ /**
4
+ * TCX plugin interface (inherits generic plugin interface)
5
+ */
3
6
  export interface ITCXPlugin extends IPlugin<TCXContext> {
4
7
  }
8
+ /**
9
+ * TCX converter plugin interface (inherits generic converter interface)
10
+ */
5
11
  export interface ITCXConverterPlugin extends IConverterPlugin<TCXContext> {
6
12
  }
13
+ /**
14
+ * TCX middleware plugin interface (inherits generic middleware interface)
15
+ */
7
16
  export interface ITCXMiddlewarePlugin extends IMiddlewarePlugin<TCXContext, TCXFileType> {
8
17
  }
18
+ /**
19
+ * TCX base converter abstract class (inherits generic base converter)
20
+ */
9
21
  export declare abstract class BaseTCXConverter extends BaseConverter<TCXContext> implements ITCXConverterPlugin {
22
+ /**
23
+ * Parse TCX heart rate value
24
+ */
10
25
  protected parseHeartRate(value: string | number | undefined): number | undefined;
26
+ /**
27
+ * Parse TCX time format (ISO 8601)
28
+ */
11
29
  protected parseTCXTime(value: string | undefined): Date | undefined;
30
+ /**
31
+ * Parse TCX distance value (meters)
32
+ */
12
33
  protected parseDistance(value: string | number | undefined): number | undefined;
34
+ /**
35
+ * Parse TCX speed value (m/s)
36
+ */
13
37
  protected parseSpeed(value: string | number | undefined): number | undefined;
38
+ /**
39
+ * Parse TCX altitude value (meters)
40
+ */
14
41
  protected parseAltitude(value: string | number | undefined): number | undefined;
42
+ /**
43
+ * Parse TCX coordinate value (latitude/longitude)
44
+ */
15
45
  protected parseCoordinate(value: string | number | undefined): number | undefined;
16
46
  }
47
+ /**
48
+ * TCX base middleware abstract class (inherits generic base middleware)
49
+ */
17
50
  export declare abstract class BaseTCXMiddleware extends BaseMiddleware<TCXContext, TCXFileType> implements ITCXMiddlewarePlugin {
18
51
  onError(error: Error, context: TCXContext): Promise<void>;
19
52
  }
@@ -1,26 +1,41 @@
1
1
  import { TokenAST } from "../types.js";
2
2
  import { BaseTCXConverter } from "./base.js";
3
3
  import { TCXContext, ActivityType, ActivityLapType, TrackType, TrackpointType, PositionType, ActivityListType, MultiActivitySessionType, AbstractSourceType } from "./types.js";
4
+ /**
5
+ * Position converter
6
+ */
4
7
  export declare class PositionConverter extends BaseTCXConverter {
5
8
  name: string;
6
9
  supportedTags: string[];
7
10
  convert(ast: TokenAST, context: TCXContext): PositionType | undefined;
8
11
  }
12
+ /**
13
+ * Trackpoint converter
14
+ */
9
15
  export declare class TrackpointConverter extends BaseTCXConverter {
10
16
  name: string;
11
17
  supportedTags: string[];
12
18
  convert(ast: TokenAST, context: TCXContext): TrackpointType | undefined;
13
19
  }
20
+ /**
21
+ * Track converter
22
+ */
14
23
  export declare class TrackConverter extends BaseTCXConverter {
15
24
  name: string;
16
25
  supportedTags: string[];
17
26
  convert(ast: TokenAST, context: TCXContext): TrackType | undefined;
18
27
  }
28
+ /**
29
+ * Activity lap converter
30
+ */
19
31
  export declare class ActivityLapConverter extends BaseTCXConverter {
20
32
  name: string;
21
33
  supportedTags: string[];
22
34
  convert(ast: TokenAST, context: TCXContext): ActivityLapType | undefined;
23
35
  }
36
+ /**
37
+ * Activity converter
38
+ */
24
39
  export declare class ActivityConverter extends BaseTCXConverter {
25
40
  name: string;
26
41
  supportedTags: string[];
@@ -28,25 +43,43 @@ export declare class ActivityConverter extends BaseTCXConverter {
28
43
  private convertTraining;
29
44
  private convertCreator;
30
45
  }
46
+ /**
47
+ * Activity list converter
48
+ */
31
49
  export declare class ActivityListConverter extends BaseTCXConverter {
32
50
  name: string;
33
51
  supportedTags: string[];
34
52
  convert(ast: TokenAST, context: TCXContext): ActivityListType | undefined;
35
53
  }
54
+ /**
55
+ * Multi-sport session converter
56
+ */
36
57
  export declare class MultiActivitySessionConverter extends BaseTCXConverter {
37
58
  name: string;
38
59
  supportedTags: string[];
39
60
  convert(ast: TokenAST, context: TCXContext): MultiActivitySessionType | undefined;
40
61
  }
62
+ /**
63
+ * Abstract source converter
64
+ */
41
65
  export declare class AbstractSourceConverter extends BaseTCXConverter {
42
66
  name: string;
43
67
  supportedTags: string[];
44
68
  convert(ast: TokenAST, context: TCXContext): AbstractSourceType | undefined;
45
69
  }
70
+ /**
71
+ * Extensions converter
72
+ */
46
73
  export declare class ExtensionsConverter extends BaseTCXConverter {
47
74
  name: string;
48
75
  supportedTags: string[];
49
76
  convert(ast: TokenAST, context: TCXContext): any | undefined;
77
+ /**
78
+ * Flatten extension element, extracting all leaf nodes
79
+ */
50
80
  private flattenExtensionElement;
81
+ /**
82
+ * Parse extension value, trying to convert to appropriate type
83
+ */
51
84
  private parseExtensionValue;
52
85
  }
@@ -1,6 +1,9 @@
1
1
  import { ExtensionsType, TokenAST } from "../types.js";
2
2
  import { ITCXConverterPlugin, ITCXMiddlewarePlugin } from "./base.js";
3
3
  import { TCXFileType } from "./types.js";
4
+ /**
5
+ * https://www8.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd
6
+ */
4
7
  export declare class TCXDecoder {
5
8
  private converterPlugins;
6
9
  private registeredPlugins;
@@ -9,22 +12,73 @@ export declare class TCXDecoder {
9
12
  private initialized;
10
13
  private defaultConvertersRegistered;
11
14
  constructor();
15
+ /**
16
+ * Initialize pipeline - register fixed core processors
17
+ */
12
18
  private initializePipeline;
19
+ /**
20
+ * Auto-register default converters - handle standard TCX tags
21
+ */
13
22
  private registerDefaultConverters;
23
+ /**
24
+ * Add converter for specified tag, sorted by priority
25
+ */
14
26
  private addConverterForTag;
27
+ /**
28
+ * Register converter plugin
29
+ */
15
30
  registerConverter(plugin: ITCXConverterPlugin): Promise<void>;
31
+ /**
32
+ * Register middleware plugin - the real extension point
33
+ */
16
34
  registerMiddleware(plugin: ITCXMiddlewarePlugin): Promise<void>;
35
+ /**
36
+ * Get converter (returns highest priority one)
37
+ */
17
38
  getConverter(tag: string): ITCXConverterPlugin | undefined;
39
+ /**
40
+ * Get all converters for specified tag (sorted by priority)
41
+ */
18
42
  getAllConverters(tag: string): ITCXConverterPlugin[];
43
+ /**
44
+ * Remove converter
45
+ */
19
46
  unregisterConverter(pluginName: string): void;
47
+ /**
48
+ * Remove middleware
49
+ */
20
50
  unregisterMiddleware(name: string): void;
51
+ /**
52
+ * Initialize decoder
53
+ */
21
54
  initialize(): Promise<void>;
55
+ /**
56
+ * Destroy decoder
57
+ */
22
58
  destroy(): Promise<void>;
59
+ /**
60
+ * Create decode context
61
+ */
23
62
  private createContext;
63
+ /**
64
+ * Execute middleware hook
65
+ */
24
66
  private executeMiddlewareHook;
67
+ /**
68
+ * Main parse method - fixed pipeline + flexible middleware
69
+ */
25
70
  parseByBuffer(buffer: Buffer): Promise<TCXFileType | undefined>;
71
+ /**
72
+ * Convert Extensions (backward compatibility)
73
+ */
26
74
  convertExtensions(extensionsAST: TokenAST): ExtensionsType;
75
+ /**
76
+ * @deprecated Use parseByBuffer instead
77
+ */
27
78
  parserByBuffer(buffer: Buffer): Promise<TCXFileType | undefined>;
79
+ /**
80
+ * @deprecated Use new plugin system instead
81
+ */
28
82
  parseByString(xmlContent: string): Promise<TCXFileType | undefined>;
29
83
  }
30
84
  declare const _default: {
@@ -1,46 +1,162 @@
1
1
  import { TCXFileType } from "./types.js";
2
+ /**
3
+ * TCX encoder - encodes TCXFileType data to TCX XML format
4
+ */
2
5
  export declare class TCXEncoder {
3
6
  private compact;
7
+ /**
8
+ * Constructor
9
+ * @param options Encoder options
10
+ */
4
11
  constructor(options?: {
5
12
  compact?: boolean;
6
13
  });
14
+ /**
15
+ * Encode TCX data to Buffer
16
+ */
7
17
  encode(tcxData: TCXFileType): Promise<Buffer>;
18
+ /**
19
+ * Encode TCX data to XML string
20
+ */
8
21
  encodeToString(tcxData: TCXFileType): string;
22
+ /**
23
+ * Build complete TCX XML
24
+ */
9
25
  private buildTCXXML;
26
+ /**
27
+ * Compress XML string, remove redundant newlines and spaces
28
+ */
10
29
  private compressXML;
30
+ /**
31
+ * Build XML header
32
+ */
11
33
  private buildXMLHeader;
34
+ /**
35
+ * Build TCX content
36
+ */
12
37
  private buildTCXContent;
38
+ /**
39
+ * Build Folders element
40
+ */
13
41
  private buildFolders;
42
+ /**
43
+ * Build History element
44
+ */
14
45
  private buildHistory;
46
+ /**
47
+ * Build HistoryFolder element
48
+ */
15
49
  private buildHistoryFolder;
50
+ /**
51
+ * Build Activities element
52
+ */
16
53
  private buildActivities;
54
+ /**
55
+ * Build single Activity element
56
+ */
17
57
  private buildActivity;
58
+ /**
59
+ * Build ActivityLap element
60
+ */
18
61
  private buildActivityLap;
62
+ /**
63
+ * Build Track element
64
+ */
19
65
  private buildTrack;
66
+ /**
67
+ * Build Trackpoint element
68
+ */
20
69
  private buildTrackpoint;
21
70
  private buildGeoCoords;
22
71
  private wrapGeoTag;
72
+ /**
73
+ * Build Position element
74
+ */
23
75
  private buildPosition;
76
+ /**
77
+ * Build Cadence element
78
+ */
24
79
  private buildCadence;
80
+ /**
81
+ * Build MultiActivitySession element
82
+ */
25
83
  private buildMultiActivitySession;
84
+ /**
85
+ * Build FirstActivity element
86
+ */
26
87
  private buildFirstActivity;
88
+ /**
89
+ * Build NextActivity element
90
+ */
27
91
  private buildNextActivity;
92
+ /**
93
+ * Build Workouts element
94
+ */
28
95
  private buildWorkouts;
96
+ /**
97
+ * Build Courses element
98
+ */
29
99
  private buildCourses;
100
+ /**
101
+ * Single TCX Course under Courses
102
+ */
30
103
  private buildCourseElement;
104
+ /**
105
+ * Lap inside Course (CourseLap schema subset)
106
+ */
31
107
  private buildCourseLap;
108
+ /** Course cue point */
32
109
  private buildCoursePoint;
110
+ /**
111
+ * Build Author element
112
+ */
33
113
  private buildAuthor;
114
+ /**
115
+ * Build extensions element
116
+ */
34
117
  private buildExtensions;
118
+ /**
119
+ * Recursively build extension content
120
+ */
35
121
  private buildExtensionContent;
122
+ /**
123
+ * Format time
124
+ */
36
125
  private formatTime;
126
+ /**
127
+ * Add optional element
128
+ */
37
129
  private addOptionalElement;
130
+ /**
131
+ * Add optional numeric element
132
+ */
38
133
  private addOptionalNumericElement;
134
+ /**
135
+ * Validate coordinate validity
136
+ */
39
137
  private isValidCoordinate;
138
+ /**
139
+ * Format coordinate
140
+ */
40
141
  private formatCoordinate;
142
+ /**
143
+ * Round number
144
+ */
41
145
  private roundTo;
146
+ /**
147
+ * XML escape
148
+ */
42
149
  private escapeXML;
150
+ /**
151
+ * XML attribute value escape (specifically for safe escaping of attribute values)
152
+ */
43
153
  private escapeXMLAttribute;
154
+ /**
155
+ * Deep clone
156
+ */
44
157
  private deepClone;
158
+ /**
159
+ * @deprecated Use encode() instead
160
+ */
45
161
  encoder(node: TCXFileType): Promise<Buffer>;
46
162
  }
@@ -1,6 +1,9 @@
1
1
  import { Token, TokenAST } from "../types.js";
2
2
  import { BaseTCXMiddleware } from "./base.js";
3
3
  import { TCXContext } from "./types.js";
4
+ /**
5
+ * TCX performance monitoring middleware
6
+ */
4
7
  export declare class TCXPerformanceMiddleware extends BaseTCXMiddleware {
5
8
  name: string;
6
9
  description: string;
@@ -9,12 +12,18 @@ export declare class TCXPerformanceMiddleware extends BaseTCXMiddleware {
9
12
  onComplete(result: any, context: TCXContext): Promise<any>;
10
13
  private countNodes;
11
14
  }
15
+ /**
16
+ * TCX validation middleware
17
+ */
12
18
  export declare class TCXValidationMiddleware extends BaseTCXMiddleware {
13
19
  name: string;
14
20
  description: string;
15
21
  onComplete(result: any, context: TCXContext): Promise<any>;
16
22
  private validateTCX;
17
23
  }
24
+ /**
25
+ * TCX data enhancement middleware
26
+ */
18
27
  export declare class TCXEnhancementMiddleware extends BaseTCXMiddleware {
19
28
  name: string;
20
29
  description: string;
@@ -22,4 +31,7 @@ export declare class TCXEnhancementMiddleware extends BaseTCXMiddleware {
22
31
  private calculateTotalDistance;
23
32
  private calculateTotalDuration;
24
33
  }
34
+ /**
35
+ * Register all default middleware
36
+ */
25
37
  export declare function registerDefaultTCXMiddlewares(decoder: any): Promise<void>;
@@ -1,37 +1,67 @@
1
1
  import { TCXContext } from "./types.js";
2
2
  import { ITCXConverterPlugin } from "./base.js";
3
+ /**
4
+ * TCX pipeline stages
5
+ */
3
6
  export declare enum TCXPipelineStage {
4
7
  TOKENIZE = "tokenize",
5
8
  AST_GENERATE = "ast-generate",
6
9
  CONVERT = "convert",
7
10
  COMPLETE = "complete"
8
11
  }
12
+ /**
13
+ * Pipeline processor interface
14
+ */
9
15
  export interface IPipelineProcessor {
10
16
  stage: TCXPipelineStage;
11
17
  name: string;
12
18
  process(context: TCXContext): Promise<TCXContext>;
13
19
  }
20
+ /**
21
+ * Tokenizer - convert XML to Token array
22
+ */
14
23
  export declare class TokenizeProcessor implements IPipelineProcessor {
15
24
  stage: TCXPipelineStage;
16
25
  name: string;
17
26
  process(context: TCXContext): Promise<TCXContext>;
18
27
  }
28
+ /**
29
+ * AST generator - convert Token array to AST tree
30
+ */
19
31
  export declare class AstGenerateProcessor implements IPipelineProcessor {
20
32
  stage: TCXPipelineStage;
21
33
  name: string;
22
34
  process(context: TCXContext): Promise<TCXContext>;
23
35
  }
36
+ /**
37
+ * Converter - convert AST to TCX data structure
38
+ */
24
39
  export declare class ConvertProcessor implements IPipelineProcessor {
25
40
  private getConverter;
26
41
  stage: TCXPipelineStage;
27
42
  name: string;
28
43
  constructor(getConverter: (tag: string) => ITCXConverterPlugin | undefined);
29
44
  process(context: TCXContext): Promise<TCXContext>;
45
+ /**
46
+ * Find TCX root node
47
+ */
30
48
  private findTCXRoot;
49
+ /**
50
+ * Convert AST node
51
+ */
31
52
  private convertAST;
53
+ /**
54
+ * Generic conversion method
55
+ */
32
56
  private genericConvert;
57
+ /**
58
+ * Count AST elements
59
+ */
33
60
  private countElements;
34
61
  }
62
+ /**
63
+ * Completion processor - final processing and cleanup
64
+ */
35
65
  export declare class CompleteProcessor implements IPipelineProcessor {
36
66
  stage: TCXPipelineStage;
37
67
  name: string;
@@ -1,5 +1,8 @@
1
1
  import { ExtensionsType, Token, TokenAST } from "../types.js";
2
2
  import { IProcessingContext } from "../core/base.js";
3
+ /**
4
+ * TCX file type
5
+ */
3
6
  export interface TCXFileType {
4
7
  version?: string;
5
8
  creator?: string;
@@ -137,6 +140,10 @@ export interface ActivityLapType {
137
140
  Extensions?: any;
138
141
  }
139
142
  export type TriggerMethodType = "Manual" | "Distance" | "Location" | "Time" | "HeartRate";
143
+ /**
144
+ * Active (high intensity)
145
+ * Resting (low intensity)
146
+ */
140
147
  export type IntensityType = "Active" | "Resting";
141
148
  export interface CadenceType {
142
149
  Low: number;
@@ -154,6 +161,9 @@ export interface MultiActivitySessionType {
154
161
  export interface FirstActivityType {
155
162
  Activity?: ActivityType;
156
163
  }
164
+ /**
165
+ * Each sport contains an optional transition and a run.
166
+ */
157
167
  export interface NextActivityType {
158
168
  Transition?: ActivityLapType;
159
169
  Activity?: ActivityType;
@@ -175,6 +185,9 @@ export interface PositionType {
175
185
  LatitudeDegrees?: string;
176
186
  LongitudeDegrees?: string;
177
187
  }
188
+ /**
189
+ * TCX processing context
190
+ */
178
191
  export interface TCXContext extends IProcessingContext {
179
192
  rawData?: Buffer;
180
193
  xmlContent?: string;
@@ -1,5 +1,9 @@
1
1
  import type { CourseEncodeOptions, DecodeOptions, EncodeOptions, TrackDocument, TrackFormat, TrackInput, TrackSwapOptions, TranscodeOptions } from "./document.js";
2
2
  import type { FileType } from "./types.js";
3
+ /**
4
+ * Stateless facade for decoding, encoding and transcoding track documents.
5
+ * Format-specific behavior lives in adapters; this class only orchestrates them.
6
+ */
3
7
  export declare class TrackSwap {
4
8
  private readonly registry;
5
9
  private disposed;
@@ -1,42 +1,85 @@
1
1
  import { IPlugin, IConverterPlugin, IMiddlewarePlugin, BaseConverter, BaseMiddleware, IProcessingContext } from "../core/base.js";
2
2
  import { ActivityType, ActivityRecordType, ActivityLapType, TokenAST, FileType } from "../types.js";
3
+ /**
4
+ * Activity processing context
5
+ */
3
6
  export interface ActivityContext extends IProcessingContext {
7
+ /** Original data type */
4
8
  sourceFormat: string;
9
+ /** Original data */
5
10
  sourceData: any;
11
+ /** Conversion result */
6
12
  result?: FileType;
13
+ /** Activity-specific performance statistics */
7
14
  performance: {
8
15
  startTime: number;
9
16
  convertTime?: number;
10
17
  endTime?: number;
11
18
  };
12
19
  }
20
+ /**
21
+ * Activity encoding context
22
+ */
13
23
  export interface ActivityEncodingContext extends IProcessingContext {
24
+ /** Target format */
14
25
  targetFormat: string;
26
+ /** Encoding result */
15
27
  result?: any;
28
+ /** Activity encoding specific performance statistics */
16
29
  performance: {
17
30
  startTime: number;
18
31
  encodeTime?: number;
19
32
  endTime?: number;
20
33
  };
21
34
  }
35
+ /**
36
+ * Activity plugin interface (inherits from generic plugin interface)
37
+ */
22
38
  export interface IActivityPlugin extends IPlugin {
23
39
  }
40
+ /**
41
+ * Activity converter plugin interface (inherits from generic converter interface)
42
+ */
24
43
  export interface IActivityConverterPlugin extends IConverterPlugin {
25
44
  convert(ast: TokenAST, context: ActivityContext): FileType | undefined;
26
45
  }
46
+ /**
47
+ * Activity middleware plugin interface (inherits from generic middleware interface)
48
+ */
27
49
  export interface IActivityMiddlewarePlugin extends IMiddlewarePlugin {
28
50
  process(context: ActivityContext): Promise<void>;
29
51
  }
52
+ /**
53
+ * Activity encoder plugin interface
54
+ */
30
55
  export interface IActivityEncoderPlugin extends IPlugin<ActivityEncodingContext> {
56
+ /** Encoding method */
31
57
  encode(file: FileType, context: ActivityEncodingContext): any | undefined;
58
+ /** Whether it supports the format */
32
59
  supports(format: string): boolean;
60
+ /** Priority (the smaller the higher the priority) */
33
61
  priority?: number;
34
62
  }
63
+ /**
64
+ * Activity base converter abstract class (inherits from generic base converter)
65
+ */
35
66
  export declare abstract class BaseActivityConverter extends BaseConverter<ActivityContext> implements IActivityConverterPlugin {
67
+ /**
68
+ * Convert point array
69
+ */
36
70
  protected convertPoints(points: any[]): ActivityRecordType[];
71
+ /**
72
+ * Convert single point
73
+ */
37
74
  protected abstract convertPoint(point: any): ActivityRecordType | undefined;
75
+ /**
76
+ * Convert time to timestamp using dayjs
77
+ */
38
78
  protected convertTime(time: Date | string | number | undefined): number | undefined;
39
79
  }
80
+ /**
81
+ * Activity base encoder abstract class
82
+ */
40
83
  export declare abstract class BaseActivityEncoder implements IActivityEncoderPlugin {
41
84
  abstract name: string;
42
85
  abstract supportedTags: string[];
@@ -52,11 +95,22 @@ export declare abstract class BaseActivityEncoder implements IActivityEncoderPlu
52
95
  protected ensureValidCoordinates(lat: number, lon: number): boolean;
53
96
  protected round(value: number, precision?: number): number;
54
97
  }
98
+ /**
99
+ * Activity base middleware abstract class (inherits from generic base middleware)
100
+ */
55
101
  export declare abstract class BaseActivityMiddleware extends BaseMiddleware<ActivityContext, ActivityType> implements IActivityMiddlewarePlugin {
56
102
  abstract process(context: ActivityContext): Promise<void>;
57
103
  onError(error: Error, context: ActivityContext): Promise<void>;
104
+ /**
105
+ * Validate ActivityType data
106
+ */
58
107
  protected validateActivityFile(file: FileType): boolean;
59
108
  protected validateActivity(activity: ActivityType): boolean;
60
109
  protected validateRoute(route: ActivityLapType): boolean;
110
+ /**
111
+ * 仅判断有没有 timestamp
112
+ * @param point
113
+ * @returns
114
+ */
61
115
  protected validatePoint(point: ActivityRecordType): boolean;
62
116
  }