@design-token-kit/core 0.1.1

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 (28) hide show
  1. package/LICENSE +159 -0
  2. package/README.md +57 -0
  3. package/lib/index.d.ts +608 -0
  4. package/lib/index.js +4737 -0
  5. package/lib/schemas/2025.10/format/group.json +55 -0
  6. package/lib/schemas/2025.10/format/groupOrToken.json +15 -0
  7. package/lib/schemas/2025.10/format/token.json +425 -0
  8. package/lib/schemas/2025.10/format/tokenType.json +23 -0
  9. package/lib/schemas/2025.10/format/values/border.json +45 -0
  10. package/lib/schemas/2025.10/format/values/color.json +515 -0
  11. package/lib/schemas/2025.10/format/values/cubicBezier.json +57 -0
  12. package/lib/schemas/2025.10/format/values/dimension.json +35 -0
  13. package/lib/schemas/2025.10/format/values/duration.json +35 -0
  14. package/lib/schemas/2025.10/format/values/fontFamily.json +34 -0
  15. package/lib/schemas/2025.10/format/values/fontWeight.json +39 -0
  16. package/lib/schemas/2025.10/format/values/gradient.json +53 -0
  17. package/lib/schemas/2025.10/format/values/number.json +8 -0
  18. package/lib/schemas/2025.10/format/values/shadow.json +103 -0
  19. package/lib/schemas/2025.10/format/values/strokeStyle.json +64 -0
  20. package/lib/schemas/2025.10/format/values/transition.json +45 -0
  21. package/lib/schemas/2025.10/format/values/typography.json +73 -0
  22. package/lib/schemas/2025.10/format.json +106 -0
  23. package/lib/schemas/2025.10/resolver/modifier.json +85 -0
  24. package/lib/schemas/2025.10/resolver/resolutionOrder.json +117 -0
  25. package/lib/schemas/2025.10/resolver/set.json +71 -0
  26. package/lib/schemas/2025.10/resolver.json +62 -0
  27. package/lib/schemas/hrdt-tokens.json +533 -0
  28. package/package.json +60 -0
