trackswap 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 TrackSwap
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,383 @@
1
+ # TrackSwap - GPX 轨迹处理库
2
+
3
+ 一个功能强大、插件化的 GPX 轨迹文件处理库,支持解析、编码、转换和扩展。
4
+
5
+ ## 🚀 快速开始
6
+
7
+ ### 安装
8
+
9
+ ```bash
10
+ npm install trackswap
11
+ ```
12
+
13
+ ## 📖 How to use
14
+
15
+ 最简单的GPX文件处理:
16
+
17
+ ```typescript
18
+ import { TrackSwap } from 'trackswap';
19
+ import fs from 'fs';
20
+
21
+ const trackSwap = new TrackSwap();
22
+
23
+ // 解析GPX文件
24
+ async function parseGPX() {
25
+ const buffer = fs.readFileSync('track.gpx');
26
+ const gpxData = await trackSwap.parseGPX(buffer);
27
+
28
+ console.log('GPX版本:', gpxData?.version);
29
+ console.log('轨迹数量:', gpxData?.trk?.length);
30
+ }
31
+
32
+ // 从字符串解析
33
+ async function parseFromString() {
34
+ const xmlString = `<?xml version="1.0"?>
35
+ <gpx version="1.1" creator="TrackSwap">
36
+ <wpt lat="39.9042" lon="116.4074">
37
+ <name>北京</name>
38
+ </wpt>
39
+ </gpx>`;
40
+
41
+ const gpxData = await trackSwap.parseGPXString(xmlString);
42
+ console.log('航路点:', gpxData?.wpt?.[0]?.name);
43
+ }
44
+ ```
45
+
46
+
47
+ ## 🔧 API 参考
48
+
49
+ ### TrackSwap
50
+
51
+ | 方法 | 说明 | 参数 | 返回值 |
52
+ |------|------|------|--------|
53
+ | `parseGPX(buffer)` | 解析GPX Buffer | `Buffer` | `Promise<GPX11Type \| undefined>` |
54
+ | `parseGPXString(xml)` | 解析GPX字符串 | `string` | `Promise<GPX11Type \| undefined>` |
55
+ | `encodeGPX(data)` | 编码为Buffer | `GPX11Type` | `Promise<Buffer>` |
56
+ | `encodeGPXString(data)` | 编码为字符串 | `GPX11Type` | `string` |
57
+ | `getDecoder()` | 获取解码器实例 | - | `GPXDecoder` |
58
+ | `getEncoder()` | 获取编码器实例 | - | `GPXEncoder` |
59
+ | `destroy()` | 清理资源 | - | `Promise<void>` |
60
+
61
+
62
+
63
+ # GPX 流水线插件化解码器
64
+
65
+ 这是一个基于流水线(Pipeline)和插件架构的GPX文件解码器,采用了现代化的设计模式,支持完整的插件生命周期管理和中间件机制。
66
+
67
+ 🏗️ GPX解码器架构说明:
68
+
69
+ ┌─────────────────────────────────────────────────────────────┐
70
+ │ GPX解码器架构图 │
71
+ ├─────────────────────────────────────────────────────────────┤
72
+ │ │
73
+ │ 🔧 固定核心处理器 (不可修改) │
74
+ │ ┌─────────────────────────────────────────────────────────┐ │
75
+ │ │ 1. TokenizeProcessor - XML → Tokens │ │
76
+ │ │ 2. AstGenerateProcessor - Tokens → AST │ │
77
+ │ │ 3. ConvertProcessor - AST → GPX对象 │ │
78
+ │ │ 4. CompleteProcessor - 最终化处理 │ │
79
+ │ └─────────────────────────────────────────────────────────┘ │
80
+ │ │
81
+ │ 🔌 可扩展中间件 (真正的扩展点) │
82
+ │ ┌─────────────────────────────────────────────────────────┐ │
83
+ │ │ • onTokenize() - Token增强、过滤 │ │
84
+ │ │ • onAstGenerate() - AST结构增强 │ │
85
+ │ │ • onConvert() - 转换结果增强 │ │
86
+ │ │ • onComplete() - 最终结果处理 │ │
87
+ │ │ • onError() - 错误处理 │ │
88
+ │ └─────────────────────────────────────────────────────────┘ │
89
+ │ │
90
+ │ 📦 转换器插件 (支持优先级) │
91
+ │ ┌─────────────────────────────────────────────────────────┐ │
92
+ │ │ • 默认转换器:wpt, rte, trk, metadata... │ │
93
+ │ │ • 自定义转换器:扩展标签、覆盖默认行为 │ │
94
+ │ │ • 优先级系统:多转换器处理同一标签 │ │
95
+ │ └─────────────────────────────────────────────────────────┘ │
96
+ │ │
97
+ └─────────────────────────────────────────────────────────────┘
98
+
99
+ ## 📋 快速开始
100
+
101
+ ```typescript
102
+ import { GPXDecoder } from './decoder';
103
+ import { registerDefaultMiddlewares } from './converters';
104
+
105
+ const decoder = new GPXDecoder();
106
+ // 可选:注册默认中间件(性能监控、验证等)
107
+ await registerDefaultMiddlewares(decoder);
108
+
109
+ // 解析GPX文件
110
+ const buffer = fs.readFileSync('track.gpx');
111
+ const gpxData = await decoder.parserByBuffer(buffer);
112
+
113
+ // 销毁解码器
114
+ await decoder.destroy();
115
+ ```
116
+
117
+
118
+ ## 🏗️ 架构设计
119
+
120
+ ### 自动注册的组件
121
+
122
+ 创建`GPXDecoder`实例时,以下组件会自动注册:
123
+
124
+ #### 🔧 核心流水线处理器(自动注册)
125
+ - `TokenizeProcessor`: XML → Token数组
126
+ - `AstGenerateProcessor`: Token数组 → AST
127
+ - `ConvertProcessor`: AST → GPX对象
128
+ - `CompleteProcessor`: 性能统计和清理
129
+
130
+ #### ✅ 默认转换器(自动注册)
131
+ - `WptConverter`: 处理 `<wpt>`, `<trkpt>`, `<rtept>` 标签
132
+ - `RteConverter`: 处理 `<rte>` 路线标签
133
+ - `TrkConverter`: 处理 `<trk>` 轨迹标签
134
+ - `TrksegConverter`: 处理 `<trkseg>` 轨迹段标签
135
+ - `MetadataConverter`: 处理 `<metadata>` 元数据标签
136
+ - `LinkConverter`: 处理 `<link>` 链接标签
137
+ - `PersonConverter`: 处理 `<author>` 作者标签
138
+ - `EmailConverter`: 处理 `<email>` 邮箱标签
139
+ - `CopyrightConverter`: 处理 `<copyright>` 版权标签
140
+ - `BoundsConverter`: 处理 `<bounds>` 边界标签
141
+
142
+ #### 🔌 用户注册的组件
143
+ - **自定义转换器**: 处理扩展标签或覆盖默认行为
144
+ - **中间件**: 在流水线各阶段插入自定义逻辑
145
+
146
+ ### 流水线阶段
147
+
148
+ ```
149
+ Input Buffer → Tokenize → AST Generate → Convert → Complete → Output
150
+ ↓ ↓ ↓ ↓ ↓
151
+ 中间件钩子 中间件钩子 中间件钩子 中间件钩子 中间件钩子
152
+ ```
153
+
154
+ ## 🔧 创建转换器插件
155
+
156
+ ### 基础转换器
157
+
158
+ ```typescript
159
+ import { BaseConverter } from './decoder';
160
+
161
+ class MyConverter extends BaseConverter {
162
+ name = 'my-converter';
163
+ supportedTags = ['custom-tag'];
164
+ priority = 50; // 优先级,数字越小优先级越高
165
+
166
+ convert(ast: TokenAST, context: DecoderContext): MyDataType | undefined {
167
+ // 验证必要属性
168
+ if (!this.hasRequiredAttributes(ast, ['required-attr'])) {
169
+ return undefined;
170
+ }
171
+
172
+ const result: MyDataType = {
173
+ value: this.parseFloat(ast.value),
174
+ name: this.parseString(ast.attributes?.name)
175
+ };
176
+
177
+ // 处理子节点
178
+ this.processChildren(ast, result, {
179
+ 'child-tag': (child, target) => {
180
+ target.childValue = this.parseString(child.value);
181
+ }
182
+ });
183
+
184
+ return result;
185
+ }
186
+
187
+ // 可选的生命周期钩子
188
+ async initialize(context: DecoderContext): Promise<void> {
189
+ console.log(`${this.name} 转换器初始化`);
190
+ }
191
+
192
+ async destroy(context: DecoderContext): Promise<void> {
193
+ console.log(`${this.name} 转换器销毁`);
194
+ }
195
+ }
196
+ ```
197
+
198
+ ### 注册和使用
199
+
200
+ ```typescript
201
+ const decoder = new GPXDecoder(); // 默认转换器已就绪
202
+ await decoder.registerConverter(new MyConverter());
203
+
204
+ // 验证注册
205
+ console.log(decoder.listConverters()); // 包含 'custom-tag' 和所有默认标签
206
+ ```
207
+
208
+ ## 🔄 创建中间件插件
209
+
210
+ ### 基础中间件
211
+
212
+ ```typescript
213
+ import { BaseMiddleware } from './decoder';
214
+
215
+ class MyMiddleware extends BaseMiddleware {
216
+ name = 'my-middleware';
217
+ description = '我的自定义中间件';
218
+
219
+ // Token处理阶段
220
+ async onTokenize(tokens: Token[], context: DecoderContext): Promise<Token[]> {
221
+ console.log(`处理了 ${tokens.length} 个token`);
222
+ // 可以修改或过滤token
223
+ return tokens.filter(token => token.type !== 'unwanted');
224
+ }
225
+
226
+ // AST生成阶段
227
+ async onAstGenerate(ast: TokenAST, context: DecoderContext): Promise<TokenAST> {
228
+ // 可以修改AST结构
229
+ this.addCustomProperties(ast);
230
+ return ast;
231
+ }
232
+
233
+ // 转换阶段
234
+ async onConvert(result: any, context: DecoderContext): Promise<any> {
235
+ // 可以对转换结果进行后处理
236
+ result.processedBy = this.name;
237
+ return result;
238
+ }
239
+
240
+ // 完成阶段
241
+ async onComplete(result: GPX11Type, context: DecoderContext): Promise<GPX11Type> {
242
+ // 最终处理
243
+ const performance = context.metadata.get('performance');
244
+ console.log('处理完成,性能指标:', performance);
245
+ return result;
246
+ }
247
+
248
+ // 错误处理
249
+ async onError(error: Error, context: DecoderContext): Promise<void> {
250
+ console.error(`中间件 ${this.name} 捕获错误:`, error.message);
251
+ // 可以进行错误上报、恢复等操作
252
+ }
253
+
254
+ private addCustomProperties(ast: TokenAST): void {
255
+ // 添加自定义属性逻辑
256
+ }
257
+ }
258
+ ```
259
+
260
+ ### 注册中间件
261
+
262
+ ```typescript
263
+ const decoder = new GPXDecoder();
264
+ await decoder.registerMiddleware(new MyMiddleware());
265
+
266
+ console.log(decoder.listMiddlewares()); // 包含 'my-middleware'
267
+ ```
268
+
269
+ ## 🎯 实际示例
270
+
271
+ ### 最简洁的使用方式
272
+
273
+ ```typescript
274
+ // 🎉 一行创建,立即可用!
275
+ const decoder = new GPXDecoder();
276
+ const result = await decoder.parserByBuffer(buffer);
277
+ ```
278
+
279
+ ### 带中间件的使用方式
280
+
281
+ ```typescript
282
+ import { registerDefaultMiddlewares } from './converters';
283
+
284
+ const decoder = new GPXDecoder();
285
+ await registerDefaultMiddlewares(decoder); // 性能监控、验证等
286
+ const result = await decoder.parserByBuffer(buffer);
287
+ ```
288
+
289
+ ### 自定义扩展处理
290
+
291
+ ```typescript
292
+ // Garmin扩展转换器
293
+ class GarminExtensionConverter extends BaseConverter {
294
+ name = 'garmin-extension';
295
+ supportedTags = ['gpxtpx:TrackPointExtension'];
296
+
297
+ convert(ast: TokenAST, context: DecoderContext): GarminExtension {
298
+ const extension: GarminExtension = {};
299
+
300
+ this.processChildren(ast, extension, {
301
+ 'gpxtpx:hr': (child, target) => target.heartRate = this.parseFloat(child.value),
302
+ 'gpxtpx:cad': (child, target) => target.cadence = this.parseFloat(child.value),
303
+ 'gpxtpx:atemp': (child, target) => target.airTemp = this.parseFloat(child.value),
304
+ });
305
+
306
+ return extension;
307
+ }
308
+ }
309
+
310
+ // 注册到已有解码器
311
+ const decoder = new GPXDecoder();
312
+ await decoder.registerConverter(new GarminExtensionConverter());
313
+ ```
314
+
315
+ ## 🛠️ 管理插件
316
+
317
+ ```typescript
318
+ const decoder = new GPXDecoder();
319
+
320
+ // 查看默认注册的转换器
321
+ console.log('默认转换器:', decoder.listConverters());
322
+ // 输出: ['wpt', 'trkpt', 'rtept', 'rte', 'trk', 'trkseg', 'metadata', 'link', 'author', 'email', 'copyright', 'bounds']
323
+
324
+ // 注册自定义插件
325
+ await decoder.registerConverter(customConverter);
326
+ await decoder.registerMiddleware(customMiddleware);
327
+
328
+ // 查看所有插件
329
+ console.log('所有转换器:', decoder.listConverters());
330
+ console.log('所有中间件:', decoder.listMiddlewares());
331
+
332
+ // 移除插件
333
+ decoder.unregisterConverter('custom-tag');
334
+ decoder.unregisterMiddleware('my-middleware');
335
+
336
+ // 销毁解码器
337
+ await decoder.destroy();
338
+ ```
339
+
340
+ ## 🔍 调试和监控
341
+
342
+ 新架构提供了丰富的调试和监控能力:
343
+
344
+ - **性能指标**: 自动收集各个阶段的处理时间
345
+ - **错误处理**: 统一的错误处理机制
346
+ - **插件状态**: 跟踪插件的生命周期状态
347
+ - **上下文传递**: 丰富的上下文信息便于调试
348
+ - **开箱即用**: 创建即可工作,无需配置
349
+
350
+ ## 📚 API参考
351
+
352
+ ### GPXDecoder
353
+
354
+ - `constructor()`: 创建解码器,自动注册默认转换器和流水线处理器
355
+ - `registerConverter(plugin: IConverterPlugin)`: 注册自定义转换器
356
+ - `registerMiddleware(plugin: IMiddlewarePlugin)`: 注册中间件
357
+ - `getConverter(tag: string)`: 获取转换器
358
+ - `unregisterConverter(tag: string)`: 移除转换器
359
+ - `unregisterMiddleware(name: string)`: 移除中间件
360
+ - `listConverters()`: 列出所有转换器
361
+ - `listMiddlewares()`: 列出所有中间件
362
+ - `initialize()`: 初始化解码器(自动调用)
363
+ - `destroy()`: 销毁解码器
364
+ - `parserByBuffer(buffer: Buffer)`: 解析GPX数据
365
+
366
+ ### BaseConverter
367
+
368
+ 提供转换器的基础实现和工具方法,详见"创建转换器插件"部分。
369
+
370
+ ### BaseMiddleware
371
+
372
+ 提供中间件的基础实现,包含所有生命周期钩子的默认实现。
373
+
374
+ ## 🎊 总结
375
+
376
+ 现在的GPX解码器真正做到了**开箱即用**:
377
+
378
+ 1. **创建即可用**: `new GPXDecoder()` 后立即支持所有标准GPX标签
379
+ 2. **按需扩展**: 只需要注册自定义转换器和中间件
380
+ 3. **零配置**: 无需了解内部流水线和默认转换器
381
+ 4. **完全可控**: 仍然支持完整的插件化定制能力
382
+
383
+ 这个新架构让GPX解码变得更加简洁、易用而又不失灵活性! 🚀
@@ -0,0 +1,84 @@
1
+ import { Token, TokenAST } from "../types.js";
2
+ import { DecoderContext, GPX11Type } from "./types.js";
3
+ /**
4
+ * 插件接口
5
+ */
6
+ export interface IPlugin {
7
+ /** 插件名称 */
8
+ name: string;
9
+ /** 插件版本 */
10
+ version?: string;
11
+ /** 插件描述 */
12
+ description?: string;
13
+ /** 依赖的其他插件 */
14
+ dependencies?: string[];
15
+ /** 支持的标签 */
16
+ supportedTags?: string[];
17
+ /** 插件初始化 */
18
+ initialize?(context: DecoderContext): Promise<void> | void;
19
+ /** 插件销毁 */
20
+ destroy?(context: DecoderContext): Promise<void> | void;
21
+ /** 插件验证 */
22
+ validate?(context: DecoderContext): Promise<boolean> | boolean;
23
+ }
24
+ /**
25
+ * 转换器插件接口
26
+ */
27
+ export interface IConverterPlugin extends IPlugin {
28
+ /** 转换方法 */
29
+ convert(ast: TokenAST, context: DecoderContext): any | undefined;
30
+ /** 是否支持该标签 */
31
+ supports(tag: string): boolean;
32
+ /** 优先级(数字越小优先级越高) */
33
+ priority?: number;
34
+ }
35
+ /**
36
+ * 中间件插件接口
37
+ */
38
+ export interface IMiddlewarePlugin extends IPlugin {
39
+ /** 在tokenize阶段执行 */
40
+ onTokenize?(tokens: Token[], context: DecoderContext): Promise<Token[]> | Token[];
41
+ /** 在AST生成阶段执行 */
42
+ onAstGenerate?(ast: TokenAST, context: DecoderContext): Promise<TokenAST> | TokenAST;
43
+ /** 在转换阶段执行 */
44
+ onConvert?(result: any, context: DecoderContext): Promise<any> | any;
45
+ /** 在完成阶段执行 */
46
+ onComplete?(result: GPX11Type, context: DecoderContext): Promise<GPX11Type> | GPX11Type;
47
+ /** 错误处理 */
48
+ onError?(error: Error, context: DecoderContext): Promise<void> | void;
49
+ }
50
+ /**
51
+ * 基础转换器抽象类
52
+ */
53
+ export declare abstract class BaseConverter implements IConverterPlugin {
54
+ abstract name: string;
55
+ abstract supportedTags: string[];
56
+ version: string;
57
+ priority: number;
58
+ abstract convert(ast: TokenAST, context: DecoderContext): any | undefined;
59
+ supports(tag: string): boolean;
60
+ initialize(context: DecoderContext): Promise<void>;
61
+ destroy(context: DecoderContext): Promise<void>;
62
+ validate(context: DecoderContext): Promise<boolean>;
63
+ protected parseFloat(value: string | number | undefined): number;
64
+ protected parseString(value: string | number | undefined): string;
65
+ protected hasRequiredAttributes(ast: TokenAST, required: string[]): boolean;
66
+ protected extractAttributes<U extends Record<string, any>>(ast: TokenAST, target: U, mapping: Record<string, keyof U>): void;
67
+ protected processChildren<U extends Record<string, any>>(ast: TokenAST, target: U, processors: Record<string, (child: TokenAST, target: U) => void>): void;
68
+ }
69
+ /**
70
+ * 基础中间件抽象类
71
+ */
72
+ export declare abstract class BaseMiddleware implements IMiddlewarePlugin {
73
+ abstract name: string;
74
+ version: string;
75
+ description: string;
76
+ initialize(context: DecoderContext): Promise<void>;
77
+ destroy(context: DecoderContext): Promise<void>;
78
+ validate(context: DecoderContext): Promise<boolean>;
79
+ onTokenize(tokens: Token[], context: DecoderContext): Promise<Token[]>;
80
+ onAstGenerate(ast: TokenAST, context: DecoderContext): Promise<TokenAST>;
81
+ onConvert(result: any, context: DecoderContext): Promise<any>;
82
+ onComplete(result: GPX11Type, context: DecoderContext): Promise<GPX11Type>;
83
+ onError(error: Error, context: DecoderContext): Promise<void>;
84
+ }
@@ -0,0 +1,83 @@
1
+ // ============ 基础工具类 ============
2
+ /**
3
+ * 基础转换器抽象类
4
+ */
5
+ export class BaseConverter {
6
+ constructor() {
7
+ this.version = "1.0.0";
8
+ this.priority = 100;
9
+ }
10
+ supports(tag) {
11
+ return this.supportedTags.includes(tag);
12
+ }
13
+ async initialize(context) {
14
+ context.metadata.set(`plugin:${this.name}:initialized`, true);
15
+ }
16
+ async destroy(context) {
17
+ context.metadata.delete(`plugin:${this.name}:initialized`);
18
+ }
19
+ async validate(context) {
20
+ return true;
21
+ }
22
+ // 工具方法
23
+ parseFloat(value) {
24
+ if (typeof value === "number")
25
+ return value;
26
+ if (typeof value === "string")
27
+ return parseFloat(value) || 0;
28
+ return 0;
29
+ }
30
+ parseString(value) {
31
+ return String(value || "");
32
+ }
33
+ hasRequiredAttributes(ast, required) {
34
+ return required.every((attr) => ast.attributes?.[attr]);
35
+ }
36
+ extractAttributes(ast, target, mapping) {
37
+ if (!ast.attributes)
38
+ return;
39
+ Object.entries(ast.attributes).forEach(([key, value]) => {
40
+ const targetKey = mapping[key];
41
+ if (targetKey && targetKey in target) {
42
+ target[targetKey] = this.parseFloat(value);
43
+ }
44
+ });
45
+ }
46
+ processChildren(ast, target, processors) {
47
+ ast.children?.forEach((child) => {
48
+ const processor = processors[child.tag];
49
+ if (processor) {
50
+ processor(child, target);
51
+ }
52
+ });
53
+ }
54
+ }
55
+ /**
56
+ * 基础中间件抽象类
57
+ */
58
+ export class BaseMiddleware {
59
+ constructor() {
60
+ this.version = "1.0.0";
61
+ this.description = "";
62
+ }
63
+ async initialize(context) { }
64
+ async destroy(context) { }
65
+ async validate(context) {
66
+ return true;
67
+ }
68
+ async onTokenize(tokens, context) {
69
+ return tokens;
70
+ }
71
+ async onAstGenerate(ast, context) {
72
+ return ast;
73
+ }
74
+ async onConvert(result, context) {
75
+ return result;
76
+ }
77
+ async onComplete(result, context) {
78
+ return result;
79
+ }
80
+ async onError(error, context) {
81
+ console.error(`中间件 ${this.name} 处理错误:`, error);
82
+ }
83
+ }
@@ -0,0 +1,108 @@
1
+ import { BaseConverter, BaseMiddleware } from "./base.js";
2
+ import { TokenAST, Token } from "../types.js";
3
+ import { BoundsType, CopyrightType, EmailType, LinkType, MetadataType, PersonType, RteType, TrksegType, TrkType, WptType, DecoderContext } from "./types.js";
4
+ /**
5
+ * WPT转换器
6
+ */
7
+ export declare class WptConverter extends BaseConverter {
8
+ name: string;
9
+ supportedTags: string[];
10
+ version: string;
11
+ convert(ast: TokenAST, context: DecoderContext): WptType | undefined;
12
+ }
13
+ /**
14
+ * Route转换器
15
+ */
16
+ export declare class RteConverter extends BaseConverter {
17
+ name: string;
18
+ supportedTags: string[];
19
+ convert(ast: TokenAST, context: DecoderContext): RteType | undefined;
20
+ }
21
+ /**
22
+ * Track转换器
23
+ */
24
+ export declare class TrkConverter extends BaseConverter {
25
+ name: string;
26
+ supportedTags: string[];
27
+ convert(ast: TokenAST, context: DecoderContext): TrkType | undefined;
28
+ }
29
+ /**
30
+ * Track Segment转换器
31
+ */
32
+ export declare class TrksegConverter extends BaseConverter {
33
+ name: string;
34
+ supportedTags: string[];
35
+ convert(ast: TokenAST, context: DecoderContext): TrksegType | undefined;
36
+ }
37
+ /**
38
+ * Link转换器
39
+ */
40
+ export declare class LinkConverter extends BaseConverter {
41
+ name: string;
42
+ supportedTags: string[];
43
+ convert(ast: TokenAST, context: DecoderContext): LinkType | undefined;
44
+ }
45
+ /**
46
+ * Metadata转换器
47
+ */
48
+ export declare class MetadataConverter extends BaseConverter {
49
+ name: string;
50
+ supportedTags: string[];
51
+ convert(ast: TokenAST, context: DecoderContext): MetadataType | undefined;
52
+ }
53
+ /**
54
+ * Person转换器
55
+ */
56
+ export declare class PersonConverter extends BaseConverter {
57
+ name: string;
58
+ supportedTags: string[];
59
+ convert(ast: TokenAST, context: DecoderContext): PersonType | undefined;
60
+ }
61
+ /**
62
+ * Email转换器
63
+ */
64
+ export declare class EmailConverter extends BaseConverter {
65
+ name: string;
66
+ supportedTags: string[];
67
+ convert(ast: TokenAST, context: DecoderContext): EmailType | undefined;
68
+ }
69
+ /**
70
+ * Copyright转换器
71
+ */
72
+ export declare class CopyrightConverter extends BaseConverter {
73
+ name: string;
74
+ supportedTags: string[];
75
+ convert(ast: TokenAST, context: DecoderContext): CopyrightType | undefined;
76
+ }
77
+ /**
78
+ * Bounds转换器
79
+ */
80
+ export declare class BoundsConverter extends BaseConverter {
81
+ name: string;
82
+ supportedTags: string[];
83
+ convert(ast: TokenAST, context: DecoderContext): BoundsType | undefined;
84
+ }
85
+ /**
86
+ * 性能监控中间件
87
+ */
88
+ export declare class PerformanceMiddleware extends BaseMiddleware {
89
+ name: string;
90
+ description: string;
91
+ onTokenize(tokens: Token[], context: DecoderContext): Promise<Token[]>;
92
+ onAstGenerate(ast: TokenAST, context: DecoderContext): Promise<TokenAST>;
93
+ onComplete(result: any, context: DecoderContext): Promise<any>;
94
+ private countNodes;
95
+ }
96
+ /**
97
+ * 验证中间件
98
+ */
99
+ export declare class ValidationMiddleware extends BaseMiddleware {
100
+ name: string;
101
+ description: string;
102
+ onComplete(result: any, context: DecoderContext): Promise<any>;
103
+ private validateGPX;
104
+ }
105
+ /**
106
+ * 注册所有默认中间件
107
+ */
108
+ export declare function registerDefaultMiddlewares(decoder: any): Promise<void>;