@adobe/design-data-spec 1.2.0 → 1.3.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/design-data-spec",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Design Data Specification — prose, JSON Schemas, rule catalog, and conformance fixtures for Spectrum design data",
5
5
  "type": "module",
6
6
  "repository": {
package/rules/rules.yaml CHANGED
@@ -415,3 +415,24 @@ rules:
415
415
  message: "Token '{token}' has {field} '{value}' which is not declared on component '{component}'"
416
416
  spec_ref: spec/component-format.md#options
417
417
  introduced_in: "1.0.0-draft"
418
+
419
+ - id: SPEC-041
420
+ name: mode-set-restriction-coverage
421
+ severity: error
422
+ layer: 2
423
+ category: completeness
424
+ rfc: "#806"
425
+ assert: >
426
+ When a manifest declares modeSetRestrictions, every token group (tokens sharing the same
427
+ non-mode-set name object fields) MUST have at least one candidate that survives ALL
428
+ restrictions simultaneously — i.e. at least one token whose name object either omits
429
+ each restricted mode set field (wildcard) or sets it to an allowed mode value for every
430
+ restriction. Restrictions are applied as a conjunction (matching cascade step 0), so a
431
+ group that satisfies each restriction individually but has no single token satisfying
432
+ all restrictions at once is also a coverage gap.
433
+ Sub-checks: (a) a modeSetRestrictions key that names an unknown mode set MUST emit a
434
+ Warning; (b) an allowed list that excludes the mode set's declared default MUST emit
435
+ an Error, since the resolver would return None for the default context on that platform.
436
+ message: "Token group '{base_name}' has no resolvable candidate under manifest mode-set restrictions ({restrictions})"
437
+ spec_ref: spec/mode-sets.md#platform-restrictions
438
+ introduced_in: "1.0.0-draft"
@@ -62,6 +62,27 @@
62
62
  ]
63
63
  }
64
64
  },
65
+ "modeSetRestrictions": {
66
+ "type": "object",
67
+ "description": "Restricts the valid mode values for each named mode set on this platform. Keys are mode set names; values declare which modes are allowed.",
68
+ "additionalProperties": {
69
+ "type": "object",
70
+ "required": ["allowed"],
71
+ "properties": {
72
+ "allowed": {
73
+ "type": "array",
74
+ "items": {
75
+ "type": "string",
76
+ "minLength": 1
77
+ },
78
+ "minItems": 1,
79
+ "uniqueItems": true,
80
+ "description": "Allowed mode values for this mode set. Must be a subset of the mode set's declared modes and must include the mode set's default."
81
+ }
82
+ },
83
+ "additionalProperties": false
84
+ }
85
+ },
65
86
  "extensions": {
66
87
  "type": "object",
67
88
  "description": "Platform-local tokens, mode sets, and formatting rules.",
package/spec/cascade.md CHANGED
@@ -41,6 +41,7 @@ A **resolution context** is a set of mode set key/value pairs (e.g. `colorScheme
41
41
 
42
42
  The following outline is **RECOMMENDED** for conforming resolvers:
43
43
 
44
+ 0. If the manifest declares `modeSetRestrictions`, **drop any candidate** whose name object sets a mode set field to a value not in the manifest’s `allowed` list for that mode set. Candidates that omit a restricted mode set field (wildcard) are **not** dropped. See [Mode Sets — Platform restrictions](mode-sets.md#platform-restrictions).
44
45
  1. Collect all token candidates whose name object **matches** the context (every specified mode set in the context equals the name object’s mode set field, or the name object omits that mode set where omission means “matches any” per mode set rules).
45
46
  2. Filter to candidates at or below the requested layer.
46
47
  3. Select the maximum **layer** precedence.
package/spec/manifest.md CHANGED
@@ -17,12 +17,13 @@ A manifest **MUST** conform to [`manifest.schema.json`](../schemas/manifest.sche
17
17
 
18
18
  ## Optional fields
19
19
 
20
- | Field | Type | Description |
21
- | ------------ | --------------- | -------------------------------------------------------------------------------- |
22
- | `include` | array of string | Semantic **queries** selecting subsets of foundation tokens to materialize. |
23
- | `exclude` | array of string | Queries removing tokens from the included set. |
24
- | `overrides` | array of object | Typed overrides; each entry **MUST** preserve the target token’s **value type**. |
25
- | `extensions` | object | New tokens or mode sets introduced at the platform layer. |
20
+ | Field | Type | Description |
21
+ | --------------------- | --------------- | --------------------------------------------------------------------------------------------------------------------- |
22
+ | `include` | array of string | Semantic **queries** selecting subsets of foundation tokens to materialize. |
23
+ | `exclude` | array of string | Queries removing tokens from the included set. |
24
+ | `overrides` | array of object | Typed overrides; each entry **MUST** preserve the target token’s **value type**. |
25
+ | `extensions` | object | New tokens or mode sets introduced at the platform layer. |
26
+ | `modeSetRestrictions` | object | Mode set restrictions for this platform; see [Mode Sets — Platform restrictions](mode-sets.md#platform-restrictions). |
26
27
 
27
28
  ### `include` / `exclude`
28
29
 
package/spec/mode-sets.md CHANGED
@@ -57,8 +57,25 @@ Additional mode sets (e.g. `language`, `motion`) **MAY** be declared in a datase
57
57
 
58
58
  **RECOMMENDED:** Explicit **combination** tokens are used for rare cross-mode-set cases instead of inferring Cartesian products.
59
59
 
60
+ ## Platform restrictions
61
+
62
+ A platform manifest **MAY** declare which mode values are valid for a given mode set on that platform. This allows a platform (e.g. iOS) to express that it only supports a subset of modes (e.g. `colorScheme: light`, not `dark`).
63
+
64
+ **NORMATIVE:** A manifest's `modeSetRestrictions` value **MUST** be an object whose keys are mode set names declared in the dataset. Each value **MUST** be an object with a required `allowed` array of mode value strings. Every mode value in `allowed` **MUST** be a member of the named mode set's `modes`. The mode set's `default` **MUST** be included in `allowed`.
65
+
66
+ ### Resolution semantics
67
+
68
+ **NORMATIVE:** At resolution time, any token candidate whose name object sets a mode set field to a value **not** in the manifest's `allowed` list for that mode set **MUST** be filtered out before specificity tie-breaking. Tokens whose name object **omits** a restricted mode set field (wildcard) are **not** affected.
69
+
70
+ This is a pre-filter step, inserted at the start of the [resolution algorithm](cascade.md#resolution-algorithm-informative-outline) before step 1 (context matching).
71
+
72
+ ### Coverage validation
73
+
74
+ **NORMATIVE:** Validators implementing rule **`SPEC-041`** (`mode-set-restriction-coverage`) **MUST** report an error when a platform manifest's mode set restrictions leave a token group with no resolvable candidate — i.e. every token sharing the same non-mode-set name object fields references a restricted mode value, with no wildcard or allowed-mode alternative available. See `rules/rules.yaml` for the full rule definition.
75
+
60
76
  ## References
61
77
 
62
78
  * [#646 — Token Schema Structure and Validation System](https://github.com/adobe/spectrum-design-data/discussions/646)
63
79
  * [#714 — Design Data Specification](https://github.com/adobe/spectrum-design-data/discussions/714)
64
80
  * [#746 — Phase 2: Mode Set declarations (machine-readable)](https://github.com/adobe/spectrum-design-data/issues/746)
81
+ * [#943 — RFC #806: platform mode-set restriction behavior](https://github.com/adobe/spectrum-design-data/issues/943)