decodal-wasm 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +19 -65
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,82 +1,36 @@
1
- # Decodal
1
+ # decodal-wasm
2
2
 
3
- Decodal is a small deterministic DSL for describing, composing, validating, and materializing structured data.
3
+ WebAssembly runtime package for Decodal.
4
4
 
5
- It is designed around a lightweight Rust library:
5
+ This package exposes the Decodal evaluator to browsers and other JavaScript runtimes that can load WebAssembly modules.
6
+ It is generated from the Rust crate in `crates/decodal-wasm` with `wasm-pack` and is used by the official playground.
6
7
 
7
- - host-supplied imports through `SourceLoader`
8
- - no filesystem access in the library core
9
- - concrete and abstract values with constraints and defaults
10
- - deterministic expression evaluation
11
- - optional regex support behind a Cargo feature
12
- - browser playground support through WebAssembly
8
+ Use `decodal-codemirror` separately when you need CodeMirror 6 language support.
13
9
 
14
- ## Library crate
15
-
16
- Embedded hosts should depend on `decodal` and provide imports with a `SourceLoader`.
17
-
18
- ```toml
19
- [dependencies]
20
- decodal = "0.1"
21
- ```
22
-
23
- ## Derive support
24
-
25
- For embedded Rust applications, Decodal can generate a schema and typed decoder from a Rust struct with the `derive` feature.
26
-
27
- ```toml
28
- [dependencies]
29
- decodal = { version = "0.1", features = ["derive"] }
30
- ```
31
-
32
- ```rust
33
- use decodal::{Decodal, DecodalDecode, DecodalSchema, Engine};
34
-
35
- #[derive(Decodal)]
36
- struct Service {
37
- name: String,
38
- #[decodal(gt = 443, default = 8443)]
39
- port: i64,
40
- #[decodal(rename = "feature.enable", default = true)]
41
- feature_enabled: bool,
42
- }
43
- ```
44
-
45
- The derive implements:
46
-
47
- - `DecodalSchema`, which produces a host schema for `Engine::bind_global`
48
- - `DecodalDecode`, which converts materialized `Data` into the Rust struct
49
-
50
- ## CLI
51
-
52
- A standalone CLI is kept in this repository as the `decodal-cli` workspace package.
53
- It builds a `decodal` binary, but it is not the primary crates.io package.
54
-
55
- Run a Decodal file from the repository:
10
+ ## Install
56
11
 
57
12
  ```sh
58
- cargo run -q -p decodal-cli -- examples/advanced/main.dcdl
13
+ npm install decodal-wasm
59
14
  ```
60
15
 
61
- Enable optional regex support when needed:
16
+ JSR:
62
17
 
63
18
  ```sh
64
- cargo run -q -p decodal-cli --features regex -- examples/regex/main.dcdl
19
+ deno add jsr:@hare/decodal-wasm
65
20
  ```
66
21
 
67
- ## Web playground
68
-
69
- The static documentation site and browser playground live under:
22
+ ## Usage
70
23
 
71
- ```text
72
- site/decodal-site/
73
- ```
24
+ ```js
25
+ import init, { evaluateProject } from 'decodal-wasm';
74
26
 
75
- ## License
27
+ await init();
76
28
 
77
- Licensed under either of:
29
+ const result = evaluateProject('main.dcdl', JSON.stringify({
30
+ 'main.dcdl': 'Server = { port = Int default 8080; };',
31
+ }));
78
32
 
79
- - Apache License, Version 2.0
80
- - MIT license
33
+ console.log(JSON.parse(result));
34
+ ```
81
35
 
82
- at your option.
36
+ The exported functions return JSON strings so callers can handle diagnostics and successful results without depending on Rust data structures.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "decodal-wasm",
3
3
  "type": "module",
4
4
  "description": "WebAssembly wrapper for evaluating Decodal in browser playgrounds.",
5
- "version": "0.1.2",
5
+ "version": "0.1.3",
6
6
  "license": "MIT OR Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",