@terrazzo/parser 0.0.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/types.d.ts ADDED
@@ -0,0 +1,519 @@
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 ADDED
@@ -0,0 +1 @@
1
+ export default null;