60 releases (22 breaking)
Uses new Rust 2024
new 0.23.0 | Apr 13, 2025 |
---|---|
0.22.1 | Mar 26, 2025 |
0.0.18 | Dec 29, 2024 |
#461 in WebAssembly
1,100 downloads per month
2.5MB
52K
SLoC
Mago WASM Bindings
This crate provides [wasm-bindgen] exports that wrap Mago’s internal functionality (formatter, parser, linter, etc.) so they can be called from JavaScript in a WebAssembly environment.
Overview
mago_get_definitions
: Returns metadata about all available plugins and rules in Mago.mago_analysis
: Parses, lints, and optionally formats a given PHP snippet and returns structured results.mago_format
: Formats a given PHP snippet according to the specified [FormatSettings].
See each function’s documentation below for details on usage and return values.
Mago WASM
mago-wasm
is a WebAssembly (WASM) crate designed to provide high-level functionality for the Mago toolchain, specifically tailored for use in browser environments.
This crate is primarily intended for the Mago Playground and similar projects where running Mago directly in the browser is required.
If you are building applications outside of a browser context, you should use the dedicated Mago crates instead of this crate.
Building
To build the WASM module, run the following command:
wasm-pack build --target web
This will generate a pkg
directory containing the WASM module and associated JavaScript bindings.
Dependencies
~11–21MB
~286K SLoC