@adobe/design-data-wasm 0.4.0 → 0.4.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/package.json +4 -2
- package/pkg/node/design_data_wasm_bg.wasm +0 -0
- package/pkg/node/package.json +17 -0
- package/pkg/web/design_data_wasm_bg.wasm +0 -0
- package/pkg/web/package.json +21 -0
- package/pkg/node/README.md +0 -121
- package/pkg/web/README.md +0 -121
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/design-data-wasm",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.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",
|
|
@@ -18,10 +18,12 @@
|
|
|
18
18
|
"pkg/node/design_data_wasm_bg.wasm",
|
|
19
19
|
"pkg/node/design_data_wasm.d.ts",
|
|
20
20
|
"pkg/node/design_data_wasm_bg.wasm.d.ts",
|
|
21
|
+
"pkg/node/package.json",
|
|
21
22
|
"pkg/web/design_data_wasm.js",
|
|
22
23
|
"pkg/web/design_data_wasm_bg.wasm",
|
|
23
24
|
"pkg/web/design_data_wasm.d.ts",
|
|
24
25
|
"pkg/web/design_data_wasm_bg.wasm.d.ts",
|
|
26
|
+
"pkg/web/package.json",
|
|
25
27
|
"README.md"
|
|
26
28
|
],
|
|
27
29
|
"keywords": [
|
|
@@ -53,4 +55,4 @@
|
|
|
53
55
|
"devDependencies": {
|
|
54
56
|
"ava": "^6.1.2"
|
|
55
57
|
}
|
|
56
|
-
}
|
|
58
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "design-data-wasm",
|
|
3
|
+
"description": "WebAssembly bindings for design-data-core — exposes query, validate, resolve, diff, and registry helpers to JavaScript/TypeScript via wasm-bindgen.",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/adobe/spectrum-design-data"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"design_data_wasm_bg.wasm",
|
|
12
|
+
"design_data_wasm.js",
|
|
13
|
+
"design_data_wasm.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"main": "design_data_wasm.js",
|
|
16
|
+
"types": "design_data_wasm.d.ts"
|
|
17
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "design-data-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "WebAssembly bindings for design-data-core — exposes query, validate, resolve, diff, and registry helpers to JavaScript/TypeScript via wasm-bindgen.",
|
|
5
|
+
"version": "0.0.1",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/adobe/spectrum-design-data"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"design_data_wasm_bg.wasm",
|
|
13
|
+
"design_data_wasm.js",
|
|
14
|
+
"design_data_wasm.d.ts"
|
|
15
|
+
],
|
|
16
|
+
"main": "design_data_wasm.js",
|
|
17
|
+
"types": "design_data_wasm.d.ts",
|
|
18
|
+
"sideEffects": [
|
|
19
|
+
"./snippets/*"
|
|
20
|
+
]
|
|
21
|
+
}
|
package/pkg/node/README.md
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
# [**@adobe/design-data-wasm**](https://github.com/adobe/design-data-wasm)
|
|
2
|
-
|
|
3
|
-
WebAssembly bindings for [`design-data-core`](../core/) — query, validate,
|
|
4
|
-
resolve, and diff Spectrum design tokens from JavaScript or TypeScript, with
|
|
5
|
-
zero native dependencies.
|
|
6
|
-
|
|
7
|
-
Generated TypeScript types are derived directly from the Rust types via
|
|
8
|
-
[tsify-next](https://github.com/nickel-lang/tsify-next) — no hand-maintained
|
|
9
|
-
parallel type surface.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
```sh
|
|
14
|
-
pnpm add @adobe/design-data-wasm
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Usage
|
|
18
|
-
|
|
19
|
-
### Node.js (synchronous — no `init()` required)
|
|
20
|
-
|
|
21
|
-
The `node` export condition resolves to a synchronous CommonJS build; named
|
|
22
|
-
imports work in ESM via cjs-module-lexer.
|
|
23
|
-
|
|
24
|
-
```js
|
|
25
|
-
import { Dataset, getValues, findValue } from '@adobe/design-data-wasm';
|
|
26
|
-
|
|
27
|
-
// Use the canonical embedded Spectrum dataset (zero config):
|
|
28
|
-
const ds = Dataset.embedded();
|
|
29
|
-
|
|
30
|
-
// Or build a dataset from your own token objects:
|
|
31
|
-
const tokens = JSON.parse(fs.readFileSync('my-tokens.json', 'utf-8'));
|
|
32
|
-
const customDs = Dataset.fromTokens(tokens);
|
|
33
|
-
|
|
34
|
-
// Query
|
|
35
|
-
const colorTokens = ds.query('property=color,colorScheme=dark');
|
|
36
|
-
console.log(colorTokens[0].name, colorTokens[0].raw.value);
|
|
37
|
-
|
|
38
|
-
// Validate (relational rules — structural/JSON-Schema checks require the CLI)
|
|
39
|
-
const { valid, errors } = ds.validate();
|
|
40
|
-
|
|
41
|
-
// Resolve a property in a given context
|
|
42
|
-
const result = ds.resolve('background', { colorScheme: 'dark', scale: 'medium' });
|
|
43
|
-
if (result) console.log(result.token.raw.value, 'specificity:', result.specificity);
|
|
44
|
-
|
|
45
|
-
// Diff two datasets
|
|
46
|
-
const oldDs = Dataset.fromTokens(oldTokens);
|
|
47
|
-
const newDs = Dataset.fromTokens(newTokens);
|
|
48
|
-
const diff = oldDs.diff(newDs);
|
|
49
|
-
console.log(`${diff.added.length} added, ${diff.deleted.length} deleted`);
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Browser / bundler (requires `await init()`)
|
|
53
|
-
|
|
54
|
-
The `browser` export condition resolves to a browser ESM build. Call `init()`
|
|
55
|
-
with the URL of the `.wasm` file before using any API.
|
|
56
|
-
|
|
57
|
-
> **Note for Deno, Bun, and non-standard bundlers:** the package's `default` export
|
|
58
|
-
> condition also resolves to the web (browser ESM) build, so runtimes or bundlers that
|
|
59
|
-
> don't honour the `node` or `browser` condition will get this build and **must** call
|
|
60
|
-
> `await init()` before using any API.
|
|
61
|
-
|
|
62
|
-
```js
|
|
63
|
-
import init, { Dataset } from '@adobe/design-data-wasm';
|
|
64
|
-
// or explicit browser path:
|
|
65
|
-
import init, { Dataset } from '@adobe/design-data-wasm/pkg/web/design_data_wasm.js';
|
|
66
|
-
|
|
67
|
-
await init(); // pass wasm URL if needed: await init(new URL('./wasm/design_data_wasm_bg.wasm', import.meta.url))
|
|
68
|
-
|
|
69
|
-
const ds = Dataset.fromTokens(tokens);
|
|
70
|
-
const results = ds.query('property=color');
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## API
|
|
74
|
-
|
|
75
|
-
### `Dataset`
|
|
76
|
-
|
|
77
|
-
| Method | Returns | Description |
|
|
78
|
-
| ------------------------------- | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
79
|
-
| `Dataset.embedded()` | `Dataset` | Open the canonical embedded Spectrum dataset (prebuilt `.redb` cache — zero config). The full token dataset is compiled into the `.wasm` binary via `include_bytes!`; use `fromTokens()` instead if binary size is a concern. |
|
|
80
|
-
| `Dataset.fromTokens(tokens)` | `Dataset` | Build a dataset from an array of raw token JSON objects |
|
|
81
|
-
| `ds.query(filterExpr)` | `TokenResult[]` | Filter tokens. Syntax: `key=value` pairs joined with `,` (AND) or `\|` (OR); `!=` negation; `*` wildcard |
|
|
82
|
-
| `ds.validate()` | `ValidationResult` | Relational validation. `valid`, `errors[]`, `warnings[]` |
|
|
83
|
-
| `ds.resolve(property, context)` | `ResolveResult \| undefined` | Resolve a property in a mode-set context, e.g. `{ colorScheme: 'dark' }` |
|
|
84
|
-
| `ds.diff(otherDataset)` | `DiffResult` | Semantic diff. Fields: `renamed`, `deprecated`, `reverted`, `added`, `deleted`, `updated` |
|
|
85
|
-
| `ds.tokenCount()` | `number` | Number of tokens in the dataset |
|
|
86
|
-
|
|
87
|
-
### Registry helpers
|
|
88
|
-
|
|
89
|
-
These match the deprecated `@adobe/design-system-registry` API, accepting the
|
|
90
|
-
`{ values: [...] }` JSON shape from `@adobe/spectrum-design-data/registry/*.json`.
|
|
91
|
-
|
|
92
|
-
| Function | Description |
|
|
93
|
-
| --------------------------- | --------------------------------- |
|
|
94
|
-
| `getValues(registry)` | Return all value IDs |
|
|
95
|
-
| `findValue(registry, term)` | Find an entry by ID or alias |
|
|
96
|
-
| `hasValue(registry, term)` | Check if an ID or alias exists |
|
|
97
|
-
| `getDefault(registry)` | Return the default entry |
|
|
98
|
-
| `getActiveValues(registry)` | Return all non-deprecated entries |
|
|
99
|
-
|
|
100
|
-
### Embedded registry helpers
|
|
101
|
-
|
|
102
|
-
Fast lookups backed by the compile-time-embedded registry data (no JSON argument
|
|
103
|
-
needed):
|
|
104
|
-
|
|
105
|
-
| Function | Description |
|
|
106
|
-
| --------------------------------- | ----------------------------------------------------------------- |
|
|
107
|
-
| `getFieldValues(fieldName)` | All IDs+aliases for a name field (`"property"`, `"component"`, …) |
|
|
108
|
-
| `hasFieldValue(fieldName, value)` | Membership check for a name field |
|
|
109
|
-
| `getAdvisoryFields()` | Names of advisory (non-normative) fields |
|
|
110
|
-
|
|
111
|
-
## TypeScript
|
|
112
|
-
|
|
113
|
-
Types are generated from the Rust structs; no parallel declaration needed.
|
|
114
|
-
|
|
115
|
-
```ts
|
|
116
|
-
import type { TokenResult, ValidationResult, DiffResult, ResolveResult } from '@adobe/design-data-wasm';
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
## License
|
|
120
|
-
|
|
121
|
-
Apache-2.0 — see [LICENSE](../../LICENSE).
|
package/pkg/web/README.md
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
# [**@adobe/design-data-wasm**](https://github.com/adobe/design-data-wasm)
|
|
2
|
-
|
|
3
|
-
WebAssembly bindings for [`design-data-core`](../core/) — query, validate,
|
|
4
|
-
resolve, and diff Spectrum design tokens from JavaScript or TypeScript, with
|
|
5
|
-
zero native dependencies.
|
|
6
|
-
|
|
7
|
-
Generated TypeScript types are derived directly from the Rust types via
|
|
8
|
-
[tsify-next](https://github.com/nickel-lang/tsify-next) — no hand-maintained
|
|
9
|
-
parallel type surface.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
```sh
|
|
14
|
-
pnpm add @adobe/design-data-wasm
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Usage
|
|
18
|
-
|
|
19
|
-
### Node.js (synchronous — no `init()` required)
|
|
20
|
-
|
|
21
|
-
The `node` export condition resolves to a synchronous CommonJS build; named
|
|
22
|
-
imports work in ESM via cjs-module-lexer.
|
|
23
|
-
|
|
24
|
-
```js
|
|
25
|
-
import { Dataset, getValues, findValue } from '@adobe/design-data-wasm';
|
|
26
|
-
|
|
27
|
-
// Use the canonical embedded Spectrum dataset (zero config):
|
|
28
|
-
const ds = Dataset.embedded();
|
|
29
|
-
|
|
30
|
-
// Or build a dataset from your own token objects:
|
|
31
|
-
const tokens = JSON.parse(fs.readFileSync('my-tokens.json', 'utf-8'));
|
|
32
|
-
const customDs = Dataset.fromTokens(tokens);
|
|
33
|
-
|
|
34
|
-
// Query
|
|
35
|
-
const colorTokens = ds.query('property=color,colorScheme=dark');
|
|
36
|
-
console.log(colorTokens[0].name, colorTokens[0].raw.value);
|
|
37
|
-
|
|
38
|
-
// Validate (relational rules — structural/JSON-Schema checks require the CLI)
|
|
39
|
-
const { valid, errors } = ds.validate();
|
|
40
|
-
|
|
41
|
-
// Resolve a property in a given context
|
|
42
|
-
const result = ds.resolve('background', { colorScheme: 'dark', scale: 'medium' });
|
|
43
|
-
if (result) console.log(result.token.raw.value, 'specificity:', result.specificity);
|
|
44
|
-
|
|
45
|
-
// Diff two datasets
|
|
46
|
-
const oldDs = Dataset.fromTokens(oldTokens);
|
|
47
|
-
const newDs = Dataset.fromTokens(newTokens);
|
|
48
|
-
const diff = oldDs.diff(newDs);
|
|
49
|
-
console.log(`${diff.added.length} added, ${diff.deleted.length} deleted`);
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Browser / bundler (requires `await init()`)
|
|
53
|
-
|
|
54
|
-
The `browser` export condition resolves to a browser ESM build. Call `init()`
|
|
55
|
-
with the URL of the `.wasm` file before using any API.
|
|
56
|
-
|
|
57
|
-
> **Note for Deno, Bun, and non-standard bundlers:** the package's `default` export
|
|
58
|
-
> condition also resolves to the web (browser ESM) build, so runtimes or bundlers that
|
|
59
|
-
> don't honour the `node` or `browser` condition will get this build and **must** call
|
|
60
|
-
> `await init()` before using any API.
|
|
61
|
-
|
|
62
|
-
```js
|
|
63
|
-
import init, { Dataset } from '@adobe/design-data-wasm';
|
|
64
|
-
// or explicit browser path:
|
|
65
|
-
import init, { Dataset } from '@adobe/design-data-wasm/pkg/web/design_data_wasm.js';
|
|
66
|
-
|
|
67
|
-
await init(); // pass wasm URL if needed: await init(new URL('./wasm/design_data_wasm_bg.wasm', import.meta.url))
|
|
68
|
-
|
|
69
|
-
const ds = Dataset.fromTokens(tokens);
|
|
70
|
-
const results = ds.query('property=color');
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## API
|
|
74
|
-
|
|
75
|
-
### `Dataset`
|
|
76
|
-
|
|
77
|
-
| Method | Returns | Description |
|
|
78
|
-
| ------------------------------- | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
79
|
-
| `Dataset.embedded()` | `Dataset` | Open the canonical embedded Spectrum dataset (prebuilt `.redb` cache — zero config). The full token dataset is compiled into the `.wasm` binary via `include_bytes!`; use `fromTokens()` instead if binary size is a concern. |
|
|
80
|
-
| `Dataset.fromTokens(tokens)` | `Dataset` | Build a dataset from an array of raw token JSON objects |
|
|
81
|
-
| `ds.query(filterExpr)` | `TokenResult[]` | Filter tokens. Syntax: `key=value` pairs joined with `,` (AND) or `\|` (OR); `!=` negation; `*` wildcard |
|
|
82
|
-
| `ds.validate()` | `ValidationResult` | Relational validation. `valid`, `errors[]`, `warnings[]` |
|
|
83
|
-
| `ds.resolve(property, context)` | `ResolveResult \| undefined` | Resolve a property in a mode-set context, e.g. `{ colorScheme: 'dark' }` |
|
|
84
|
-
| `ds.diff(otherDataset)` | `DiffResult` | Semantic diff. Fields: `renamed`, `deprecated`, `reverted`, `added`, `deleted`, `updated` |
|
|
85
|
-
| `ds.tokenCount()` | `number` | Number of tokens in the dataset |
|
|
86
|
-
|
|
87
|
-
### Registry helpers
|
|
88
|
-
|
|
89
|
-
These match the deprecated `@adobe/design-system-registry` API, accepting the
|
|
90
|
-
`{ values: [...] }` JSON shape from `@adobe/spectrum-design-data/registry/*.json`.
|
|
91
|
-
|
|
92
|
-
| Function | Description |
|
|
93
|
-
| --------------------------- | --------------------------------- |
|
|
94
|
-
| `getValues(registry)` | Return all value IDs |
|
|
95
|
-
| `findValue(registry, term)` | Find an entry by ID or alias |
|
|
96
|
-
| `hasValue(registry, term)` | Check if an ID or alias exists |
|
|
97
|
-
| `getDefault(registry)` | Return the default entry |
|
|
98
|
-
| `getActiveValues(registry)` | Return all non-deprecated entries |
|
|
99
|
-
|
|
100
|
-
### Embedded registry helpers
|
|
101
|
-
|
|
102
|
-
Fast lookups backed by the compile-time-embedded registry data (no JSON argument
|
|
103
|
-
needed):
|
|
104
|
-
|
|
105
|
-
| Function | Description |
|
|
106
|
-
| --------------------------------- | ----------------------------------------------------------------- |
|
|
107
|
-
| `getFieldValues(fieldName)` | All IDs+aliases for a name field (`"property"`, `"component"`, …) |
|
|
108
|
-
| `hasFieldValue(fieldName, value)` | Membership check for a name field |
|
|
109
|
-
| `getAdvisoryFields()` | Names of advisory (non-normative) fields |
|
|
110
|
-
|
|
111
|
-
## TypeScript
|
|
112
|
-
|
|
113
|
-
Types are generated from the Rust structs; no parallel declaration needed.
|
|
114
|
-
|
|
115
|
-
```ts
|
|
116
|
-
import type { TokenResult, ValidationResult, DiffResult, ResolveResult } from '@adobe/design-data-wasm';
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
## License
|
|
120
|
-
|
|
121
|
-
Apache-2.0 — see [LICENSE](../../LICENSE).
|