trackswap 0.0.1 → 0.0.3

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 (58) hide show
  1. package/README.md +322 -281
  2. package/dist/FIT/base.d.ts +61 -0
  3. package/dist/FIT/crc.d.ts +1 -0
  4. package/dist/FIT/decoder.d.ts +35 -0
  5. package/dist/FIT/encoder.d.ts +45 -0
  6. package/dist/FIT/index.d.ts +12 -0
  7. package/dist/FIT/mesg.d.ts +37 -0
  8. package/dist/FIT/middleware.d.ts +33 -0
  9. package/dist/FIT/plugins.d.ts +17 -0
  10. package/dist/FIT/processor.d.ts +34 -0
  11. package/dist/FIT/types/course_point.d.ts +56 -0
  12. package/dist/FIT/types/event.d.ts +49 -0
  13. package/dist/FIT/types/event_type.d.ts +18 -0
  14. package/dist/FIT/types/file.d.ts +23 -0
  15. package/dist/FIT/types/index.d.ts +119 -0
  16. package/dist/FIT/types/mesg_num.d.ts +105 -0
  17. package/dist/FIT/types/sport.d.ts +47 -0
  18. package/dist/FIT/types.d.ts +196 -0
  19. package/dist/FIT/util.d.ts +1 -0
  20. package/dist/GPX/base.d.ts +14 -77
  21. package/dist/GPX/converters.d.ts +12 -66
  22. package/dist/GPX/decoder.d.ts +5 -71
  23. package/dist/GPX/encoder.d.ts +4 -109
  24. package/dist/GPX/index.d.ts +1 -1
  25. package/dist/GPX/middleware.d.ts +18 -0
  26. package/dist/GPX/processor.d.ts +0 -18
  27. package/dist/GPX/types.d.ts +2 -111
  28. package/dist/TCX/base.d.ts +19 -0
  29. package/dist/TCX/converters.d.ts +51 -0
  30. package/dist/TCX/decoder.d.ts +33 -0
  31. package/dist/TCX/encoder.d.ts +41 -0
  32. package/dist/TCX/index.d.ts +13 -0
  33. package/dist/TCX/middleware.d.ts +18 -0
  34. package/dist/TCX/processor.d.ts +30 -0
  35. package/dist/TCX/types.d.ts +190 -0
  36. package/dist/TrackSwap.d.ts +37 -33
  37. package/dist/core/base.d.ts +73 -0
  38. package/dist/core/index.d.ts +2 -0
  39. package/dist/core/xml-utils.d.ts +17 -0
  40. package/dist/index.js +24 -5
  41. package/dist/sport/base.d.ts +63 -0
  42. package/dist/sport/converters.d.ts +33 -0
  43. package/dist/sport/encoders.d.ts +34 -0
  44. package/dist/sport/index.d.ts +17 -0
  45. package/dist/sport/processor.d.ts +19 -0
  46. package/dist/types.d.ts +91 -13
  47. package/package.json +25 -7
  48. package/dist/GPX/base.js +0 -83
  49. package/dist/GPX/converters.js +0 -444
  50. package/dist/GPX/decoder.js +0 -403
  51. package/dist/GPX/encoder.js +0 -510
  52. package/dist/GPX/extensions/index.js +0 -14
  53. package/dist/GPX/index.js +0 -11
  54. package/dist/GPX/processor.js +0 -187
  55. package/dist/GPX/types.js +0 -1
  56. package/dist/GPX/util.js +0 -18
  57. package/dist/TrackSwap.js +0 -84
  58. package/dist/types.js +0 -1
@@ -1,150 +1,45 @@
1
1
  import { GPX11Type } from "./types.js";
