Move wasm package under packages
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
# 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.
|
||||
Reference in New Issue
Block a user