trackswap 0.0.2 → 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.
- package/README.md +322 -281
- package/dist/FIT/base.d.ts +0 -30
- package/dist/FIT/decoder.d.ts +0 -48
- package/dist/FIT/encoder.d.ts +0 -97
- package/dist/FIT/mesg.d.ts +0 -3
- package/dist/FIT/middleware.d.ts +0 -15
- package/dist/FIT/plugins.d.ts +0 -9
- package/dist/FIT/processor.d.ts +0 -24
- package/dist/FIT/types/mesg_num.d.ts +102 -102
- package/dist/FIT/types/sport.d.ts +44 -44
- package/dist/FIT/types.d.ts +0 -35
- package/dist/GPX/base.d.ts +0 -39
- package/dist/GPX/converters.d.ts +0 -30
- package/dist/GPX/decoder.d.ts +0 -66
- package/dist/GPX/encoder.d.ts +0 -109
- package/dist/GPX/middleware.d.ts +0 -9
- package/dist/GPX/processor.d.ts +0 -18
- package/dist/GPX/types.d.ts +0 -108
- package/dist/TCX/base.d.ts +0 -33
- package/dist/TCX/converters.d.ts +0 -24
- package/dist/TCX/decoder.d.ts +0 -54
- package/dist/TCX/encoder.d.ts +0 -109
- package/dist/TCX/index.d.ts +4 -1
- package/dist/TCX/middleware.d.ts +0 -9
- package/dist/TCX/processor.d.ts +0 -18
- package/dist/TCX/types.d.ts +0 -13
- package/dist/TrackSwap.d.ts +37 -33
- package/dist/core/base.d.ts +0 -46
- package/dist/core/xml-utils.d.ts +0 -24
- package/dist/index.js +24 -5
- package/dist/sport/base.d.ts +63 -0
- package/dist/sport/converters.d.ts +33 -0
- package/dist/sport/encoders.d.ts +34 -0
- package/dist/sport/index.d.ts +17 -0
- package/dist/sport/processor.d.ts +19 -0
- package/dist/types.d.ts +91 -13
- package/package.json +18 -3
- package/dist/FIT/base.js +0 -101
- package/dist/FIT/crc.js +0 -16
- package/dist/FIT/decoder.js +0 -323
- package/dist/FIT/encoder.js +0 -445
- package/dist/FIT/index.js +0 -13
- package/dist/FIT/mesg.js +0 -208
- package/dist/FIT/middleware.js +0 -206
- package/dist/FIT/plugins.js +0 -104
- package/dist/FIT/processor.js +0 -170
- package/dist/FIT/types/course_point.js +0 -58
- package/dist/FIT/types/event.js +0 -50
- package/dist/FIT/types/event_type.js +0 -19
- package/dist/FIT/types/file.js +0 -24
- package/dist/FIT/types/index.js +0 -297
- package/dist/FIT/types/mesg_num.js +0 -106
- package/dist/FIT/types/sport.js +0 -48
- package/dist/FIT/types.js +0 -1
- package/dist/FIT/util.js +0 -7
- package/dist/GPX/base.js +0 -56
- package/dist/GPX/converters.js +0 -352
- package/dist/GPX/decoder.js +0 -409
- package/dist/GPX/encoder.js +0 -513
- package/dist/GPX/extensions/index.js +0 -14
- package/dist/GPX/index.js +0 -11
- package/dist/GPX/middleware.js +0 -93
- package/dist/GPX/processor.js +0 -188
- package/dist/GPX/types.js +0 -1
- package/dist/GPX/util.js +0 -18
- package/dist/TCX/base.js +0 -62
- package/dist/TCX/converters.js +0 -333
- package/dist/TCX/decoder.js +0 -350
- package/dist/TCX/encoder.js +0 -513
- package/dist/TCX/index.js +0 -9
- package/dist/TCX/middleware.js +0 -93
- package/dist/TCX/processor.js +0 -197
- package/dist/TCX/types.js +0 -1
- package/dist/TrackSwap.js +0 -84
- package/dist/core/base.js +0 -138
- package/dist/core/decoder.d.ts +0 -66
- package/dist/core/decoder.js +0 -90
- package/dist/core/index.js +0 -4
- package/dist/core/processor.d.ts +0 -69
- package/dist/core/processor.js +0 -265
- package/dist/core/xml-utils.js +0 -140
- package/dist/types.js +0 -1
package/dist/GPX/types.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { DegreesType, ExtensionsType, LatitudeType, LongitudeType, Token, TokenAST } from "../types.js";
|
|
2
2
|
import { IProcessingContext } from "../core/base.js";
|
|
3
|
-
/**
|
|
4
|
-
* Two lat/lon pairs defining the extent of an element.
|
|
5
|
-
*/
|
|
6
3
|
export interface BoundsType {
|
|
7
4
|
minlat?: LatitudeType;
|
|
8
5
|
minlon?: LongitudeType;
|
|
@@ -23,27 +20,12 @@ export interface EmailType {
|
|
|
23
20
|
id?: string;
|
|
24
21
|
domain?: string;
|
|
25
22
|
}
|
|
26
|
-
/**
|
|
27
|
-
* 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
|
|
28
|
-
*/
|
|
29
23
|
type FixType = "none" | "2d" | "3d" | "dgps" | "pps" | string;
|
|
30
24
|
export type LinkType = {
|
|
31
|
-
/**
|
|
32
|
-
* URL of hyperlink.
|
|
33
|
-
*/
|
|
34
25
|
href?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Text of hyperlink.
|
|
37
|
-
*/
|
|
38
26
|
text?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Mime type of content (image/jpeg)
|
|
41
|
-
*/
|
|
42
27
|
type?: string;
|
|
43
28
|
};
|
|
44
|
-
/**
|
|
45
|
-
* GPX 1.1 version type
|
|
46
|
-
*/
|
|
47
29
|
export interface GPX11Type {
|
|
48
30
|
version?: string;
|
|
49
31
|
creator?: string;
|
|
@@ -61,9 +43,6 @@ export interface GPX11Type {
|
|
|
61
43
|
export interface MetadataType {
|
|
62
44
|
name?: string;
|
|
63
45
|
desc?: string;
|
|
64
|
-
/**
|
|
65
|
-
* The person or organization who created the GPX file.
|
|
66
|
-
*/
|
|
67
46
|
author?: PersonType;
|
|
68
47
|
copyright?: CopyrightType;
|
|
69
48
|
link?: LinkType[];
|
|
@@ -73,126 +52,39 @@ export interface MetadataType {
|
|
|
73
52
|
extensions?: ExtensionsType;
|
|
74
53
|
[key: string]: any;
|
|
75
54
|
}
|
|
76
|
-
/**
|
|
77
|
-
* A list of waypoints.
|
|
78
|
-
*/
|
|
79
55
|
export interface WptType {
|
|
80
56
|
lat: LatitudeType;
|
|
81
57
|
lon: LongitudeType;
|
|
82
|
-
/**
|
|
83
|
-
* Elevation (in meters) of the point.
|
|
84
|
-
*/
|
|
85
58
|
ele?: number;
|
|
86
|
-
/**
|
|
87
|
-
* 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.
|
|
88
|
-
*/
|
|
89
59
|
time?: Date;
|
|
90
|
-
/**
|
|
91
|
-
* Instantaneous speed at the point (meters per second)
|
|
92
|
-
*/
|
|
93
60
|
speed?: number;
|
|
94
|
-
/**
|
|
95
|
-
* Instantaneous course at the point (degrees, true north)
|
|
96
|
-
*/
|
|
97
61
|
course?: number;
|
|
98
|
-
/**
|
|
99
|
-
* Magnetic variation (in degrees) at the point
|
|
100
|
-
*/
|
|
101
62
|
magvar?: DegreesType;
|
|
102
|
-
/**
|
|
103
|
-
* Height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid. As defined in NMEA GGA message.
|
|
104
|
-
*/
|
|
105
63
|
geoidheight?: number;
|
|
106
|
-
/**
|
|
107
|
-
* 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.
|
|
108
|
-
*/
|
|
109
64
|
name?: string;
|
|
110
|
-
/**
|
|
111
|
-
* GPS waypoint comment. Sent to GPS as comment.
|
|
112
|
-
*/
|
|
113
65
|
cmt?: string;
|
|
114
|
-
/**
|
|
115
|
-
* A text description of the element. Holds additional information about the element intended for the user, not the GPS.
|
|
116
|
-
*/
|
|
117
66
|
desc?: string;
|
|
118
|
-
/**
|
|
119
|
-
* Source of data. Included to give user some idea of reliability and accuracy of data. "Garmin eTrex", "USGS quad Boston North", e.g.
|
|
120
|
-
*/
|
|
121
67
|
src?: string;
|
|
122
|
-
/**
|
|
123
|
-
* Link to additional information about the waypoint.
|
|
124
|
-
*/
|
|
125
68
|
link?: LinkType[];
|
|
126
|
-
/**
|
|
127
|
-
* 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.
|
|
128
|
-
*/
|
|
129
69
|
sym?: string;
|
|
130
|
-
/**
|
|
131
|
-
* Type (classification) of the waypoint.
|
|
132
|
-
*/
|
|
133
70
|
type?: string;
|
|
134
71
|
fix?: FixType;
|
|
135
|
-
/**
|
|
136
|
-
* Number of satellites used to calculate the GPX fix.
|
|
137
|
-
*/
|
|
138
72
|
sat?: string;
|
|
139
|
-
/**
|
|
140
|
-
* Horizontal dilution of precision.
|
|
141
|
-
*/
|
|
142
73
|
hdop?: number;
|
|
143
|
-
/**
|
|
144
|
-
* Vertical dilution of precision.
|
|
145
|
-
*/
|
|
146
74
|
vdop?: number;
|
|
147
|
-
/**
|
|
148
|
-
* Position dilution of precision.
|
|
149
|
-
*/
|
|
150
75
|
pdop?: number;
|
|
151
|
-
/**
|
|
152
|
-
* Number of seconds since last DGPS update.
|
|
153
|
-
*/
|
|
154
76
|
ageofdgpsdata?: number;
|
|
155
|
-
/**
|
|
156
|
-
* ID of DGPS station used in differential correction.
|
|
157
|
-
*/
|
|
158
77
|
dgpsid?: DegreesType;
|
|
159
|
-
/**
|
|
160
|
-
* You can add extend GPX by adding your own elements from another schema here.
|
|
161
|
-
*/
|
|
162
78
|
extensions?: ExtensionsType;
|
|
163
79
|
}
|
|
164
|
-
/**
|
|
165
|
-
* A list of route points.
|
|
166
|
-
*/
|
|
167
80
|
type RteptType = WptType;
|
|
168
81
|
export interface RteType {
|
|
169
|
-
/**
|
|
170
|
-
* GPS name of route.
|
|
171
|
-
*/
|
|
172
82
|
name?: string;
|
|
173
|
-
/**
|
|
174
|
-
* GPS comment for route.
|
|
175
|
-
*/
|
|
176
83
|
cmt?: string;
|
|
177
|
-
/**
|
|
178
|
-
* Text description of route for user. Not sent to GPS.
|
|
179
|
-
*/
|
|
180
84
|
desc?: string;
|
|
181
|
-
/**
|
|
182
|
-
* Source of data. Included to give user some idea of reliability and accuracy of data.
|
|
183
|
-
*/
|
|
184
85
|
src?: string;
|
|
185
|
-
/**
|
|
186
|
-
* Links to external information about the route.
|
|
187
|
-
*/
|
|
188
86
|
link?: LinkType[];
|
|
189
|
-
/**
|
|
190
|
-
* GPS route number.
|
|
191
|
-
*/
|
|
192
87
|
number?: number;
|
|
193
|
-
/**
|
|
194
|
-
* Type (classification) of route.
|
|
195
|
-
*/
|
|
196
88
|
type?: string;
|
|
197
89
|
extensions?: ExtensionsType;
|
|
198
90
|
rtept?: RteptType[];
|
package/dist/TCX/base.d.ts
CHANGED
|
@@ -1,52 +1,19 @@
|
|
|
1
1
|
import { IPlugin, IConverterPlugin, IMiddlewarePlugin, BaseConverter, BaseMiddleware } from "../core/base.js";
|
|
2
2
|
import { TCXContext, TCXFileType } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* TCX 插件接口(继承通用插件接口)
|
|
5
|
-
*/
|
|
6
3
|
export interface ITCXPlugin extends IPlugin<TCXContext> {
|
|
7
4
|
}
|
|
8
|
-
/**
|
|
9
|
-
* TCX 转换器插件接口(继承通用转换器接口)
|
|
10
|
-
*/
|
|
11
5
|
export interface ITCXConverterPlugin extends IConverterPlugin<TCXContext> {
|
|
12
6
|
}
|
|
13
|
-
/**
|
|
14
|
-
* TCX 中间件插件接口(继承通用中间件接口)
|
|
15
|
-
*/
|
|
16
7
|
export interface ITCXMiddlewarePlugin extends IMiddlewarePlugin<TCXContext, TCXFileType> {
|
|
17
8
|
}
|
|
18
|
-
/**
|
|
19
|
-
* TCX 基础转换器抽象类(继承通用基础转换器)
|
|
20
|
-
*/
|
|
21
9
|
export declare abstract class BaseTCXConverter extends BaseConverter<TCXContext> implements ITCXConverterPlugin {
|
|
22
|
-
/**
|
|
23
|
-
* 解析 TCX 心率值
|
|
24
|
-
*/
|
|
25
10
|
protected parseHeartRate(value: string | number | undefined): number | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* 解析 TCX 时间格式(ISO 8601)
|
|
28
|
-
*/
|
|
29
11
|
protected parseTCXTime(value: string | undefined): Date | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* 解析 TCX 距离值(米)
|
|
32
|
-
*/
|
|
33
12
|
protected parseDistance(value: string | number | undefined): number | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* 解析 TCX 速度值(m/s)
|
|
36
|
-
*/
|
|
37
13
|
protected parseSpeed(value: string | number | undefined): number | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* 解析 TCX 海拔值(米)
|
|
40
|
-
*/
|
|
41
14
|
protected parseAltitude(value: string | number | undefined): number | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* 解析 TCX 坐标值(纬度/经度)
|
|
44
|
-
*/
|
|
45
15
|
protected parseCoordinate(value: string | number | undefined): number | undefined;
|
|
46
16
|
}
|
|
47
|
-
/**
|
|
48
|
-
* TCX 基础中间件抽象类(继承通用基础中间件)
|
|
49
|
-
*/
|
|
50
17
|
export declare abstract class BaseTCXMiddleware extends BaseMiddleware<TCXContext, TCXFileType> implements ITCXMiddlewarePlugin {
|
|
51
18
|
onError(error: Error, context: TCXContext): Promise<void>;
|
|
52
19
|
}
|
package/dist/TCX/converters.d.ts
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import { TokenAST } from "../types.js";
|
|
2
2
|
import { BaseTCXConverter } from "./base.js";
|
|
3
3
|
import { TCXContext, ActivityType, ActivityLapType, TrackType, TrackpointType, PositionType, ActivityListType, MultiSportSessionType, AbstractSourceType } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* 位置转换器
|
|
6
|
-
*/
|
|
7
4
|
export declare class PositionConverter extends BaseTCXConverter {
|
|
8
5
|
name: string;
|
|
9
6
|
supportedTags: string[];
|
|
10
7
|
convert(ast: TokenAST, context: TCXContext): PositionType | undefined;
|
|
11
8
|
}
|
|
12
|
-
/**
|
|
13
|
-
* 轨迹点转换器
|
|
14
|
-
*/
|
|
15
9
|
export declare class TrackpointConverter extends BaseTCXConverter {
|
|
16
10
|
name: string;
|
|
17
11
|
supportedTags: string[];
|
|
@@ -19,17 +13,11 @@ export declare class TrackpointConverter extends BaseTCXConverter {
|
|
|
19
13
|
protected convertExtensions(extensionsAST: TokenAST): any;
|
|
20
14
|
protected convertExtensionContent(extension: TokenAST): any;
|
|
21
15
|
}
|
|
22
|
-
/**
|
|
23
|
-
* 轨迹转换器
|
|
24
|
-
*/
|
|
25
16
|
export declare class TrackConverter extends BaseTCXConverter {
|
|
26
17
|
name: string;
|
|
27
18
|
supportedTags: string[];
|
|
28
19
|
convert(ast: TokenAST, context: TCXContext): TrackType | undefined;
|
|
29
20
|
}
|
|
30
|
-
/**
|
|
31
|
-
* 活动圈数转换器
|
|
32
|
-
*/
|
|
33
21
|
export declare class ActivityLapConverter extends BaseTCXConverter {
|
|
34
22
|
name: string;
|
|
35
23
|
supportedTags: string[];
|
|
@@ -37,9 +25,6 @@ export declare class ActivityLapConverter extends BaseTCXConverter {
|
|
|
37
25
|
protected convertExtensions(extensionsAST: TokenAST): any;
|
|
38
26
|
protected convertExtensionContent(extension: TokenAST): any;
|
|
39
27
|
}
|
|
40
|
-
/**
|
|
41
|
-
* 活动转换器
|
|
42
|
-
*/
|
|
43
28
|
export declare class ActivityConverter extends BaseTCXConverter {
|
|
44
29
|
name: string;
|
|
45
30
|
supportedTags: string[];
|
|
@@ -49,25 +34,16 @@ export declare class ActivityConverter extends BaseTCXConverter {
|
|
|
49
34
|
protected convertExtensions(extensionsAST: TokenAST): any;
|
|
50
35
|
protected convertExtensionContent(extension: TokenAST): any;
|
|
51
36
|
}
|
|
52
|
-
/**
|
|
53
|
-
* 活动列表转换器
|
|
54
|
-
*/
|
|
55
37
|
export declare class ActivityListConverter extends BaseTCXConverter {
|
|
56
38
|
name: string;
|
|
57
39
|
supportedTags: string[];
|
|
58
40
|
convert(ast: TokenAST, context: TCXContext): ActivityListType | undefined;
|
|
59
41
|
}
|
|
60
|
-
/**
|
|
61
|
-
* 多运动会话转换器
|
|
62
|
-
*/
|
|
63
42
|
export declare class MultiSportSessionConverter extends BaseTCXConverter {
|
|
64
43
|
name: string;
|
|
65
44
|
supportedTags: string[];
|
|
66
45
|
convert(ast: TokenAST, context: TCXContext): MultiSportSessionType | undefined;
|
|
67
46
|
}
|
|
68
|
-
/**
|
|
69
|
-
* 抽象来源转换器
|
|
70
|
-
*/
|
|
71
47
|
export declare class AbstractSourceConverter extends BaseTCXConverter {
|
|
72
48
|
name: string;
|
|
73
49
|
supportedTags: string[];
|
package/dist/TCX/decoder.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
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
|
-
*/
|
|
7
4
|
export declare class TCXDecoder {
|
|
8
5
|
private converterPlugins;
|
|
9
6
|
private registeredPlugins;
|
|
@@ -12,73 +9,22 @@ export declare class TCXDecoder {
|
|
|
12
9
|
private initialized;
|
|
13
10
|
private defaultConvertersRegistered;
|
|
14
11
|
constructor();
|
|
15
|
-
/**
|
|
16
|
-
* 初始化流水线 - 注册固定的核心处理器
|
|
17
|
-
*/
|
|
18
12
|
private initializePipeline;
|
|
19
|
-
/**
|
|
20
|
-
* 自动注册默认转换器 - 处理标准TCX标签
|
|
21
|
-
*/
|
|
22
13
|
private registerDefaultConverters;
|
|
23
|
-
/**
|
|
24
|
-
* 为指定标签添加转换器,按优先级排序
|
|
25
|
-
*/
|
|
26
14
|
private addConverterForTag;
|
|
27
|
-
/**
|
|
28
|
-
* 注册转换器插件
|
|
29
|
-
*/
|
|
30
15
|
registerConverter(plugin: ITCXConverterPlugin): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* 注册中间件插件 - 真正的扩展点
|
|
33
|
-
*/
|
|
34
16
|
registerMiddleware(plugin: ITCXMiddlewarePlugin): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* 获取转换器(返回优先级最高的)
|
|
37
|
-
*/
|
|
38
17
|
getConverter(tag: string): ITCXConverterPlugin | undefined;
|
|
39
|
-
/**
|
|
40
|
-
* 获取指定标签的所有转换器(按优先级排序)
|
|
41
|
-
*/
|
|
42
18
|
getAllConverters(tag: string): ITCXConverterPlugin[];
|
|
43
|
-
/**
|
|
44
|
-
* 移除转换器
|
|
45
|
-
*/
|
|
46
19
|
unregisterConverter(pluginName: string): void;
|
|
47
|
-
/**
|
|
48
|
-
* 移除中间件
|
|
49
|
-
*/
|
|
50
20
|
unregisterMiddleware(name: string): void;
|
|
51
|
-
/**
|
|
52
|
-
* 初始化解码器
|
|
53
|
-
*/
|
|
54
21
|
initialize(): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* 销毁解码器
|
|
57
|
-
*/
|
|
58
22
|
destroy(): Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* 创建解码上下文
|
|
61
|
-
*/
|
|
62
23
|
private createContext;
|
|
63
|
-
/**
|
|
64
|
-
* 执行中间件钩子
|
|
65
|
-
*/
|
|
66
24
|
private executeMiddlewareHook;
|
|
67
|
-
/**
|
|
68
|
-
* 主解析方法 - 固定的流水线 + 灵活的中间件
|
|
69
|
-
*/
|
|
70
25
|
parseByBuffer(buffer: Buffer): Promise<TCXFileType | undefined>;
|
|
71
|
-
/**
|
|
72
|
-
* 转换Extensions(向后兼容)
|
|
73
|
-
*/
|
|
74
26
|
convertExtensions(extensionsAST: TokenAST): ExtensionsType;
|
|
75
|
-
/**
|
|
76
|
-
* @deprecated 使用 parseByBuffer 替代
|
|
77
|
-
*/
|
|
78
27
|
parserByBuffer(buffer: Buffer): Promise<TCXFileType | undefined>;
|
|
79
|
-
/**
|
|
80
|
-
* @deprecated 使用新的插件系统替代
|
|
81
|
-
*/
|
|
82
28
|
parseByString(xmlContent: string): Promise<TCXFileType | undefined>;
|
|
83
29
|
}
|
|
84
30
|
declare const _default: {
|
package/dist/TCX/encoder.d.ts
CHANGED
|
@@ -1,150 +1,41 @@
|
|
|
1
1
|
import { TCXFileType } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* TCX 编码器 - 将 TCXFileType 数据编码为 TCX XML 格式
|
|
4
|
-
*/
|
|
5
2
|
export declare class TCXEncoder {
|
|
6
3
|
private compact;
|
|
7
|
-
/**
|
|
8
|
-
* 构造函数
|
|
9
|
-
* @param options 编码器选项
|
|
10
|
-
*/
|
|
11
4
|
constructor(options?: {
|
|
12
5
|
compact?: boolean;
|
|
13
6
|
});
|
|
14
|
-
/**
|
|
15
|
-
* 编码 TCX 数据为 Buffer
|
|
16
|
-
*/
|
|
17
7
|
encode(tcxData: TCXFileType): Promise<Buffer>;
|
|
18
|
-
/**
|
|
19
|
-
* 编码 TCX 数据为 XML 字符串
|
|
20
|
-
*/
|
|
21
8
|
encodeToString(tcxData: TCXFileType): string;
|
|
22
|
-
/**
|
|
23
|
-
* 构建完整的 TCX XML
|
|
24
|
-
*/
|
|
25
9
|
private buildTCXXML;
|
|
26
|
-
/**
|
|
27
|
-
* 压缩XML字符串,去掉多余的换行和空格
|
|
28
|
-
*/
|
|
29
10
|
private compressXML;
|
|
30
|
-
/**
|
|
31
|
-
* 构建 XML 头部
|
|
32
|
-
*/
|
|
33
11
|
private buildXMLHeader;
|
|
34
|
-
/**
|
|
35
|
-
* 构建 TCX 内容
|
|
36
|
-
*/
|
|
37
12
|
private buildTCXContent;
|
|
38
|
-
/**
|
|
39
|
-
* 构建 Folders 元素
|
|
40
|
-
*/
|
|
41
13
|
private buildFolders;
|
|
42
|
-
/**
|
|
43
|
-
* 构建 History 元素
|
|
44
|
-
*/
|
|
45
14
|
private buildHistory;
|
|
46
|
-
/**
|
|
47
|
-
* 构建 HistoryFolder 元素
|
|
48
|
-
*/
|
|
49
15
|
private buildHistoryFolder;
|
|
50
|
-
/**
|
|
51
|
-
* 构建 Activities 元素
|
|
52
|
-
*/
|
|
53
16
|
private buildActivities;
|
|
54
|
-
/**
|
|
55
|
-
* 构建单个 Activity 元素
|
|
56
|
-
*/
|
|
57
17
|
private buildActivity;
|
|
58
|
-
/**
|
|
59
|
-
* 构建 ActivityLap 元素
|
|
60
|
-
*/
|
|
61
18
|
private buildActivityLap;
|
|
62
|
-
/**
|
|
63
|
-
* 构建 Track 元素
|
|
64
|
-
*/
|
|
65
19
|
private buildTrack;
|
|
66
|
-
/**
|
|
67
|
-
* 构建 Trackpoint 元素
|
|
68
|
-
*/
|
|
69
20
|
private buildTrackpoint;
|
|
70
|
-
/**
|
|
71
|
-
* 构建 Position 元素
|
|
72
|
-
*/
|
|
73
21
|
private buildPosition;
|
|
74
|
-
/**
|
|
75
|
-
* 构建 Cadence 元素
|
|
76
|
-
*/
|
|
77
22
|
private buildCadence;
|
|
78
|
-
/**
|
|
79
|
-
* 构建 MultiSportSession 元素
|
|
80
|
-
*/
|
|
81
23
|
private buildMultiSportSession;
|
|
82
|
-
/**
|
|
83
|
-
* 构建 FirstSport 元素
|
|
84
|
-
*/
|
|
85
24
|
private buildFirstSport;
|
|
86
|
-
/**
|
|
87
|
-
* 构建 NextSport 元素
|
|
88
|
-
*/
|
|
89
25
|
private buildNextSport;
|
|
90
|
-
/**
|
|
91
|
-
* 构建 Workouts 元素
|
|
92
|
-
*/
|
|
93
26
|
private buildWorkouts;
|
|
94
|
-
/**
|
|
95
|
-
* 构建 Courses 元素
|
|
96
|
-
*/
|
|
97
27
|
private buildCourses;
|
|
98
|
-
/**
|
|
99
|
-
* 构建 Author 元素
|
|
100
|
-
*/
|
|
101
28
|
private buildAuthor;
|
|
102
|
-
/**
|
|
103
|
-
* 构建扩展元素
|
|
104
|
-
*/
|
|
105
29
|
private buildExtensions;
|
|
106
|
-
/**
|
|
107
|
-
* 递归构建扩展内容
|
|
108
|
-
*/
|
|
109
30
|
private buildExtensionContent;
|
|
110
|
-
/**
|
|
111
|
-
* 格式化时间
|
|
112
|
-
*/
|
|
113
31
|
private formatTime;
|
|
114
|
-
/**
|
|
115
|
-
* 添加可选元素
|
|
116
|
-
*/
|
|
117
32
|
private addOptionalElement;
|
|
118
|
-
/**
|
|
119
|
-
* 添加可选数值元素
|
|
120
|
-
*/
|
|
121
33
|
private addOptionalNumericElement;
|
|
122
|
-
/**
|
|
123
|
-
* 验证坐标有效性
|
|
124
|
-
*/
|
|
125
34
|
private isValidCoordinate;
|
|
126
|
-
/**
|
|
127
|
-
* 格式化坐标
|
|
128
|
-
*/
|
|
129
35
|
private formatCoordinate;
|
|
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: TCXFileType): Promise<Buffer>;
|
|
150
41
|
}
|
package/dist/TCX/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { TCXDecoder } from "./decoder.js";
|
|
2
|
+
import { TCXEncoder } from "./encoder.js";
|
|
1
3
|
export { TCXDecoder } from "./decoder.js";
|
|
4
|
+
export { TCXEncoder } from "./encoder.js";
|
|
2
5
|
export { TCXFileType, TCXContext } from "./types.js";
|
|
3
6
|
export { AstGenerateProcessor, CompleteProcessor, ConvertProcessor, IPipelineProcessor, TokenizeProcessor, PipelineStage, } from "./processor.js";
|
|
4
7
|
export * from "./base.js";
|
|
5
8
|
export * from "./converters.js";
|
|
6
|
-
import { TCXDecoder } from "./decoder.js";
|
|
7
9
|
declare const _default: {
|
|
8
10
|
TCXDecoder: typeof TCXDecoder;
|
|
11
|
+
TCXEncoder: typeof TCXEncoder;
|
|
9
12
|
};
|
|
10
13
|
export default _default;
|
package/dist/TCX/middleware.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { Token, TokenAST } from "../types.js";
|
|
2
2
|
import { BaseTCXMiddleware } from "./base.js";
|
|
3
3
|
import { TCXContext } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* 性能监控中间件
|
|
6
|
-
*/
|
|
7
4
|
export declare class PerformanceMiddleware extends BaseTCXMiddleware {
|
|
8
5
|
name: string;
|
|
9
6
|
description: string;
|
|
@@ -12,16 +9,10 @@ export declare class PerformanceMiddleware extends BaseTCXMiddleware {
|
|
|
12
9
|
onComplete(result: any, context: TCXContext): Promise<any>;
|
|
13
10
|
private countNodes;
|
|
14
11
|
}
|
|
15
|
-
/**
|
|
16
|
-
* 验证中间件
|
|
17
|
-
*/
|
|
18
12
|
export declare class ValidationMiddleware extends BaseTCXMiddleware {
|
|
19
13
|
name: string;
|
|
20
14
|
description: string;
|
|
21
15
|
onComplete(result: any, context: TCXContext): Promise<any>;
|
|
22
16
|
private validateGPX;
|
|
23
17
|
}
|
|
24
|
-
/**
|
|
25
|
-
* 注册所有默认中间件
|
|
26
|
-
*/
|
|
27
18
|
export declare function registerDefaultMiddlewares(decoder: any): Promise<void>;
|
package/dist/TCX/processor.d.ts
CHANGED
|
@@ -1,37 +1,22 @@
|
|
|
1
1
|
import { TCXContext } 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: TCXContext): Promise<TCXContext>;
|
|
17
11
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Tokenize处理器,将XML转为Token
|
|
20
|
-
*/
|
|
21
12
|
export declare class TokenizeProcessor implements IPipelineProcessor {
|
|
22
13
|
stage: PipelineStage;
|
|
23
14
|
process(context: TCXContext): Promise<TCXContext>;
|
|
24
15
|
}
|
|
25
|
-
/**
|
|
26
|
-
* AST生成处理器
|
|
27
|
-
*/
|
|
28
16
|
export declare class AstGenerateProcessor implements IPipelineProcessor {
|
|
29
17
|
stage: PipelineStage;
|
|
30
18
|
process(context: TCXContext): Promise<TCXContext>;
|
|
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: TCXContext): Promise<TCXContext>;
|
|
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: TCXContext): Promise<TCXContext>;
|
package/dist/TCX/types.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { ExtensionsType, Token, TokenAST } from "../types.js";
|
|
2
2
|
import { IProcessingContext } from "../core/base.js";
|
|
3
|
-
/**
|
|
4
|
-
* TCX 文件类型
|
|
5
|
-
*/
|
|
6
3
|
export interface TCXFileType {
|
|
7
4
|
version?: string;
|
|
8
5
|
creator?: string;
|
|
@@ -139,10 +136,6 @@ export interface ActivityLapType {
|
|
|
139
136
|
Extensions?: any;
|
|
140
137
|
}
|
|
141
138
|
export type TriggerMethodType = "Manual" | "Distance" | "Location" | "Time" | "HeartRate";
|
|
142
|
-
/**
|
|
143
|
-
* Active(高强度)
|
|
144
|
-
* Resting(低强度)
|
|
145
|
-
*/
|
|
146
139
|
export type IntensityType = "Active" | "Resting";
|
|
147
140
|
export interface CadenceType {
|
|
148
141
|
Low: number;
|
|
@@ -160,9 +153,6 @@ export interface MultiSportSessionType {
|
|
|
160
153
|
export interface FirstSportType {
|
|
161
154
|
Activity?: ActivityType;
|
|
162
155
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Each sport contains an optional transition and a run.
|
|
165
|
-
*/
|
|
166
156
|
export interface NextSportType {
|
|
167
157
|
Transition?: ActivityLapType;
|
|
168
158
|
Activity?: ActivityType;
|
|
@@ -184,9 +174,6 @@ export interface PositionType {
|
|
|
184
174
|
LatitudeDegrees?: string;
|
|
185
175
|
LongitudeDegrees?: string;
|
|
186
176
|
}
|
|
187
|
-
/**
|
|
188
|
-
* TCX 解码上下文
|
|
189
|
-
*/
|
|
190
177
|
export interface TCXContext extends IProcessingContext {
|
|
191
178
|
rawData?: Buffer;
|
|
192
179
|
xmlContent?: string;
|