2
- /**
3
- * GPX 编码器 - 将 GPX11Type 数据编码为 GPX XML 格式
4
- */
5
2
  export declare class GPXEncoder {
6
3
  private compact;
7
- /**
8
- * 构造函数
9
- * @param options 编码器选项
10
- */
11
4
  constructor(options?: {
12
5
  compact?: boolean;
13
6
  });
14
- /**
15
- * 编码 GPX 数据为 Buffer
16
- */
17
7
  encode(gpxData: GPX11Type): Promise<Buffer>;
18
- /**
19
- * 编码 GPX 数据为 XML 字符串
20
- */
21
8
  encodeToString(gpxData: GPX11Type): string;
22
- /**
23
- * 构建完整的 GPX XML
24
- */
25
9
  private buildGPXXML;
26
- /**
27
- * 压缩XML字符串,去掉多余的换行和空格
28
- */
29
10
  private compressXML;
30
- /**
31
- * 构建 XML 头部
32
- */
33
11
  private buildXMLHeader;
34
- /**
35
- * 构建 GPX 内容
36
- */
37
12
  private buildGPXContent;
38
- /**
39
- * 构建 metadata 元素
40
- */
41
13
  private buildMetadata;
42
- /**
43
- * 构建 author 元素
44
- */
45
14
  private buildAuthor;
46
- /**
47
- * 构建 copyright 元素
48
- */
49
15
  private buildCopyright;
50
- /**
51
- * 构建 bounds 元素
52
- */
53
16
  private buildBounds;
54
- /**
55
- * 构建航路点元素
56
- */
57
17
  private buildWaypoint;
58
- /**
59
- * 添加标准航路点元素
60
- */
61
18
  private addStandardWaypointElements;
62
- /**
63
- * 构建 rte 元素
64
- */
65
19
  private buildRoute;
66
- /**
67
- * 构建轨迹元素
68
- */
69
20
  private buildTrack;
70
- /**
71
- * 构建轨迹段元素
72
- */
73
21
  private buildTrackSegment;
74
- /**
75
- * 添加路线和轨迹的公共元素
76
- */
77
22
  private addRouteTrackCommonElements;
78
- /**
79
- * 处理点的扩展属性
80
- */
81
23
  private processPointExtensions;
82
- /**
83
- * 构建 TrackPoint 扩展
84
- */
85
24
  private buildTrackPointExtension;
86
- /**
87
- * 构建 Power 扩展
88
- */
89
25
  private buildPowerExtension;
90
- /**
91
- * 构建 GPX 扩展
92
- */
93
26
  private buildGpxExtensions;
94
- /**
95
- * 构建扩展元素
96
- */
97
27
  private buildExtensions;
98
- /**
99
- * 递归构建扩展内容
100
- */
101
28
  private buildExtensionContent;
102
- /**
103
- * 构建 link 元素
104
- */
105
29
  private buildLink;
106
- /**
107
- * 添加多个 link 元素
108
- */
109
30
  private addLinks;
110
- /**
111
- * 构建时间元素
112
- */
113
31
  private buildTimeElement;
114
- /**
115
- * 添加可选元素
116
- */
117
32
  private addOptionalElement;
118
- /**
119
- * 验证坐标有效性
120
- */
121
33
  private isValidCoordinate;
122
- /**
123
- * 格式化坐标
124
- */
125
34
  private formatCoordinate;
126
- /**
127
- * 格式化高程
128
- */
129
35
  private formatElevation;
130
- /**
131
- * 数字四舍五入
132
- */
133
36
  private roundTo;
134
- /**
135
- * XML 转义
136
- */
137
37
  private escapeXML;
138
- /**
139
- * XML 属性值转义(专门用于属性值的安全转义)
140
- */
141
38
  private escapeXMLAttribute;
142
- /**
143
- * 深度拷贝
144
- */
145
39
  private deepClone;
146
- /**
147
- * @deprecated 使用 encode() 替代
148
- */
149
40
  encoder(node: GPX11Type): Promise<Buffer>;
150
41
  }
42
+ declare const _default: {
43
+ GPXEncoder: typeof GPXEncoder;
44
+ };
45
+ export default _default;
@@ -1,6 +1,6 @@
1
1
  import { GPXDecoder } from "./decoder.js";
2
2
  import { GPXEncoder } from "./encoder.js";
