@typstyle/typstyle-wasm-bundler
v0.15.0
Published
WebAssembly bindings for Typstyle
Readme
typstyle-wasm
WebAssembly bindings for Typstyle, a beautiful and reliable Typst code formatter.
⚠️ API Stability Warning: The API is unstable and may change in any future version.
Building
Prerequisites
- Rust stable toolchain with the
wasm32-unknown-unknowntarget - wasm-pack
rustup target add wasm32-unknown-unknown
cargo binstall wasm-packFor the Playground
The playground lives in the playground/ directory and uses a local wasm build:
cd playground
pnpm build:wasm # Production build (optimized)
pnpm dev:wasm # Development build (with debug info, faster compile)This runs wasm-pack build against this crate and outputs to playground/typstyle-wasm/.
For NPM Publishing
cd crates/typstyle-wasm
wasm-pack build --target bundler --out-dir pkg --scope typstyleThis produces the @typstyle/typstyle-wasm-bundler package in crates/typstyle-wasm/pkg/.
Installation
# For bundlers (Webpack, Vite, etc.)
npm install @typstyle/typstyle-wasm-bundlerUsage
Bundler Target
import { format } from "@typstyle/typstyle-wasm-bundler";
const formatted = format("#let x=1", {}); // Format with default configAPI
format(text: string, config: Config): string- Format Typst codeformat_ir(text: string, config: Config): string- Return formatting IRparse(text: string): string- Parse code and return AST debug string
Configuration
See the auto-generated docstring of Config type.
License
Apache License 2.0. See LICENSE.