@@ -0,0 +1,39 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://www.designtokens.org/schemas/2025.10/format/values/fontWeight.json",
4
+ "title": "Font Weight Value",
5
+ "description": "Value schema for fontWeight type tokens. Represents a font weight as per the OpenType wght tag specification. Lower numbers represent lighter weights, higher numbers represent thicker weights.",
6
+ "oneOf": [
7
+ {
8
+ "type": "number",
9
+ "description": "Numeric font weight value",
10
+ "minimum": 1,
11
+ "maximum": 1000
12
+ },
13
+ {
14
+ "type": "string",
15
+ "description": "Pre-defined font weight string value",
16
+ "enum": [
17
+ "thin",
18
+ "hairline",
19
+ "extra-light",
20
+ "ultra-light",
21
+ "light",
22
+ "normal",
23
+ "regular",
24
+ "book",
25
+ "medium",
26
+ "semi-bold",
27
+ "demi-bold",
28
+ "bold",
29
+ "extra-bold",
30
+ "ultra-bold",
31
+ "black",
32
+ "heavy",
33
+ "extra-black",
34
+ "ultra-black"
35
+ ]
36
+ }
37
+ ]
38
+ }
39
+
@@ -0,0 +1,53 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://www.designtokens.org/schemas/2025.10/format/values/gradient.json",
4
+ "title": "Gradient Value",
5
+ "description": "Value schema for gradient type tokens. Represents a color gradient.",
6
+ "type": "array",
7
+ "items": {
8
+ "oneOf": [
9
+ {
10
+ "$ref": "#/definitions/gradientStop"
11
+ },
12
+ {
13
+ "$ref": "../../format.json#/definitions/tokenValueReference"
14
+ }
15
+ ]
16
+ },
17
+ "minItems": 1,
18
+ "definitions": {
19
+ "gradientStop": {
20
+ "title": "Gradient Stop",
21
+ "type": "object",
22
+ "properties": {
23
+ "color": {
24
+ "description": "The color value at the stop's position on the gradient",
25
+ "oneOf": [
26
+ {
27
+ "$ref": "color.json"
28
+ },
29
+ {
30
+ "$ref": "../../format.json#/definitions/tokenValueReference"
31
+ }
32
+ ]
33
+ },
34
+ "position": {
35
+ "description": "The position of the stop along the gradient's axis (range [0, 1]). Values outside this range are clamped.",
36
+ "oneOf": [
37
+ {
38
+ "type": "number",
39
+ "minimum": 0,
40
+ "maximum": 1
41
+ },
42
+ {
43
+ "$ref": "../../format.json#/definitions/tokenValueReference"
44
+ }
45
+ ]
46
+ }
47
+ },
48
+ "required": ["color", "position"],
49
+ "additionalProperties": false
50
+ }
51
+ }
52
+ }
53
+
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://www.designtokens.org/schemas/2025.10/format/values/number.json",
4
+ "title": "Number Value",
5
+ "description": "Value schema for number type tokens. Numbers can be positive, negative and have fractions. Example uses are gradient stop positions or unitless line heights.",
6
+ "type": "number"
7
+ }
8
+
@@ -0,0 +1,103 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://www.designtokens.org/schemas/2025.10/format/values/shadow.json",
4
+ "title": "Shadow Value",
5
+ "description": "Value schema for shadow type tokens. Represents a shadow style.",
6
+ "oneOf": [
7
+ {
8
+ "$ref": "#/definitions/shadowObject"
9
+ },
10
+ {
11
+ "type": "array",
12
+ "description": "Array of shadow objects and/or references to shadow tokens",
13
+ "items": {
14
+ "oneOf": [
15
+ {
16
+ "$ref": "#/definitions/shadowObject"
17
+ },
18
+ {
19
+ "$ref": "../../format.json#/definitions/tokenValueReference"
20
+ }
21
+ ]
22
+ },
23
+ "minItems": 1
24
+ }
25
+ ],
26
+ "definitions": {
27
+ "shadowObject": {
28
+ "title": "Shadow Object",
29
+ "type": "object",
30
+ "properties": {
31
+ "color": {
32
+ "description": "The color of the shadow",
33
+ "oneOf": [
34
+ {
35
+ "$ref": "color.json"
36
+ },
37
+ {
38
+ "$ref": "../../format.json#/definitions/tokenValueReference"
39
+ }
40
+ ]
41
+ },
42
+ "offsetX": {
43
+ "description": "The horizontal offset that shadow has from the element it is applied to",
44
+ "oneOf": [
45
+ {
46
+ "$ref": "dimension.json"
47
+ },
48
+ {
49
+ "$ref": "../../format.json#/definitions/tokenValueReference"
50
+ }
51
+ ]
52
+ },
53
+ "offsetY": {
54
+ "description": "The vertical offset that shadow has from the element it is applied to",
55
+ "oneOf": [
56
+ {
57
+ "$ref": "dimension.json"
58
+ },
59
+ {
60
+ "$ref": "../../format.json#/definitions/tokenValueReference"
61
+ }
62
+ ]
63
+ },
64
+ "blur": {
65
+ "description": "The blur radius that is applied to the shadow",
66
+ "oneOf": [
67
+ {
68
+ "$ref": "dimension.json"
69
+ },
70
+ {
71
+ "$ref": "../../format.json#/definitions/tokenValueReference"
72
+ }
73
+ ]
74
+ },
75
+ "spread": {
76
+ "description": "The amount by which to expand or contract the shadow",
77
+ "oneOf": [
78
+ {
79
+ "$ref": "dimension.json"
80
+ },
81
+ {
82
+ "$ref": "../../format.json#/definitions/tokenValueReference"
83
+ }
84
+ ]
85
+ },
86
+ "inset": {
87
+ "description": "Whether this shadow is inside the containing shape (inner shadow) rather than a drop shadow (default: false)",
88
+ "oneOf": [
89
+ {
90
+ "type": "boolean"
91
+ },
92
+ {
93
+ "$ref": "../../format.json#/definitions/jsonPointerReferenceObject"
94
+ }
95
+ ]
96
+ }
97
+ },
98
+ "required": ["color", "offsetX", "offsetY", "blur", "spread"],
99
+ "additionalProperties": false
100
+ }
101
+ }
102
+ }
103
+
@@ -0,0 +1,64 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://www.designtokens.org/schemas/2025.10/format/values/strokeStyle.json",
4
+ "title": "Stroke Style Value",
5
+ "description": "Value schema for strokeStyle type tokens. Represents the style applied to lines or borders.",
6
+ "oneOf": [
7
+ {
8
+ "type": "string",
9
+ "enum": [
10
+ "solid",
11
+ "dashed",
12
+ "dotted",
13
+ "double",
14
+ "groove",
15
+ "ridge",
16
+ "outset",
17
+ "inset"
18
+ ],
19
+ "description": "Pre-defined stroke style values with the same meaning as CSS line style values"
20
+ },
21
+ {
22
+ "type": "object",
23
+ "properties": {
24
+ "dashArray": {
25
+ "description": "Array of dimension values specifying lengths of alternating dashes and gaps",
26
+ "oneOf": [
27
+ {
28
+ "type": "array",
29
+ "items": {
30
+ "oneOf": [
31
+ {
32
+ "$ref": "dimension.json"
33
+ },
34
+ {
35
+ "$ref": "../../format.json#/definitions/tokenValueReference"
36
+ }
37
+ ]
38
+ },
39
+ "minItems": 1
40
+ },
41
+ {
42
+ "$ref": "../../format.json#/definitions/jsonPointerReferenceObject"
43
+ }
44
+ ]
45
+ },
46
+ "lineCap": {
47
+ "description": "Line cap style, same meaning as SVG stroke-linecap attribute",
48
+ "oneOf": [
49
+ {
50
+ "type": "string",
51
+ "enum": ["round", "butt", "square"]
52
+ },
53
+ {
54
+ "$ref": "../../format.json#/definitions/jsonPointerReferenceObject"
55
+ }
56
+ ]
57
+ }
58
+ },
59
+ "required": ["dashArray", "lineCap"],
60
+ "additionalProperties": false
61
+ }
62
+ ]
63
+ }
64
+
@@ -0,0 +1,45 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://www.designtokens.org/schemas/2025.10/format/values/transition.json",
4
+ "title": "Transition Value",
5
+ "description": "Value schema for transition type tokens. Represents an animated transition between two states.",
6
+ "type": "object",
7
+ "properties": {
8
+ "duration": {
9
+ "description": "The duration of the transition",
10
+ "oneOf": [
11
+ {
12
+ "$ref": "duration.json"
13
+ },
14
+ {
15
+ "$ref": "../../format.json#/definitions/tokenValueReference"
16
+ }
17
+ ]
18
+ },
19
+ "delay": {
20
+ "description": "The time to wait before the transition begins",
21
+ "oneOf": [
22
+ {
23
+ "$ref": "duration.json"
24
+ },
25
+ {
26
+ "$ref": "../../format.json#/definitions/tokenValueReference"
27
+ }
28
+ ]
29
+ },
30
+ "timingFunction": {
31
+ "description": "The timing function of the transition",
32
+ "oneOf": [
33
+ {
34
+ "$ref": "cubicBezier.json"
35
+ },
36
+ {
37
+ "$ref": "../../format.json#/definitions/tokenValueReference"
38
+ }
39
+ ]
40
+ }
41
+ },
42
+ "required": ["duration", "delay", "timingFunction"],
43
+ "additionalProperties": false
44
+ }
45
+
@@ -0,0 +1,73 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://www.designtokens.org/schemas/2025.10/format/values/typography.json",
4
+ "title": "Typography Value",
5
+ "description": "Value schema for typography type tokens. Represents a typographic style.",
6
+ "type": "object",
7
+ "properties": {
8
+ "fontFamily": {
9
+ "description": "The typography's font",
10
+ "oneOf": [
11
+ {
12
+ "$ref": "fontFamily.json"
13
+ },
14
+ {
15
+ "$ref": "../../format.json#/definitions/tokenValueReference"
16
+ }
17
+ ]
18
+ },
19
+ "fontSize": {
20
+ "description": "The size of the typography",
21
+ "oneOf": [
22
+ {
23
+ "$ref": "dimension.json"
24
+ },
25
+ {
26
+ "$ref": "../../format.json#/definitions/tokenValueReference"
27
+ }
28
+ ]
29
+ },
30
+ "fontWeight": {
31
+ "description": "The weight of the typography",
32
+ "oneOf": [
33
+ {
34
+ "$ref": "fontWeight.json"
35
+ },
36
+ {
37
+ "$ref": "../../format.json#/definitions/tokenValueReference"
38
+ }
39
+ ]
40
+ },
41
+ "letterSpacing": {
42
+ "description": "The horizontal spacing between characters",
43
+ "oneOf": [
44
+ {
45
+ "$ref": "dimension.json"
46
+ },
47
+ {
48
+ "$ref": "../../format.json#/definitions/tokenValueReference"
49
+ }
50
+ ]
51
+ },
52
+ "lineHeight": {
53
+ "description": "The vertical spacing between lines of typography (interpreted as a multiplier of fontSize)",
54
+ "oneOf": [
55
+ {
56
+ "$ref": "number.json"
57
+ },
58
+ {
59
+ "$ref": "../../format.json#/definitions/tokenValueReference"
60
+ }
61
+ ]
62
+ }
63
+ },
64
+ "required": [
65
+ "fontFamily",
66
+ "fontSize",
67
+ "fontWeight",
68
+ "letterSpacing",
69
+ "lineHeight"
70
+ ],
71
+ "additionalProperties": false
72
+ }
73
+
@@ -0,0 +1,106 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://www.designtokens.org/schemas/2025.10/format.json",
4
+ "title": "DTCG Format Schema",
5
+ "description": "JSON Schema for the Design Tokens Community Group (DTCG) Format specification.",
6
+ "type": "object",
7
+ "properties": {
8
+ "$schema": {
9
+ "type": "string",
10
+ "format": "uri-reference",
11
+ "description": "URI reference to this JSON schema.",
12
+ "$comment": "$schema is not part of the official DTCG specification."
13
+ },
14
+ "$type": {
15
+ "$ref": "format/tokenType.json",
16
+ "description": "The type for tokens in this group (inherited by nested tokens unless overridden)"
17
+ },
18
+ "$description": {
19
+ "type": "string",
20
+ "description": "A plain text description of the group"
21
+ },
22
+ "$extensions": {
23
+ "type": "object",
24
+ "description": "Vendor-specific extensions"
25
+ },
26
+ "$extends": {
27
+ "oneOf": [
28
+ {
29
+ "$ref": "#/definitions/curlyBraceReference"
30
+ },
31
+ {
32
+ "$ref": "#/definitions/jsonPointerReference"
33
+ }
34
+ ],
35
+ "description": "Reference to another group to inherit tokens and properties from"
36
+ },
37
+ "$deprecated": {
38
+ "oneOf": [
39
+ {
40
+ "type": "boolean"
41
+ },
42
+ {
43
+ "type": "string"
44
+ }
45
+ ],
46
+ "description": "Whether this group is deprecated"
47
+ },
48
+ "$root": {
49
+ "description": "Root token for this group. The $root token provides a base value for the group while allowing for variants or extensions.",
50
+ "$ref": "format/token.json"
51
+ }
52
+ },
53
+ "patternProperties": {
54
+ "^[^${}.][^{}.]*$": {
55
+ "description": "Nested groups and tokens (see #/definitions/tokenOrGroupName for pattern definition)",
56
+ "$ref": "format/groupOrToken.json"
57
+ }
58
+ },
59
+ "additionalProperties": false,
60
+ "definitions": {
61
+ "tokenOrGroupName": {
62
+ "title": "Token or Group Name",
63
+ "type": "string",
64
+ "pattern": "^[^${}.][^{}.]*$",
65
+ "description": "Valid token/group names: must not start with $ and must not contain {, }, or ."
66
+ },
67
+ "curlyBraceReference": {
68
+ "title": "Curly Brace Reference",
69
+ "type": "string",
70
+ "pattern": "^\\{[^${}.][^{}.]*(\\.[^${}.][^{}.]*)*\\}$",
71
+ "description": "Curly brace reference (e.g., '{tokenName}' or '{group.nested.token}')"
72
+ },
73
+ "jsonPointerReference": {
74
+ "title": "JSON Pointer Reference",
75
+ "type": "string",
76
+ "pattern": "^#/",
77
+ "format": "json-pointer-uri-fragment",
78
+ "description": "JSON Pointer reference (RFC 6901) to a location in the document (e.g., '#/path/to/target')"
79
+ },
80
+ "jsonPointerReferenceObject": {
81
+ "title": "JSON Pointer Reference Object",
82
+ "type": "object",
83
+ "properties": {
84
+ "$ref": {
85
+ "$ref": "#/definitions/jsonPointerReference"
86
+ }
87
+ },
88
+ "required": ["$ref"],
89
+ "additionalProperties": false,
90
+ "description": "Object containing a JSON Pointer reference for property-level references"
91
+ },
92
+ "tokenValueReference": {
93
+ "title": "Token Value Reference",
94
+ "oneOf": [
95
+ {
96
+ "$ref": "#/definitions/curlyBraceReference"
97
+ },
98
+ {
99
+ "$ref": "#/definitions/jsonPointerReferenceObject"
100
+ }
101
+ ],
102
+ "description": "A reference to a token value using either curly brace syntax or JSON Pointer syntax"
103
+ }
104
+ }
105
+ }
106
+
@@ -0,0 +1,85 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://www.designtokens.org/schemas/2025.10/resolver/modifier.json",
4
+ "title": "Modifier",
5
+ "description": "A modifier is similar to a set, but allows for conditional inclusion via the contexts map. A modifier MUST declare a contexts map of string values to arrays of token sources.",
6
+ "type": "object",
7
+ "required": ["contexts"],
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "description": {
11
+ "title": "Description",
12
+ "type": "string",
13
+ "description": "A human-readable description of the purpose of the modifier."
14
+ },
15
+ "contexts": {
16
+ "title": "Contexts",
17
+ "type": "object",
18
+ "description": "A map of context names to arrays of token sources. Each context represents a possible variant (e.g., 'light' vs 'dark' for theme, 'small' vs 'large' for size).",
19
+ "minProperties": 2,
20
+ "patternProperties": {
21
+ "^.+$": {
22
+ "$ref": "#/definitions/tokenSourcesForModifiers",
23
+ "description": "An array of token sources for this context. Can contain reference objects pointing to JSON files, inline token definitions, or any combination. If the array declares multiple sources, they will be merged in array order, meaning if a token is declared multiple times, the last occurrence in the array will be the final value."
24
+ }
25
+ },
26
+ "additionalProperties": false
27
+ },
28
+ "default": {
29
+ "title": "Default Context",
30
+ "type": "string",
31
+ "description": "An optional default value that MUST match one of the keys in contexts. If provided, tools will use this context when no input is provided for this modifier.",
32
+ "$comment": "JSON Schema cannot validate that this value matches a key in 'contexts'. This validation must be performed at runtime by the implementation."
33
+ },
34
+ "$extensions": {
35
+ "title": "Extensions",
36
+ "type": "object",
37
+ "description": "Vendor-specific extensions. Keys are vendor-specific namespaces."
38
+ }
39
+ },
40
+ "definitions": {
41
+ "referenceObjectForModifiers": {
42
+ "title": "Reference Object (For Modifiers)",
43
+ "type": "object",
44
+ "required": ["$ref"],
45
+ "properties": {
46
+ "$ref": {
47
+ "title": "JSON Reference",
48
+ "type": "string",
49
+ "format": "uri-reference",
50
+ "description": "A JSON Pointer (RFC 6901) or URI reference. Modifiers MUST NOT reference other modifiers (#/modifiers/...) or resolutionOrder items (#/resolutionOrder/...).",
51
+ "not": {
52
+ "anyOf": [
53
+ {
54
+ "pattern": "^#/modifiers/",
55
+ "$comment": "Modifiers cannot reference other modifiers"
56
+ },
57
+ {
58
+ "pattern": "^#/resolutionOrder/",
59
+ "$comment": "Nothing can reference resolutionOrder items"
60
+ }
61
+ ]
62
+ }
63
+ }
64
+ },
65
+ "description": "A reference object for use within modifier contexts. Cannot point to other modifiers or resolutionOrder items."
66
+ },
67
+ "tokenSourcesForModifiers": {
68
+ "title": "Token Sources (For Modifiers)",
69
+ "type": "array",
70
+ "description": "An array of token sources for modifier contexts - can reference sets but not other modifiers or resolutionOrder items.",
71
+ "items": {
72
+ "oneOf": [
73
+ {
74
+ "$ref": "#/definitions/referenceObjectForModifiers"
75
+ },
76
+ {
77
+ "$ref": "../format.json",
78
+ "description": "Inline design tokens in DTCG format"
79
+ }
80
+ ]
81
+ }
82
+ }
83
+ }
84
+ }
85
+