@terrazzo/parser 0.0.5 → 0.0.7
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/build/index.d.ts +3 -3
- package/build/index.js +22 -7
- package/index.d.ts +1 -1
- package/index.js +0 -2
- package/lint/index.d.ts +1 -1
- package/logger.d.ts +1 -2
- package/package.json +14 -17
- package/parse/index.d.ts +1 -1
- package/parse/normalize.d.ts +1 -1
- package/parse/normalize.js +4 -1
- package/parse/validate.js +82 -4
- package/types.d.ts +0 -519
- package/types.js +0 -1
package/build/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DocumentNode } from '@humanwhocodes/momoa';
|
|
2
|
+
import type { TokenNormalized } from '@terrazzo/token-tools';
|
|
2
3
|
import type { ConfigInit } from '../config.js';
|
|
3
4
|
import type Logger from '../logger.js';
|
|
4
|
-
import type { TokenNormalized } from '../types.js';
|
|
5
5
|
|
|
6
6
|
export interface BuildRunnerOptions {
|
|
7
7
|
ast: DocumentNode;
|
|
@@ -62,14 +62,14 @@ export interface TransformHookOptions {
|
|
|
62
62
|
/** Map of tokens */
|
|
63
63
|
tokens: Record<string, TokenNormalized>;
|
|
64
64
|
/** Query transformed values */
|
|
65
|
-
getTransforms(params: TransformParams): TokenTransformed;
|
|
65
|
+
getTransforms(params: TransformParams): TokenTransformed[];
|
|
66
66
|
/** Update transformed values */
|
|
67
67
|
setTransform(
|
|
68
68
|
id: string,
|
|
69
69
|
params: {
|
|
70
70
|
format: string;
|
|
71
71
|
localID?: string;
|
|
72
|
-
value: string | Record<string, string>;
|
|
72
|
+
value: string | Record<string, string | undefined>; // allow looser type for input (`undefined` will just get stripped)
|
|
73
73
|
mode?: string;
|
|
74
74
|
},
|
|
75
75
|
): void;
|
package/build/index.js
CHANGED
|
@@ -47,7 +47,7 @@ function validateTransformParams({ params, token, logger, pluginName }) {
|
|
|
47
47
|
}`,
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
if (typeof params.value === 'object' && Object.values(params.value).some((v) =>
|
|
50
|
+
if (typeof params.value === 'object' && Object.values(params.value).some((v) => typeof v !== 'string')) {
|
|
51
51
|
logger.error({
|
|
52
52
|
...baseEntry,
|
|
53
53
|
message: 'setTransform() value expected object of strings, received some non-string values',
|
|
@@ -67,9 +67,9 @@ export default async function build(tokens, { ast, logger = new Logger(), config
|
|
|
67
67
|
function getTransforms(params) {
|
|
68
68
|
return (formats[params.format] ?? []).filter((token) => {
|
|
69
69
|
if (params.$type) {
|
|
70
|
-
if (typeof params.$type === 'string' && token.$type !== params.$type) {
|
|
70
|
+
if (typeof params.$type === 'string' && token.token.$type !== params.$type) {
|
|
71
71
|
return false;
|
|
72
|
-
} else if (Array.isArray(params.$type) && !params.$type.some(($type) => token.type === $type)) {
|
|
72
|
+
} else if (Array.isArray(params.$type) && !params.$type.some(($type) => token.token.type === $type)) {
|
|
73
73
|
return false;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -107,7 +107,20 @@ export default async function build(tokens, { ast, logger = new Logger(), config
|
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
109
|
const token = tokens[id];
|
|
110
|
-
|
|
110
|
+
|
|
111
|
+
// allow `undefined` values, but remove them here
|
|
112
|
+
const cleanValue = typeof params.value === 'string' ? params.value : { ...params.value };
|
|
113
|
+
if (typeof cleanValue === 'object') {
|
|
114
|
+
for (const k in cleanValue) {
|
|
115
|
+
if (Object.hasOwn(cleanValue, k)) {
|
|
116
|
+
if (cleanValue[k] === undefined) {
|
|
117
|
+
delete cleanValue[k];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
validateTransformParams({ token, logger, params: { ...params, value: cleanValue }, pluginName: plugin.name });
|
|
111
124
|
|
|
112
125
|
// upsert
|
|
113
126
|
if (!formats[params.format]) {
|
|
@@ -115,6 +128,7 @@ export default async function build(tokens, { ast, logger = new Logger(), config
|
|
|
115
128
|
}
|
|
116
129
|
const foundTokenI = formats[params.format].findIndex(
|
|
117
130
|
(t) =>
|
|
131
|
+
id === t.id &&
|
|
118
132
|
params.localID === t.localID &&
|
|
119
133
|
(!params.mode || params.mode === t.mode) &&
|
|
120
134
|
(!params.variant || params.variant === t.variant),
|
|
@@ -122,13 +136,14 @@ export default async function build(tokens, { ast, logger = new Logger(), config
|
|
|
122
136
|
if (foundTokenI === -1) {
|
|
123
137
|
formats[params.format].push({
|
|
124
138
|
...params,
|
|
125
|
-
|
|
139
|
+
value: cleanValue,
|
|
140
|
+
type: typeof cleanValue === 'string' ? SINGLE_VALUE : MULTI_VALUE,
|
|
126
141
|
mode: params.mode || '.',
|
|
127
142
|
token: structuredClone(token),
|
|
128
143
|
});
|
|
129
144
|
} else {
|
|
130
|
-
formats[params.format][foundTokenI].value =
|
|
131
|
-
formats[params.format][foundTokenI].type = typeof
|
|
145
|
+
formats[params.format][foundTokenI].value = cleanValue;
|
|
146
|
+
formats[params.format][foundTokenI].type = typeof cleanValue === 'string' ? SINGLE_VALUE : MULTI_VALUE;
|
|
132
147
|
}
|
|
133
148
|
},
|
|
134
149
|
});
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/lint/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AnyNode, DocumentNode } from '@humanwhocodes/momoa';
|
|
2
|
+
import type { Group } from '@terrazzo/token-tools';
|
|
2
3
|
import type { ConfigInit } from '../config.js';
|
|
3
4
|
import type Logger from '../logger.js';
|
|
4
|
-
import type { Group } from '../types.js';
|
|
5
5
|
|
|
6
6
|
export interface LintNotice {
|
|
7
7
|
/** Lint message shown to the user */
|
package/logger.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrazzo/parser",
|
|
3
3
|
"description": "Parser/validator for the Design Tokens Community Group (DTCG) standard.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Drew Powers",
|
|
7
7
|
"email": "drew@pow.rs"
|
|
@@ -26,22 +26,19 @@
|
|
|
26
26
|
"type": "module",
|
|
27
27
|
"main": "./index.js",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@babel/code-frame": "^7.24
|
|
30
|
-
"@humanwhocodes/momoa": "^3.0
|
|
31
|
-
"@types/babel__code-frame": "^7.0
|
|
32
|
-
"@types/culori": "^2.1
|
|
33
|
-
"@types/deep-equal": "^1.0
|
|
34
|
-
"culori": "^4.0
|
|
35
|
-
"deep-equal": "^2.2
|
|
36
|
-
"is-what": "^4.1
|
|
37
|
-
"merge-anything": "^5.1
|
|
38
|
-
"picocolors": "^1.0
|
|
39
|
-
"wildcard-match": "^5.1
|
|
40
|
-
"yaml": "^2.4
|
|
41
|
-
"@terrazzo/token-tools": "^0.0.
|
|
42
|
-
},
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"strip-ansi": "^7.1.0"
|
|
29
|
+
"@babel/code-frame": "^7.24",
|
|
30
|
+
"@humanwhocodes/momoa": "^3.0",
|
|
31
|
+
"@types/babel__code-frame": "^7.0",
|
|
32
|
+
"@types/culori": "^2.1",
|
|
33
|
+
"@types/deep-equal": "^1.0",
|
|
34
|
+
"culori": "^4.0",
|
|
35
|
+
"deep-equal": "^2.2",
|
|
36
|
+
"is-what": "^4.1",
|
|
37
|
+
"merge-anything": "^5.1",
|
|
38
|
+
"picocolors": "^1.0",
|
|
39
|
+
"wildcard-match": "^5.1",
|
|
40
|
+
"yaml": "^2.4",
|
|
41
|
+
"@terrazzo/token-tools": "^0.0.3"
|
|
45
42
|
},
|
|
46
43
|
"scripts": {
|
|
47
44
|
"lint": "biome check .",
|
package/parse/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DocumentNode } from '@humanwhocodes/momoa';
|
|
2
|
+
import type { TokenNormalized } from '@terrazzo/token-tools';
|
|
2
3
|
import type { ConfigInit } from '../config.js';
|
|
3
|
-
import type { TokenNormalized } from '../types.js';
|
|
4
4
|
import type Logger from '../logger.js';
|
|
5
5
|
|
|
6
6
|
export * from './validate.js';
|
package/parse/normalize.d.ts
CHANGED
package/parse/normalize.js
CHANGED
|
@@ -37,7 +37,10 @@ export default function normalizeValue(token) {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
case 'color': {
|
|
40
|
-
|
|
40
|
+
if (typeof token.$value === 'string') {
|
|
41
|
+
return parseColor(token.$value);
|
|
42
|
+
}
|
|
43
|
+
return 'alpha' in token.$value ? token.$value : { ...token.$value, alpha: 1 };
|
|
41
44
|
}
|
|
42
45
|
case 'cubicBezier': {
|
|
43
46
|
return token.$value.map((value) =>
|
package/parse/validate.js
CHANGED
|
@@ -11,6 +11,24 @@ const listFormat = new Intl.ListFormat('en-us', { type: 'disjunction' });
|
|
|
11
11
|
* @typedef {import("@babel/code-frame").SourceLocation} SourceLocation
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
export const VALID_COLORSPACES = new Set([
|
|
15
|
+
'adobe-rgb',
|
|
16
|
+
'display-p3',
|
|
17
|
+
'hsl',
|
|
18
|
+
'hwb',
|
|
19
|
+
'lab',
|
|
20
|
+
'lch',
|
|
21
|
+
'oklab',
|
|
22
|
+
'oklch',
|
|
23
|
+
'prophoto',
|
|
24
|
+
'rec2020',
|
|
25
|
+
'srgb',
|
|
26
|
+
'srgb-linear',
|
|
27
|
+
'xyz',
|
|
28
|
+
'xyz-d50',
|
|
29
|
+
'xyz-d65',
|
|
30
|
+
]);
|
|
31
|
+
|
|
14
32
|
export const FONT_WEIGHT_VALUES = new Set([
|
|
15
33
|
'thin',
|
|
16
34
|
'hairline',
|
|
@@ -128,10 +146,70 @@ export function validateBorder($value, node, { source, logger }) {
|
|
|
128
146
|
* @return {void}
|
|
129
147
|
*/
|
|
130
148
|
export function validateColor($value, node, { source, logger }) {
|
|
131
|
-
if ($value.type
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
149
|
+
if ($value.type === 'String') {
|
|
150
|
+
// TODO: enable when object notation is finalized
|
|
151
|
+
// logger.warn({
|
|
152
|
+
// message: 'String colors are no longer recommended; please use the object notation instead.',
|
|
153
|
+
// node: $value,
|
|
154
|
+
// source,
|
|
155
|
+
// });
|
|
156
|
+
if ($value.value === '') {
|
|
157
|
+
logger.error({ message: 'Expected color, received empty string', node: $value, source });
|
|
158
|
+
}
|
|
159
|
+
} else if ($value.type === 'Object') {
|
|
160
|
+
validateMembersAs(
|
|
161
|
+
$value,
|
|
162
|
+
{
|
|
163
|
+
colorSpace: {
|
|
164
|
+
validator: (v) => {
|
|
165
|
+
if (v.type !== 'String') {
|
|
166
|
+
logger.error({ message: `Expected string, received ${print(v)}`, node: v, source });
|
|
167
|
+
}
|
|
168
|
+
if (!VALID_COLORSPACES.has(v.value)) {
|
|
169
|
+
logger.error({ message: `Unsupported colorspace ${print(v)}`, node: v, source });
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
required: true,
|
|
173
|
+
},
|
|
174
|
+
channels: {
|
|
175
|
+
validator: (v, node) => {
|
|
176
|
+
if (v.type !== 'Array') {
|
|
177
|
+
logger.error({ message: `Expected array, received ${print(v)}`, node: v, source });
|
|
178
|
+
}
|
|
179
|
+
if (v.elements?.length !== 3) {
|
|
180
|
+
logger.error({ message: `Expected 3 channels, received ${v.elements?.length ?? 0}`, node: v, source });
|
|
181
|
+
}
|
|
182
|
+
for (const element of v.elements) {
|
|
183
|
+
if (element.value.type !== 'Number') {
|
|
184
|
+
logger.error({ message: `Expected number, received ${print(element.value)}`, node: element, source });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
required: true,
|
|
189
|
+
},
|
|
190
|
+
hex: {
|
|
191
|
+
validator: (v) => {
|
|
192
|
+
if (
|
|
193
|
+
v.type !== 'String' ||
|
|
194
|
+
// this is a weird one—with the RegEx we test, it will work for
|
|
195
|
+
// lengths of 3, 4, 6, and 8 (but not 5 or 7). So we check length
|
|
196
|
+
// here, to keep the RegEx simple and readable. The "+ 1" is just
|
|
197
|
+
// accounting for the '#' prefix character.
|
|
198
|
+
v.value.length === 5 + 1 ||
|
|
199
|
+
v.value.length === 7 + 1 ||
|
|
200
|
+
!/^#[a-f0-9]{3,8}$/i.test(v.value)
|
|
201
|
+
) {
|
|
202
|
+
logger.error({ message: `Invalid hex color ${print(v)}`, node: v, source });
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
alpha: { validator: validateNumber },
|
|
207
|
+
},
|
|
208
|
+
node,
|
|
209
|
+
{ source, logger },
|
|
210
|
+
);
|
|
211
|
+
} else {
|
|
212
|
+
logger.error({ message: `Expected object, received ${$value.type}`, node: $value, source });
|
|
135
213
|
}
|
|
136
214
|
}
|
|
137
215
|
|
package/types.d.ts
DELETED
|
@@ -1,519 +0,0 @@
|
|
|
1
|
-
import type { ObjectNode } from '@humanwhocodes/momoa';
|
|
2
|
-
|
|
3
|
-
export interface TokenCore<E extends {} = Record<string, unknown>> {
|
|
4
|
-
$description?: string;
|
|
5
|
-
$extensions?: E;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type Token =
|
|
9
|
-
| BooleanToken
|
|
10
|
-
| BorderToken
|
|
11
|
-
| ColorToken
|
|
12
|
-
| CubicBézierToken
|
|
13
|
-
| DimensionToken
|
|
14
|
-
| DurationToken
|
|
15
|
-
| FontFamilyToken
|
|
16
|
-
| FontWeightToken
|
|
17
|
-
| GradientToken
|
|
18
|
-
| LinkToken
|
|
19
|
-
| NumberToken
|
|
20
|
-
| ShadowToken
|
|
21
|
-
| StringToken
|
|
22
|
-
| StringToken
|
|
23
|
-
| TransitionToken
|
|
24
|
-
| TypographyToken
|
|
25
|
-
| StrokeStyleToken;
|
|
26
|
-
|
|
27
|
-
export type AliasValue = string;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* 8.? Boolean (beta)
|
|
31
|
-
*/
|
|
32
|
-
export interface BooleanToken extends TokenCore {
|
|
33
|
-
$type: 'boolean';
|
|
34
|
-
$value: BooleanValue | AliasValue;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export type BooleanValue = boolean;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 9.3 Border
|
|
41
|
-
*/
|
|
42
|
-
export interface BorderToken extends TokenCore {
|
|
43
|
-
$type: 'border';
|
|
44
|
-
$value: BorderValue | AliasValue;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface BorderValue {
|
|
48
|
-
color: ColorValue | AliasValue;
|
|
49
|
-
width: DimensionValue | AliasValue;
|
|
50
|
-
style: StrokeStyleValue | AliasValue;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* 8.1 Color
|
|
55
|
-
*/
|
|
56
|
-
export interface ColorToken extends TokenCore {
|
|
57
|
-
$type: 'color';
|
|
58
|
-
$value: ColorValue | AliasValue;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export type ColorValue = AliasValue | string;
|
|
62
|
-
|
|
63
|
-
export interface CubicBézierToken extends TokenCore {
|
|
64
|
-
$type: 'cubicBezier';
|
|
65
|
-
$value: CubicBézierValue | AliasValue;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export type CubicBézierValue = [number, number, number, number];
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 8.2 Dimension
|
|
72
|
-
*/
|
|
73
|
-
export interface DimensionToken extends TokenCore {
|
|
74
|
-
$type: 'dimension';
|
|
75
|
-
$value: string | AliasValue;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export type DimensionValue = `${number}px` | `${number}em` | `${number}rem`;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* 8.5 Duration
|
|
82
|
-
*/
|
|
83
|
-
export interface DurationToken extends TokenCore {
|
|
84
|
-
$type: 'duration';
|
|
85
|
-
$value: string | AliasValue;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export type DurationValue = `${number}ms` | `${number}s`;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 9.6 Gradient
|
|
92
|
-
*/
|
|
93
|
-
export interface GradientToken extends TokenCore {
|
|
94
|
-
$type: 'gradient';
|
|
95
|
-
$value: GradientValue | AliasValue;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export type GradientValue = GradientStop[];
|
|
99
|
-
|
|
100
|
-
export interface GradientStop {
|
|
101
|
-
color: ColorValue | AliasValue;
|
|
102
|
-
position: NumberValue | AliasValue;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* 8.3 Font Family
|
|
107
|
-
*/
|
|
108
|
-
export interface FontFamilyToken extends TokenCore {
|
|
109
|
-
$type: 'fontFamily';
|
|
110
|
-
$value: FontFamilyValue | AliasValue;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export type FontFamilyValue = string | string[];
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* 8.4 Font Weight
|
|
117
|
-
*/
|
|
118
|
-
export interface FontWeightToken extends TokenCore {
|
|
119
|
-
$type: 'fontWeight';
|
|
120
|
-
$value: FontWeightValue | AliasValue;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export type FontWeightValue =
|
|
124
|
-
| 'thin'
|
|
125
|
-
| 'hairline'
|
|
126
|
-
| 'extra-light'
|
|
127
|
-
| 'ultra-light'
|
|
128
|
-
| 'light'
|
|
129
|
-
| 'normal'
|
|
130
|
-
| 'regular'
|
|
131
|
-
| 'book'
|
|
132
|
-
| 'medium'
|
|
133
|
-
| 'semi-bold'
|
|
134
|
-
| 'demi-bold'
|
|
135
|
-
| 'bold'
|
|
136
|
-
| 'extra-bold'
|
|
137
|
-
| 'ultra-bold'
|
|
138
|
-
| 'black'
|
|
139
|
-
| 'heavy'
|
|
140
|
-
| 'extra-black'
|
|
141
|
-
| 'ultra-black'
|
|
142
|
-
| number;
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* 8.? Link (beta)
|
|
146
|
-
*/
|
|
147
|
-
export interface LinkToken extends TokenCore {
|
|
148
|
-
$type: 'link';
|
|
149
|
-
$value: LinkValue | AliasValue;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export type LinkValue = string;
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* 8.7 Number
|
|
156
|
-
*/
|
|
157
|
-
export interface NumberToken extends TokenCore {
|
|
158
|
-
$type: 'number';
|
|
159
|
-
$value: NumberValue | AliasValue;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export type NumberValue = number;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* 8.? String (beta)
|
|
166
|
-
*/
|
|
167
|
-
export interface StringToken extends TokenCore {
|
|
168
|
-
$type: 'string';
|
|
169
|
-
$value: StringValue | AliasValue;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export type StringValue = string;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* 9.2 Stroke Style
|
|
176
|
-
*/
|
|
177
|
-
export interface StrokeStyleToken extends TokenCore {
|
|
178
|
-
$type: 'strokeStyle';
|
|
179
|
-
$value: StrokeStyleValue | AliasValue;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export type StrokeStyleValue =
|
|
183
|
-
| 'solid'
|
|
184
|
-
| 'dashed'
|
|
185
|
-
| 'dotted'
|
|
186
|
-
| 'double'
|
|
187
|
-
| 'groove'
|
|
188
|
-
| 'ridge'
|
|
189
|
-
| 'outset'
|
|
190
|
-
| 'inset'
|
|
191
|
-
| StrokeStyleValueExpanded;
|
|
192
|
-
|
|
193
|
-
export interface StrokeStyleValueExpanded {
|
|
194
|
-
dashArray: DimensionValue[];
|
|
195
|
-
lineCap: 'round' | 'butt' | 'square';
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* 9.5 Shadow
|
|
200
|
-
*/
|
|
201
|
-
export interface ShadowToken extends TokenCore {
|
|
202
|
-
$type: 'shadow';
|
|
203
|
-
$value: ShadowValue | ShadowValue[] | AliasValue;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export interface ShadowValue {
|
|
207
|
-
color: ColorValue | AliasValue;
|
|
208
|
-
offsetX: DimensionValue | AliasValue;
|
|
209
|
-
offsetY: DimensionValue | AliasValue;
|
|
210
|
-
blur?: DimensionValue | AliasValue;
|
|
211
|
-
spread?: DimensionValue | AliasValue;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* 9.4 Transition
|
|
216
|
-
*/
|
|
217
|
-
export interface TransitionToken extends TokenCore {
|
|
218
|
-
$type: 'transition';
|
|
219
|
-
$value: TransitionValue | AliasValue;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export interface TransitionValue {
|
|
223
|
-
duration: DurationValue | AliasValue;
|
|
224
|
-
delay: DurationValue | AliasValue;
|
|
225
|
-
timingFunction: CubicBézierValue | AliasValue;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* 9.7 Typography
|
|
230
|
-
*/
|
|
231
|
-
export interface TypographyToken extends TokenCore {
|
|
232
|
-
$type: 'typography';
|
|
233
|
-
$value: TypographyValue | AliasValue;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export interface TypographyValue {
|
|
237
|
-
fontFamily?: FontFamilyValue | AliasValue;
|
|
238
|
-
fontSize?: DimensionValue | AliasValue;
|
|
239
|
-
fontStyle?: string;
|
|
240
|
-
fontVariant?: string;
|
|
241
|
-
fontVariantAlternatives?: string;
|
|
242
|
-
fontVariantCaps?: string;
|
|
243
|
-
fontVariantEastAsian?: string;
|
|
244
|
-
fontVariantEmoji?: string;
|
|
245
|
-
fontVariantLigatures?: string;
|
|
246
|
-
fontVariantNumeric?: string;
|
|
247
|
-
fontVariantPosition?: string;
|
|
248
|
-
fontVariationSettings?: string;
|
|
249
|
-
fontWeight?: FontWeightValue | AliasValue;
|
|
250
|
-
letterSpacing?: DimensionValue | AliasValue;
|
|
251
|
-
lineHeight?: DimensionValue | NumberValue | AliasValue;
|
|
252
|
-
textDecoration?: string;
|
|
253
|
-
textTransform?: string;
|
|
254
|
-
[key: string]: any;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
export interface GroupCore {
|
|
258
|
-
$description?: string;
|
|
259
|
-
$type?: Token['$type'];
|
|
260
|
-
$extensions?: Record<string, unknown>;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export type Group = GroupCore & { [key: string]: GroupOrToken };
|
|
264
|
-
|
|
265
|
-
export type GroupOrToken = Group | Token;
|
|
266
|
-
|
|
267
|
-
export interface TokenNormalizedCore {
|
|
268
|
-
$description?: string;
|
|
269
|
-
$extensions?: Record<string, unknown>;
|
|
270
|
-
id: string;
|
|
271
|
-
sourceNode: ObjectNode;
|
|
272
|
-
group: {
|
|
273
|
-
$description?: string;
|
|
274
|
-
$extensions?: Record<string, unknown>;
|
|
275
|
-
id: string;
|
|
276
|
-
/** IDs of all tokens contained in this group */
|
|
277
|
-
tokens: string[];
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
export type TokenNormalized =
|
|
282
|
-
| BooleanTokenNormalized
|
|
283
|
-
| BorderTokenNormalized
|
|
284
|
-
| ColorTokenNormalized
|
|
285
|
-
| CubicBézierTokenNormalized
|
|
286
|
-
| DimensionTokenNormalized
|
|
287
|
-
| DurationTokenNormalized
|
|
288
|
-
| FontFamilyTokenNormalized
|
|
289
|
-
| FontWeightTokenNormalized
|
|
290
|
-
| GradientTokenNormalized
|
|
291
|
-
| LinkTokenNormalized
|
|
292
|
-
| NumberTokenNormalized
|
|
293
|
-
| ShadowTokenNormalized
|
|
294
|
-
| StringTokenNormalized
|
|
295
|
-
| StrokeStyleTokenNormalized
|
|
296
|
-
| TransitionTokenNormalized
|
|
297
|
-
| TypographyTokenNormalized;
|
|
298
|
-
|
|
299
|
-
export interface BooleanTokenNormalized extends TokenNormalizedCore {
|
|
300
|
-
$type: 'boolean';
|
|
301
|
-
$value: BooleanValue;
|
|
302
|
-
aliasOf?: string;
|
|
303
|
-
partialAliasOf?: never;
|
|
304
|
-
mode: Record<string, BooleanTokenNormalized | undefined>;
|
|
305
|
-
originalValue: BooleanToken;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
export interface BorderTokenNormalized extends TokenNormalizedCore {
|
|
309
|
-
$type: 'border';
|
|
310
|
-
$value: BorderValueNormalized;
|
|
311
|
-
aliasOf?: string;
|
|
312
|
-
partialAliasOf?: Partial<Record<keyof BorderValueNormalized, string>>;
|
|
313
|
-
mode: Record<string, BorderTokenNormalized | undefined>;
|
|
314
|
-
originalValue: BorderToken;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
export interface BorderValueNormalized {
|
|
318
|
-
color: ColorValueNormalized;
|
|
319
|
-
width: DimensionValue;
|
|
320
|
-
style: StrokeStyleValueExpanded;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
export interface ColorTokenNormalized extends TokenNormalizedCore {
|
|
324
|
-
$type: 'color';
|
|
325
|
-
$value: ColorValueNormalized;
|
|
326
|
-
aliasOf?: string;
|
|
327
|
-
partialAliasOf?: never;
|
|
328
|
-
mode: Record<string, ColorTokenNormalized | undefined>;
|
|
329
|
-
originalValue: ColorToken;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
export interface ColorValueNormalized {
|
|
333
|
-
/** Colorspace (default: `srgb`) @see https://www.w3.org/TR/css-color-4/#predefined */
|
|
334
|
-
colorSpace: ColorSpace;
|
|
335
|
-
/** Color channels. Will be normalized to 1 unless the colorspace prevents it (e.g. XYZ, LAB) */
|
|
336
|
-
channels: [number, number, number];
|
|
337
|
-
/** Alpha channel, normalized from 0 – 1 */
|
|
338
|
-
alpha: number;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
export type ColorSpace =
|
|
342
|
-
| 'a98'
|
|
343
|
-
| 'display-p3'
|
|
344
|
-
| 'hsb'
|
|
345
|
-
| 'hsl'
|
|
346
|
-
| 'hsv'
|
|
347
|
-
| 'lab'
|
|
348
|
-
| 'lch'
|
|
349
|
-
| 'oklab'
|
|
350
|
-
| 'oklch'
|
|
351
|
-
| 'prophoto-rgb'
|
|
352
|
-
| 'rec2020'
|
|
353
|
-
| 'srgb-linear'
|
|
354
|
-
| 'srgb'
|
|
355
|
-
| 'xyz-d50'
|
|
356
|
-
| 'xyz-d65';
|
|
357
|
-
|
|
358
|
-
export interface CubicBézierTokenNormalized extends TokenNormalizedCore {
|
|
359
|
-
$type: 'cubicBezier';
|
|
360
|
-
$value: CubicBézierValue;
|
|
361
|
-
aliasOf?: string;
|
|
362
|
-
partialAliasOf?: [string | undefined, string | undefined, string | undefined, string | undefined];
|
|
363
|
-
mode: Record<string, CubicBézierTokenNormalized | undefined>;
|
|
364
|
-
originalValue: CubicBézierToken;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
export interface DimensionTokenNormalized extends TokenNormalizedCore {
|
|
368
|
-
$type: 'dimension';
|
|
369
|
-
$value: DimensionValue;
|
|
370
|
-
aliasOf?: string;
|
|
371
|
-
partialAliasOf?: never;
|
|
372
|
-
mode: Record<string, DimensionTokenNormalized | undefined>;
|
|
373
|
-
originalValue: DimensionToken;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
export interface DurationTokenNormalized extends TokenNormalizedCore {
|
|
377
|
-
$type: 'duration';
|
|
378
|
-
$value: DurationValue;
|
|
379
|
-
aliasOf?: string;
|
|
380
|
-
partialAliasOf?: never;
|
|
381
|
-
mode: Record<string, DurationTokenNormalized | undefined>;
|
|
382
|
-
originalValue: DurationToken;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
export interface FontFamilyTokenNormalized extends TokenNormalizedCore {
|
|
386
|
-
$type: 'fontFamily';
|
|
387
|
-
$value: FontFamilyValueNormalized;
|
|
388
|
-
aliasOf?: string;
|
|
389
|
-
partialAliasOf?: never;
|
|
390
|
-
mode: Record<string, FontFamilyTokenNormalized | undefined>;
|
|
391
|
-
originalValue: FontFamilyToken;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
export type FontFamilyValueNormalized = string[];
|
|
395
|
-
|
|
396
|
-
export interface FontWeightTokenNormalized extends TokenNormalizedCore {
|
|
397
|
-
$type: 'fontWeight';
|
|
398
|
-
$value: FontWeightValueNormalized;
|
|
399
|
-
aliasOf?: string;
|
|
400
|
-
partialAliasOf?: never;
|
|
401
|
-
mode: Record<string, FontWeightTokenNormalized | undefined>;
|
|
402
|
-
originalValue: FontWeightToken;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
export type FontWeightValueNormalized = number;
|
|
406
|
-
|
|
407
|
-
export interface GradientTokenNormalized extends TokenNormalizedCore {
|
|
408
|
-
$type: 'gradient';
|
|
409
|
-
$value: GradientValueNormalized;
|
|
410
|
-
aliasOf?: string;
|
|
411
|
-
partialAliasOf?: Partial<Record<keyof GradientStopNormalized, string>>[];
|
|
412
|
-
mode: Record<string, GradientTokenNormalized | undefined>;
|
|
413
|
-
originalValue: GradientTokenNormalized;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
export type GradientValueNormalized = GradientStopNormalized[];
|
|
417
|
-
|
|
418
|
-
export interface GradientStopNormalized {
|
|
419
|
-
color: ColorValueNormalized;
|
|
420
|
-
position: number;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
export interface LinkTokenNormalized extends TokenNormalizedCore {
|
|
424
|
-
$type: 'link';
|
|
425
|
-
$value: LinkValue;
|
|
426
|
-
aliasOf?: string;
|
|
427
|
-
partialAliasOf?: never;
|
|
428
|
-
mode: Record<string, LinkTokenNormalized | undefined>;
|
|
429
|
-
originalValue: LinkToken;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
export interface NumberTokenNormalized extends TokenNormalizedCore {
|
|
433
|
-
$type: 'number';
|
|
434
|
-
$value: NumberValue;
|
|
435
|
-
aliasOf?: string;
|
|
436
|
-
partialAliasOf?: never;
|
|
437
|
-
mode: Record<string, NumberTokenNormalized | undefined>;
|
|
438
|
-
originalValue: NumberToken;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
export interface ShadowTokenNormalized extends TokenNormalizedCore {
|
|
442
|
-
$type: 'shadow';
|
|
443
|
-
$value: ShadowValueNormalized[];
|
|
444
|
-
aliasOf?: string;
|
|
445
|
-
partialAliasOf?: Partial<Record<keyof ShadowValueNormalized, string>>[];
|
|
446
|
-
mode: Record<string, ShadowTokenNormalized | undefined>;
|
|
447
|
-
originalValue: ShadowToken;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
export interface ShadowValueNormalized {
|
|
451
|
-
color: ColorValueNormalized;
|
|
452
|
-
offsetX: DimensionValue;
|
|
453
|
-
offsetY: DimensionValue;
|
|
454
|
-
blur: DimensionValue;
|
|
455
|
-
spread: DimensionValue;
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
export interface StringTokenNormalized extends TokenNormalizedCore {
|
|
459
|
-
$type: 'string';
|
|
460
|
-
$value: StringValue;
|
|
461
|
-
aliasOf?: string;
|
|
462
|
-
partialAliasOf?: never;
|
|
463
|
-
mode: Record<string, StringTokenNormalized | undefined>;
|
|
464
|
-
originalValue: StringTokenNormalized;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
export interface StrokeStyleTokenNormalized extends TokenNormalizedCore {
|
|
468
|
-
$type: 'strokeStyle';
|
|
469
|
-
$value: StrokeStyleValueExpanded;
|
|
470
|
-
aliasOf?: string;
|
|
471
|
-
partialAliasOf?: never;
|
|
472
|
-
mode: Record<string, StrokeStyleTokenNormalized | undefined>;
|
|
473
|
-
originalValue: StrokeStyleToken;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
export interface TransitionTokenNormalized extends TokenNormalizedCore {
|
|
477
|
-
$type: 'transition';
|
|
478
|
-
$value: TransitionValueNormalized;
|
|
479
|
-
aliasOf?: string;
|
|
480
|
-
partialAliasOf?: Partial<Record<keyof TransitionValueNormalized, string>>;
|
|
481
|
-
mode: Record<string, TransitionTokenNormalized | undefined>;
|
|
482
|
-
originalValue: TransitionToken;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
export interface TransitionValueNormalized {
|
|
486
|
-
duration: DurationValue;
|
|
487
|
-
delay: DurationValue;
|
|
488
|
-
timingFunction: CubicBézierValue;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
export interface TypographyTokenNormalized extends TokenNormalizedCore {
|
|
492
|
-
$type: 'typography';
|
|
493
|
-
$value: TypographyValueNormalized;
|
|
494
|
-
aliasOf?: string;
|
|
495
|
-
partialAliasOf?: Record<string, string>;
|
|
496
|
-
mode: Record<string, TypographyTokenNormalized | undefined>;
|
|
497
|
-
originalValue: TypographyToken;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
export interface TypographyValueNormalized {
|
|
501
|
-
fontFamily?: FontFamilyValue;
|
|
502
|
-
fontSize?: DimensionValue;
|
|
503
|
-
fontStyle?: string;
|
|
504
|
-
fontVariant?: string;
|
|
505
|
-
fontVariantAlternatives?: string;
|
|
506
|
-
fontVariantCaps?: string;
|
|
507
|
-
fontVariantEastAsian?: string;
|
|
508
|
-
fontVariantEmoji?: string;
|
|
509
|
-
fontVariantLigatures?: string;
|
|
510
|
-
fontVariantNumeric?: string;
|
|
511
|
-
fontVariantPosition?: string;
|
|
512
|
-
fontVariationSettings?: string;
|
|
513
|
-
fontWeight?: FontWeightValue;
|
|
514
|
-
letterSpacing?: DimensionValue;
|
|
515
|
-
lineHeight?: DimensionValue | NumberValue;
|
|
516
|
-
textDecoration?: string;
|
|
517
|
-
textTransform?: string;
|
|
518
|
-
[key: string]: any;
|
|
519
|
-
}
|
package/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default null;
|