3
- import { registerDefaultMiddlewares } from "./converters.js";
3
+ import { registerDefaultMiddlewares } from "./middleware.js";
4
4
  import { PipelineStage } from "./processor.js";
5
5
  export { GPXDecoder, GPXEncoder, registerDefaultMiddlewares, PipelineStage };
6
6
  declare const _default: {
@@ -0,0 +1,18 @@
1
+ import { Token, TokenAST } from "../types";
2
+ import { BaseGPXMiddleware } from "./base";
3
+ import { DecoderContext } from "./types";
4
+ export declare class PerformanceMiddleware extends BaseGPXMiddleware {
5
+ name: string;
6
+ description: string;
7
+ onTokenize(tokens: Token[], context: DecoderContext): Promise<Token[]>;
8
+ onAstGenerate(ast: TokenAST, context: DecoderContext): Promise<TokenAST>;
9
+ onComplete(result: any, context: DecoderContext): Promise<any>;
10
+ private countNodes;
11
+ }
12
+ export declare class ValidationMiddleware extends BaseGPXMiddleware {
13
+ name: string;
14
+ description: string;
15
+ onComplete(result: any, context: DecoderContext): Promise<any>;
16
+ private validateGPX;
17
+ }
18
+ export declare function registerDefaultMiddlewares(decoder: any): Promise<void>;
@@ -1,37 +1,22 @@
1
1
  import { DecoderContext } from "./types.js";
2
- /**
3
- * 流水线阶段
4
- */
5
2
  export declare enum PipelineStage {
6
3
  TOKENIZE = "tokenize",
7
4
  AST_GENERATE = "ast_generate",
8
5
  CONVERT = "convert",
9
6
  COMPLETE = "complete"
10
7
  }
11
- /**
12
- * 流水线处理器
13
- */
14
8
  export interface IPipelineProcessor {
15
9
  stage: PipelineStage;
16
10
  process(context: DecoderContext): Promise<DecoderContext>;
17
11
  }
18
- /**
19
- * Tokenize处理器
20
- */
21
12
  export declare class TokenizeProcessor implements IPipelineProcessor {
22
13
  stage: PipelineStage;
23
14
  process(context: DecoderContext): Promise<DecoderContext>;
24
15
  }
25
- /**
26
- * AST生成处理器
27
- */
28
16
  export declare class AstGenerateProcessor implements IPipelineProcessor {
29
17
  stage: PipelineStage;
30
18
  process(context: DecoderContext): Promise<DecoderContext>;
31
19
  }
32
- /**
33
- * 转换处理器
34
- */
35
20
  export declare class ConvertProcessor implements IPipelineProcessor {
36
21
  private getConverter;
37
22
  stage: PipelineStage;
@@ -39,9 +24,6 @@ export declare class ConvertProcessor implements IPipelineProcessor {
39
24
  process(context: DecoderContext): Promise<DecoderContext>;
40
25
  private assignResult;
41
26
  }
42
- /**
43
- * 完成处理器
44
- */
45
27
  export declare class CompleteProcessor implements IPipelineProcessor {
46
28
  stage: PipelineStage;
47
29
  process(context: DecoderContext): Promise<DecoderContext>;
@@ -1,7 +1,5 @@
1
1
  import { DegreesType, ExtensionsType, LatitudeType, LongitudeType, Token, TokenAST } from "../types.js";
2
- /**
3
- * Two lat/lon pairs defining the extent of an element.
4
- */
2
+ import { IProcessingContext } from "../core/base.js";
5
3
  export interface BoundsType {
6
4
  minlat?: LatitudeType;
7
5
  minlon?: LongitudeType;
@@ -22,27 +20,12 @@ export interface EmailType {
22
20
  id?: string;
23
21
  domain?: string;
24
22
  }
25
- /**
26
- * Type of GPS fix. none means GPS had no fix. To signify "the fix info is unknown, leave out fixType entirely. pps = military signal used
27
- */
28
23
  type FixType = "none" | "2d" | "3d" | "dgps" | "pps" | string;
29
24
  export type LinkType = {
30
- /**
31
- * URL of hyperlink.
32
- */
33
25
  href?: string;
34
- /**
35
- * Text of hyperlink.
36
- */
37
26
  text?: string;
38
- /**
39
- * Mime type of content (image/jpeg)
40
- */
41
27
  type?: string;
42
28
  };
43
- /**
44
- * GPX 1.1 version type
45
- */
46
29
  export interface GPX11Type {
47
30
  version?: string;
48
31
  creator?: string;
@@ -60,9 +43,6 @@ export interface GPX11Type {
60
43
  export interface MetadataType {
61
44
  name?: string;
62
45
  desc?: string;
63
- /**
64
- * The person or organization who created the GPX file.
65
- */
66
46
  author?: PersonType;
67
47
  copyright?: CopyrightType;
68
48
  link?: LinkType[];
@@ -72,126 +52,39 @@ export interface MetadataType {
72
52
  extensions?: ExtensionsType;
73
53
  [key: string]: any;
74
54
  }
75
- /**
76
- * A list of waypoints.
77
- */
78
55
  export interface WptType {
79
56
  lat: LatitudeType;
80
57
  lon: LongitudeType;
81
- /**
82
- * Elevation (in meters) of the point.
83
- */
84
58
  ele?: number;
85
- /**
86
- * Creation/modification timestamp for element. Date and time in are in Univeral Coordinated Time (UTC), not local time! Conforms to ISO 8601 specification for date/time representation. Fractional seconds are allowed for millisecond timing in tracklogs.
87
- */
88
59
  time?: Date;
89
- /**
90
- * Instantaneous speed at the point (meters per second)
91
- */
92
60
  speed?: number;
93
- /**
94
- * Instantaneous course at the point (degrees, true north)
95
- */
96
61
  course?: number;
97
- /**
98
- * Magnetic variation (in degrees) at the point
99
- */
100
62
  magvar?: DegreesType;
101
- /**
102
- * Height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid. As defined in NMEA GGA message.
103
- */
104
63
  geoidheight?: number;
105
- /**
106
- * The GPS name of the waypoint. This field will be transferred to and from the GPS. GPX does not place restrictions on the length of this field or the characters contained in it. It is up to the receiving application to validate the field before sending it to the GPS.
107
- */
108
64
  name?: string;
109
- /**
110
- * GPS waypoint comment. Sent to GPS as comment.
111
- */
112
65
  cmt?: string;
113
- /**
114
- * A text description of the element. Holds additional information about the element intended for the user, not the GPS.
115
- */
116
66
  desc?: string;
117
- /**
118
- * Source of data. Included to give user some idea of reliability and accuracy of data. "Garmin eTrex", "USGS quad Boston North", e.g.
119
- */
120
67
  src?: string;
121
- /**
122
- * Link to additional information about the waypoint.
123
- */
124
68
  link?: LinkType[];
125
- /**
126
- * Text of GPS symbol name. For interchange with other programs, use the exact spelling of the symbol as displayed on the GPS. If the GPS abbreviates words, spell them out.
127
- */
128
69
  sym?: string;
129
- /**
130
- * Type (classification) of the waypoint.
131
- */
132
70
  type?: string;
133
71
  fix?: FixType;
134
- /**
135
- * Number of satellites used to calculate the GPX fix.
136
- */
137
72
  sat?: string;
138
- /**
139
- * Horizontal dilution of precision.
140
- */
141
73
  hdop?: number;
142
- /**
143
- * Vertical dilution of precision.
144
- */
145
74
  vdop?: number;
146
- /**
147
- * Position dilution of precision.
148
- */
149
75
  pdop?: number;
150
- /**
151
- * Number of seconds since last DGPS update.
152
- */
153
76
  ageofdgpsdata?: number;
154
- /**
155
- * ID of DGPS station used in differential correction.
156
- */
157
77
  dgpsid?: DegreesType;
158
- /**
159
- * You can add extend GPX by adding your own elements from another schema here.
160
- */
161
78
  extensions?: ExtensionsType;
162
79
  }
163
- /**
164
- * A list of route points.
165
- */
166
80
  type RteptType = WptType;
167
81
  export interface RteType {
168
- /**
169
- * GPS name of route.
170
- */
171
82
  name?: string;
172
- /**
173
- * GPS comment for route.
174
- */
175
83
  cmt?: string;
176
- /**
177
- * Text description of route for user. Not sent to GPS.
178
- */
179
84
  desc?: string;
180
- /**
181
- * Source of data. Included to give user some idea of reliability and accuracy of data.
182
- */
183
85
  src?: string;
184
- /**
185
- * Links to external information about the route.
186
- */
187
86
  link?: LinkType[];
188
- /**
189
- * GPS route number.
190
- */
191
87
  number?: number;
192
- /**
193
- * Type (classification) of route.
194
- */
195
88
  type?: string;
196
89
  extensions?: ExtensionsType;
197
90
  rtept?: RteptType[];
@@ -211,14 +104,12 @@ export interface TrksegType {
211
104
  trkpt?: WptType[];
212
105
  extensions?: ExtensionsType;
213
106
  }
214
- export interface DecoderContext {
107
+ export interface DecoderContext extends IProcessingContext {
215
108
  rawData?: Buffer;
216
109
  xmlContent?: string;
217
110
  tokens?: Token[];
218
111
  ast?: TokenAST;
219
112
  result?: GPX11Type;
220
- metadata: Map<string, any>;
221
- errors: Error[];
222
113
  performance: {
223
114
  startTime: number;
224
115
  tokenizeTime?: number;
@@ -0,0 +1,19 @@
1
+ import { IPlugin, IConverterPlugin, IMiddlewarePlugin, BaseConverter, BaseMiddleware } from "../core/base.js";
2
+ import { TCXContext, TCXFileType } from "./types.js";
3
+ export interface ITCXPlugin extends IPlugin<TCXContext> {
4
+ }
5
+ export interface ITCXConverterPlugin extends IConverterPlugin<TCXContext> {
6
+ }
7
+ export interface ITCXMiddlewarePlugin extends IMiddlewarePlugin<TCXContext, TCXFileType> {
8
+ }
9
+ export declare abstract class BaseTCXConverter extends BaseConverter<TCXContext> implements ITCXConverterPlugin {
10
+ protected parseHeartRate(value: string | number | undefined): number | undefined;
11
+ protected parseTCXTime(value: string | undefined): Date | undefined;
12
+ protected parseDistance(value: string | number | undefined): number | undefined;
13
+ protected parseSpeed(value: string | number | undefined): number | undefined;
14
+ protected parseAltitude(value: string | number | undefined): number | undefined;
15
+ protected parseCoordinate(value: string | number | undefined): number | undefined;
16
+ }
17
+ export declare abstract class BaseTCXMiddleware extends BaseMiddleware<TCXContext, TCXFileType> implements ITCXMiddlewarePlugin {
18
+ onError(error: Error, context: TCXContext): Promise<void>;
19
+ }
@@ -0,0 +1,51 @@
1
+ import { TokenAST } from "../types.js";
2
+ import { BaseTCXConverter } from "./base.js";
3
+ import { TCXContext, ActivityType, ActivityLapType, TrackType, TrackpointType, PositionType, ActivityListType, MultiSportSessionType, AbstractSourceType } from "./types.js";
4
+ export declare class PositionConverter extends BaseTCXConverter {
5
+ name: string;
6
+ supportedTags: string[];
7
+ convert(ast: TokenAST, context: TCXContext): PositionType | undefined;
8
+ }
9
+ export declare class TrackpointConverter extends BaseTCXConverter {
10
+ name: string;
11
+ supportedTags: string[];
12
+ convert(ast: TokenAST, context: TCXContext): TrackpointType | undefined;
13
+ protected convertExtensions(extensionsAST: TokenAST): any;
14
+ protected convertExtensionContent(extension: TokenAST): any;
15
+ }
16
+ export declare class TrackConverter extends BaseTCXConverter {
17
+ name: string;
18
+ supportedTags: string[];
19
+ convert(ast: TokenAST, context: TCXContext): TrackType | undefined;
20
+ }
21
+ export declare class ActivityLapConverter extends BaseTCXConverter {
22
+ name: string;
23
+ supportedTags: string[];
24
+ convert(ast: TokenAST, context: TCXContext): ActivityLapType | undefined;
25
+ protected convertExtensions(extensionsAST: TokenAST): any;
26
+ protected convertExtensionContent(extension: TokenAST): any;
27
+ }
28
+ export declare class ActivityConverter extends BaseTCXConverter {
29
+ name: string;
30
+ supportedTags: string[];
31
+ convert(ast: TokenAST, context: TCXContext): ActivityType | undefined;
32
+ private convertTraining;
33
+ private convertCreator;
34
+ protected convertExtensions(extensionsAST: TokenAST): any;
35
+ protected convertExtensionContent(extension: TokenAST): any;
36
+ }
37
+ export declare class ActivityListConverter extends BaseTCXConverter {
38
+ name: string;
39
+ supportedTags: string[];
40
+ convert(ast: TokenAST, context: TCXContext): ActivityListType | undefined;
41
+ }
42
+ export declare class MultiSportSessionConverter extends BaseTCXConverter {
43
+ name: string;
44
+ supportedTags: string[];
45
+ convert(ast: TokenAST, context: TCXContext): MultiSportSessionType | undefined;
46
+ }
47
+ export declare class AbstractSourceConverter extends BaseTCXConverter {
48
+ name: string;
49
+ supportedTags: string[];
50
+ convert(ast: TokenAST, context: TCXContext): AbstractSourceType | undefined;
51
+ }
@@ -0,0 +1,33 @@
1
+ import { ExtensionsType, TokenAST } from "../types.js";
2
+ import { ITCXConverterPlugin, ITCXMiddlewarePlugin } from "./base.js";
3
+ import { TCXFileType } from "./types.js";
4
+ export declare class TCXDecoder {
5
+ private converterPlugins;
6
+ private registeredPlugins;
7
+ private middlewarePlugins;
8
+ private processors;
9
+ private initialized;
10
+ private defaultConvertersRegistered;
11
+ constructor();
12
+ private initializePipeline;
13
+ private registerDefaultConverters;
14
+ private addConverterForTag;
15
+ registerConverter(plugin: ITCXConverterPlugin): Promise<void>;
16
+ registerMiddleware(plugin: ITCXMiddlewarePlugin): Promise<void>;
17
+ getConverter(tag: string): ITCXConverterPlugin | undefined;
18
+ getAllConverters(tag: string): ITCXConverterPlugin[];
19
+ unregisterConverter(pluginName: string): void;
20
+ unregisterMiddleware(name: string): void;
21
+ initialize(): Promise<void>;
22
+ destroy(): Promise<void>;
23
+ private createContext;
24
+ private executeMiddlewareHook;
25
+ parseByBuffer(buffer: Buffer): Promise<TCXFileType | undefined>;
26
+ convertExtensions(extensionsAST: TokenAST): ExtensionsType;
27
+ parserByBuffer(buffer: Buffer): Promise<TCXFileType | undefined>;
28
+ parseByString(xmlContent: string): Promise<TCXFileType | undefined>;
29
+ }
30
+ declare const _default: {
31
+ TCXDecoder: typeof TCXDecoder;
32
+ };
33
+ export default _default;
@@ -0,0 +1,41 @@
1
+ import { TCXFileType } from "./types.js";
2
+ export declare class TCXEncoder {
3
+ private compact;
4
+ constructor(options?: {
5
+ compact?: boolean;
6
+ });
7
+ encode(tcxData: TCXFileType): Promise<Buffer>;
8
+ encodeToString(tcxData: TCXFileType): string;
9
+ private buildTCXXML;
10
+ private compressXML;
11
+ private buildXMLHeader;
12
+ private buildTCXContent;
13
+ private buildFolders;
14
+ private buildHistory;
15
+ private buildHistoryFolder;
16
+ private buildActivities;
17
+ private buildActivity;
18
+ private buildActivityLap;
19
+ private buildTrack;
20
+ private buildTrackpoint;
21
+ private buildPosition;
22
+ private buildCadence;
23
+ private buildMultiSportSession;
24
+ private buildFirstSport;
25
+ private buildNextSport;
26
+ private buildWorkouts;
27
+ private buildCourses;
28
+ private buildAuthor;
29
+ private buildExtensions;
30
+ private buildExtensionContent;
31
+ private formatTime;
32
+ private addOptionalElement;
33
+ private addOptionalNumericElement;
34
+ private isValidCoordinate;
35
+ private formatCoordinate;
36
+ private roundTo;
37
+ private escapeXML;
38
+ private escapeXMLAttribute;
39
+ private deepClone;
40
+ encoder(node: TCXFileType): Promise<Buffer>;
41
+ }
@@ -0,0 +1,13 @@
1
+ import { TCXDecoder } from "./decoder.js";
2
+ import { TCXEncoder } from "./encoder.js";
3
+ export { TCXDecoder } from "./decoder.js";
4
+ export { TCXEncoder } from "./encoder.js";
5
+ export { TCXFileType, TCXContext } from "./types.js";
6
+ export { AstGenerateProcessor, CompleteProcessor, ConvertProcessor, IPipelineProcessor, TokenizeProcessor, PipelineStage, } from "./processor.js";
7
+ export * from "./base.js";
8
+ export * from "./converters.js";
9
+ declare const _default: {
10
+ TCXDecoder: typeof TCXDecoder;
11
+ TCXEncoder: typeof TCXEncoder;
12
+ };
13
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import { Token, TokenAST } from "../types.js";
2
+ import { BaseTCXMiddleware } from "./base.js";
3
+ import { TCXContext } from "./types.js";
4
+ export declare class PerformanceMiddleware extends BaseTCXMiddleware {
5
+ name: string;
6
+ description: string;
7
+ onTokenize(tokens: Token[], context: TCXContext): Promise<Token[]>;
8
+ onAstGenerate(ast: TokenAST, context: TCXContext): Promise<TokenAST>;
9
+ onComplete(result: any, context: TCXContext): Promise<any>;
10
+ private countNodes;
11
+ }
12
+ export declare class ValidationMiddleware extends BaseTCXMiddleware {
13
+ name: string;
14
+ description: string;
15
+ onComplete(result: any, context: TCXContext): Promise<any>;
16
+ private validateGPX;
17
+ }
18
+ export declare function registerDefaultMiddlewares(decoder: any): Promise<void>;
@@ -0,0 +1,30 @@
1
+ import { TCXContext } from "./types.js";
2
+ export declare enum PipelineStage {
3
+ TOKENIZE = "tokenize",
4
+ AST_GENERATE = "ast_generate",
5
+ CONVERT = "convert",
6
+ COMPLETE = "complete"
7
+ }
8
+ export interface IPipelineProcessor {
9
+ stage: PipelineStage;
10
+ process(context: TCXContext): Promise<TCXContext>;
11
+ }
12
+ export declare class TokenizeProcessor implements IPipelineProcessor {
13
+ stage: PipelineStage;
14
+ process(context: TCXContext): Promise<TCXContext>;
15
+ }
16
+ export declare class AstGenerateProcessor implements IPipelineProcessor {
17
+ stage: PipelineStage;
18
+ process(context: TCXContext): Promise<TCXContext>;
19
+ }
20
+ export declare class ConvertProcessor implements IPipelineProcessor {
21
+ private getConverter;
22
+ stage: PipelineStage;
23
+ constructor(getConverter: (tag: string) => any);
24
+ process(context: TCXContext): Promise<TCXContext>;
25
+ private assignResult;
26
+ }
27
+ export declare class CompleteProcessor implements IPipelineProcessor {
28
+ stage: PipelineStage;
29
+ process(context: TCXContext): Promise<TCXContext>;
30
+ }