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
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
export declare enum Sport {
|
|
2
|
-
GENERIC = 0
|
|
3
|
-
RUNNING = 1
|
|
4
|
-
CYCLING = 2
|
|
5
|
-
TRANSITION = 3
|
|
6
|
-
FITNESS_EQUIPMENT = 4
|
|
7
|
-
SWIMMING = 5
|
|
8
|
-
BASKETBALL = 6
|
|
9
|
-
SOCCER = 7
|
|
10
|
-
TENNIS = 8
|
|
11
|
-
AMERICAN_FOOTBALL = 9
|
|
12
|
-
TRAINING = 10
|
|
13
|
-
WALKING = 11
|
|
14
|
-
CROSS_COUNTRY_SKIING = 12
|
|
15
|
-
ALPINE_SKIING = 13
|
|
16
|
-
SNOWBOARDING = 14
|
|
17
|
-
ROWING = 15
|
|
18
|
-
MOUNTAINEERING = 16
|
|
19
|
-
HIKING = 17
|
|
20
|
-
MULTISPORT = 18
|
|
21
|
-
PADDLING = 19
|
|
22
|
-
FLYING = 20
|
|
23
|
-
E_BIKING = 21
|
|
24
|
-
MOTORCYCLING = 22
|
|
25
|
-
BOATING = 23
|
|
26
|
-
DRIVING = 24
|
|
27
|
-
GOLF = 25
|
|
28
|
-
HANG_GLIDING = 26
|
|
29
|
-
HORSEBACK_RIDING = 27
|
|
30
|
-
HUNTING = 28
|
|
31
|
-
FISHING = 29
|
|
32
|
-
INLINE_SKATING = 30
|
|
33
|
-
ROCK_CLIMBING = 31
|
|
34
|
-
SAILING = 32
|
|
35
|
-
ICE_SKATING = 33
|
|
36
|
-
SKY_DIVING = 34
|
|
37
|
-
SNOWSHOEING = 35
|
|
38
|
-
SNOWMOBILING = 36
|
|
39
|
-
STAND_UP_PADDLEBOARDING = 37
|
|
40
|
-
SURFING = 38
|
|
41
|
-
WAKEBOARDING = 39
|
|
42
|
-
WATER_SKIING = 40
|
|
43
|
-
YOGA = 41
|
|
44
|
-
PILATES = 42
|
|
45
|
-
CALISTHENICS = 43
|
|
2
|
+
GENERIC = 0,
|
|
3
|
+
RUNNING = 1,
|
|
4
|
+
CYCLING = 2,
|
|
5
|
+
TRANSITION = 3,
|
|
6
|
+
FITNESS_EQUIPMENT = 4,
|
|
7
|
+
SWIMMING = 5,
|
|
8
|
+
BASKETBALL = 6,
|
|
9
|
+
SOCCER = 7,
|
|
10
|
+
TENNIS = 8,
|
|
11
|
+
AMERICAN_FOOTBALL = 9,
|
|
12
|
+
TRAINING = 10,
|
|
13
|
+
WALKING = 11,
|
|
14
|
+
CROSS_COUNTRY_SKIING = 12,
|
|
15
|
+
ALPINE_SKIING = 13,
|
|
16
|
+
SNOWBOARDING = 14,
|
|
17
|
+
ROWING = 15,
|
|
18
|
+
MOUNTAINEERING = 16,
|
|
19
|
+
HIKING = 17,
|
|
20
|
+
MULTISPORT = 18,
|
|
21
|
+
PADDLING = 19,
|
|
22
|
+
FLYING = 20,
|
|
23
|
+
E_BIKING = 21,
|
|
24
|
+
MOTORCYCLING = 22,
|
|
25
|
+
BOATING = 23,
|
|
26
|
+
DRIVING = 24,
|
|
27
|
+
GOLF = 25,
|
|
28
|
+
HANG_GLIDING = 26,
|
|
29
|
+
HORSEBACK_RIDING = 27,
|
|
30
|
+
HUNTING = 28,
|
|
31
|
+
FISHING = 29,
|
|
32
|
+
INLINE_SKATING = 30,
|
|
33
|
+
ROCK_CLIMBING = 31,
|
|
34
|
+
SAILING = 32,
|
|
35
|
+
ICE_SKATING = 33,
|
|
36
|
+
SKY_DIVING = 34,
|
|
37
|
+
SNOWSHOEING = 35,
|
|
38
|
+
SNOWMOBILING = 36,
|
|
39
|
+
STAND_UP_PADDLEBOARDING = 37,
|
|
40
|
+
SURFING = 38,
|
|
41
|
+
WAKEBOARDING = 39,
|
|
42
|
+
WATER_SKIING = 40,
|
|
43
|
+
YOGA = 41,
|
|
44
|
+
PILATES = 42,
|
|
45
|
+
CALISTHENICS = 43,
|
|
46
46
|
ALL = 254
|
|
47
47
|
}
|
package/dist/FIT/types.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { IProcessingContext } from "../core/base.js";
|
|
2
|
-
/**
|
|
3
|
-
* Session 对应 AbstractTrackType Lap 对应 RouteSegType Records 对应 RouteType 每个Record 对应 PointType
|
|
4
|
-
*/
|
|
5
2
|
export interface FITFileType {
|
|
6
3
|
fileIdMesgs?: FileIdMesgType[];
|
|
7
4
|
fileCreatorMesgs?: FileCreatorMesgType[];
|
|
@@ -62,9 +59,6 @@ export interface DeviceSettingsMesgType {
|
|
|
62
59
|
timeZoneOffset?: number;
|
|
63
60
|
backlightMode?: string;
|
|
64
61
|
}
|
|
65
|
-
/**
|
|
66
|
-
* FIT userProfileMesg
|
|
67
|
-
*/
|
|
68
62
|
export interface UserProfileMesgType {
|
|
69
63
|
friendlyName?: string;
|
|
70
64
|
weight?: number;
|
|
@@ -84,17 +78,8 @@ export interface UserProfileMesgType {
|
|
|
84
78
|
positionSetting?: string;
|
|
85
79
|
temperatureSetting?: string;
|
|
86
80
|
}
|
|
87
|
-
/**
|
|
88
|
-
* FIT SessionMesg
|
|
89
|
-
*/
|
|
90
81
|
export interface SessionMesgType {
|
|
91
|
-
/**
|
|
92
|
-
* 时间
|
|
93
|
-
*/
|
|
94
82
|
timestamp?: string;
|
|
95
|
-
/**
|
|
96
|
-
* 开始时间
|
|
97
|
-
*/
|
|
98
83
|
startTime?: string;
|
|
99
84
|
startPositionLat?: number;
|
|
100
85
|
startPositionLong?: number;
|
|
@@ -114,13 +99,7 @@ export interface SessionMesgType {
|
|
|
114
99
|
maxSpeed?: number;
|
|
115
100
|
avgPower?: number;
|
|
116
101
|
maxPower?: number;
|
|
117
|
-
/**
|
|
118
|
-
* 总爬升
|
|
119
|
-
*/
|
|
120
102
|
totalAscent?: number;
|
|
121
|
-
/**
|
|
122
|
-
* 总下降
|
|
123
|
-
*/
|
|
124
103
|
totalDescent?: number;
|
|
125
104
|
firstLapIndex?: number;
|
|
126
105
|
numLaps?: number;
|
|
@@ -140,9 +119,6 @@ export interface SessionMesgType {
|
|
|
140
119
|
enhancedMaxSpeed?: number;
|
|
141
120
|
lapMesgs?: LapMesgType[];
|
|
142
121
|
}
|
|
143
|
-
/**
|
|
144
|
-
* FIT RecordMesg
|
|
145
|
-
*/
|
|
146
122
|
export interface RecordMesgType {
|
|
147
123
|
timestamp?: string;
|
|
148
124
|
positionLat?: number;
|
|
@@ -159,9 +135,6 @@ export interface RecordMesgType {
|
|
|
159
135
|
enhancedSpeed?: number;
|
|
160
136
|
[key: string]: number | string | undefined | any;
|
|
161
137
|
}
|
|
162
|
-
/**
|
|
163
|
-
* FIT 文件额外记录的数据 LapMesg
|
|
164
|
-
*/
|
|
165
138
|
export interface LapMesgType {
|
|
166
139
|
timestamp?: string;
|
|
167
140
|
startTime?: string;
|
|
@@ -204,23 +177,15 @@ export interface ActivityMesgType {
|
|
|
204
177
|
eventType?: string;
|
|
205
178
|
[key: string]: number | string | undefined | any;
|
|
206
179
|
}
|
|
207
|
-
/**
|
|
208
|
-
* FIT 消息处理上下文
|
|
209
|
-
*/
|
|
210
180
|
export interface FITContext extends IProcessingContext {
|
|
211
|
-
/** 原始二进制数据 */
|
|
212
181
|
rawData?: Buffer;
|
|
213
|
-
/** FIT SDK 解析的原始消息 */
|
|
214
182
|
rawMessages?: FITDecoderMesgs;
|
|
215
|
-
/** 最终结果 */
|
|
216
183
|
result?: FITFileType;
|
|
217
|
-
/** FIT 文件头信息 */
|
|
218
184
|
fileHeader?: {
|
|
219
185
|
type?: string;
|
|
220
186
|
manufacturer?: string;
|
|
221
187
|
product?: number;
|
|
222
188
|
};
|
|
223
|
-
/** FIT 特定的性能统计 */
|
|
224
189
|
performance: {
|
|
225
190
|
startTime: number;
|
|
226
191
|
parseTime?: number;
|
package/dist/GPX/base.d.ts
CHANGED
|
@@ -1,60 +1,21 @@
|
|
|
1
1
|
import { IPlugin as ICorePlugin, IConverterPlugin as ICoreConverterPlugin, IMiddlewarePlugin as ICoreMiddlewarePlugin, BaseConverter as CoreBaseConverter, BaseMiddleware as CoreBaseMiddleware } from "../core/base.js";
|
|
2
2
|
import { DecoderContext, GPX11Type } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* GPX 插件接口(继承通用插件接口)
|
|
5
|
-
*/
|
|
6
3
|
export interface IGPXPlugin extends ICorePlugin<DecoderContext> {
|
|
7
4
|
}
|
|
8
|
-
/**
|
|
9
|
-
* GPX 转换器插件接口(继承通用转换器接口)
|
|
10
|
-
*/
|
|
11
5
|
export interface IGPXConverterPlugin extends ICoreConverterPlugin<DecoderContext> {
|
|
12
6
|
}
|
|
13
|
-
/**
|
|
14
|
-
* GPX 中间件插件接口(继承通用中间件接口)
|
|
15
|
-
*/
|
|
16
7
|
export interface IGPXMiddlewarePlugin extends ICoreMiddlewarePlugin<DecoderContext, GPX11Type> {
|
|
17
8
|
}
|
|
18
|
-
/**
|
|
19
|
-
* GPX 基础转换器抽象类(继承通用基础转换器)
|
|
20
|
-
*/
|
|
21
9
|
export declare abstract class BaseGPXConverter extends CoreBaseConverter<DecoderContext> implements IGPXConverterPlugin {
|
|
22
|
-
/**
|
|
23
|
-
* 解析 GPX 坐标值(经纬度)
|
|
24
|
-
*/
|
|
25
10
|
protected parseCoordinate(value: string | number | undefined): number | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* 解析 GPX 时间格式
|
|
28
|
-
*/
|
|
29
11
|
protected parseGPXTime(value: string | undefined): Date | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* 提取数值属性(GPX 常用的处理方式)
|
|
32
|
-
*/
|
|
33
12
|
protected extractNumericAttributes<U extends Record<string, any>>(ast: any, target: U, mapping: Record<string, keyof U>): void;
|
|
34
13
|
}
|
|
35
|
-
/**
|
|
36
|
-
* GPX 基础中间件抽象类(继承通用基础中间件)
|
|
37
|
-
*/
|
|
38
14
|
export declare abstract class BaseGPXMiddleware extends CoreBaseMiddleware<DecoderContext, GPX11Type> implements IGPXMiddlewarePlugin {
|
|
39
15
|
onError(error: Error, context: DecoderContext): Promise<void>;
|
|
40
16
|
}
|
|
41
|
-
/**
|
|
42
|
-
* @deprecated 使用 IGPXPlugin 替代
|
|
43
|
-
*/
|
|
44
17
|
export type IPlugin = IGPXPlugin;
|
|
45
|
-
/**
|
|
46
|
-
* @deprecated 使用 IGPXConverterPlugin 替代
|
|
47
|
-
*/
|
|
48
18
|
export type IConverterPlugin = IGPXConverterPlugin;
|
|
49
|
-
/**
|
|
50
|
-
* @deprecated 使用 IGPXMiddlewarePlugin 替代
|
|
51
|
-
*/
|
|
52
19
|
export type IMiddlewarePlugin = IGPXMiddlewarePlugin;
|
|
53
|
-
/**
|
|
54
|
-
* @deprecated 使用 BaseGPXConverter 替代
|
|
55
|
-
*/
|
|
56
20
|
export declare const BaseConverter: typeof BaseGPXConverter;
|
|
57
|
-
/**
|
|
58
|
-
* @deprecated 使用 BaseGPXMiddleware 替代
|
|
59
|
-
*/
|
|
60
21
|
export declare const BaseMiddleware: typeof BaseGPXMiddleware;
|
package/dist/GPX/converters.d.ts
CHANGED
|
@@ -1,82 +1,52 @@
|
|
|
1
1
|
import { BaseGPXConverter } from "./base.js";
|
|
2
2
|
import { TokenAST } from "../types.js";
|
|
3
3
|
import { BoundsType, CopyrightType, EmailType, LinkType, MetadataType, PersonType, RteType, TrksegType, TrkType, WptType, DecoderContext } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* WPT转换器
|
|
6
|
-
*/
|
|
7
4
|
export declare class WptConverter extends BaseGPXConverter {
|
|
8
5
|
name: string;
|
|
9
6
|
supportedTags: string[];
|
|
10
7
|
version: string;
|
|
11
8
|
convert(ast: TokenAST, context: DecoderContext): WptType | undefined;
|
|
12
9
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Route转换器
|
|
15
|
-
*/
|
|
16
10
|
export declare class RteConverter extends BaseGPXConverter {
|
|
17
11
|
name: string;
|
|
18
12
|
supportedTags: string[];
|
|
19
13
|
convert(ast: TokenAST, context: DecoderContext): RteType | undefined;
|
|
20
14
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Track转换器
|
|
23
|
-
*/
|
|
24
15
|
export declare class TrkConverter extends BaseGPXConverter {
|
|
25
16
|
name: string;
|
|
26
17
|
supportedTags: string[];
|
|
27
18
|
convert(ast: TokenAST, context: DecoderContext): TrkType | undefined;
|
|
28
19
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Track Segment转换器
|
|
31
|
-
*/
|
|
32
20
|
export declare class TrksegConverter extends BaseGPXConverter {
|
|
33
21
|
name: string;
|
|
34
22
|
supportedTags: string[];
|
|
35
23
|
convert(ast: TokenAST, context: DecoderContext): TrksegType | undefined;
|
|
36
24
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Link转换器
|
|
39
|
-
*/
|
|
40
25
|
export declare class LinkConverter extends BaseGPXConverter {
|
|
41
26
|
name: string;
|
|
42
27
|
supportedTags: string[];
|
|
43
28
|
convert(ast: TokenAST, context: DecoderContext): LinkType | undefined;
|
|
44
29
|
}
|
|
45
|
-
/**
|
|
46
|
-
* Metadata转换器
|
|
47
|
-
*/
|
|
48
30
|
export declare class MetadataConverter extends BaseGPXConverter {
|
|
49
31
|
name: string;
|
|
50
32
|
supportedTags: string[];
|
|
51
33
|
convert(ast: TokenAST, context: DecoderContext): MetadataType | undefined;
|
|
52
34
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Person转换器
|
|
55
|
-
*/
|
|
56
35
|
export declare class PersonConverter extends BaseGPXConverter {
|
|
57
36
|
name: string;
|
|
58
37
|
supportedTags: string[];
|
|
59
38
|
convert(ast: TokenAST, context: DecoderContext): PersonType | undefined;
|
|
60
39
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Email转换器
|
|
63
|
-
*/
|
|
64
40
|
export declare class EmailConverter extends BaseGPXConverter {
|
|
65
41
|
name: string;
|
|
66
42
|
supportedTags: string[];
|
|
67
43
|
convert(ast: TokenAST, context: DecoderContext): EmailType | undefined;
|
|
68
44
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Copyright转换器
|
|
71
|
-
*/
|
|
72
45
|
export declare class CopyrightConverter extends BaseGPXConverter {
|
|
73
46
|
name: string;
|
|
74
47
|
supportedTags: string[];
|
|
75
48
|
convert(ast: TokenAST, context: DecoderContext): CopyrightType | undefined;
|
|
76
49
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Bounds转换器
|
|
79
|
-
*/
|
|
80
50
|
export declare class BoundsConverter extends BaseGPXConverter {
|
|
81
51
|
name: string;
|
|
82
52
|
supportedTags: string[];
|
package/dist/GPX/decoder.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { ExtensionsType, TokenAST } from "../types.js";
|
|
2
2
|
import { IGPXConverterPlugin, IGPXMiddlewarePlugin } from "./base.js";
|
|
3
3
|
import { GPX11Type } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* GPX解码器主类
|
|
6
|
-
*/
|
|
7
4
|
export declare class GPXDecoder {
|
|
8
5
|
private converterPlugins;
|
|
9
6
|
private registeredPlugins;
|
|
@@ -12,95 +9,32 @@ export declare class GPXDecoder {
|
|
|
12
9
|
private initialized;
|
|
13
10
|
private defaultConvertersRegistered;
|
|
14
11
|
constructor();
|
|
15
|
-
/**
|
|
16
|
-
* 初始化流水线 - 注册固定的核心处理器
|
|
17
|
-
*/
|
|
18
12
|
private initializePipeline;
|
|
19
|
-
/**
|
|
20
|
-
* 自动注册默认转换器 - 处理标准GPX标签
|
|
21
|
-
*/
|
|
22
13
|
private registerDefaultConverters;
|
|
23
|
-
/**
|
|
24
|
-
* 为指定标签添加转换器,按优先级排序
|
|
25
|
-
*/
|
|
26
14
|
private addConverterForTag;
|
|
27
|
-
/**
|
|
28
|
-
* 注册转换器插件
|
|
29
|
-
*/
|
|
30
15
|
registerConverter(plugin: IGPXConverterPlugin): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* 注册中间件插件 - 真正的扩展点
|
|
33
|
-
*/
|
|
34
16
|
registerMiddleware(plugin: IGPXMiddlewarePlugin): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* 获取转换器(返回优先级最高的)
|
|
37
|
-
*/
|
|
38
17
|
getConverter(tag: string): IGPXConverterPlugin | undefined;
|
|
39
|
-
/**
|
|
40
|
-
* 获取指定标签的所有转换器(按优先级排序)
|
|
41
|
-
*/
|
|
42
18
|
getAllConverters(tag: string): IGPXConverterPlugin[];
|
|
43
|
-
/**
|
|
44
|
-
* 移除转换器
|
|
45
|
-
*/
|
|
46
19
|
unregisterConverter(pluginName: string): void;
|
|
47
|
-
/**
|
|
48
|
-
* 移除中间件
|
|
49
|
-
*/
|
|
50
20
|
unregisterMiddleware(name: string): void;
|
|
51
|
-
/**
|
|
52
|
-
* 列出所有已注册的转换器标签
|
|
53
|
-
*/
|
|
54
21
|
listConverters(): string[];
|
|
55
|
-
/**
|
|
56
|
-
* 列出所有已注册的转换器插件
|
|
57
|
-
*/
|
|
58
22
|
listConverterPlugins(): string[];
|
|
59
|
-
/**
|
|
60
|
-
* 列出所有已注册的中间件
|
|
61
|
-
*/
|
|
62
23
|
listMiddlewares(): string[];
|
|
63
|
-
/**
|
|
64
|
-
* 列出核心处理器(只读)
|
|
65
|
-
*/
|
|
66
24
|
listProcessors(): string[];
|
|
67
|
-
/**
|
|
68
|
-
* 获取标签的转换器详情(包括优先级信息)
|
|
69
|
-
*/
|
|
70
25
|
getConverterDetails(tag?: string): Record<string, Array<{
|
|
71
26
|
name: string;
|
|
72
27
|
priority: number;
|
|
73
28
|
}>>;
|
|
74
|
-
/**
|
|
75
|
-
* 获取中间件详情(包括支持的钩子)
|
|
76
|
-
*/
|
|
77
29
|
getMiddlewareDetails(): Array<{
|
|
78
30
|
name: string;
|
|
79
31
|
hooks: string[];
|
|
80
32
|
}>;
|
|
81
|
-
/**
|
|
82
|
-
* 初始化解码器
|
|
83
|
-
*/
|
|
84
33
|
initialize(): Promise<void>;
|
|
85
|
-
/**
|
|
86
|
-
* 销毁解码器
|
|
87
|
-
*/
|
|
88
34
|
destroy(): Promise<void>;
|
|
89
|
-
/**
|
|
90
|
-
* 创建解码上下文
|
|
91
|
-
*/
|
|
92
35
|
private createContext;
|
|
93
|
-
/**
|
|
94
|
-
* 执行中间件钩子
|
|
95
|
-
*/
|
|
96
36
|
private executeMiddlewareHook;
|
|
97
|
-
/**
|
|
98
|
-
* 主解析方法 - 固定的流水线 + 灵活的中间件
|
|
99
|
-
*/
|
|
100
37
|
parserByBuffer(buffer: Buffer): Promise<GPX11Type | undefined>;
|
|
101
|
-
/**
|
|
102
|
-
* 转换Extensions(向后兼容)
|
|
103
|
-
*/
|
|
104
38
|
convertExtensions(extensionsAST: TokenAST): ExtensionsType;
|
|
105
39
|
}
|
|
106
40
|
declare const _default: {
|
package/dist/GPX/encoder.d.ts
CHANGED
|
@@ -1,151 +1,42 @@
|
|
|
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
|
}
|
|
151
42
|
declare const _default: {
|
package/dist/GPX/middleware.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { Token, TokenAST } from "../types";
|
|
2
2
|
import { BaseGPXMiddleware } from "./base";
|
|
3
3
|
import { DecoderContext } from "./types";
|
|
4
|
-
/**
|
|
5
|
-
* 性能监控中间件
|
|
6
|
-
*/
|
|
7
4
|
export declare class PerformanceMiddleware extends BaseGPXMiddleware {
|
|
8
5
|
name: string;
|
|
9
6
|
description: string;
|
|
@@ -12,16 +9,10 @@ export declare class PerformanceMiddleware extends BaseGPXMiddleware {
|
|
|
12
9
|
onComplete(result: any, context: DecoderContext): Promise<any>;
|
|
13
10
|
private countNodes;
|
|
14
11
|
}
|
|
15
|
-
/**
|
|
16
|
-
* 验证中间件
|
|
17
|
-
*/
|
|
18
12
|
export declare class ValidationMiddleware extends BaseGPXMiddleware {
|
|
19
13
|
name: string;
|
|
20
14
|
description: string;
|
|
21
15
|
onComplete(result: any, context: DecoderContext): Promise<any>;
|
|
22
16
|
private validateGPX;
|
|
23
17
|
}
|
|
24
|
-
/**
|
|
25
|
-
* 注册所有默认中间件
|
|
26
|
-
*/
|
|
27
18
|
export declare function registerDefaultMiddlewares(decoder: any): Promise<void>;
|
package/dist/GPX/processor.d.ts
CHANGED
|
@@ -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处理器, 将xml转为 token
|
|
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>;
|