34 releases (9 breaking)
new 0.9.1 | Feb 8, 2025 |
---|---|
0.8.1 | Feb 2, 2025 |
0.0.18 | Dec 29, 2024 |
#199 in WebAssembly
2,254 downloads per month
2MB
42K
SLoC
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.
lib.rs
:
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.
Dependencies
~10–20MB
~282K SLoC