@kaiord/zwo 4.0.0
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 +21 -0
- package/README.md +83 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +1202 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Pablo Albaladejo
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# @kaiord/zwo
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@kaiord/zwo)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
ZWO format adapter for Kaiord workout data conversion. Provides reading, writing, and validation of Zwift workout XML files.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm add @kaiord/core @kaiord/zwo
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
### With Core Providers (Recommended)
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { createDefaultProviders } from "@kaiord/core";
|
|
20
|
+
import { createZwoProviders } from "@kaiord/zwo";
|
|
21
|
+
|
|
22
|
+
const providers = createDefaultProviders({
|
|
23
|
+
zwo: createZwoProviders(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// ZWO to KRD
|
|
27
|
+
const krd = await providers.convertZwiftToKrd!({ zwiftString });
|
|
28
|
+
|
|
29
|
+
// KRD to ZWO
|
|
30
|
+
const zwoString = await providers.convertKrdToZwift!({ krd });
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Standalone Adapter Access
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import {
|
|
37
|
+
createFastXmlZwiftReader,
|
|
38
|
+
createFastXmlZwiftWriter,
|
|
39
|
+
createZwiftValidator,
|
|
40
|
+
} from "@kaiord/zwo";
|
|
41
|
+
import { createConsoleLogger } from "@kaiord/core";
|
|
42
|
+
|
|
43
|
+
const logger = createConsoleLogger();
|
|
44
|
+
const validator = createZwiftValidator(logger);
|
|
45
|
+
const reader = createFastXmlZwiftReader(logger, validator);
|
|
46
|
+
const writer = createFastXmlZwiftWriter(logger, validator);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## API
|
|
50
|
+
|
|
51
|
+
### `createZwoProviders(logger?: Logger): ZwoProviders`
|
|
52
|
+
|
|
53
|
+
Creates ZWO adapter instances for use with `createDefaultProviders()`.
|
|
54
|
+
|
|
55
|
+
### `createFastXmlZwiftReader(logger: Logger, validator: ZwiftValidator): ZwiftReader`
|
|
56
|
+
|
|
57
|
+
Creates a ZWO file reader using fast-xml-parser.
|
|
58
|
+
|
|
59
|
+
### `createFastXmlZwiftWriter(logger: Logger, validator: ZwiftValidator): ZwiftWriter`
|
|
60
|
+
|
|
61
|
+
Creates a ZWO file writer using fast-xml-parser.
|
|
62
|
+
|
|
63
|
+
### `createZwiftValidator(logger: Logger): ZwiftValidator`
|
|
64
|
+
|
|
65
|
+
Creates a validator that uses XSD validation in Node.js and well-formedness checking in browsers.
|
|
66
|
+
|
|
67
|
+
### `createXsdZwiftValidator(logger: Logger): ZwiftValidator`
|
|
68
|
+
|
|
69
|
+
Creates a strict XSD schema validator (Node.js only).
|
|
70
|
+
|
|
71
|
+
## Supported ZWO Features
|
|
72
|
+
|
|
73
|
+
- SteadyState intervals
|
|
74
|
+
- Warmup and Cooldown ramps
|
|
75
|
+
- IntervalsT (structured intervals)
|
|
76
|
+
- FreeRide segments
|
|
77
|
+
- Power targets (FTP percentage)
|
|
78
|
+
- Heart rate and cadence targets
|
|
79
|
+
- Text events
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
|
|
83
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Logger, ZwiftReader, ZwiftWriter, ZwiftValidator } from '@kaiord/core';
|
|
2
|
+
|
|
3
|
+
type ZwoProviders = {
|
|
4
|
+
zwiftReader: ZwiftReader;
|
|
5
|
+
zwiftWriter: ZwiftWriter;
|
|
6
|
+
zwiftValidator: ZwiftValidator;
|
|
7
|
+
};
|
|
8
|
+
declare const createZwoProviders: (logger?: Logger) => ZwoProviders;
|
|
9
|
+
|
|
10
|
+
declare const createFastXmlZwiftReader: (logger: Logger, validator: ZwiftValidator) => ZwiftReader;
|
|
11
|
+
declare const createFastXmlZwiftWriter: (logger: Logger, validator: ZwiftValidator) => ZwiftWriter;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Creates a Zwift validator that automatically chooses the appropriate validation strategy:
|
|
15
|
+
* - In Node.js: Full XSD schema validation
|
|
16
|
+
* - In browsers: XML well-formedness validation only
|
|
17
|
+
*
|
|
18
|
+
* This ensures the library works in both environments without requiring separate builds.
|
|
19
|
+
*
|
|
20
|
+
* @param logger - Logger instance for diagnostic messages
|
|
21
|
+
* @returns ZwiftValidator function
|
|
22
|
+
*/
|
|
23
|
+
declare const createZwiftValidator: (logger: Logger) => ZwiftValidator;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a Zwift validator with full XSD schema validation.
|
|
26
|
+
* Only available in Node.js environments.
|
|
27
|
+
*
|
|
28
|
+
* @param logger - Logger instance for diagnostic messages
|
|
29
|
+
* @returns ZwiftValidator function with XSD validation
|
|
30
|
+
*/
|
|
31
|
+
declare const createXsdZwiftValidator: (logger: Logger) => ZwiftValidator;
|
|
32
|
+
|
|
33
|
+
export { type ZwoProviders, createFastXmlZwiftReader, createFastXmlZwiftWriter, createXsdZwiftValidator, createZwiftValidator, createZwoProviders };
|