dispersa 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.
- package/LICENSE +21 -0
- package/dist/builders.cjs +1832 -0
- package/dist/builders.cjs.map +1 -0
- package/dist/builders.d.cts +228 -0
- package/dist/builders.d.ts +228 -0
- package/dist/builders.js +1824 -0
- package/dist/builders.js.map +1 -0
- package/dist/errors.cjs +110 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +97 -0
- package/dist/errors.d.ts +97 -0
- package/dist/errors.js +99 -0
- package/dist/errors.js.map +1 -0
- package/dist/filters.cjs +445 -0
- package/dist/filters.cjs.map +1 -0
- package/dist/filters.d.cts +86 -0
- package/dist/filters.d.ts +86 -0
- package/dist/filters.js +440 -0
- package/dist/filters.js.map +1 -0
- package/dist/index-CPB9Ea9U.d.ts +581 -0
- package/dist/index-DKf9WMQG.d.cts +581 -0
- package/dist/index.cjs +7843 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +332 -0
- package/dist/index.d.ts +332 -0
- package/dist/index.js +7802 -0
- package/dist/index.js.map +1 -0
- package/dist/preprocessors.cjs +13 -0
- package/dist/preprocessors.cjs.map +1 -0
- package/dist/preprocessors.d.cts +17 -0
- package/dist/preprocessors.d.ts +17 -0
- package/dist/preprocessors.js +11 -0
- package/dist/preprocessors.js.map +1 -0
- package/dist/renderers.cjs +28 -0
- package/dist/renderers.cjs.map +1 -0
- package/dist/renderers.d.cts +43 -0
- package/dist/renderers.d.ts +43 -0
- package/dist/renderers.js +24 -0
- package/dist/renderers.js.map +1 -0
- package/dist/transforms.cjs +453 -0
- package/dist/transforms.cjs.map +1 -0
- package/dist/transforms.d.cts +138 -0
- package/dist/transforms.d.ts +138 -0
- package/dist/transforms.js +429 -0
- package/dist/transforms.js.map +1 -0
- package/dist/types-BDY1xBmD.d.cts +30 -0
- package/dist/types-C1GpiJ6q.d.cts +368 -0
- package/dist/types-C1GpiJ6q.d.ts +368 -0
- package/dist/types-Cl-1UYGD.d.ts +30 -0
- package/dist/types-DJH6_4U9.d.ts +430 -0
- package/dist/types-DM5faYUn.d.cts +43 -0
- package/dist/types-DbufGPrb.d.cts +430 -0
- package/dist/types-DdPWYkgh.d.ts +43 -0
- package/package.json +141 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Token types - extended from schema-generated types
|
|
3
|
+
*
|
|
4
|
+
* Base token types are defined manually to match DTCG 2025.10.
|
|
5
|
+
* This keeps TypeScript types stable while runtime validation relies on
|
|
6
|
+
* the vendored DTCG JSON Schemas.
|
|
7
|
+
*/
|
|
8
|
+
type JsonPointerReferenceObject = {
|
|
9
|
+
$ref: string;
|
|
10
|
+
};
|
|
11
|
+
type TokenValueReference = string | JsonPointerReferenceObject;
|
|
12
|
+
type Token = {
|
|
13
|
+
$value?: TokenValue | TokenValueReference;
|
|
14
|
+
$ref?: string;
|
|
15
|
+
$type?: TokenType;
|
|
16
|
+
$description?: string;
|
|
17
|
+
$deprecated?: boolean | string;
|
|
18
|
+
$extensions?: Record<string, unknown>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Internal token shape used by the resolver pipeline
|
|
22
|
+
*/
|
|
23
|
+
type InternalToken = Token & {
|
|
24
|
+
/** Internal: Source modifier tag for bundle outputs (not part of DTCG spec) */
|
|
25
|
+
_sourceModifier?: string;
|
|
26
|
+
};
|
|
27
|
+
type TokenGroupMetadataValue = string | boolean | Record<string, unknown> | undefined;
|
|
28
|
+
type TokenGroupBase = {
|
|
29
|
+
$type?: TokenType;
|
|
30
|
+
$description?: string;
|
|
31
|
+
$deprecated?: boolean | string;
|
|
32
|
+
$extensions?: Record<string, unknown>;
|
|
33
|
+
$extends?: string;
|
|
34
|
+
$root?: Token;
|
|
35
|
+
};
|
|
36
|
+
interface TokenGroup extends TokenGroupBase {
|
|
37
|
+
[key: string]: Token | InternalToken | TokenGroup | TokenGroupMetadataValue;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Token type discriminator - union of all valid token type strings
|
|
41
|
+
*
|
|
42
|
+
* Represents the possible values for the $type property in DTCG tokens.
|
|
43
|
+
*/
|
|
44
|
+
type TokenType = 'color' | 'dimension' | 'fontFamily' | 'fontWeight' | 'duration' | 'cubicBezier' | 'number' | 'shadow' | 'typography' | 'border' | 'strokeStyle' | 'transition' | 'gradient';
|
|
45
|
+
/**
|
|
46
|
+
* Token value types - any valid value that can appear in a token
|
|
47
|
+
*
|
|
48
|
+
* Represents the possible types for the $value property in tokens.
|
|
49
|
+
* Can be primitives, objects, or arrays depending on the token type.
|
|
50
|
+
*/
|
|
51
|
+
type TokenValue = string | number | boolean | Record<string, unknown> | unknown[];
|
|
52
|
+
/**
|
|
53
|
+
* Valid DTCG color space identifiers
|
|
54
|
+
* All 14 color spaces from DTCG Color Module 2025-10
|
|
55
|
+
*/
|
|
56
|
+
type ColorSpace = 'srgb' | 'srgb-linear' | 'hsl' | 'hwb' | 'lab' | 'lch' | 'oklab' | 'oklch' | 'display-p3' | 'a98-rgb' | 'prophoto-rgb' | 'rec2020' | 'xyz-d65' | 'xyz-d50';
|
|
57
|
+
/**
|
|
58
|
+
* Color component value: number or the "none" keyword for missing channels
|
|
59
|
+
* Token references are handled separately via alias resolution
|
|
60
|
+
*/
|
|
61
|
+
type ColorComponent = number | 'none';
|
|
62
|
+
/**
|
|
63
|
+
* DTCG color object format with colorSpace and components
|
|
64
|
+
* Each color space has different component meanings and ranges:
|
|
65
|
+
* - RGB-based (srgb, srgb-linear, display-p3, a98-rgb, prophoto-rgb, rec2020): [R: 0-1, G: 0-1, B: 0-1]
|
|
66
|
+
* - HSL: [H: angle, S: 0-100, L: 0-100]
|
|
67
|
+
* - HWB: [H: angle, W: 0-100, B: 0-100]
|
|
68
|
+
* - Lab/CIELab: [L: 0-100, a: -125 to 125, b: -125 to 125]
|
|
69
|
+
* - LCH: [L: 0-100, C: 0-150, H: angle]
|
|
70
|
+
* - OKLab: [L: 0-1, a: -0.4 to 0.4, b: -0.4 to 0.4]
|
|
71
|
+
* - OKLCH: [L: 0-1, C: 0-0.4, H: angle]
|
|
72
|
+
* - XYZ: [X: unbounded, Y: unbounded, Z: unbounded]
|
|
73
|
+
*/
|
|
74
|
+
type ColorValueObject = {
|
|
75
|
+
colorSpace: ColorSpace;
|
|
76
|
+
components: [ColorComponent, ColorComponent, ColorComponent];
|
|
77
|
+
alpha?: number;
|
|
78
|
+
hex?: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* DTCG 2025-10 compliant color value
|
|
82
|
+
*
|
|
83
|
+
* Per DTCG spec, color values must be one of:
|
|
84
|
+
* 1. **Color object** with colorSpace and components (e.g., `{ colorSpace: 'srgb', components: [1, 0, 0] }`)
|
|
85
|
+
* 2. **Token reference** using `{token.path}` or JSON Pointer object (e.g., `"{color.brand.primary}"`)
|
|
86
|
+
*
|
|
87
|
+
* ⚠️ **Important**: Arbitrary CSS color strings like `"#ff0000"`, `"rgb(255, 0, 0)"`, or `"red"`
|
|
88
|
+
* are NOT valid per DTCG spec. String values MUST be alias references.
|
|
89
|
+
*
|
|
90
|
+
* @see {@link https://www.designtokens.org/tr/2025.10/color/ | DTCG Color Module}
|
|
91
|
+
* @see {@link https://www.designtokens.org/tr/2025.10/format/#color-0 | DTCG Format: Color Type}
|
|
92
|
+
*
|
|
93
|
+
* @example Valid color values
|
|
94
|
+
* ```typescript
|
|
95
|
+
* // Object format (preferred)
|
|
96
|
+
* const color1: ColorValue = {
|
|
97
|
+
* colorSpace: 'srgb',
|
|
98
|
+
* components: [1, 0, 0],
|
|
99
|
+
* alpha: 1
|
|
100
|
+
* }
|
|
101
|
+
*
|
|
102
|
+
* // Alias reference (resolves to another token)
|
|
103
|
+
* const color2: ColorValue = "{color.brand.primary}"
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
type ColorValue = ColorValueObject | TokenValueReference;
|
|
107
|
+
/**
|
|
108
|
+
* DTCG 2025-10 compliant dimension value
|
|
109
|
+
*
|
|
110
|
+
* Per DTCG spec, dimension values MUST use object format with
|
|
111
|
+
* numeric value and string unit properties.
|
|
112
|
+
*
|
|
113
|
+
* ⚠️ **Important**: String values like `"16px"` are NOT valid per DTCG spec.
|
|
114
|
+
* Dimensions MUST be objects with separate value and unit properties.
|
|
115
|
+
*
|
|
116
|
+
* @see {@link https://www.designtokens.org/tr/2025.10/format/#dimension-0 | DTCG Format: Dimension Type}
|
|
117
|
+
*
|
|
118
|
+
* @example Valid dimension values
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const spacing: DimensionValue = { value: 16, unit: 'px' }
|
|
121
|
+
* const fontSize: DimensionValue = { value: 1.5, unit: 'rem' }
|
|
122
|
+
* const borderWidth: DimensionValue = { value: 2, unit: 'px' }
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
type DimensionValue = {
|
|
126
|
+
value: number;
|
|
127
|
+
unit: 'px' | 'rem';
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Font family value - single string or array of fallback fonts
|
|
131
|
+
*/
|
|
132
|
+
type FontFamilyValue = string | string[];
|
|
133
|
+
/**
|
|
134
|
+
* Font weight value - numeric (1-1000) or named value
|
|
135
|
+
*/
|
|
136
|
+
type FontWeightValue = number | string;
|
|
137
|
+
/**
|
|
138
|
+
* Duration value - DTCG duration object
|
|
139
|
+
*/
|
|
140
|
+
type DurationValue = {
|
|
141
|
+
value: number;
|
|
142
|
+
unit: 'ms' | 's';
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Cubic bezier value - 4-number array for animation easing
|
|
146
|
+
*/
|
|
147
|
+
type CubicBezierValue = [number, number, number, number];
|
|
148
|
+
/**
|
|
149
|
+
* Shadow value object (DTCG 2025.10 composite type - Section 9.6)
|
|
150
|
+
*
|
|
151
|
+
* Represents a shadow effect with color, offset, blur, and optional spread.
|
|
152
|
+
* Uses proper ColorValue and DimensionValue types per DTCG spec.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```json
|
|
156
|
+
* {
|
|
157
|
+
* "$type": "shadow",
|
|
158
|
+
* "$value": {
|
|
159
|
+
* "color": { "colorSpace": "srgb", "components": [0, 0, 0], "alpha": 0.5 },
|
|
160
|
+
* "offsetX": { "value": 0, "unit": "px" },
|
|
161
|
+
* "offsetY": { "value": 4, "unit": "px" },
|
|
162
|
+
* "blur": { "value": 8, "unit": "px" },
|
|
163
|
+
* "spread": { "value": 0, "unit": "px" }
|
|
164
|
+
* }
|
|
165
|
+
* }
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
type ShadowValueObject = {
|
|
169
|
+
/** Shadow color (color object or alias reference) */
|
|
170
|
+
color: ColorValue;
|
|
171
|
+
/** Horizontal offset */
|
|
172
|
+
offsetX: DimensionValue;
|
|
173
|
+
/** Vertical offset */
|
|
174
|
+
offsetY: DimensionValue;
|
|
175
|
+
/** Blur radius */
|
|
176
|
+
blur: DimensionValue;
|
|
177
|
+
/** Spread radius */
|
|
178
|
+
spread: DimensionValue;
|
|
179
|
+
/** Whether shadow is inset */
|
|
180
|
+
inset?: boolean;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Stroke style value object
|
|
184
|
+
*/
|
|
185
|
+
type StrokeStyleValueObject = {
|
|
186
|
+
dashArray: DimensionValue[];
|
|
187
|
+
lineCap: 'round' | 'butt' | 'square';
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Stroke style value
|
|
191
|
+
*/
|
|
192
|
+
type StrokeStyleValue = string | StrokeStyleValueObject;
|
|
193
|
+
/**
|
|
194
|
+
* Border value object
|
|
195
|
+
*/
|
|
196
|
+
type BorderValue = {
|
|
197
|
+
color: ColorValue;
|
|
198
|
+
width: DimensionValue;
|
|
199
|
+
style: StrokeStyleValue;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Typography value object
|
|
203
|
+
*/
|
|
204
|
+
type TypographyValue = {
|
|
205
|
+
fontFamily: FontFamilyValue;
|
|
206
|
+
fontSize: DimensionValue;
|
|
207
|
+
fontWeight: FontWeightValue;
|
|
208
|
+
letterSpacing: DimensionValue;
|
|
209
|
+
lineHeight: number;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Transition value object
|
|
213
|
+
*/
|
|
214
|
+
type TransitionValue = {
|
|
215
|
+
duration: DurationValue;
|
|
216
|
+
delay: DurationValue;
|
|
217
|
+
timingFunction: CubicBezierValue;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Gradient stop value object
|
|
221
|
+
*/
|
|
222
|
+
type GradientStop = {
|
|
223
|
+
color: ColorValue;
|
|
224
|
+
position: number;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Gradient value
|
|
228
|
+
*/
|
|
229
|
+
type GradientValue = GradientStop[];
|
|
230
|
+
/**
|
|
231
|
+
* Union of all known DTCG token value types.
|
|
232
|
+
*
|
|
233
|
+
* Provides narrower typing than `TokenValue` for consumers who want
|
|
234
|
+
* better autocomplete and type checking when working with resolved tokens.
|
|
235
|
+
*
|
|
236
|
+
* Use the type guard helpers (`isColorToken`, `isDimensionToken`, etc.)
|
|
237
|
+
* to narrow a `ResolvedToken` to a specific value type.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```typescript
|
|
241
|
+
* import type { ResolvedToken } from 'dispersa'
|
|
242
|
+
* import { isColorToken, isDimensionToken } from 'dispersa'
|
|
243
|
+
*
|
|
244
|
+
* function process(token: ResolvedToken) {
|
|
245
|
+
* if (isColorToken(token)) {
|
|
246
|
+
* // token.$value is narrowed to ColorValue
|
|
247
|
+
* }
|
|
248
|
+
* if (isDimensionToken(token)) {
|
|
249
|
+
* // token.$value is narrowed to DimensionValue
|
|
250
|
+
* }
|
|
251
|
+
* }
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
type DesignTokenValue = ColorValueObject | DimensionValue | DurationValue | CubicBezierValue | ShadowValueObject | ShadowValueObject[] | TypographyValue | BorderValue | StrokeStyleValueObject | StrokeStyleValue | TransitionValue | GradientValue | FontFamilyValue | FontWeightValue | number | boolean;
|
|
255
|
+
/** Type-narrowed token whose `$value` is a `ColorValueObject` or color string */
|
|
256
|
+
type ColorToken = ResolvedToken & {
|
|
257
|
+
$type: 'color';
|
|
258
|
+
};
|
|
259
|
+
/** Type-narrowed token whose `$value` is a `DimensionValue` */
|
|
260
|
+
type DimensionToken = ResolvedToken & {
|
|
261
|
+
$type: 'dimension';
|
|
262
|
+
};
|
|
263
|
+
/** Type-narrowed token whose `$value` is a `ShadowValue` */
|
|
264
|
+
type ShadowToken = ResolvedToken & {
|
|
265
|
+
$type: 'shadow';
|
|
266
|
+
};
|
|
267
|
+
/** Type-narrowed token whose `$value` is a `TypographyValue` */
|
|
268
|
+
type TypographyTokenNarrowed = ResolvedToken & {
|
|
269
|
+
$type: 'typography';
|
|
270
|
+
};
|
|
271
|
+
/** Type-narrowed token whose `$value` is a `BorderValue` */
|
|
272
|
+
type BorderTokenNarrowed = ResolvedToken & {
|
|
273
|
+
$type: 'border';
|
|
274
|
+
};
|
|
275
|
+
/** Type-narrowed token whose `$value` is a `DurationValue` */
|
|
276
|
+
type DurationToken = ResolvedToken & {
|
|
277
|
+
$type: 'duration';
|
|
278
|
+
};
|
|
279
|
+
/** Type-narrowed token whose `$value` is a `TransitionValue` */
|
|
280
|
+
type TransitionTokenNarrowed = ResolvedToken & {
|
|
281
|
+
$type: 'transition';
|
|
282
|
+
};
|
|
283
|
+
/** Type-narrowed token whose `$value` is a `GradientValue` */
|
|
284
|
+
type GradientTokenNarrowed = ResolvedToken & {
|
|
285
|
+
$type: 'gradient';
|
|
286
|
+
};
|
|
287
|
+
/** Check if a resolved token is a color token */
|
|
288
|
+
declare function isColorToken(token: ResolvedToken): token is ColorToken;
|
|
289
|
+
/** Check if a resolved token is a dimension token */
|
|
290
|
+
declare function isDimensionToken(token: ResolvedToken): token is DimensionToken;
|
|
291
|
+
/** Check if a resolved token is a shadow token */
|
|
292
|
+
declare function isShadowToken(token: ResolvedToken): token is ShadowToken;
|
|
293
|
+
/** Check if a resolved token is a typography token */
|
|
294
|
+
declare function isTypographyToken(token: ResolvedToken): token is TypographyTokenNarrowed;
|
|
295
|
+
/** Check if a resolved token is a border token */
|
|
296
|
+
declare function isBorderToken(token: ResolvedToken): token is BorderTokenNarrowed;
|
|
297
|
+
/** Check if a resolved token is a duration token */
|
|
298
|
+
declare function isDurationToken(token: ResolvedToken): token is DurationToken;
|
|
299
|
+
/** Check if a resolved token is a transition token */
|
|
300
|
+
declare function isTransitionToken(token: ResolvedToken): token is TransitionTokenNarrowed;
|
|
301
|
+
/** Check if a resolved token is a gradient token */
|
|
302
|
+
declare function isGradientToken(token: ResolvedToken): token is GradientTokenNarrowed;
|
|
303
|
+
/**
|
|
304
|
+
* Internal token document nodes used during resolution
|
|
305
|
+
*/
|
|
306
|
+
type InternalTokenNode = InternalToken | TokenGroup;
|
|
307
|
+
/**
|
|
308
|
+
* Internal token document structure (pre-resolution, with internal metadata)
|
|
309
|
+
*/
|
|
310
|
+
type InternalTokenDocument = Record<string, InternalTokenNode>;
|
|
311
|
+
/**
|
|
312
|
+
* Fully resolved token with computed metadata
|
|
313
|
+
*
|
|
314
|
+
* After resolution, tokens include additional metadata like their
|
|
315
|
+
* full path in the token hierarchy and the original value before
|
|
316
|
+
* any alias or reference resolution.
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```typescript
|
|
320
|
+
* {
|
|
321
|
+
* $value: "#ff0000",
|
|
322
|
+
* $type: "color",
|
|
323
|
+
* path: ["color", "brand", "primary"],
|
|
324
|
+
* name: "color.brand.primary",
|
|
325
|
+
* originalValue: "{color.red.500}" // Before alias resolution
|
|
326
|
+
* }
|
|
327
|
+
* ```
|
|
328
|
+
*/
|
|
329
|
+
type ResolvedToken = Token & {
|
|
330
|
+
/** Hierarchical path segments (e.g., ['color', 'brand', 'primary']) */
|
|
331
|
+
path: string[];
|
|
332
|
+
/** Fully qualified token name (e.g., 'color.brand.primary') */
|
|
333
|
+
name: string;
|
|
334
|
+
/**
|
|
335
|
+
* The raw value before any alias or reference resolution.
|
|
336
|
+
*
|
|
337
|
+
* For alias tokens this contains the alias reference string
|
|
338
|
+
* (e.g., `"{color.primary}"`) or a composite value with embedded
|
|
339
|
+
* alias references. For non-alias tokens this equals `$value`.
|
|
340
|
+
*
|
|
341
|
+
* Use the built-in `isAlias()` / `isBase()` filters or inspect
|
|
342
|
+
* this value with `getPureAliasReferenceName()` to determine
|
|
343
|
+
* whether the token was originally an alias.
|
|
344
|
+
*/
|
|
345
|
+
originalValue: TokenValue;
|
|
346
|
+
};
|
|
347
|
+
/**
|
|
348
|
+
* Collection of resolved tokens indexed by name
|
|
349
|
+
*
|
|
350
|
+
* Maps token names to their resolved definitions. This is the primary
|
|
351
|
+
* format used throughout Dispersa after token resolution.
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```typescript
|
|
355
|
+
* {
|
|
356
|
+
* "color.brand.primary": {
|
|
357
|
+
* $value: "#ff0000",
|
|
358
|
+
* $type: "color",
|
|
359
|
+
* path: ["color", "brand", "primary"],
|
|
360
|
+
* name: "color.brand.primary",
|
|
361
|
+
* originalValue: "#ff0000"
|
|
362
|
+
* }
|
|
363
|
+
* }
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
type ResolvedTokens = Record<string, ResolvedToken>;
|
|
367
|
+
|
|
368
|
+
export { type BorderValue as B, type ColorToken as C, type DesignTokenValue as D, type GradientValue as G, type InternalTokenDocument as I, type ResolvedTokens as R, type ShadowToken as S, type TokenType as T, type ResolvedToken as a, type DimensionToken as b, type DurationToken as c, type ColorValueObject as d, type DimensionValue as e, type ShadowValueObject as f, type TypographyValue as g, type TransitionValue as h, isColorToken as i, isDimensionToken as j, isShadowToken as k, isTypographyToken as l, isBorderToken as m, isDurationToken as n, isTransitionToken as o, isGradientToken as p };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { a as ResolvedToken } from './types-C1GpiJ6q.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Filter system types for token selection
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Filter definition for selecting tokens
|
|
9
|
+
*
|
|
10
|
+
* Filters determine which tokens should be included in output configuration.
|
|
11
|
+
* They are applied before transforms.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const colorsOnly: Filter = {
|
|
16
|
+
* filter: (token) => token.$type === 'color'
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
type Filter = {
|
|
21
|
+
/**
|
|
22
|
+
* Function that determines if a token should be included
|
|
23
|
+
*
|
|
24
|
+
* @param token - Token to test
|
|
25
|
+
* @returns true if token should be included in output, false otherwise
|
|
26
|
+
*/
|
|
27
|
+
filter: (token: ResolvedToken) => boolean;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type { Filter as F };
|