How wesleyel/war3parser works
Main Components
• Core Library: Represented by the crates/lib folder. This is the heart of the project containing various parser modules (e.g., parser/w3i, parser/w3x, parser/wts) and utility functions (e.g., binary reading, error handling). It also has functionalities to extract metadata and operate on map files.
• Command-Line Interface (CLI): In the crates/cli folder, this component consumes the core library to offer commands for dumping metadata, extracting files, and converting images.
• WASM Module: Located in the crates/wasm folder, this part packages the library’s functionalities into a WebAssembly binary to be used from JavaScript, providing an interface that wraps the core functionality.
• External Data/Resources: Represent the test_data folder that contains sample .w3x map files used for testing and as input examples.
• Build/CI Infrastructure: Indicate the GitHub workflows under .github/workflows and the Justfile for build tasks, which show the support for continuous integration and deployment.
Relationships and Interactions
• The Core Library is the central component. Both the CLI and WASM components depend on it.
• Interactions where data flows from input map files (such as those from test_data) into the Core Library, which then processes and returns parsed data, and then those results flow to the CLI or are exposed via the WASM interface.
Architectural Patterns and Principles
• Modularity: The separation into different crates (CLI, lib, wasm) reflects a modular design that isolates core functionality, user-facing CLI interactivity, and web integration.
• Reusability: The core library is built to be reused in multiple interfaces (CLI and WASM), emphasizing a separation of concerns.
• Layered Architecture: The system can be visualized as layers – the lower layer being the core parsing logic, and the upper layers being different interfaces/wrappers.
Relevant Technologies
• Rust: The primary language and toolchain (Cargo) used for development.
• Cargo and Justfile: For building, dependency management, and automation.
• WASM: For web integration, highlighting that the library is compiled to WebAssembly.
• GitHub Actions: For CI/CD integration depicted via the workflows in .github/workflows.
• The central parsing engine (the war3parser Core Library), broken down into submodules for various file formats.
• The two main interfaces that consume the core library: the CLI tool (for direct command-line use) and the WASM interface (for integration within web environments).
• Interaction dynamics with external map data and integration with build/CI pipelines.