40 lines
894 B
Markdown
40 lines
894 B
Markdown
# decodal-wasm
|
|
|
|
WebAssembly runtime package for Decodal.
|
|
|
|
This package exposes the Decodal evaluator to browsers and other JavaScript runtimes that can load WebAssembly modules.
|
|
It is generated from the Rust crate in `crates/decodal-wasm` with `wasm-pack` and is used by the official playground.
|
|
|
|
Use `decodal-codemirror` separately when you need CodeMirror 6 language support.
|
|
|
|
## Install
|
|
|
|
```sh
|
|
npm install decodal-wasm
|
|
```
|
|
|
|
JSR:
|
|
|
|
```sh
|
|
deno add jsr:@hare/decodal-wasm
|
|
```
|
|
|
|
## Usage
|
|
|
|
```js
|
|
import init, { evaluateProject } from 'decodal-wasm';
|
|
|
|
await init();
|
|
|
|
const result = evaluateProject(JSON.stringify({
|
|
entry: 'main.dcdl',
|
|
files: {
|
|
'main.dcdl': 'Server = { port = Int default 8080; };',
|
|
},
|
|
}));
|
|
|
|
console.log(JSON.parse(result));
|
|
```
|
|
|
|
The exported functions return JSON strings so callers can handle diagnostics and successful results without depending on Rust data structures.
|