@terrazzo/parser 0.0.6 → 0.0.8
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/LICENSE +2 -2
- package/build/index.d.ts +3 -3
- package/build/index.js +22 -7
- package/config.d.ts +1 -1
- 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 -13
- package/parse/index.d.ts +1 -1
- package/parse/index.js +4 -4
- package/parse/normalize.d.ts +1 -1
- package/types.d.ts +0 -523
- package/types.js +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2024 Drew Powers
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
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/config.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface Config {
|
|
|
13
13
|
lint?: {
|
|
14
14
|
/** Configure build behavior */
|
|
15
15
|
build?: {
|
|
16
|
-
/** Should linters run with `
|
|
16
|
+
/** Should linters run with `tz build`? (default: true) */
|
|
17
17
|
enabled?: boolean;
|
|
18
18
|
};
|
|
19
19
|
/** Configure lint rules */
|
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,18 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrazzo/parser",
|
|
3
|
+
"version": "0.0.8",
|
|
3
4
|
"description": "Parser/validator for the Design Tokens Community Group (DTCG) standard.",
|
|
4
|
-
"
|
|
5
|
+
"type": "module",
|
|
5
6
|
"author": {
|
|
6
7
|
"name": "Drew Powers",
|
|
7
8
|
"email": "drew@pow.rs"
|
|
8
9
|
},
|
|
9
10
|
"keywords": [
|
|
10
11
|
"design tokens",
|
|
11
|
-
"design tokens community group",
|
|
12
|
-
"design tokens format module",
|
|
13
12
|
"dtcg",
|
|
14
13
|
"cli",
|
|
15
|
-
"w3c
|
|
14
|
+
"w3c",
|
|
16
15
|
"design system",
|
|
17
16
|
"typescript",
|
|
18
17
|
"sass",
|
|
@@ -22,12 +21,17 @@
|
|
|
22
21
|
"linting",
|
|
23
22
|
"lint"
|
|
24
23
|
],
|
|
25
|
-
"license": "MIT",
|
|
26
|
-
"type": "module",
|
|
27
24
|
"main": "./index.js",
|
|
25
|
+
"homepage": "https://terrazzoapp.com/docs/cli/api/js",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/terrazzoapp/terrazzo.git",
|
|
29
|
+
"directory": "./packages/parser/"
|
|
30
|
+
},
|
|
31
|
+
"license": "MIT",
|
|
28
32
|
"dependencies": {
|
|
29
|
-
"@babel/code-frame": "^7.24.
|
|
30
|
-
"@humanwhocodes/momoa": "^3.0.
|
|
33
|
+
"@babel/code-frame": "^7.24.7",
|
|
34
|
+
"@humanwhocodes/momoa": "^3.0.6",
|
|
31
35
|
"@types/babel__code-frame": "^7.0.6",
|
|
32
36
|
"@types/culori": "^2.1.0",
|
|
33
37
|
"@types/deep-equal": "^1.0.4",
|
|
@@ -37,11 +41,8 @@
|
|
|
37
41
|
"merge-anything": "^5.1.7",
|
|
38
42
|
"picocolors": "^1.0.1",
|
|
39
43
|
"wildcard-match": "^5.1.3",
|
|
40
|
-
"yaml": "^2.4.
|
|
41
|
-
"@terrazzo/token-tools": "^0.0.
|
|
42
|
-
},
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"strip-ansi": "^7.1.0"
|
|
44
|
+
"yaml": "^2.4.5",
|
|
45
|
+
"@terrazzo/token-tools": "^0.0.4"
|
|
45
46
|
},
|
|
46
47
|
"scripts": {
|
|
47
48
|
"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/index.js
CHANGED
|
@@ -193,7 +193,7 @@ export default async function parse(input, { logger = new Logger(), skipLint = f
|
|
|
193
193
|
if (members.$value) {
|
|
194
194
|
node = members.$value;
|
|
195
195
|
}
|
|
196
|
-
logger.error({ message: err.message, source, node });
|
|
196
|
+
logger.error({ message: err.message, source, node, continueOnError: true });
|
|
197
197
|
}
|
|
198
198
|
for (const mode in tokens[id].mode) {
|
|
199
199
|
if (mode === '.') {
|
|
@@ -207,7 +207,7 @@ export default async function parse(input, { logger = new Logger(), skipLint = f
|
|
|
207
207
|
if (members.$value) {
|
|
208
208
|
node = members.$value;
|
|
209
209
|
}
|
|
210
|
-
logger.error({ message: err.message, source, node: tokens[id].mode[mode].sourceNode });
|
|
210
|
+
logger.error({ message: err.message, source, node: tokens[id].mode[mode].sourceNode, continueOnError: true });
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
}
|
|
@@ -302,10 +302,10 @@ export function maybeJSONString(input) {
|
|
|
302
302
|
export function resolveAlias(alias, { tokens, logger, source, node, scanned = [] }) {
|
|
303
303
|
const { id } = parseAlias(alias);
|
|
304
304
|
if (!tokens[id]) {
|
|
305
|
-
logger.error({ message: `Alias "${alias}" not found`, source, node });
|
|
305
|
+
logger.error({ message: `Alias "${alias}" not found`, source, node, continueOnError: true });
|
|
306
306
|
}
|
|
307
307
|
if (scanned.includes(id)) {
|
|
308
|
-
logger.error({ message: `Circular alias detected from "${alias}"`, source, node });
|
|
308
|
+
logger.error({ message: `Circular alias detected from "${alias}"`, source, node, continueOnError: true });
|
|
309
309
|
}
|
|
310
310
|
const token = tokens[id];
|
|
311
311
|
if (!isAlias(token.$value)) {
|
package/parse/normalize.d.ts
CHANGED
package/types.d.ts
DELETED
|
@@ -1,523 +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 =
|
|
62
|
-
| string
|
|
63
|
-
| { colorSpace: ColorSpace; channels: [number, number, number]; alpha?: number; hex?: string };
|
|
64
|
-
|
|
65
|
-
export interface CubicBézierToken extends TokenCore {
|
|
66
|
-
$type: 'cubicBezier';
|
|
67
|
-
$value: CubicBézierValue | AliasValue;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export type CubicBézierValue = [number, number, number, number];
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* 8.2 Dimension
|
|
74
|
-
*/
|
|
75
|
-
export interface DimensionToken extends TokenCore {
|
|
76
|
-
$type: 'dimension';
|
|
77
|
-
$value: string | AliasValue;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export type DimensionValue = `${number}px` | `${number}em` | `${number}rem`;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* 8.5 Duration
|
|
84
|
-
*/
|
|
85
|
-
export interface DurationToken extends TokenCore {
|
|
86
|
-
$type: 'duration';
|
|
87
|
-
$value: string | AliasValue;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export type DurationValue = `${number}ms` | `${number}s`;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* 9.6 Gradient
|
|
94
|
-
*/
|
|
95
|
-
export interface GradientToken extends TokenCore {
|
|
96
|
-
$type: 'gradient';
|
|
97
|
-
$value: GradientValue | AliasValue;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export type GradientValue = GradientStop[];
|
|
101
|
-
|
|
102
|
-
export interface GradientStop {
|
|
103
|
-
color: ColorValue | AliasValue;
|
|
104
|
-
position: NumberValue | AliasValue;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* 8.3 Font Family
|
|
109
|
-
*/
|
|
110
|
-
export interface FontFamilyToken extends TokenCore {
|
|
111
|
-
$type: 'fontFamily';
|
|
112
|
-
$value: FontFamilyValue | AliasValue;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export type FontFamilyValue = string | string[];
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* 8.4 Font Weight
|
|
119
|
-
*/
|
|
120
|
-
export interface FontWeightToken extends TokenCore {
|
|
121
|
-
$type: 'fontWeight';
|
|
122
|
-
$value: FontWeightValue | AliasValue;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export type FontWeightValue =
|
|
126
|
-
| 'thin'
|
|
127
|
-
| 'hairline'
|
|
128
|
-
| 'extra-light'
|
|
129
|
-
| 'ultra-light'
|
|
130
|
-
| 'light'
|
|
131
|
-
| 'normal'
|
|
132
|
-
| 'regular'
|
|
133
|
-
| 'book'
|
|
134
|
-
| 'medium'
|
|
135
|
-
| 'semi-bold'
|
|
136
|
-
| 'demi-bold'
|
|
137
|
-
| 'bold'
|
|
138
|
-
| 'extra-bold'
|
|
139
|
-
| 'ultra-bold'
|
|
140
|
-
| 'black'
|
|
141
|
-
| 'heavy'
|
|
142
|
-
| 'extra-black'
|
|
143
|
-
| 'ultra-black'
|
|
144
|
-
| number;
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* 8.? Link (beta)
|
|
148
|
-
*/
|
|
149
|
-
export interface LinkToken extends TokenCore {
|
|
150
|
-
$type: 'link';
|
|
151
|
-
$value: LinkValue | AliasValue;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export type LinkValue = string;
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* 8.7 Number
|
|
158
|
-
*/
|
|
159
|
-
export interface NumberToken extends TokenCore {
|
|
160
|
-
$type: 'number';
|
|
161
|
-
$value: NumberValue | AliasValue;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export type NumberValue = number;
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* 8.? String (beta)
|
|
168
|
-
*/
|
|
169
|
-
export interface StringToken extends TokenCore {
|
|
170
|
-
$type: 'string';
|
|
171
|
-
$value: StringValue | AliasValue;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export type StringValue = string;
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* 9.2 Stroke Style
|
|
178
|
-
*/
|
|
179
|
-
export interface StrokeStyleToken extends TokenCore {
|
|
180
|
-
$type: 'strokeStyle';
|
|
181
|
-
$value: StrokeStyleValue | AliasValue;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export type StrokeStyleValue =
|
|
185
|
-
| 'solid'
|
|
186
|
-
| 'dashed'
|
|
187
|
-
| 'dotted'
|
|
188
|
-
| 'double'
|
|
189
|
-
| 'groove'
|
|
190
|
-
| 'ridge'
|
|
191
|
-
| 'outset'
|
|
192
|
-
| 'inset'
|
|
193
|
-
| StrokeStyleValueExpanded;
|
|
194
|
-
|
|
195
|
-
export interface StrokeStyleValueExpanded {
|
|
196
|
-
dashArray: DimensionValue[];
|
|
197
|
-
lineCap: 'round' | 'butt' | 'square';
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* 9.5 Shadow
|
|
202
|
-
*/
|
|
203
|
-
export interface ShadowToken extends TokenCore {
|
|
204
|
-
$type: 'shadow';
|
|
205
|
-
$value: ShadowValue | ShadowValue[] | AliasValue;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export interface ShadowValue {
|
|
209
|
-
color: ColorValue | AliasValue;
|
|
210
|
-
offsetX: DimensionValue | AliasValue;
|
|
211
|
-
offsetY: DimensionValue | AliasValue;
|
|
212
|
-
blur?: DimensionValue | AliasValue;
|
|
213
|
-
spread?: DimensionValue | AliasValue;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* 9.4 Transition
|
|
218
|
-
*/
|
|
219
|
-
export interface TransitionToken extends TokenCore {
|
|
220
|
-
$type: 'transition';
|
|
221
|
-
$value: TransitionValue | AliasValue;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export interface TransitionValue {
|
|
225
|
-
duration: DurationValue | AliasValue;
|
|
226
|
-
delay: DurationValue | AliasValue;
|
|
227
|
-
timingFunction: CubicBézierValue | AliasValue;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* 9.7 Typography
|
|
232
|
-
*/
|
|
233
|
-
export interface TypographyToken extends TokenCore {
|
|
234
|
-
$type: 'typography';
|
|
235
|
-
$value: TypographyValue | AliasValue;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
export interface TypographyValue {
|
|
239
|
-
fontFamily?: FontFamilyValue | AliasValue;
|
|
240
|
-
fontSize?: DimensionValue | AliasValue;
|
|
241
|
-
fontStyle?: string;
|
|
242
|
-
fontVariant?: string;
|
|
243
|
-
fontVariantAlternatives?: string;
|
|
244
|
-
fontVariantCaps?: string;
|
|
245
|
-
fontVariantEastAsian?: string;
|
|
246
|
-
fontVariantEmoji?: string;
|
|
247
|
-
fontVariantLigatures?: string;
|
|
248
|
-
fontVariantNumeric?: string;
|
|
249
|
-
fontVariantPosition?: string;
|
|
250
|
-
fontVariationSettings?: string;
|
|
251
|
-
fontWeight?: FontWeightValue | AliasValue;
|
|
252
|
-
letterSpacing?: DimensionValue | AliasValue;
|
|
253
|
-
lineHeight?: DimensionValue | NumberValue | AliasValue;
|
|
254
|
-
textDecoration?: string;
|
|
255
|
-
textTransform?: string;
|
|
256
|
-
[key: string]: any;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
export interface GroupCore {
|
|
260
|
-
$description?: string;
|
|
261
|
-
$type?: Token['$type'];
|
|
262
|
-
$extensions?: Record<string, unknown>;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export type Group = GroupCore & { [key: string]: GroupOrToken };
|
|
266
|
-
|
|
267
|
-
export type GroupOrToken = Group | Token;
|
|
268
|
-
|
|
269
|
-
export interface TokenNormalizedCore {
|
|
270
|
-
$description?: string;
|
|
271
|
-
$extensions?: Record<string, unknown>;
|
|
272
|
-
id: string;
|
|
273
|
-
sourceNode: ObjectNode;
|
|
274
|
-
group: {
|
|
275
|
-
$description?: string;
|
|
276
|
-
$extensions?: Record<string, unknown>;
|
|
277
|
-
id: string;
|
|
278
|
-
/** IDs of all tokens contained in this group */
|
|
279
|
-
tokens: string[];
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
export type TokenNormalized =
|
|
284
|
-
| BooleanTokenNormalized
|
|
285
|
-
| BorderTokenNormalized
|
|
286
|
-
| ColorTokenNormalized
|
|
287
|
-
| CubicBézierTokenNormalized
|
|
288
|
-
| DimensionTokenNormalized
|
|
289
|
-
| DurationTokenNormalized
|
|
290
|
-
| FontFamilyTokenNormalized
|
|
291
|
-
| FontWeightTokenNormalized
|
|
292
|
-
| GradientTokenNormalized
|
|
293
|
-
| LinkTokenNormalized
|
|
294
|
-
| NumberTokenNormalized
|
|
295
|
-
| ShadowTokenNormalized
|
|
296
|
-
| StringTokenNormalized
|
|
297
|
-
| StrokeStyleTokenNormalized
|
|
298
|
-
| TransitionTokenNormalized
|
|
299
|
-
| TypographyTokenNormalized;
|
|
300
|
-
|
|
301
|
-
export interface BooleanTokenNormalized extends TokenNormalizedCore {
|
|
302
|
-
$type: 'boolean';
|
|
303
|
-
$value: BooleanValue;
|
|
304
|
-
aliasOf?: string;
|
|
305
|
-
partialAliasOf?: never;
|
|
306
|
-
mode: Record<string, BooleanTokenNormalized | undefined>;
|
|
307
|
-
originalValue: BooleanToken;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
export interface BorderTokenNormalized extends TokenNormalizedCore {
|
|
311
|
-
$type: 'border';
|
|
312
|
-
$value: BorderValueNormalized;
|
|
313
|
-
aliasOf?: string;
|
|
314
|
-
partialAliasOf?: Partial<Record<keyof BorderValueNormalized, string>>;
|
|
315
|
-
mode: Record<string, BorderTokenNormalized | undefined>;
|
|
316
|
-
originalValue: BorderToken;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
export interface BorderValueNormalized {
|
|
320
|
-
color: ColorValueNormalized;
|
|
321
|
-
width: DimensionValue;
|
|
322
|
-
style: StrokeStyleValueExpanded;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
export interface ColorTokenNormalized extends TokenNormalizedCore {
|
|
326
|
-
$type: 'color';
|
|
327
|
-
$value: ColorValueNormalized;
|
|
328
|
-
aliasOf?: string;
|
|
329
|
-
partialAliasOf?: never;
|
|
330
|
-
mode: Record<string, ColorTokenNormalized | undefined>;
|
|
331
|
-
originalValue: ColorToken;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
export interface ColorValueNormalized {
|
|
335
|
-
/** Colorspace (default: `srgb`) @see https://www.w3.org/TR/css-color-4/#predefined */
|
|
336
|
-
colorSpace: ColorSpace;
|
|
337
|
-
/** Color channels. Will be normalized to 1 unless the colorspace prevents it (e.g. XYZ, LAB) */
|
|
338
|
-
channels: [number, number, number];
|
|
339
|
-
/** Alpha channel, normalized from 0 – 1 */
|
|
340
|
-
alpha: number;
|
|
341
|
-
/** Hex fallback (for sRGB) */
|
|
342
|
-
hex?: string;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
export type ColorSpace =
|
|
346
|
-
| 'a98'
|
|
347
|
-
| 'display-p3'
|
|
348
|
-
| 'hsb'
|
|
349
|
-
| 'hsl'
|
|
350
|
-
| 'hsv'
|
|
351
|
-
| 'lab'
|
|
352
|
-
| 'lch'
|
|
353
|
-
| 'oklab'
|
|
354
|
-
| 'oklch'
|
|
355
|
-
| 'prophoto-rgb'
|
|
356
|
-
| 'rec2020'
|
|
357
|
-
| 'srgb-linear'
|
|
358
|
-
| 'srgb'
|
|
359
|
-
| 'xyz-d50'
|
|
360
|
-
| 'xyz-d65';
|
|
361
|
-
|
|
362
|
-
export interface CubicBézierTokenNormalized extends TokenNormalizedCore {
|
|
363
|
-
$type: 'cubicBezier';
|
|
364
|
-
$value: CubicBézierValue;
|
|
365
|
-
aliasOf?: string;
|
|
366
|
-
partialAliasOf?: [string | undefined, string | undefined, string | undefined, string | undefined];
|
|
367
|
-
mode: Record<string, CubicBézierTokenNormalized | undefined>;
|
|
368
|
-
originalValue: CubicBézierToken;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
export interface DimensionTokenNormalized extends TokenNormalizedCore {
|
|
372
|
-
$type: 'dimension';
|
|
373
|
-
$value: DimensionValue;
|
|
374
|
-
aliasOf?: string;
|
|
375
|
-
partialAliasOf?: never;
|
|
376
|
-
mode: Record<string, DimensionTokenNormalized | undefined>;
|
|
377
|
-
originalValue: DimensionToken;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
export interface DurationTokenNormalized extends TokenNormalizedCore {
|
|
381
|
-
$type: 'duration';
|
|
382
|
-
$value: DurationValue;
|
|
383
|
-
aliasOf?: string;
|
|
384
|
-
partialAliasOf?: never;
|
|
385
|
-
mode: Record<string, DurationTokenNormalized | undefined>;
|
|
386
|
-
originalValue: DurationToken;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
export interface FontFamilyTokenNormalized extends TokenNormalizedCore {
|
|
390
|
-
$type: 'fontFamily';
|
|
391
|
-
$value: FontFamilyValueNormalized;
|
|
392
|
-
aliasOf?: string;
|
|
393
|
-
partialAliasOf?: never;
|
|
394
|
-
mode: Record<string, FontFamilyTokenNormalized | undefined>;
|
|
395
|
-
originalValue: FontFamilyToken;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
export type FontFamilyValueNormalized = string[];
|
|
399
|
-
|
|
400
|
-
export interface FontWeightTokenNormalized extends TokenNormalizedCore {
|
|
401
|
-
$type: 'fontWeight';
|
|
402
|
-
$value: FontWeightValueNormalized;
|
|
403
|
-
aliasOf?: string;
|
|
404
|
-
partialAliasOf?: never;
|
|
405
|
-
mode: Record<string, FontWeightTokenNormalized | undefined>;
|
|
406
|
-
originalValue: FontWeightToken;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
export type FontWeightValueNormalized = number;
|
|
410
|
-
|
|
411
|
-
export interface GradientTokenNormalized extends TokenNormalizedCore {
|
|
412
|
-
$type: 'gradient';
|
|
413
|
-
$value: GradientValueNormalized;
|
|
414
|
-
aliasOf?: string;
|
|
415
|
-
partialAliasOf?: Partial<Record<keyof GradientStopNormalized, string>>[];
|
|
416
|
-
mode: Record<string, GradientTokenNormalized | undefined>;
|
|
417
|
-
originalValue: GradientTokenNormalized;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
export type GradientValueNormalized = GradientStopNormalized[];
|
|
421
|
-
|
|
422
|
-
export interface GradientStopNormalized {
|
|
423
|
-
color: ColorValueNormalized;
|
|
424
|
-
position: number;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
export interface LinkTokenNormalized extends TokenNormalizedCore {
|
|
428
|
-
$type: 'link';
|
|
429
|
-
$value: LinkValue;
|
|
430
|
-
aliasOf?: string;
|
|
431
|
-
partialAliasOf?: never;
|
|
432
|
-
mode: Record<string, LinkTokenNormalized | undefined>;
|
|
433
|
-
originalValue: LinkToken;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
export interface NumberTokenNormalized extends TokenNormalizedCore {
|
|
437
|
-
$type: 'number';
|
|
438
|
-
$value: NumberValue;
|
|
439
|
-
aliasOf?: string;
|
|
440
|
-
partialAliasOf?: never;
|
|
441
|
-
mode: Record<string, NumberTokenNormalized | undefined>;
|
|
442
|
-
originalValue: NumberToken;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
export interface ShadowTokenNormalized extends TokenNormalizedCore {
|
|
446
|
-
$type: 'shadow';
|
|
447
|
-
$value: ShadowValueNormalized[];
|
|
448
|
-
aliasOf?: string;
|
|
449
|
-
partialAliasOf?: Partial<Record<keyof ShadowValueNormalized, string>>[];
|
|
450
|
-
mode: Record<string, ShadowTokenNormalized | undefined>;
|
|
451
|
-
originalValue: ShadowToken;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
export interface ShadowValueNormalized {
|
|
455
|
-
color: ColorValueNormalized;
|
|
456
|
-
offsetX: DimensionValue;
|
|
457
|
-
offsetY: DimensionValue;
|
|
458
|
-
blur: DimensionValue;
|
|
459
|
-
spread: DimensionValue;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
export interface StringTokenNormalized extends TokenNormalizedCore {
|
|
463
|
-
$type: 'string';
|
|
464
|
-
$value: StringValue;
|
|
465
|
-
aliasOf?: string;
|
|
466
|
-
partialAliasOf?: never;
|
|
467
|
-
mode: Record<string, StringTokenNormalized | undefined>;
|
|
468
|
-
originalValue: StringTokenNormalized;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
export interface StrokeStyleTokenNormalized extends TokenNormalizedCore {
|
|
472
|
-
$type: 'strokeStyle';
|
|
473
|
-
$value: StrokeStyleValueExpanded;
|
|
474
|
-
aliasOf?: string;
|
|
475
|
-
partialAliasOf?: never;
|
|
476
|
-
mode: Record<string, StrokeStyleTokenNormalized | undefined>;
|
|
477
|
-
originalValue: StrokeStyleToken;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
export interface TransitionTokenNormalized extends TokenNormalizedCore {
|
|
481
|
-
$type: 'transition';
|
|
482
|
-
$value: TransitionValueNormalized;
|
|
483
|
-
aliasOf?: string;
|
|
484
|
-
partialAliasOf?: Partial<Record<keyof TransitionValueNormalized, string>>;
|
|
485
|
-
mode: Record<string, TransitionTokenNormalized | undefined>;
|
|
486
|
-
originalValue: TransitionToken;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
export interface TransitionValueNormalized {
|
|
490
|
-
duration: DurationValue;
|
|
491
|
-
delay: DurationValue;
|
|
492
|
-
timingFunction: CubicBézierValue;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
export interface TypographyTokenNormalized extends TokenNormalizedCore {
|
|
496
|
-
$type: 'typography';
|
|
497
|
-
$value: TypographyValueNormalized;
|
|
498
|
-
aliasOf?: string;
|
|
499
|
-
partialAliasOf?: Record<string, string>;
|
|
500
|
-
mode: Record<string, TypographyTokenNormalized | undefined>;
|
|
501
|
-
originalValue: TypographyToken;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
export interface TypographyValueNormalized {
|
|
505
|
-
fontFamily?: FontFamilyValue;
|
|
506
|
-
fontSize?: DimensionValue;
|
|
507
|
-
fontStyle?: string;
|
|
508
|
-
fontVariant?: string;
|
|
509
|
-
fontVariantAlternatives?: string;
|
|
510
|
-
fontVariantCaps?: string;
|
|
511
|
-
fontVariantEastAsian?: string;
|
|
512
|
-
fontVariantEmoji?: string;
|
|
513
|
-
fontVariantLigatures?: string;
|
|
514
|
-
fontVariantNumeric?: string;
|
|
515
|
-
fontVariantPosition?: string;
|
|
516
|
-
fontVariationSettings?: string;
|
|
517
|
-
fontWeight?: FontWeightValue;
|
|
518
|
-
letterSpacing?: DimensionValue;
|
|
519
|
-
lineHeight?: DimensionValue | NumberValue;
|
|
520
|
-
textDecoration?: string;
|
|
521
|
-
textTransform?: string;
|
|
522
|
-
[key: string]: any;
|
|
523
|
-
}
|
package/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default null;
|