@menapo/vicss 0.0.0-stage → 1.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/LICENSE +21 -0
- package/README.md +627 -2
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1311 -0
- package/dist/config-loader-DzP68Snn.js +162 -0
- package/dist/config-loader-pLzP9par.js +1 -0
- package/dist/config.d.ts +821 -0
- package/dist/config.js +2690 -0
- package/dist/index.d.ts +1471 -0
- package/dist/index.js +369 -0
- package/dist/lint.d.ts +114 -0
- package/dist/lint.js +0 -0
- package/dist/pool-BGXMhLfL.js +2942 -0
- package/dist/print-Ds6fkgio.js +5093 -0
- package/dist/snapshot-BQb8ZmSV.js +149 -0
- package/dist/theme-C-0LpsJx.js +2437 -0
- package/dist/types-file-R_knFzME.js +2481 -0
- package/dist/vite.d.ts +245 -0
- package/dist/vite.js +1926 -0
- package/dist/worker.d.ts +1 -0
- package/dist/worker.js +113 -0
- package/package.json +66 -3
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,821 @@
|
|
|
1
|
+
//#region src/core/types.d.ts
|
|
2
|
+
/** Token scales a property can draw its values from. */
|
|
3
|
+
type ScaleName = "colors" | "spacing" | "sizes" | "radii" | "fonts" | "fontSizes" | "fontWeights" | "lineHeights" | "letterSpacings" | "shadows" | "textShadows" | "durations" | "easings" | "zIndices" | "opacities" | "blurs" | "aspectRatios" | "breakpoints" | "containers";
|
|
4
|
+
/** A style object as authors write it. Values are checked by `normalizeStyle`. */
|
|
5
|
+
interface StyleObject {
|
|
6
|
+
[key: string]: StyleValue | StyleObject | undefined;
|
|
7
|
+
}
|
|
8
|
+
type StyleValue = string | number | ConditionalValue | null | undefined;
|
|
9
|
+
/** `{ base: 4, _md: 6, _hover: { _md: 8 } }`: a value per condition. */
|
|
10
|
+
interface ConditionalValue {
|
|
11
|
+
[condition: string]: StyleValue;
|
|
12
|
+
}
|
|
13
|
+
/** A token tree node: a value, or a group of nodes. `DEFAULT` names the group itself. */
|
|
14
|
+
type TokenTree = {
|
|
15
|
+
[name: string]: string | number | TokenTree;
|
|
16
|
+
};
|
|
17
|
+
/** A semantic token: one value, or a value per mode (`{ base, _dark }`). */
|
|
18
|
+
type SemanticTokenValue = string | {
|
|
19
|
+
[modeOrBase: string]: string;
|
|
20
|
+
};
|
|
21
|
+
type SemanticTokenTree = {
|
|
22
|
+
[name: string]: SemanticTokenValue | SemanticTokenTree;
|
|
23
|
+
};
|
|
24
|
+
/** A utility turns one authored value into a style object (`size: 4` → width and height). */
|
|
25
|
+
interface UtilityDefinition {
|
|
26
|
+
/** Scale used to type and resolve the utility's value. */
|
|
27
|
+
readonly scale?: ScaleName;
|
|
28
|
+
/** `true`-only utilities (`truncate: true`) set this. */
|
|
29
|
+
readonly boolean?: boolean;
|
|
30
|
+
readonly transform: (value: string | number | boolean) => StyleObject;
|
|
31
|
+
}
|
|
32
|
+
interface VicssConfig {
|
|
33
|
+
presets?: VicssConfig[];
|
|
34
|
+
tokens?: { [scale in ScaleName]?: TokenTree; } & {
|
|
35
|
+
spacing?: TokenTree | {
|
|
36
|
+
step: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
semanticTokens?: { [scale in ScaleName]?: SemanticTokenTree; };
|
|
40
|
+
textStyles?: Record<string, StyleObject>;
|
|
41
|
+
/** Extra named conditions: `"[data-brand=b] &"`, `"@media (…)"`, `"@container (…)"`, `"@supports (…)"`, `"&:is(…)"`. */
|
|
42
|
+
conditions?: Record<string, string | string[]>;
|
|
43
|
+
utilities?: Record<string, UtilityDefinition>;
|
|
44
|
+
/** Element styles by selector, printed in `@layer vicss.global` (PLAN §4.9). */
|
|
45
|
+
globalCss?: Record<string, StyleObject>;
|
|
46
|
+
/** `@keyframes` by name: frame selectors (`from`, `to`, `"50%"`) → style. */
|
|
47
|
+
keyframes?: Record<string, Record<string, StyleObject>>;
|
|
48
|
+
/** `@font-face` rules, descriptors in camelCase: `{ fontFamily: "Inter", src: "url(…)" }`. */
|
|
49
|
+
fontFaces?: Array<Record<string, string | number>>;
|
|
50
|
+
/** How `_dark` and semantic-token dark values are selected (PLAN D12). */
|
|
51
|
+
darkMode?: "attribute-or-media" | "attribute" | "media" | {
|
|
52
|
+
selector: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* What a value outside a property's scale may be (PLAN D8): one level for
|
|
56
|
+
* every scale, or levels by scale, property or utility name, with
|
|
57
|
+
* `default` for the rest (`{ default: "tokens", maxWidth: "css" }`).
|
|
58
|
+
*/
|
|
59
|
+
strict?: Strictness | StrictnessMap;
|
|
60
|
+
reset?: boolean;
|
|
61
|
+
include?: string[];
|
|
62
|
+
exclude?: string[];
|
|
63
|
+
/** Modules that re-export the vicss runtime (a design system's `./ds`). */
|
|
64
|
+
importSources?: string[];
|
|
65
|
+
/** Prefix for token custom properties: `""` gives `--color-accent`. */
|
|
66
|
+
cssVarPrefix?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Colour palettes (PLAN §4.8): styles write `palette.600`, and
|
|
69
|
+
* `colorPalette: "red"` points it at `colors.red.600` for an element and
|
|
70
|
+
* its subtree. Off without this key, which reserves the `colors.palette`
|
|
71
|
+
* group.
|
|
72
|
+
*/
|
|
73
|
+
palettes?: PalettesConfig;
|
|
74
|
+
/**
|
|
75
|
+
* Which tokens app styles may name (PLAN §4.1, public and private
|
|
76
|
+
* tokens): a token pattern → `"private"` or `"public"`. `"colors"` is the
|
|
77
|
+
* scale's raw tokens (`tokens.colors`), `"colors.blue"` a token and every
|
|
78
|
+
* token under it, raw or semantic, and `*` one path segment
|
|
79
|
+
* (`"colors.*.950"`). The most specific pattern wins; presets mark their
|
|
80
|
+
* own tokens and the config changes any entry by its pattern.
|
|
81
|
+
*/
|
|
82
|
+
tokenVisibility?: Record<string, TokenVisibility>;
|
|
83
|
+
/**
|
|
84
|
+
* Modules that belong to the design system and may name private tokens:
|
|
85
|
+
* globs relative to the root, like `include` (`"src/design-system/**"`),
|
|
86
|
+
* or an installed library's directory (`"node_modules/@acme/ui/**"`).
|
|
87
|
+
*/
|
|
88
|
+
privateAccess?: string[];
|
|
89
|
+
/**
|
|
90
|
+
* The classes a build ships (PLAN §5.5, D31): `prefix` (default `"v"`)
|
|
91
|
+
* plus a hash of at least `minLength` characters (default 4, 6 in a
|
|
92
|
+
* library build), or the readable names dev serves (`md:p_6`) with
|
|
93
|
+
* `readable: true`. Dev serves readable names unless `readable` is false.
|
|
94
|
+
*/
|
|
95
|
+
classNames?: {
|
|
96
|
+
prefix?: string;
|
|
97
|
+
minLength?: number;
|
|
98
|
+
readable?: boolean;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
type TokenVisibility = "private" | "public";
|
|
102
|
+
interface PalettesConfig {
|
|
103
|
+
/** The palette of every element no `colorPalette` applies to: a colour group. */
|
|
104
|
+
default: string;
|
|
105
|
+
/**
|
|
106
|
+
* The colour groups `colorPalette` may name. Default: every top-level
|
|
107
|
+
* colour group, raw or semantic (`red` for `red.50` … `red.950`, `accent`
|
|
108
|
+
* for `accent` and `accent.hover`).
|
|
109
|
+
*/
|
|
110
|
+
names?: string[];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* PLAN D8. `"css"` (the default): a value outside the scale is written as
|
|
114
|
+
* it is when it is valid CSS for the property, and anything else (a typo of
|
|
115
|
+
* a token) fails the build. `"warn"`: the same, with a warning for each
|
|
116
|
+
* value outside the scale. `"tokens"`: only the scale's tokens, CSS-wide
|
|
117
|
+
* and the scale's keywords, percentages where the scale takes them, and
|
|
118
|
+
* zero. `"off"`: anything, unchecked.
|
|
119
|
+
*/
|
|
120
|
+
type Strictness = "tokens" | "warn" | "css" | "off";
|
|
121
|
+
/** Levels by scale (`colors`), CSS property (`maxWidth`) or utility (`size`); `default` for the rest. */
|
|
122
|
+
type StrictnessMap = {
|
|
123
|
+
readonly default?: Strictness;
|
|
124
|
+
} & {
|
|
125
|
+
readonly [scaleOrProperty: string]: Strictness | undefined;
|
|
126
|
+
};
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/config/refs.d.ts
|
|
129
|
+
declare const GROUP: unique symbol;
|
|
130
|
+
/**
|
|
131
|
+
* A group of tokens (`colors.gray`), which names no token of its own: index
|
|
132
|
+
* it to reach one. An interface, so a group is not a value per mode
|
|
133
|
+
* (`{ [mode: string]: string }`) either, which a plain object of strings
|
|
134
|
+
* would be.
|
|
135
|
+
*/
|
|
136
|
+
interface TokenGroupRef {
|
|
137
|
+
readonly [GROUP]: "a group of tokens: name one of its tokens";
|
|
138
|
+
}
|
|
139
|
+
type Key = string | number;
|
|
140
|
+
/** `{ base, _dark }`: a semantic token's value per mode, which is one token. */
|
|
141
|
+
type IsModeMap<T> = [keyof T] extends ["base" | `_${string}`] ? "base" extends keyof T ? true : false : false;
|
|
142
|
+
type Named<T> = Exclude<keyof T, "DEFAULT" | symbol>;
|
|
143
|
+
type RefNode<T, P extends string, Semantic extends boolean> = T extends string | number ? `{${P}}` : Semantic extends true ? IsModeMap<T> extends true ? `{${P}}` : Group<T, P, Semantic> : Group<T, P, Semantic>;
|
|
144
|
+
/** A group with `DEFAULT` is a token itself, and still a group. */
|
|
145
|
+
type Group<T, P extends string, Semantic extends boolean> = ("DEFAULT" extends keyof T ? `{${P}}` : TokenGroupRef) & { readonly [K in Named<T>]-?: RefNode<NonNullable<T[K]>, `${P}.${K & Key}`, Semantic>; };
|
|
146
|
+
/** The config and its presets, depth first, to a depth no real config reaches. */
|
|
147
|
+
type Layers<C, Depth extends unknown[] = []> = Depth["length"] extends 6 ? C : C | (C extends {
|
|
148
|
+
readonly presets?: infer P;
|
|
149
|
+
} ? P extends readonly (infer Preset)[] ? Layers<Preset, [...Depth, unknown]> : never : never);
|
|
150
|
+
/** A tree that declares no names: `TokenTree`'s index signature. */
|
|
151
|
+
type Unnamed<T> = T extends unknown ? (string extends keyof T ? true : never) : never;
|
|
152
|
+
/**
|
|
153
|
+
* A layer's scales of field `F`, but those whose names its type does not
|
|
154
|
+
* declare (a `dtcg()` result, a preset typed `VicssConfig`): an index
|
|
155
|
+
* signature would turn every path into a reference, typos included, and
|
|
156
|
+
* `noUncheckedIndexedAccess` each one into `| undefined`.
|
|
157
|
+
*/
|
|
158
|
+
type Field<L, F extends "tokens" | "semanticTokens"> = L extends unknown ? F extends keyof L ? { [S in keyof NonNullable<L[F]> as [Unnamed<NonNullable<NonNullable<L[F]>[S]>>] extends [never] ? S : never]: NonNullable<L[F]>[S]; } : never : never;
|
|
159
|
+
type Intersect<U> = (U extends unknown ? (u: U) => void : never) extends ((i: infer I) => void) ? I : never;
|
|
160
|
+
type ScaleRef<T, S extends string, Semantic extends boolean> = S extends keyof T ? RefNode<NonNullable<T[S]>, S, Semantic> : unknown;
|
|
161
|
+
/**
|
|
162
|
+
* What the callback of `defineConfig(config, (tokens) => …)` receives: every
|
|
163
|
+
* scale `config` and its presets define, raw and semantic, as a tree of
|
|
164
|
+
* references. `tokens.colors.gray[900]` is `"{colors.gray.900}"`; a group
|
|
165
|
+
* that is no token (`tokens.colors.gray`) is a `TokenGroupRef`, which no
|
|
166
|
+
* config value accepts.
|
|
167
|
+
*/
|
|
168
|
+
type TokenRefs<C> = Layers<C> extends (infer L) ? Intersect<Field<L, "tokens">> extends (infer Raw) ? Intersect<Field<L, "semanticTokens">> extends (infer Semantic) ? { readonly [S in (keyof Raw | keyof Semantic) & ScaleName]: ScaleRef<Raw, S, false> & ScaleRef<Semantic, S, true>; } : never : never : never;
|
|
169
|
+
/**
|
|
170
|
+
* What the callback returns: any config key but `tokens` and `presets`,
|
|
171
|
+
* which the references are built from, so they stay in the first argument.
|
|
172
|
+
*/
|
|
173
|
+
type DerivedConfig = Omit<VicssConfig, "tokens" | "presets"> & {
|
|
174
|
+
readonly tokens?: never;
|
|
175
|
+
readonly presets?: never;
|
|
176
|
+
};
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/config/presets/reset.d.ts
|
|
179
|
+
/**
|
|
180
|
+
* The `reset` preset: `presets: [reset]` is `reset: true`, a modern reset in
|
|
181
|
+
* the `vicss.reset` layer (PLAN §4.9, D15; the rules are in
|
|
182
|
+
* `src/core/reset.ts`). It is opt-in because a reset is the app's choice: a
|
|
183
|
+
* component library's preset must never carry it.
|
|
184
|
+
*/
|
|
185
|
+
export declare const reset: {
|
|
186
|
+
reset: true;
|
|
187
|
+
};
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region src/config/presets/shorthands.d.ts
|
|
190
|
+
export declare const shorthands: {
|
|
191
|
+
utilities: Record<string, UtilityDefinition>;
|
|
192
|
+
};
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/config/presets/tailwind.d.ts
|
|
195
|
+
export declare const tailwind: {
|
|
196
|
+
tokens: {
|
|
197
|
+
colors: {
|
|
198
|
+
red: {
|
|
199
|
+
50: string;
|
|
200
|
+
100: string;
|
|
201
|
+
200: string;
|
|
202
|
+
300: string;
|
|
203
|
+
400: string;
|
|
204
|
+
500: string;
|
|
205
|
+
600: string;
|
|
206
|
+
700: string;
|
|
207
|
+
800: string;
|
|
208
|
+
900: string;
|
|
209
|
+
950: string;
|
|
210
|
+
};
|
|
211
|
+
orange: {
|
|
212
|
+
50: string;
|
|
213
|
+
100: string;
|
|
214
|
+
200: string;
|
|
215
|
+
300: string;
|
|
216
|
+
400: string;
|
|
217
|
+
500: string;
|
|
218
|
+
600: string;
|
|
219
|
+
700: string;
|
|
220
|
+
800: string;
|
|
221
|
+
900: string;
|
|
222
|
+
950: string;
|
|
223
|
+
};
|
|
224
|
+
amber: {
|
|
225
|
+
50: string;
|
|
226
|
+
100: string;
|
|
227
|
+
200: string;
|
|
228
|
+
300: string;
|
|
229
|
+
400: string;
|
|
230
|
+
500: string;
|
|
231
|
+
600: string;
|
|
232
|
+
700: string;
|
|
233
|
+
800: string;
|
|
234
|
+
900: string;
|
|
235
|
+
950: string;
|
|
236
|
+
};
|
|
237
|
+
yellow: {
|
|
238
|
+
50: string;
|
|
239
|
+
100: string;
|
|
240
|
+
200: string;
|
|
241
|
+
300: string;
|
|
242
|
+
400: string;
|
|
243
|
+
500: string;
|
|
244
|
+
600: string;
|
|
245
|
+
700: string;
|
|
246
|
+
800: string;
|
|
247
|
+
900: string;
|
|
248
|
+
950: string;
|
|
249
|
+
};
|
|
250
|
+
lime: {
|
|
251
|
+
50: string;
|
|
252
|
+
100: string;
|
|
253
|
+
200: string;
|
|
254
|
+
300: string;
|
|
255
|
+
400: string;
|
|
256
|
+
500: string;
|
|
257
|
+
600: string;
|
|
258
|
+
700: string;
|
|
259
|
+
800: string;
|
|
260
|
+
900: string;
|
|
261
|
+
950: string;
|
|
262
|
+
};
|
|
263
|
+
green: {
|
|
264
|
+
50: string;
|
|
265
|
+
100: string;
|
|
266
|
+
200: string;
|
|
267
|
+
300: string;
|
|
268
|
+
400: string;
|
|
269
|
+
500: string;
|
|
270
|
+
600: string;
|
|
271
|
+
700: string;
|
|
272
|
+
800: string;
|
|
273
|
+
900: string;
|
|
274
|
+
950: string;
|
|
275
|
+
};
|
|
276
|
+
emerald: {
|
|
277
|
+
50: string;
|
|
278
|
+
100: string;
|
|
279
|
+
200: string;
|
|
280
|
+
300: string;
|
|
281
|
+
400: string;
|
|
282
|
+
500: string;
|
|
283
|
+
600: string;
|
|
284
|
+
700: string;
|
|
285
|
+
800: string;
|
|
286
|
+
900: string;
|
|
287
|
+
950: string;
|
|
288
|
+
};
|
|
289
|
+
teal: {
|
|
290
|
+
50: string;
|
|
291
|
+
100: string;
|
|
292
|
+
200: string;
|
|
293
|
+
300: string;
|
|
294
|
+
400: string;
|
|
295
|
+
500: string;
|
|
296
|
+
600: string;
|
|
297
|
+
700: string;
|
|
298
|
+
800: string;
|
|
299
|
+
900: string;
|
|
300
|
+
950: string;
|
|
301
|
+
};
|
|
302
|
+
cyan: {
|
|
303
|
+
50: string;
|
|
304
|
+
100: string;
|
|
305
|
+
200: string;
|
|
306
|
+
300: string;
|
|
307
|
+
400: string;
|
|
308
|
+
500: string;
|
|
309
|
+
600: string;
|
|
310
|
+
700: string;
|
|
311
|
+
800: string;
|
|
312
|
+
900: string;
|
|
313
|
+
950: string;
|
|
314
|
+
};
|
|
315
|
+
sky: {
|
|
316
|
+
50: string;
|
|
317
|
+
100: string;
|
|
318
|
+
200: string;
|
|
319
|
+
300: string;
|
|
320
|
+
400: string;
|
|
321
|
+
500: string;
|
|
322
|
+
600: string;
|
|
323
|
+
700: string;
|
|
324
|
+
800: string;
|
|
325
|
+
900: string;
|
|
326
|
+
950: string;
|
|
327
|
+
};
|
|
328
|
+
blue: {
|
|
329
|
+
50: string;
|
|
330
|
+
100: string;
|
|
331
|
+
200: string;
|
|
332
|
+
300: string;
|
|
333
|
+
400: string;
|
|
334
|
+
500: string;
|
|
335
|
+
600: string;
|
|
336
|
+
700: string;
|
|
337
|
+
800: string;
|
|
338
|
+
900: string;
|
|
339
|
+
950: string;
|
|
340
|
+
};
|
|
341
|
+
indigo: {
|
|
342
|
+
50: string;
|
|
343
|
+
100: string;
|
|
344
|
+
200: string;
|
|
345
|
+
300: string;
|
|
346
|
+
400: string;
|
|
347
|
+
500: string;
|
|
348
|
+
600: string;
|
|
349
|
+
700: string;
|
|
350
|
+
800: string;
|
|
351
|
+
900: string;
|
|
352
|
+
950: string;
|
|
353
|
+
};
|
|
354
|
+
violet: {
|
|
355
|
+
50: string;
|
|
356
|
+
100: string;
|
|
357
|
+
200: string;
|
|
358
|
+
300: string;
|
|
359
|
+
400: string;
|
|
360
|
+
500: string;
|
|
361
|
+
600: string;
|
|
362
|
+
700: string;
|
|
363
|
+
800: string;
|
|
364
|
+
900: string;
|
|
365
|
+
950: string;
|
|
366
|
+
};
|
|
367
|
+
purple: {
|
|
368
|
+
50: string;
|
|
369
|
+
100: string;
|
|
370
|
+
200: string;
|
|
371
|
+
300: string;
|
|
372
|
+
400: string;
|
|
373
|
+
500: string;
|
|
374
|
+
600: string;
|
|
375
|
+
700: string;
|
|
376
|
+
800: string;
|
|
377
|
+
900: string;
|
|
378
|
+
950: string;
|
|
379
|
+
};
|
|
380
|
+
fuchsia: {
|
|
381
|
+
50: string;
|
|
382
|
+
100: string;
|
|
383
|
+
200: string;
|
|
384
|
+
300: string;
|
|
385
|
+
400: string;
|
|
386
|
+
500: string;
|
|
387
|
+
600: string;
|
|
388
|
+
700: string;
|
|
389
|
+
800: string;
|
|
390
|
+
900: string;
|
|
391
|
+
950: string;
|
|
392
|
+
};
|
|
393
|
+
pink: {
|
|
394
|
+
50: string;
|
|
395
|
+
100: string;
|
|
396
|
+
200: string;
|
|
397
|
+
300: string;
|
|
398
|
+
400: string;
|
|
399
|
+
500: string;
|
|
400
|
+
600: string;
|
|
401
|
+
700: string;
|
|
402
|
+
800: string;
|
|
403
|
+
900: string;
|
|
404
|
+
950: string;
|
|
405
|
+
};
|
|
406
|
+
rose: {
|
|
407
|
+
50: string;
|
|
408
|
+
100: string;
|
|
409
|
+
200: string;
|
|
410
|
+
300: string;
|
|
411
|
+
400: string;
|
|
412
|
+
500: string;
|
|
413
|
+
600: string;
|
|
414
|
+
700: string;
|
|
415
|
+
800: string;
|
|
416
|
+
900: string;
|
|
417
|
+
950: string;
|
|
418
|
+
};
|
|
419
|
+
slate: {
|
|
420
|
+
50: string;
|
|
421
|
+
100: string;
|
|
422
|
+
200: string;
|
|
423
|
+
300: string;
|
|
424
|
+
400: string;
|
|
425
|
+
500: string;
|
|
426
|
+
600: string;
|
|
427
|
+
700: string;
|
|
428
|
+
800: string;
|
|
429
|
+
900: string;
|
|
430
|
+
950: string;
|
|
431
|
+
};
|
|
432
|
+
gray: {
|
|
433
|
+
50: string;
|
|
434
|
+
100: string;
|
|
435
|
+
200: string;
|
|
436
|
+
300: string;
|
|
437
|
+
400: string;
|
|
438
|
+
500: string;
|
|
439
|
+
600: string;
|
|
440
|
+
700: string;
|
|
441
|
+
800: string;
|
|
442
|
+
900: string;
|
|
443
|
+
950: string;
|
|
444
|
+
};
|
|
445
|
+
zinc: {
|
|
446
|
+
50: string;
|
|
447
|
+
100: string;
|
|
448
|
+
200: string;
|
|
449
|
+
300: string;
|
|
450
|
+
400: string;
|
|
451
|
+
500: string;
|
|
452
|
+
600: string;
|
|
453
|
+
700: string;
|
|
454
|
+
800: string;
|
|
455
|
+
900: string;
|
|
456
|
+
950: string;
|
|
457
|
+
};
|
|
458
|
+
neutral: {
|
|
459
|
+
50: string;
|
|
460
|
+
100: string;
|
|
461
|
+
200: string;
|
|
462
|
+
300: string;
|
|
463
|
+
400: string;
|
|
464
|
+
500: string;
|
|
465
|
+
600: string;
|
|
466
|
+
700: string;
|
|
467
|
+
800: string;
|
|
468
|
+
900: string;
|
|
469
|
+
950: string;
|
|
470
|
+
};
|
|
471
|
+
stone: {
|
|
472
|
+
50: string;
|
|
473
|
+
100: string;
|
|
474
|
+
200: string;
|
|
475
|
+
300: string;
|
|
476
|
+
400: string;
|
|
477
|
+
500: string;
|
|
478
|
+
600: string;
|
|
479
|
+
700: string;
|
|
480
|
+
800: string;
|
|
481
|
+
900: string;
|
|
482
|
+
950: string;
|
|
483
|
+
};
|
|
484
|
+
mauve: {
|
|
485
|
+
50: string;
|
|
486
|
+
100: string;
|
|
487
|
+
200: string;
|
|
488
|
+
300: string;
|
|
489
|
+
400: string;
|
|
490
|
+
500: string;
|
|
491
|
+
600: string;
|
|
492
|
+
700: string;
|
|
493
|
+
800: string;
|
|
494
|
+
900: string;
|
|
495
|
+
950: string;
|
|
496
|
+
};
|
|
497
|
+
olive: {
|
|
498
|
+
50: string;
|
|
499
|
+
100: string;
|
|
500
|
+
200: string;
|
|
501
|
+
300: string;
|
|
502
|
+
400: string;
|
|
503
|
+
500: string;
|
|
504
|
+
600: string;
|
|
505
|
+
700: string;
|
|
506
|
+
800: string;
|
|
507
|
+
900: string;
|
|
508
|
+
950: string;
|
|
509
|
+
};
|
|
510
|
+
mist: {
|
|
511
|
+
50: string;
|
|
512
|
+
100: string;
|
|
513
|
+
200: string;
|
|
514
|
+
300: string;
|
|
515
|
+
400: string;
|
|
516
|
+
500: string;
|
|
517
|
+
600: string;
|
|
518
|
+
700: string;
|
|
519
|
+
800: string;
|
|
520
|
+
900: string;
|
|
521
|
+
950: string;
|
|
522
|
+
};
|
|
523
|
+
taupe: {
|
|
524
|
+
50: string;
|
|
525
|
+
100: string;
|
|
526
|
+
200: string;
|
|
527
|
+
300: string;
|
|
528
|
+
400: string;
|
|
529
|
+
500: string;
|
|
530
|
+
600: string;
|
|
531
|
+
700: string;
|
|
532
|
+
800: string;
|
|
533
|
+
900: string;
|
|
534
|
+
950: string;
|
|
535
|
+
};
|
|
536
|
+
black: string;
|
|
537
|
+
white: string;
|
|
538
|
+
};
|
|
539
|
+
spacing: {
|
|
540
|
+
step: string;
|
|
541
|
+
};
|
|
542
|
+
sizes: {
|
|
543
|
+
"3xs": string;
|
|
544
|
+
"2xs": string;
|
|
545
|
+
xs: string;
|
|
546
|
+
sm: string;
|
|
547
|
+
md: string;
|
|
548
|
+
lg: string;
|
|
549
|
+
xl: string;
|
|
550
|
+
"2xl": string;
|
|
551
|
+
"3xl": string;
|
|
552
|
+
"4xl": string;
|
|
553
|
+
"5xl": string;
|
|
554
|
+
"6xl": string;
|
|
555
|
+
"7xl": string;
|
|
556
|
+
};
|
|
557
|
+
breakpoints: {
|
|
558
|
+
sm: string;
|
|
559
|
+
md: string;
|
|
560
|
+
lg: string;
|
|
561
|
+
xl: string;
|
|
562
|
+
"2xl": string;
|
|
563
|
+
};
|
|
564
|
+
containers: {
|
|
565
|
+
"3xs": string;
|
|
566
|
+
"2xs": string;
|
|
567
|
+
xs: string;
|
|
568
|
+
sm: string;
|
|
569
|
+
md: string;
|
|
570
|
+
lg: string;
|
|
571
|
+
xl: string;
|
|
572
|
+
"2xl": string;
|
|
573
|
+
"3xl": string;
|
|
574
|
+
"4xl": string;
|
|
575
|
+
"5xl": string;
|
|
576
|
+
"6xl": string;
|
|
577
|
+
"7xl": string;
|
|
578
|
+
};
|
|
579
|
+
fonts: {
|
|
580
|
+
sans: string;
|
|
581
|
+
serif: string;
|
|
582
|
+
mono: string;
|
|
583
|
+
};
|
|
584
|
+
fontSizes: {
|
|
585
|
+
xs: string;
|
|
586
|
+
sm: string;
|
|
587
|
+
base: string;
|
|
588
|
+
lg: string;
|
|
589
|
+
xl: string;
|
|
590
|
+
"2xl": string;
|
|
591
|
+
"3xl": string;
|
|
592
|
+
"4xl": string;
|
|
593
|
+
"5xl": string;
|
|
594
|
+
"6xl": string;
|
|
595
|
+
"7xl": string;
|
|
596
|
+
"8xl": string;
|
|
597
|
+
"9xl": string;
|
|
598
|
+
};
|
|
599
|
+
fontWeights: {
|
|
600
|
+
thin: string;
|
|
601
|
+
extralight: string;
|
|
602
|
+
light: string;
|
|
603
|
+
normal: string;
|
|
604
|
+
medium: string;
|
|
605
|
+
semibold: string;
|
|
606
|
+
bold: string;
|
|
607
|
+
extrabold: string;
|
|
608
|
+
black: string;
|
|
609
|
+
};
|
|
610
|
+
letterSpacings: {
|
|
611
|
+
tighter: string;
|
|
612
|
+
tight: string;
|
|
613
|
+
normal: string;
|
|
614
|
+
wide: string;
|
|
615
|
+
wider: string;
|
|
616
|
+
widest: string;
|
|
617
|
+
};
|
|
618
|
+
lineHeights: {
|
|
619
|
+
tight: string;
|
|
620
|
+
snug: string;
|
|
621
|
+
normal: string;
|
|
622
|
+
relaxed: string;
|
|
623
|
+
loose: string;
|
|
624
|
+
};
|
|
625
|
+
radii: {
|
|
626
|
+
xs: string;
|
|
627
|
+
sm: string;
|
|
628
|
+
md: string;
|
|
629
|
+
lg: string;
|
|
630
|
+
xl: string;
|
|
631
|
+
"2xl": string;
|
|
632
|
+
"3xl": string;
|
|
633
|
+
"4xl": string;
|
|
634
|
+
};
|
|
635
|
+
shadows: {
|
|
636
|
+
"2xs": string;
|
|
637
|
+
xs: string;
|
|
638
|
+
sm: string;
|
|
639
|
+
md: string;
|
|
640
|
+
lg: string;
|
|
641
|
+
xl: string;
|
|
642
|
+
"2xl": string;
|
|
643
|
+
};
|
|
644
|
+
textShadows: {
|
|
645
|
+
"2xs": string;
|
|
646
|
+
xs: string;
|
|
647
|
+
sm: string;
|
|
648
|
+
md: string;
|
|
649
|
+
lg: string;
|
|
650
|
+
};
|
|
651
|
+
easings: {
|
|
652
|
+
in: string;
|
|
653
|
+
out: string;
|
|
654
|
+
"in-out": string;
|
|
655
|
+
};
|
|
656
|
+
blurs: {
|
|
657
|
+
xs: string;
|
|
658
|
+
sm: string;
|
|
659
|
+
md: string;
|
|
660
|
+
lg: string;
|
|
661
|
+
xl: string;
|
|
662
|
+
"2xl": string;
|
|
663
|
+
"3xl": string;
|
|
664
|
+
};
|
|
665
|
+
aspectRatios: {
|
|
666
|
+
video: string;
|
|
667
|
+
};
|
|
668
|
+
};
|
|
669
|
+
textStyles: {
|
|
670
|
+
xs: {
|
|
671
|
+
fontSize: string;
|
|
672
|
+
lineHeight: string;
|
|
673
|
+
};
|
|
674
|
+
sm: {
|
|
675
|
+
fontSize: string;
|
|
676
|
+
lineHeight: string;
|
|
677
|
+
};
|
|
678
|
+
base: {
|
|
679
|
+
fontSize: string;
|
|
680
|
+
lineHeight: string;
|
|
681
|
+
};
|
|
682
|
+
lg: {
|
|
683
|
+
fontSize: string;
|
|
684
|
+
lineHeight: string;
|
|
685
|
+
};
|
|
686
|
+
xl: {
|
|
687
|
+
fontSize: string;
|
|
688
|
+
lineHeight: string;
|
|
689
|
+
};
|
|
690
|
+
"2xl": {
|
|
691
|
+
fontSize: string;
|
|
692
|
+
lineHeight: string;
|
|
693
|
+
};
|
|
694
|
+
"3xl": {
|
|
695
|
+
fontSize: string;
|
|
696
|
+
lineHeight: string;
|
|
697
|
+
};
|
|
698
|
+
"4xl": {
|
|
699
|
+
fontSize: string;
|
|
700
|
+
lineHeight: string;
|
|
701
|
+
};
|
|
702
|
+
"5xl": {
|
|
703
|
+
fontSize: string;
|
|
704
|
+
lineHeight: string;
|
|
705
|
+
};
|
|
706
|
+
"6xl": {
|
|
707
|
+
fontSize: string;
|
|
708
|
+
lineHeight: string;
|
|
709
|
+
};
|
|
710
|
+
"7xl": {
|
|
711
|
+
fontSize: string;
|
|
712
|
+
lineHeight: string;
|
|
713
|
+
};
|
|
714
|
+
"8xl": {
|
|
715
|
+
fontSize: string;
|
|
716
|
+
lineHeight: string;
|
|
717
|
+
};
|
|
718
|
+
"9xl": {
|
|
719
|
+
fontSize: string;
|
|
720
|
+
lineHeight: string;
|
|
721
|
+
};
|
|
722
|
+
};
|
|
723
|
+
keyframes: {
|
|
724
|
+
spin: {
|
|
725
|
+
to: {
|
|
726
|
+
transform: string;
|
|
727
|
+
};
|
|
728
|
+
};
|
|
729
|
+
ping: {
|
|
730
|
+
"75%, 100%": {
|
|
731
|
+
transform: string;
|
|
732
|
+
opacity: string;
|
|
733
|
+
};
|
|
734
|
+
};
|
|
735
|
+
pulse: {
|
|
736
|
+
"50%": {
|
|
737
|
+
opacity: string;
|
|
738
|
+
};
|
|
739
|
+
};
|
|
740
|
+
bounce: {
|
|
741
|
+
"0%, 100%": {
|
|
742
|
+
transform: string;
|
|
743
|
+
animationTimingFunction: string;
|
|
744
|
+
};
|
|
745
|
+
"50%": {
|
|
746
|
+
transform: string;
|
|
747
|
+
animationTimingFunction: string;
|
|
748
|
+
};
|
|
749
|
+
};
|
|
750
|
+
};
|
|
751
|
+
};
|
|
752
|
+
//#endregion
|
|
753
|
+
//#region src/config/dtcg.d.ts
|
|
754
|
+
/** Where a group's tokens go: a scale, the text styles, or nowhere (`false`). */
|
|
755
|
+
type DtcgTarget = ScaleName | "textStyles";
|
|
756
|
+
interface DtcgOptions {
|
|
757
|
+
/**
|
|
758
|
+
* Group path (DTCG names joined with `.`, as in an alias) → scale, or
|
|
759
|
+
* `false` to leave the group out without a warning. The longest matching
|
|
760
|
+
* path wins, and it beats the group-name and `$type` rules. A path that
|
|
761
|
+
* names no group is an error, so a typo cannot pass silently.
|
|
762
|
+
*/
|
|
763
|
+
scales?: Record<string, DtcgTarget | false>;
|
|
764
|
+
/**
|
|
765
|
+
* Resolver files: modifier → context → the vicss mode its values become
|
|
766
|
+
* (`"dark"` or `"_dark"`), `"base"` for the unconditioned values, or
|
|
767
|
+
* `false` to ignore the context. Unlisted contexts: the modifier's
|
|
768
|
+
* `default` (else its first context) is `"base"`, and every other context
|
|
769
|
+
* is the mode of the same name in camelCase (`high-contrast` →
|
|
770
|
+
* `highContrast`), which the config must declare as a condition unless it
|
|
771
|
+
* is `dark` or `light`.
|
|
772
|
+
*/
|
|
773
|
+
modes?: Record<string, Record<string, string | false>>;
|
|
774
|
+
/** Receives one message per kind of skipped token. Defaults to `console.warn`. */
|
|
775
|
+
onWarn?: (message: string) => void;
|
|
776
|
+
}
|
|
777
|
+
/** The token part of a config: spread it into `defineConfig`, or pass it in `presets`. */
|
|
778
|
+
type DtcgConfig = Pick<VicssConfig, "tokens" | "semanticTokens" | "textStyles" | "tokenVisibility">;
|
|
779
|
+
/**
|
|
780
|
+
* Reads DTCG 2025.10 tokens: a path or `file:` URL of a `.tokens.json`,
|
|
781
|
+
* `.tokens` or `.resolver.json` file, or a parsed object. A relative path is
|
|
782
|
+
* relative to the vicss config file being loaded, else to `process.cwd()`
|
|
783
|
+
* (a config built in `vite.config.ts`); `new URL("./x", import.meta.url)` is
|
|
784
|
+
* relative to the calling module everywhere, which a preset package needs.
|
|
785
|
+
* Files a resolver references are read relative to the resolver.
|
|
786
|
+
*
|
|
787
|
+
* ```ts
|
|
788
|
+
* export default defineConfig({ presets: [dtcg("./tokens.resolver.json")] });
|
|
789
|
+
* ```
|
|
790
|
+
*/
|
|
791
|
+
/**
|
|
792
|
+
* A `file:` URL (`new URL("./tokens.json", import.meta.url)`), by its shape:
|
|
793
|
+
* the declarations stay free of the DOM's and Node's `URL`, which a config-
|
|
794
|
+
* only or Workers program does not have.
|
|
795
|
+
*/
|
|
796
|
+
interface FileUrl {
|
|
797
|
+
readonly href: string;
|
|
798
|
+
readonly protocol: string;
|
|
799
|
+
}
|
|
800
|
+
export declare function dtcg(source: string | FileUrl | object, options?: DtcgOptions): DtcgConfig;
|
|
801
|
+
//#endregion
|
|
802
|
+
//#region src/config/index.d.ts
|
|
803
|
+
/**
|
|
804
|
+
* Types the config of a project: `export default defineConfig({ … })`.
|
|
805
|
+
*
|
|
806
|
+
* With a second argument, the values that name tokens are typed too (PLAN
|
|
807
|
+
* D32): `defineConfig({ presets, tokens }, ({ colors }) => ({ semanticTokens:
|
|
808
|
+
* { colors: { text: colors.gray[900] } } }))`. The callback receives every
|
|
809
|
+
* token of the first argument and its presets, each the brace string the
|
|
810
|
+
* config takes (`"{colors.gray.900}"`), and returns any key but `tokens` and
|
|
811
|
+
* `presets`; a key it returns replaces the first argument's.
|
|
812
|
+
*/
|
|
813
|
+
export declare function defineConfig(config: VicssConfig): VicssConfig;
|
|
814
|
+
export declare function defineConfig<C extends VicssConfig>(config: C, derive: (tokens: TokenRefs<C>) => DerivedConfig): VicssConfig;
|
|
815
|
+
/**
|
|
816
|
+
* Types a design system shared as a preset: `presets: [myPreset]`. Its token
|
|
817
|
+
* names stay in its type, for the callback of `defineConfig`.
|
|
818
|
+
*/
|
|
819
|
+
export declare function definePreset<P extends VicssConfig>(preset: P): P;
|
|
820
|
+
//#endregion
|
|
821
|
+
export type { DerivedConfig, DtcgConfig, DtcgOptions, DtcgTarget, FileUrl, PalettesConfig, ScaleName, SemanticTokenTree, Strictness, StrictnessMap, StyleObject, TokenGroupRef, TokenRefs, TokenTree, TokenVisibility, UtilityDefinition, VicssConfig };
|