@k67/kaitai-struct-ts 0.6.0 → 0.7.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/README.md +110 -37
- package/dist/cli.js +2776 -0
- package/dist/index.d.mts +197 -229
- package/dist/index.d.ts +197 -229
- package/dist/index.js +5 -110
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -110
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -18
package/README.md
CHANGED
@@ -33,9 +33,6 @@ Parse any binary data format by providing a `.ksy` (Kaitai Struct YAML) definiti
|
|
33
33
|
- 🎨 **Enums** - Named constants with expression access
|
34
34
|
- 🔁 **Conditional parsing** - if, repeat-expr, repeat-until
|
35
35
|
- 📍 **Positioned reads** - Absolute positioning with pos attribute
|
36
|
-
- 🔧 **Processing framework** - Ready for zlib/encryption (infrastructure)
|
37
|
-
- 🎯 **Parametric types** - Type parameters and arguments (infrastructure)
|
38
|
-
- ⚡ **Performance optimized** - Efficient memory management
|
39
36
|
|
40
37
|
## Installation
|
41
38
|
|
@@ -49,6 +46,33 @@ yarn add @k67/kaitai-struct-ts
|
|
49
46
|
|
50
47
|
## Quick Start
|
51
48
|
|
49
|
+
### CLI Usage
|
50
|
+
|
51
|
+
Parse binary files directly from the command line:
|
52
|
+
|
53
|
+
```bash
|
54
|
+
# Using npx (no installation needed)
|
55
|
+
npx @k67/kaitai-struct-ts format.ksy data.bin
|
56
|
+
|
57
|
+
# Or with pnpm
|
58
|
+
pnpx @k67/kaitai-struct-ts format.ksy data.bin
|
59
|
+
|
60
|
+
# After installing globally
|
61
|
+
npm install -g @k67/kaitai-struct-ts
|
62
|
+
kaitai format.ksy data.bin
|
63
|
+
|
64
|
+
# Save output to file
|
65
|
+
kaitai format.ksy data.bin -o output.json
|
66
|
+
|
67
|
+
# Extract specific field
|
68
|
+
kaitai format.ksy data.bin --field header.version
|
69
|
+
|
70
|
+
# Get help
|
71
|
+
kaitai --help
|
72
|
+
```
|
73
|
+
|
74
|
+
### Library Usage
|
75
|
+
|
52
76
|
```typescript
|
53
77
|
import { parse, KaitaiStream } from '@k67/kaitai-struct-ts'
|
54
78
|
import { readFileSync } from 'fs'
|
@@ -73,12 +97,35 @@ seq:
|
|
73
97
|
const binaryData = readFileSync('data.bin')
|
74
98
|
|
75
99
|
// Parse!
|
76
|
-
const result =
|
100
|
+
const result = parse(ksyDefinition, binaryData)
|
77
101
|
|
78
102
|
console.log(result.version) // Access parsed fields
|
79
103
|
console.log(result.name)
|
80
104
|
```
|
81
105
|
|
106
|
+
## Current Status
|
107
|
+
|
108
|
+
**Version:** 0.7.0
|
109
|
+
**Status:** Production Ready 🚀
|
110
|
+
**Completion:** ~95% toward v1.0.0
|
111
|
+
|
112
|
+
### ✅ Fully Implemented
|
113
|
+
- **Core Runtime** - Complete binary stream reader with all primitive types
|
114
|
+
- **KSY Parser** - Full YAML parser with schema validation
|
115
|
+
- **Type Interpreter** - Execute schemas against binary data
|
116
|
+
- **Expression Evaluator** - Complete Kaitai expression language support
|
117
|
+
- **Advanced Features** - Conditionals, enums, repetitions, instances, switch/case
|
118
|
+
- **CLI Tool** - Command-line utility for parsing binary files
|
119
|
+
- **Testing** - 100+ comprehensive tests, all passing
|
120
|
+
- **Documentation** - Complete user and developer documentation
|
121
|
+
|
122
|
+
### 🔄 Remaining for v1.0.0
|
123
|
+
- Substream processing (zlib, encryption)
|
124
|
+
- Type imports across files
|
125
|
+
- Additional performance optimizations
|
126
|
+
|
127
|
+
See [docs/development/PROGRESS.md](./docs/development/PROGRESS.md) for detailed progress tracking and [docs/ARCHITECTURE.md](./docs/ARCHITECTURE.md) for architecture diagrams.
|
128
|
+
|
82
129
|
## API Documentation
|
83
130
|
|
84
131
|
### `parse(ksy: string, buffer: ArrayBuffer | Uint8Array, options?: ParseOptions): Record<string, unknown>`
|
@@ -111,19 +158,38 @@ const value = stream.readU4le() // Read 4-byte unsigned little-endian integer
|
|
111
158
|
|
112
159
|
See [API Documentation](./docs/api.md) for complete reference (coming soon).
|
113
160
|
|
114
|
-
##
|
161
|
+
## CLI Reference
|
115
162
|
|
116
|
-
|
117
|
-
- Quick start guide
|
118
|
-
- Real-world format examples (PNG, ZIP, ELF, etc.)
|
119
|
-
- Links to 100+ format definitions
|
120
|
-
- Sample binary files for testing
|
163
|
+
The `kaitai` command-line tool allows you to parse binary files without writing code.
|
121
164
|
|
122
|
-
|
165
|
+
```bash
|
166
|
+
# Basic usage
|
167
|
+
kaitai <ksy-file> <binary-file> [options]
|
168
|
+
|
169
|
+
# Examples
|
170
|
+
kaitai format.ksy data.bin # Parse and display
|
171
|
+
kaitai format.ksy data.bin -o result.json # Save to file
|
172
|
+
kaitai format.ksy data.bin --field version # Extract field
|
173
|
+
kaitai format.ksy data.bin --quiet # Quiet mode
|
174
|
+
```
|
175
|
+
|
176
|
+
**📖 Full CLI Documentation:** [docs/CLI.md](./docs/CLI.md)
|
177
|
+
|
178
|
+
**Quick Reference:**
|
179
|
+
- `-o, --output <file>` - Write to file
|
180
|
+
- `--field <path>` - Extract specific field
|
181
|
+
- `-q, --quiet` - Suppress progress messages
|
182
|
+
- `-h, --help` - Show help
|
183
|
+
- See [docs/CLI.md](./docs/CLI.md) for all options and examples
|
123
184
|
|
124
|
-
|
125
|
-
|
126
|
-
|
185
|
+
## Examples
|
186
|
+
|
187
|
+
Check the [examples](./examples) directory for more usage examples:
|
188
|
+
|
189
|
+
- Basic struct parsing
|
190
|
+
- Working with enums
|
191
|
+
- Conditional parsing
|
192
|
+
- Repetitions
|
127
193
|
|
128
194
|
## Development
|
129
195
|
|
@@ -152,50 +218,57 @@ pnpm format
|
|
152
218
|
|
153
219
|
## Roadmap
|
154
220
|
|
155
|
-
### Phase 1: Foundation (
|
156
|
-
- ✅
|
157
|
-
- ✅
|
158
|
-
- ✅
|
159
|
-
- ✅ String encoding support
|
221
|
+
### ✅ Phase 1: Foundation (v0.1.0) - Complete
|
222
|
+
- ✅ Binary stream reader (KaitaiStream)
|
223
|
+
- ✅ All primitive types (u1-u8, s1-s8, f4, f8)
|
224
|
+
- ✅ String encoding (UTF-8, ASCII, Latin-1, UTF-16)
|
160
225
|
- ✅ Byte arrays and positioning
|
226
|
+
- ✅ Error handling system
|
161
227
|
|
162
|
-
### Phase 2: Core Features -
|
228
|
+
### ✅ Phase 2: Core Features (v0.2.0-v0.4.0) - Complete
|
229
|
+
- ✅ KSY parser with validation
|
230
|
+
- ✅ Type interpreter
|
163
231
|
- ✅ Expression evaluator (full Kaitai expression language)
|
164
232
|
- ✅ Conditionals (if attribute)
|
165
233
|
- ✅ Enums with expression access
|
166
234
|
- ✅ Repetitions (repeat-expr, repeat-until, repeat-eos)
|
167
|
-
- ✅
|
235
|
+
- ✅ Nested user-defined types
|
168
236
|
|
169
|
-
### Phase 3: Advanced Features -
|
237
|
+
### ✅ Phase 3: Advanced Features (v0.5.0-v0.6.0) - Complete
|
170
238
|
- ✅ Switch/case type selection
|
171
|
-
- ✅ Instances (lazy-evaluated fields)
|
172
|
-
- ✅
|
173
|
-
- ✅
|
174
|
-
- ✅
|
175
|
-
- ✅
|
176
|
-
|
177
|
-
|
178
|
-
- ✅
|
179
|
-
- ✅
|
239
|
+
- ✅ Instances (lazy-evaluated fields with caching)
|
240
|
+
- ✅ Parametric types
|
241
|
+
- ✅ Positioned reads (pos attribute)
|
242
|
+
- ✅ Sized substreams
|
243
|
+
- ✅ Processing framework (ready for zlib/encryption)
|
244
|
+
|
245
|
+
### ✅ Phase 4: CLI & Polish (v0.7.0) - Complete
|
246
|
+
- ✅ Command-line interface
|
247
|
+
- ✅ Documentation reorganization
|
248
|
+
- ✅ Production-ready release
|
180
249
|
|
181
|
-
|
250
|
+
### 🔄 Phase 5: v1.0.0 - Final Polish (In Progress)
|
251
|
+
- ⏳ Processing implementations (zlib, encryption)
|
252
|
+
- ⏳ Type imports across files
|
253
|
+
- ⏳ Additional performance optimizations
|
254
|
+
- ⏳ Extended format testing
|
182
255
|
|
183
|
-
|
256
|
+
**Current Status:** Production-ready, ~95% complete toward v1.0.0
|
184
257
|
|
185
258
|
## Contributing
|
186
259
|
|
187
260
|
Contributions are welcome! Please read our [Contributing Guidelines](./CONTRIBUTING.md) first.
|
188
261
|
|
262
|
+
## License
|
263
|
+
|
264
|
+
MIT © Fabiano Pinto
|
265
|
+
|
189
266
|
## Related Projects
|
190
267
|
|
191
268
|
- [Kaitai Struct](https://kaitai.io/) - Official Kaitai Struct project
|
192
269
|
- [kaitai-struct-compiler](https://github.com/kaitai-io/kaitai_struct_compiler) - Official compiler
|
193
270
|
- [Format Gallery](https://formats.kaitai.io/) - Collection of .ksy format definitions
|
194
271
|
|
195
|
-
## License
|
196
|
-
|
197
|
-
MIT © Fabiano Pinto
|
198
|
-
|
199
272
|
## Acknowledgments
|
200
273
|
|
201
274
|
This project implements the [Kaitai Struct specification](https://doc.kaitai.io/) created by the Kaitai Struct team.
|