@adobe/design-data-wasm 0.10.1 → 0.10.2
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.
package/README.md
CHANGED
|
@@ -14,6 +14,17 @@ parallel type surface.
|
|
|
14
14
|
pnpm add @adobe/design-data-wasm
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
## Release verification
|
|
18
|
+
|
|
19
|
+
Run `moon run sdk-wasm:verify-package` to build both targets and check the
|
|
20
|
+
packed package before publishing. The check installs the tarball in a temporary
|
|
21
|
+
consumer outside the workspace and runs embedded-data queries through the Node
|
|
22
|
+
and web entrypoints. It also checks that the bindings, types, and wasm binaries
|
|
23
|
+
are present and valid. It does not publish packages.
|
|
24
|
+
|
|
25
|
+
Snapshot and stable release workflows run the same check after downloading
|
|
26
|
+
their wasm build artifacts.
|
|
27
|
+
|
|
17
28
|
## Usage
|
|
18
29
|
|
|
19
30
|
### Node.js (synchronous — no `init()` required)
|
|
@@ -22,25 +33,29 @@ The `node` export condition resolves to a synchronous CommonJS build; named
|
|
|
22
33
|
imports work in ESM via cjs-module-lexer.
|
|
23
34
|
|
|
24
35
|
```js
|
|
25
|
-
import { Dataset, getValues, findValue } from
|
|
36
|
+
import { Dataset, getValues, findValue } from "@adobe/design-data-wasm";
|
|
26
37
|
|
|
27
38
|
// Use the canonical embedded Spectrum dataset (zero config):
|
|
28
39
|
const ds = Dataset.embedded();
|
|
29
40
|
|
|
30
41
|
// Or build a dataset from your own token objects:
|
|
31
|
-
const tokens = JSON.parse(fs.readFileSync(
|
|
42
|
+
const tokens = JSON.parse(fs.readFileSync("my-tokens.json", "utf-8"));
|
|
32
43
|
const customDs = Dataset.fromTokens(tokens);
|
|
33
44
|
|
|
34
45
|
// Query
|
|
35
|
-
const colorTokens = ds.query(
|
|
46
|
+
const colorTokens = ds.query("property=color,colorScheme=dark");
|
|
36
47
|
console.log(colorTokens[0].name, colorTokens[0].raw.value);
|
|
37
48
|
|
|
38
49
|
// Validate (relational rules — structural/JSON-Schema checks require the CLI)
|
|
39
50
|
const { valid, errors } = ds.validate();
|
|
40
51
|
|
|
41
52
|
// Resolve a property in a given context
|
|
42
|
-
const result = ds.resolve(
|
|
43
|
-
|
|
53
|
+
const result = ds.resolve("background", {
|
|
54
|
+
colorScheme: "dark",
|
|
55
|
+
scale: "medium",
|
|
56
|
+
});
|
|
57
|
+
if (result)
|
|
58
|
+
console.log(result.token.raw.value, "specificity:", result.specificity);
|
|
44
59
|
|
|
45
60
|
// Diff two datasets
|
|
46
61
|
const oldDs = Dataset.fromTokens(oldTokens);
|
|
@@ -60,14 +75,16 @@ with the URL of the `.wasm` file before using any API.
|
|
|
60
75
|
> `await init()` before using any API.
|
|
61
76
|
|
|
62
77
|
```js
|
|
63
|
-
import init, { Dataset } from
|
|
78
|
+
import init, { Dataset } from "@adobe/design-data-wasm";
|
|
64
79
|
// or explicit browser path:
|
|
65
|
-
import init, {
|
|
80
|
+
import init, {
|
|
81
|
+
Dataset,
|
|
82
|
+
} from "@adobe/design-data-wasm/pkg/web/design_data_wasm.js";
|
|
66
83
|
|
|
67
84
|
await init(); // pass wasm URL if needed: await init(new URL('./wasm/design_data_wasm_bg.wasm', import.meta.url))
|
|
68
85
|
|
|
69
86
|
const ds = Dataset.fromTokens(tokens);
|
|
70
|
-
const results = ds.query(
|
|
87
|
+
const results = ds.query("property=color");
|
|
71
88
|
```
|
|
72
89
|
|
|
73
90
|
## API
|
|
@@ -113,7 +130,12 @@ needed):
|
|
|
113
130
|
Types are generated from the Rust structs; no parallel declaration needed.
|
|
114
131
|
|
|
115
132
|
```ts
|
|
116
|
-
import type {
|
|
133
|
+
import type {
|
|
134
|
+
TokenResult,
|
|
135
|
+
ValidationResult,
|
|
136
|
+
DiffResult,
|
|
137
|
+
ResolveResult,
|
|
138
|
+
} from "@adobe/design-data-wasm";
|
|
117
139
|
```
|
|
118
140
|
|
|
119
141
|
## License
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/design-data-wasm",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "WebAssembly bindings for design-data-core — query, validate, resolve, diff, and registry helpers for Spectrum design tokens",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./pkg/node/design_data_wasm.js",
|
|
Binary file
|
|
Binary file
|