@sugarcube-org/core 0.0.1-alpha.9 → 0.1.0-alpha.18

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/dist/index.d.ts CHANGED
@@ -1,20 +1,30 @@
1
1
  import { z } from 'zod';
2
2
 
3
- /**
4
- * Directional variants for utility properties
5
- */
3
+ declare const DEFAULT_CONFIG: {
4
+ readonly output: {
5
+ readonly cssRoot: "src/styles";
6
+ readonly components: "src/components/ui";
7
+ readonly themeAttribute: "data-theme";
8
+ };
9
+ readonly transforms: {
10
+ readonly fluid: {
11
+ readonly min: 320;
12
+ readonly max: 1200;
13
+ };
14
+ readonly colorFallbackStrategy: "native";
15
+ };
16
+ };
17
+
6
18
  type DirectionalVariant = "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all";
7
- /**
8
- * Properties-first utility configuration
9
- * This is the approach where users configure utilities by CSS property
10
- * Made it separate in case we want other types of configs later
11
- */
12
19
  type PropertyUtilityConfig = {
20
+ /** Token path pattern (e.g., "space.*", "color.primary.*"). */
13
21
  source: string;
22
+ /** Directional variants for spacing properties. */
14
23
  directions?: DirectionalVariant | DirectionalVariant[];
24
+ /** Custom prefix for generated classes. */
15
25
  prefix?: string;
26
+ /** Strip duplicate prefix (e.g., "text-text-quiet" → "text-quiet"). */
16
27
  stripDuplicates?: boolean;
17
- collection?: string;
18
28
  };
19
29
 
20
30
  type ColorFallbackStrategy = "native" | "polyfill";
@@ -22,754 +32,539 @@ type FluidConfig = {
22
32
  min: number;
23
33
  max: number;
24
34
  };
25
- /**
26
- * Theme configuration can be either:
27
- * - Simple: string[] of file paths
28
- * - Nested: { source: string[], modes?: Record<string, string[]> }
29
- */
30
- type ThemeConfig = string[] | {
31
- source: string[];
32
- /** Mode variations within this theme */
33
- modes?: Record<string, string[]>;
34
- };
35
- type TokenCollection = {
36
- source: string[];
37
- /** Mode variations (light/dark) - generates [data-mode="..."] selectors */
38
- modes?: Record<string, string[]>;
39
- /** Theme variations (color schemes) - generates [data-theme="..."] selectors */
40
- themes?: Record<string, ThemeConfig>;
41
- };
42
- /**
43
- * Multiple named collections of tokens.
44
- * Each key is a collection name (e.g., "base", "ui", "marketing").
45
- */
46
- type TokenCollections = Record<string, TokenCollection>;
47
- type UserTransformsConfig = {
48
- fluid?: FluidConfig;
49
- colorFallbackStrategy?: ColorFallbackStrategy;
50
- };
51
- /**
52
- * Configuration for transforms applied to tokens during processing (internal config)
53
- */
54
35
  type TransformsConfig = {
55
36
  fluid: FluidConfig;
56
37
  colorFallbackStrategy: ColorFallbackStrategy;
57
38
  };
58
- /**
59
- * Configuration for output directories (user config - optional fields)
60
- */
61
- type UserOutputConfig = {
62
- css?: string;
63
- components?: string;
64
- separate?: boolean;
65
- /** Attribute name for mode selectors (default: "data-mode") */
66
- modeAttribute?: string;
67
- /** Attribute name for theme selectors (default: "data-theme") */
68
- themeAttribute?: string;
69
- };
70
- /**
71
- * Configuration for output directories (internal config - required fields)
72
- */
73
39
  type OutputConfig = {
74
- css: string;
40
+ cssRoot: string;
41
+ variables?: string;
42
+ utilities?: string;
43
+ cube?: string;
75
44
  components?: string;
76
- separate: boolean;
77
- /** Attribute name for mode selectors */
78
- modeAttribute: string;
79
- /** Attribute name for theme selectors */
80
45
  themeAttribute: string;
46
+ defaultContext?: string;
81
47
  };
82
- /**
83
- * Utilities configuration
84
- * This is the approach where users configure utilities by CSS property
85
- * Can be a single configuration or an array of configurations
86
- */
87
48
  type UtilitiesConfig = Record<string, PropertyUtilityConfig | PropertyUtilityConfig[]>;
88
- interface UserConfig {
89
- tokens?: TokenCollection | TokenCollections;
90
- transforms?: UserTransformsConfig;
91
- output?: UserOutputConfig;
49
+ /**
50
+ * Configuration for sugarcube.
51
+ * This is the shape of your config file (sugarcube.config.ts).
52
+ *
53
+ * @example
54
+ * // sugarcube.config.ts
55
+ * import { defineConfig } from "@sugarcube-org/vite";
56
+ *
57
+ * export default defineConfig({
58
+ * resolver: "./tokens.resolver.json",
59
+ * output: { cssRoot: "src/styles" }
60
+ * });
61
+ */
62
+ interface SugarcubeConfig {
63
+ /**
64
+ * Path to the DTCG resolver document (.resolver.json).
65
+ * The resolver defines token sources, sets, and modifiers.
66
+ */
67
+ resolver?: string;
68
+ /**
69
+ * Token transformation options.
70
+ */
71
+ transforms?: {
72
+ /**
73
+ * Viewport range for fluid typography calculations.
74
+ * Tokens with $type: "fluidDimension" will scale between min and max viewport widths.
75
+ */
76
+ fluid?: FluidConfig;
77
+ /**
78
+ * How to handle colors that can't be represented in sRGB.
79
+ * - "native": Use CSS color functions directly (modern browsers only)
80
+ * - "polyfill": Generate fallback values for older browsers
81
+ */
82
+ colorFallbackStrategy?: ColorFallbackStrategy;
83
+ };
84
+ /**
85
+ * Output configuration.
86
+ */
87
+ output?: {
88
+ /**
89
+ * Base directory path where CSS files will be written.
90
+ * This is the primary output location for generated styles.
91
+ */
92
+ cssRoot?: string;
93
+ /**
94
+ * Directory path where token variable CSS files will be written.
95
+ * @default "{cssRoot}/global"
96
+ */
97
+ variables?: string;
98
+ /**
99
+ * Directory path where utility class CSS files will be written.
100
+ * @default "{cssRoot}/utilities"
101
+ */
102
+ utilities?: string;
103
+ /**
104
+ * Directory path where CUBE CSS files will be written.
105
+ * @default "{cssRoot}"
106
+ */
107
+ cube?: string;
108
+ /** Directory path where component files will be written. */
109
+ components?: string;
110
+ /**
111
+ * HTML attribute used for theme selectors.
112
+ * @default "data-theme"
113
+ */
114
+ themeAttribute?: string;
115
+ /**
116
+ * Which context should use the :root selector.
117
+ * Other contexts will use [themeAttribute="contextName"] selectors.
118
+ * @default The resolver's default context
119
+ */
120
+ defaultContext?: string;
121
+ };
122
+ /**
123
+ * CSS utility class generation configuration.
124
+ * Maps CSS property names to token sources and options.
125
+ *
126
+ * @example
127
+ * utilities: {
128
+ * "background-color": { source: "color.background.*" },
129
+ * "padding": { source: "space.*", directions: ["x", "y", "all"] }
130
+ * }
131
+ */
92
132
  utilities?: UtilitiesConfig;
93
133
  }
94
134
  /**
95
- * Internal configuration type - what code uses (complete, required fields)
135
+ * Normalized configuration with all defaults applied.
136
+ * Used internally after processing SugarcubeConfig.
96
137
  */
97
138
  interface InternalConfig {
98
- tokens?: TokenCollection | TokenCollections;
139
+ resolver?: string;
99
140
  transforms: TransformsConfig;
100
141
  output: OutputConfig;
101
142
  utilities?: UtilitiesConfig;
102
143
  }
103
144
 
104
145
  /**
105
- * Base error type that all other error types extend from.
106
- * Used as the foundation for all error types in the system.
107
- * Provides a consistent structure for error messages across the codebase.
146
+ * Result of loading a sugarcube configuration file.
147
+ * Contains the validated, normalized configuration and its source path.
108
148
  */
109
- type BaseError = {
110
- /** A human-readable error message describing what went wrong */
111
- message: string;
149
+ type LoadedConfig = {
150
+ /** The validated and normalized configuration with defaults applied. */
151
+ config: InternalConfig;
152
+ /** The absolute path to the config file that was loaded. */
153
+ configPath: string;
112
154
  };
113
-
114
155
  /**
115
- * A token value that can either be a raw value or a reference.
116
- * This is the base type for all token values in the W3C Design Token Format.
117
- * @template T - The type of token (e.g., "color", "dimension", etc.)
156
+ * Checks if a sugarcube configuration file exists.
157
+ *
158
+ * @param basePath - Base path without extension (default: "sugarcube.config")
159
+ * @returns True if a .ts or .js config file exists
118
160
  */
119
- type TokenValue<T extends TokenType> = RawTokenValue<T> | Reference<T>;
161
+ declare function configFileExists(basePath?: string): boolean;
120
162
  /**
121
- * The actual value of a token without references.
122
- * This represents the concrete value that will be used in the final output.
123
- * @template T - The type of token (e.g., "color", "dimension", etc.)
163
+ * Loads and validates a sugarcube configuration file.
164
+ * Returns the user-facing config without internal defaults applied.
165
+ *
166
+ * @param configPath - Optional path to config file. If omitted, searches for sugarcube.config.ts/js
167
+ * @returns The validated config and its resolved path
168
+ * @throws Error if config file not found or invalid
124
169
  */
125
- type RawTokenValue<T extends TokenType> = T extends SimpleTokenType ? SimpleTokenValue<T> : T extends CompositeTokenType ? CompositeTokenValue<T> : never;
170
+ declare function loadSugarcubeConfig(configPath?: string): Promise<{
171
+ config: SugarcubeConfig;
172
+ configPath: string;
173
+ }>;
174
+ /**
175
+ * Loads, validates, and normalizes a sugarcube configuration file.
176
+ * Returns a complete internal config with all defaults applied.
177
+ *
178
+ * @param configPath - Optional path to config file. If omitted, searches for sugarcube.config.ts/js
179
+ * @returns The normalized config with defaults and its resolved path
180
+ * @throws Error if config file not found or invalid
181
+ */
182
+ declare function loadInternalConfig(configPath?: string): Promise<LoadedConfig>;
183
+
184
+ /**
185
+ * Validates a user configuration object against the schema and fills in defaults.
186
+ *
187
+ * @param config - The user configuration object to validate
188
+ * @returns The validated configuration with defaults filled in
189
+ * @throws Error if the configuration is invalid
190
+ *
191
+ * @example
192
+ * const config = { resolver: "./tokens.resolver.json" };
193
+ * const validatedConfig = validateConfig(config);
194
+ */
195
+ declare function validateConfig(config: Partial<SugarcubeConfig>): InternalConfig;
196
+
126
197
  /**
127
- * A reference to another token, with optional type checking.
128
- * References are strings that point to other tokens in the token tree.
129
- * The phantom type parameter ensures type safety when resolving references.
130
- * @template T - The type of token being referenced
198
+ * Fills in default values for any omitted fields in a user configuration.
199
+ *
200
+ * This function takes a user config (with optional fields) and
201
+ * returns a complete internal config (with all required fields filled in).
202
+ *
203
+ * @param userConfig - The user configuration with optional fields
204
+ * @returns A complete configuration with all defaults filled in
205
+ *
206
+ * @example
207
+ * const userConfig = {
208
+ * resolver: "./tokens.resolver.json"
209
+ * };
210
+ * const completeConfig = fillDefaults(userConfig);
211
+ * // completeConfig.output.cssRoot === "src/styles"
131
212
  */
213
+ declare function fillDefaults(userConfig: SugarcubeConfig): InternalConfig;
214
+
215
+ type BaseError = {
216
+ message: string;
217
+ };
218
+
219
+ type TokenValue<T extends TokenType> = RawTokenValue<T> | Reference<T>;
220
+ type RawTokenValue<T extends TokenType> = T extends SimpleTokenType ? SimpleTokenValue<T> : T extends CompositeTokenType ? CompositeTokenValue<T> : never;
221
+ /** Reference to another token. String format: "{path.to.token}". */
132
222
  type Reference<T extends TokenType = TokenType> = string & {
133
- /** Phantom type for type safety during reference resolution */
134
223
  __tokenType?: T;
135
224
  };
136
- /**
137
- * Metadata that can be attached to any node in the token tree.
138
- * This includes descriptions and custom extensions as defined in the W3C spec.
139
- */
140
225
  type NodeMetadata = {
141
- /** Optional description of the token or group */
142
226
  $description?: string;
143
- /** Optional custom extensions as defined in the W3C spec */
144
227
  $extensions?: {
145
228
  [key: string]: unknown;
146
229
  };
147
230
  };
148
- /**
149
- * A single token with its value and metadata.
150
- * This is the basic building block of the token system.
151
- */
152
231
  type Token = NodeMetadata & {
153
- /** The value of the token, which can be a raw value or a reference */
154
232
  $value: TokenValue<TokenType>;
155
- /** Optional type specification, can be inherited from parent groups */
156
233
  $type?: TokenType;
157
234
  };
158
- /**
159
- * A group of tokens that can be nested.
160
- * The type allows for:
161
- * - Regular token properties (non-$ prefixed) which must be Token | TokenGroup
162
- * - Metadata properties from NodeMetadata (like $description, $extensions)
163
- * - $type property for type inheritance as specified in the W3C spec
164
- * - undefined to support optional metadata properties
165
- */
166
235
  type TokenGroup = NodeMetadata & {
167
- /** Optional type specification for the group, can be inherited by child tokens */
168
236
  $type?: TokenType;
169
- /** Dynamic properties that can be either tokens, token groups, or undefined */
170
237
  [key: string]: Token | TokenGroup | TokenType | undefined;
171
238
  };
172
- /**
173
- * All possible token types, either simple or composite.
174
- * This is the union of all supported token types in the system.
175
- */
176
239
  type TokenType = SimpleTokenType | CompositeTokenType;
177
- /**
178
- * Token types that contain a single value.
179
- * These are the basic building blocks of the token system.
180
- */
181
240
  type SimpleTokenType = "color" | "dimension" | "fluidDimension" | "duration" | "cubicBezier" | "fontFamily" | "fontWeight" | "number";
182
- /**
183
- * Values for simple token types.
184
- * Maps each simple token type to its corresponding value type.
185
- * @template T - The type of token (e.g., "color", "dimension", etc.)
186
- */
187
241
  type SimpleTokenValue<T extends SimpleTokenType = SimpleTokenType> = T extends "color" ? Color : T extends "dimension" ? Dimension : T extends "fluidDimension" ? FluidDimension : T extends "duration" ? Duration : T extends "cubicBezier" ? CubicBezier : T extends "fontFamily" ? FontFamily : T extends "fontWeight" ? FontWeight : T extends "number" ? number : never;
188
- /**
189
- * Token types that contain multiple values or are structurally complex.
190
- * These types combine multiple simple types to create more complex tokens.
191
- */
192
242
  type CompositeTokenType = AlwaysDecomposedType | "border" | "shadow" | "gradient" | "transition" | StructuralCompositeType;
193
- /**
194
- * Token types that must always be broken down into their constituent parts.
195
- * These types are never used directly in CSS output.
196
- */
243
+ /** Types that decompose into multiple CSS properties (e.g., typography → font-family, font-size, etc.). */
197
244
  type AlwaysDecomposedType = "typography";
198
- /**
199
- * Token types that define structural patterns.
200
- * These types are used to define reusable patterns in the token system.
201
- */
202
245
  type StructuralCompositeType = "strokeStyle";
203
- /**
204
- * Values for composite token types.
205
- * Maps each composite token type to its corresponding value type.
206
- * @template T - The type of token (e.g., "typography", "border", etc.)
207
- */
208
246
  type CompositeTokenValue<T extends CompositeTokenType = CompositeTokenType> = T extends "typography" ? Typography : T extends "border" ? Border : T extends "shadow" ? Shadow : T extends "gradient" ? Gradient : T extends "transition" ? Transition : T extends "strokeStyle" ? StrokeStyle : never;
209
- /**
210
- * A color value in any valid CSS color format.
211
- * This can be either:
212
- * - A string that is valid in CSS color contexts (legacy format)
213
- * - A W3C color object with colorSpace, components, and optional alpha/hex
214
- */
247
+ /** CSS color string or W3C color object with colorSpace. */
215
248
  type Color = string | {
216
- /** The color space - supports "oklch" and "display-p3" */
217
249
  colorSpace: "oklch" | "display-p3";
218
- /** Array of 3 numbers representing the color components */
219
250
  components: [number, number, number];
220
- /** Optional alpha value between 0 and 1 (defaults to 1 if omitted) */
221
251
  alpha?: number;
222
- /** Optional hex fallback value for compatibility */
223
252
  hex?: string;
224
253
  };
225
- /**
226
- * A dimensional value with a numeric value and unit.
227
- * Used for measurements like width, height, spacing, etc.
228
- */
229
254
  type Dimension = {
230
- /** The numeric value of the dimension */
231
255
  value: number;
232
- /** The unit of measurement (px or rem) */
233
256
  unit: "px" | "rem";
234
257
  };
235
- /**
236
- * A fluid dimension that scales between min and max values.
237
- * Used for responsive design tokens that need to scale with viewport size.
238
- */
258
+ /** Responsive dimension that scales between viewport sizes. */
239
259
  type FluidDimension = {
240
- /** The minimum value at the smallest viewport size */
241
260
  min: Dimension;
242
- /** The maximum value at the largest viewport size */
243
261
  max: Dimension;
244
262
  };
245
- /**
246
- * A duration value with a numeric value and time unit.
247
- * Used for animations, transitions, and other time-based values.
248
- */
249
263
  type Duration = {
250
- /** The numeric value of the duration */
251
264
  value: number;
252
- /** The unit of time (milliseconds or seconds) */
253
265
  unit: "ms" | "s";
254
266
  };
255
- /**
256
- * A cubic bezier curve defined by four control points.
257
- * Used for defining custom easing functions in animations and transitions.
258
- * The four numbers represent the x,y coordinates of the two control points.
259
- */
267
+ /** Bezier curve control points: [x1, y1, x2, y2]. */
260
268
  type CubicBezier = [number, number, number, number];
261
- /**
262
- * A font family name or list of fallback fonts.
263
- * Can be a single font name or an array of fonts in order of preference.
264
- */
265
269
  type FontFamily = string | string[];
266
- /**
267
- * A font weight value as either a number or semantic string.
268
- * Numbers range from 100-900, strings are semantic names for common weights.
269
- */
270
270
  type FontWeight = number | FontWeightString;
271
- /**
272
- * Semantic font weight names.
273
- * These are standardized names for common font weights.
274
- */
275
271
  type FontWeightString = "thin" | "hairline" | "extra-light" | "ultra-light" | "light" | "normal" | "regular" | "book" | "medium" | "semi-bold" | "demi-bold" | "bold" | "extra-bold" | "ultra-bold" | "black" | "heavy" | "extra-black" | "ultra-black";
276
- /**
277
- * Line cap style for strokes.
278
- * Defines how the end of a stroke should be rendered.
279
- */
280
272
  type LineCap = "round" | "butt" | "square";
281
- /**
282
- * Typography token combining font properties.
283
- * This is a composite type that combines multiple font-related properties.
284
- */
285
273
  type Typography = {
286
- /** The font family to use */
287
274
  fontFamily: TokenValue<"fontFamily">;
288
- /** The size of the font */
289
275
  fontSize: TokenValue<"dimension">;
290
- /** Optional font weight */
291
276
  fontWeight?: TokenValue<"fontWeight">;
292
- /** Optional letter spacing */
293
277
  letterSpacing?: TokenValue<"dimension">;
294
- /** Optional line height as a multiplier */
295
278
  lineHeight?: TokenValue<"number">;
296
279
  };
297
- /**
298
- * Transition token defining animation properties.
299
- * Used to define how properties should animate between states.
300
- */
301
280
  type Transition = {
302
- /** How long the transition should take */
303
281
  duration: TokenValue<"duration">;
304
- /** Optional delay before the transition starts */
305
282
  delay?: TokenValue<"duration">;
306
- /** The easing function to use for the transition */
307
283
  timingFunction: TokenValue<"cubicBezier">;
308
284
  };
309
- /**
310
- * Predefined stroke style keywords.
311
- * These are the standard stroke styles available in CSS.
312
- */
313
285
  type StrokeStyleKeyword = "solid" | "dashed" | "dotted" | "double" | "groove" | "ridge" | "outset" | "inset";
314
- /**
315
- * Custom stroke style definition.
316
- * Used when the predefined stroke styles are not sufficient.
317
- */
318
286
  type StrokeStyleCustom = {
319
- /** Array of dimensions defining the dash pattern */
320
287
  dashArray: Array<TokenValue<"dimension">>;
321
- /** How the ends of the stroke should be rendered */
322
288
  lineCap: LineCap;
323
289
  };
324
- /**
325
- * A stroke style can be either a predefined keyword or a custom definition.
326
- * This allows for both simple and complex stroke styles.
327
- */
328
290
  type StrokeStyle = StrokeStyleKeyword | StrokeStyleCustom;
329
- /**
330
- * Border token combining color, width, and style.
331
- * This is a composite type that defines a complete border.
332
- */
333
291
  type Border = {
334
- /** The color of the border */
335
292
  color: TokenValue<"color">;
336
- /** The width of the border */
337
293
  width: TokenValue<"dimension">;
338
- /** The style of the border, either a stroke style or a reference to one */
339
294
  style: StrokeStyle | Reference<"strokeStyle">;
340
295
  };
341
- /**
342
- * A single shadow definition.
343
- * This is the basic building block for shadow tokens.
344
- */
345
296
  type ShadowObject = {
346
- /** The color of the shadow */
347
297
  color: TokenValue<"color">;
348
- /** Horizontal offset of the shadow */
349
298
  offsetX: TokenValue<"dimension">;
350
- /** Vertical offset of the shadow */
351
299
  offsetY: TokenValue<"dimension">;
352
- /** How much the shadow should blur */
353
300
  blur: TokenValue<"dimension">;
354
- /** How much the shadow should spread */
355
301
  spread: TokenValue<"dimension">;
356
- /** Whether the shadow should be inset */
357
302
  inset?: boolean;
358
303
  };
359
- /**
360
- * A shadow can be either a single shadow or multiple shadows.
361
- * Multiple shadows are rendered in order, with later shadows appearing on top.
362
- */
363
304
  type Shadow = ShadowObject | ShadowObject[];
364
- /**
365
- * A single stop in a gradient.
366
- * Defines the color and position of a point in the gradient.
367
- */
368
305
  type GradientStop = {
369
- /** The color at this point in the gradient */
370
306
  color: TokenValue<"color">;
371
- /** The position of this point in the gradient (0-1) */
372
307
  position: number | Reference<"number">;
373
308
  };
374
- /**
375
- * A gradient is defined by a series of stops.
376
- * The stops define how the gradient transitions between colors.
377
- */
378
309
  type Gradient = GradientStop[];
379
310
 
380
311
  /**
381
- * Source information for a token, tracking its collection, theme, and mode.
382
- * This metadata helps with error reporting and token organization.
312
+ * Source information for a token, tracking where it came from.
313
+ * Used for error reporting and context-aware processing.
383
314
  */
384
315
  type TokenSource = {
385
- /** The collection this token belongs to (e.g., "base", "ui", "marketing") */
386
- collection: string;
387
- /** Optional theme name for color scheme variations (e.g., "ocean", "sunset") */
388
- theme?: string;
389
- /** Optional mode name for light/dark variations (e.g., "dark", "light") */
390
- mode?: string;
391
- /** The path to the source file containing this token */
316
+ /**
317
+ * The context name for modifier variations (e.g., "dark", "light").
318
+ * Aligns with DTCG Resolver Module 2025.10 terminology.
319
+ */
320
+ context?: string;
321
+ /** The file path where this token was defined. */
392
322
  sourcePath: string;
393
323
  };
394
324
  /**
395
- * A complete token tree with collection, theme, and mode information.
396
- * This represents a single token file's contents with its metadata.
325
+ * A loaded token file with its contents and source metadata.
326
+ * Represents a single token file after loading but before processing.
397
327
  */
398
328
  type TokenTree = {
399
- /** The collection this token tree belongs to (e.g., "base", "ui", "marketing") */
400
- collection: string;
401
- /** Optional theme name for color scheme variations (e.g., "ocean", "sunset") */
402
- theme?: string;
403
- /** Optional mode name for light/dark variations (e.g., "dark", "light") */
404
- mode?: string;
405
- /** The actual token data following the W3C design tokens format */
329
+ /**
330
+ * The context name for modifier variations (e.g., "dark", "compact").
331
+ * Undefined for base/default tokens.
332
+ */
333
+ context?: string;
334
+ /** The token data following the W3C Design Tokens format. */
406
335
  tokens: TokenGroup;
407
- /** The path to the source file containing these tokens */
336
+ /** The file path where these tokens were loaded from. */
408
337
  sourcePath: string;
409
338
  };
410
339
 
340
+ type FlattenError = BaseError & {
341
+ path: string;
342
+ source: TokenSource;
343
+ };
344
+
345
+ /**
346
+ * A generated CSS file with its output path and content.
347
+ */
348
+ type CSSFile = {
349
+ /** The file path where the CSS will be written. */
350
+ path: string;
351
+ /** The generated CSS content. */
352
+ css: string;
353
+ };
354
+ /**
355
+ * Array of generated CSS files from the pipeline.
356
+ * Each file contains a path and the CSS content to write.
357
+ */
358
+ type CSSFileOutput = CSSFile[];
359
+
360
+ /** In-memory token data keyed by file path. */
361
+ type TokenMemoryData = Record<string, {
362
+ context?: string;
363
+ content: string;
364
+ }>;
365
+ type LoadError = BaseError & {
366
+ file: string;
367
+ };
368
+
411
369
  /**
412
- * A resolved token with its final value.
413
- * Contains both the original token data and its resolved value after reference resolution.
414
- * @template T - The type of token (e.g., "color", "dimension", etc.)
370
+ * A token with all references resolved to their final values.
371
+ * Contains both the original value (which may include references)
372
+ * and the fully resolved value.
415
373
  */
416
374
  type ResolvedToken<T extends TokenType = TokenType> = NodeMetadata & {
417
- /** The type of the token */
375
+ /** The token type (e.g., "color", "dimension"). */
418
376
  $type: T;
419
- /** The original value of the token, which may contain references */
377
+ /** The original value, which may contain references like "{color.primary}". */
420
378
  $value: RawTokenValue<T>;
421
- /** The path to this token in the token tree */
379
+ /** The dot-separated path to this token (e.g., "color.primary"). */
422
380
  $path: string;
423
- /** Information about where this token was loaded from */
381
+ /** Source information about where this token was defined. */
424
382
  $source: TokenSource;
425
- /** The original path before any resolution */
383
+ /** The original path before any processing. */
426
384
  $originalPath: string;
427
- /** The final resolved value after all references are resolved */
385
+ /** The final value after all references have been resolved. */
428
386
  $resolvedValue: RawTokenValue<T>;
429
387
  };
430
388
  /**
431
- * A map of resolved tokens by their lookup path.
432
- * Used to store the final resolved state of all tokens in a collection.
433
- * Keys are token paths, values are either resolved tokens or node metadata.
389
+ * A collection of resolved tokens keyed by their lookup path.
390
+ * Includes both tokens and group metadata nodes.
434
391
  */
435
392
  type ResolvedTokens = {
436
- /** Token path as key, resolved token or metadata as value */
437
393
  [lookupKey: string]: ResolvedToken | NodeMetadata;
438
394
  };
439
- /**
440
- * Type of resolution error that occurred.
441
- * - "circular": A circular reference was detected
442
- * - "missing": A referenced token could not be found
443
- * - "type-mismatch": A referenced token's type doesn't match the expected type
444
- */
445
395
  type ResolutionErrorType = "circular" | "missing" | "type-mismatch";
446
- /**
447
- * An error that occurred during token resolution.
448
- * Extends the base error type with resolution-specific information.
449
- */
450
396
  type ResolutionError = BaseError & {
451
- /** The type of resolution error that occurred */
452
397
  type: ResolutionErrorType;
453
- /** The path to the token that failed resolution */
454
398
  path: string;
455
- /** Source information about where the token was loaded from */
399
+ source: TokenSource;
400
+ };
401
+
402
+ type ValidationError = BaseError & {
403
+ path: string;
456
404
  source: TokenSource;
457
405
  };
458
406
 
459
407
  /**
460
- * A token that has been converted to CSS properties.
461
- * Extends ResolvedToken with CSS-specific properties.
462
- * @template T The type of token
408
+ * Metadata about a modifier (e.g., theme, density) for CSS generation.
409
+ * Used to build attribute selectors like [data-theme="dark"].
463
410
  */
464
- type ConvertedToken<T extends TokenType = TokenType> = ResolvedToken<T> & {
465
- /** The CSS properties generated from the token */
466
- $cssProperties: CSSProperties<T>;
411
+ type ModifierMeta = {
412
+ /** The modifier name (e.g., "theme", "density"). */
413
+ name: string;
414
+ /** The HTML attribute name (e.g., "data-theme", "data-density"). */
415
+ attribute: string;
416
+ /** The default context that uses :root selector. */
417
+ defaultContext: string;
418
+ /** Available non-default context names. */
419
+ contexts: string[];
467
420
  };
468
421
  /**
469
- * A collection of converted tokens.
470
- * Maps token paths to their converted values or metadata nodes.
422
+ * Result of running the token processing pipeline.
423
+ * Contains generated CSS output, processed tokens, and any errors encountered.
471
424
  */
472
- type ConvertedTokens = {
473
- [lookupKey: string]: ConvertedToken | NodeMetadata;
425
+ type PipelineResult = {
426
+ /** The generated CSS files ready to be written to disk. */
427
+ output: CSSFileOutput;
428
+ /** The loaded and processed token trees. */
429
+ trees: TokenTree[];
430
+ /** Modifier metadata for CSS selector generation. */
431
+ modifiers?: ModifierMeta[];
432
+ /** Any errors that occurred during pipeline execution. */
433
+ errors: PipelineErrors;
474
434
  };
475
435
  /**
476
- * A collection of converted tokens organized by mode (light/dark).
477
- * Each mode contains its own set of converted tokens.
436
+ * Errors organized by the pipeline stage where they occurred.
478
437
  */
479
- type ConvertedModeTokenSet = {
480
- /** The default mode's tokens (typically light) */
481
- default: ConvertedTokens;
482
- /** Additional mode-specific tokens (e.g., dark) */
483
- [mode: string]: ConvertedTokens;
438
+ type PipelineErrors = {
439
+ /** Errors from loading token files. */
440
+ load: LoadError[];
441
+ /** Errors from flattening token trees. */
442
+ flatten: FlattenError[];
443
+ /** Errors from validating token values. */
444
+ validation: ValidationError[];
445
+ /** Errors from resolving token references. */
446
+ resolution: ResolutionError[];
484
447
  };
485
448
  /**
486
- * A collection of converted tokens organized by theme (color scheme).
487
- * Each theme contains modes (light/dark variations).
449
+ * Defines the source of tokens for the pipeline.
450
+ *
451
+ * @example
452
+ * // Load from a DTCG resolver document
453
+ * const source: TokenPipelineSource = {
454
+ * type: "resolver",
455
+ * resolverPath: "./tokens.resolver.json",
456
+ * config: internalConfig
457
+ * };
458
+ *
459
+ * @example
460
+ * // Load from in-memory data (for testing)
461
+ * const source: TokenPipelineSource = {
462
+ * type: "memory",
463
+ * data: { "tokens.json": { content: '{"color": {...}}' } },
464
+ * config: internalConfig
465
+ * };
488
466
  */
489
- type ConvertedThemeTokenSet = {
490
- /** The default theme's modes */
491
- default: ConvertedModeTokenSet;
492
- /** Additional theme-specific modes (e.g., ocean, sunset) */
493
- [theme: string]: ConvertedModeTokenSet;
467
+ type TokenPipelineSource = {
468
+ type: "resolver";
469
+ /** Path to the DTCG resolver document (.resolver.json). */
470
+ resolverPath: string;
471
+ /** Pipeline configuration. */
472
+ config: InternalConfig;
473
+ } | {
474
+ type: "memory";
475
+ /** In-memory token data keyed by file path. */
476
+ data: TokenMemoryData;
477
+ /** Pipeline configuration. */
478
+ config: InternalConfig;
494
479
  };
480
+
495
481
  /**
496
- * A collection of converted tokens organized by collection, theme, and mode.
497
- * Structure: collection → theme → mode → tokens
482
+ * Result of loading and resolving tokens.
498
483
  */
499
- type NormalizedConvertedTokens = {
500
- [collection: string]: ConvertedThemeTokenSet;
484
+ type LoadAndResolveResult = {
485
+ /** The loaded token trees */
486
+ trees: TokenTree[];
487
+ /** Resolved tokens after reference resolution */
488
+ resolved: ResolvedTokens;
489
+ /** Modifier metadata for CSS selector generation */
490
+ modifiers: ModifierMeta[];
491
+ /** Any errors that occurred */
492
+ errors: PipelineResult["errors"];
501
493
  };
502
494
  /**
503
- * CSS property types for different token types.
504
- * Maps token types to their corresponding CSS property structures.
505
- * @template T The type of token
495
+ * Core token processing pipeline that handles loading, validation, and resolution.
496
+ *
497
+ * This pipeline:
498
+ * 1. Loads token trees from resolver document or memory
499
+ * 2. Flattens trees into a single structure
500
+ * 3. Validates tokens for correctness
501
+ * 4. Resolves all token references
502
+ *
503
+ * For resolver sources, loads ALL contexts (not just default) and returns
504
+ * modifier metadata needed for CSS selector generation.
505
+ *
506
+ * @param source - The source of tokens to process (resolver or memory)
507
+ * @returns Processed tokens with modifier metadata and any errors
508
+ *
509
+ * @example
510
+ * const result = await loadAndResolveTokens({
511
+ * type: "resolver",
512
+ * resolverPath: "tokens.resolver.json",
513
+ * config
514
+ * });
515
+ * // result.trees - all token trees (base + modifier contexts)
516
+ * // result.modifiers - metadata for CSS selectors
506
517
  */
507
- type CSSProperties<T extends TokenType> = T extends SimpleTokenType ? SimpleCSSProperties : T extends AlwaysDecomposedType ? AlwaysDecomposedProperties : T extends "border" ? CSSBorderProperties : T extends "shadow" ? CSSShadowProperties : T extends "gradient" ? CSSGradientProperties : T extends "transition" ? CSSTransitionProperties : T extends StructuralCompositeType ? SimpleCSSProperties : never;
518
+ declare function loadAndResolveTokens(source: TokenPipelineSource): Promise<LoadAndResolveResult>;
519
+
520
+ type ConvertedToken<T extends TokenType = TokenType> = ResolvedToken<T> & {
521
+ $cssProperties: CSSProperties<T>;
522
+ };
523
+ type ConvertedTokens = {
524
+ [lookupKey: string]: ConvertedToken | NodeMetadata;
525
+ };
508
526
  /**
509
- * Simple CSS properties with a single value.
510
- * Used for tokens that map to a single CSS property.
527
+ * Tokens that have been converted to CSS properties, organized by context.
528
+ * Each context (e.g., "default", "dark") maps to its converted tokens.
511
529
  */
530
+ type NormalizedConvertedTokens = {
531
+ [context: string]: ConvertedTokens;
532
+ };
533
+ type CSSProperties<T extends TokenType> = T extends SimpleTokenType ? SimpleCSSProperties : T extends AlwaysDecomposedType ? AlwaysDecomposedProperties : T extends "border" ? CSSBorderProperties : T extends "shadow" ? CSSShadowProperties : T extends "gradient" ? CSSGradientProperties : T extends "transition" ? CSSTransitionProperties : T extends StructuralCompositeType ? SimpleCSSProperties : never;
512
534
  type SimpleCSSProperties = {
513
- /** The CSS value */
514
535
  value: string | number;
515
- /** Optional feature queries for responsive values */
536
+ /** Feature queries for progressive enhancement (e.g., P3 colors). */
516
537
  featureValues?: Array<{
517
538
  query: string;
518
539
  value: string;
519
540
  }>;
520
541
  };
521
- /**
522
- * CSS properties that are always broken down into multiple properties.
523
- * Currently only used for typography tokens.
524
- */
525
542
  type AlwaysDecomposedProperties = CSSTypographyProperties;
526
- /**
527
- * CSS properties specific to typography tokens.
528
- * Maps typography tokens to their corresponding CSS properties.
529
- */
530
543
  type CSSTypographyProperties = {
531
- /** The font family to use */
532
544
  "font-family": string;
533
- /** The font size */
534
545
  "font-size": string;
535
- /** The font weight */
536
546
  "font-weight"?: number | string;
537
- /** The letter spacing */
538
547
  "letter-spacing"?: string;
539
- /** The line height */
540
548
  "line-height"?: number | string;
541
549
  };
542
- /**
543
- * CSS properties for specific token types.
544
- * These types represent tokens that map to single CSS properties.
545
- */
546
- /**
547
- * CSS properties for border tokens.
548
- */
549
550
  type CSSBorderProperties = {
550
- /** The border value */
551
551
  value: string;
552
552
  };
553
- /**
554
- * CSS properties for shadow tokens.
555
- */
556
553
  type CSSShadowProperties = {
557
- /** The shadow value */
558
554
  value: string;
559
555
  };
560
- /**
561
- * CSS properties for gradient tokens.
562
- */
563
556
  type CSSGradientProperties = {
564
- /** The gradient value */
565
557
  value: string;
566
558
  };
567
- /**
568
- * CSS properties for transition tokens.
569
- */
570
559
  type CSSTransitionProperties = {
571
- /** The transition value */
572
560
  value: string;
573
561
  };
574
562
 
575
- /**
576
- * Represents a single CSS file output with its path and content
577
- */
578
- type CSSFile = {
579
- /** The path where the CSS file will be written */
580
- path: string;
581
- /** The CSS content to write to the file */
582
- css: string;
583
- /** The collection name (e.g., "default", "base", "ui", "marketing") */
584
- collection: string;
585
- };
586
- /**
587
- * Represents multiple CSS file outputs from generateSeparateFiles or generateSingleFile
588
- */
589
- type CSSFileOutput = CSSFile[];
590
-
591
- declare function generateCSSVariables(convertedTokens: NormalizedConvertedTokens, config: InternalConfig): Promise<CSSFileOutput>;
592
-
593
- /**
594
- * An error that occurred during token flattening.
595
- * Extends the base error type with flattening-specific information.
596
- */
597
- type FlattenError = BaseError & {
598
- /** The path to the token that failed flattening */
599
- path: string;
600
- /** Source information about where the token was loaded from */
601
- source: TokenSource;
602
- };
603
-
604
- /**
605
- * Result of loading a Sugarcube configuration file
606
- */
607
- type LoadedConfig = {
608
- /** The validated configuration */
609
- config: InternalConfig;
610
- /** The path to the config file that was loaded */
611
- configPath: string;
612
- };
613
- /**
614
- * Data structure for loading tokens from memory.
615
- * Maps file paths to their token content and metadata.
616
- * Used for programmatic token loading.
617
- */
618
- type TokenMemoryData = Record<string, {
619
- /** The collection name this token belongs to */
620
- collection: string;
621
- /** Optional theme name for color scheme variations */
622
- theme?: string;
623
- /** Optional mode name for light/dark variations */
624
- mode?: string;
625
- /** The raw token content as a string */
626
- content: string;
627
- }>;
628
- /**
629
- * An error that occurred during token loading.
630
- * Extends the base error type with file-specific information.
631
- */
632
- type LoadError = BaseError & {
633
- /** The file path where the error occurred */
634
- file: string;
635
- };
636
-
637
- /**
638
- * An error that occurred during token validation.
639
- * Extends the base error type with token-specific information.
640
- */
641
- type ValidationError = BaseError & {
642
- /** The path to the token that failed validation */
643
- path: string;
644
- /** Source information about where the token was loaded from */
645
- source: TokenSource;
646
- };
647
-
648
- /**
649
- * Result of running any pipeline.
650
- * Contains the generated output, token trees, and any errors.
651
- */
652
- type PipelineResult = {
653
- /** The generated output (e.g. CSS files) */
654
- output: CSSFileOutput;
655
- /** The loaded token trees */
656
- trees: TokenTree[];
657
- /** Any errors that occurred during pipeline execution */
658
- errors: PipelineErrors;
659
- };
660
- /**
661
- * Common error types that can occur during pipeline execution.
662
- * Organizes errors by the pipeline stage where they occurred.
663
- */
664
- type PipelineErrors = {
665
- /** Errors that occurred during token loading */
666
- load: LoadError[];
667
- /** Errors that occurred during token flattening */
668
- flatten: FlattenError[];
669
- /** Errors that occurred during token validation */
670
- validation: ValidationError[];
671
- /** Errors that occurred during token resolution */
672
- resolution: ResolutionError[];
673
- };
674
- /**
675
- * Defines how tokens should be loaded and processed.
676
- * Either from files using a config, or from memory with token data.
677
- */
678
- type TokenPipelineSource = {
679
- type: "files";
680
- config: InternalConfig;
681
- } | {
682
- type: "memory";
683
- data: Record<string, {
684
- collection: string;
685
- content: string;
686
- }>;
687
- config: InternalConfig;
688
- };
689
- /**
690
- * Options for loading tokens in the pipeline.
691
- * Specifies whether to load tokens from files or memory.
692
- */
693
- type TokenLoader = {
694
- type: "files";
695
- paths: InternalConfig;
696
- } | {
697
- type: "memory";
698
- data: TokenMemoryData;
699
- };
700
-
701
- /**
702
- * Core token processing pipeline that handles loading, validation, and resolution of tokens.
703
- * This is the foundation for all other token processing operations.
704
- *
705
- * This pipeline:
706
- * 1. Loads token trees from config or memory
707
- * 2. Flattens trees into a single structure
708
- * 3. Validates tokens for correctness
709
- * 4. Resolves all token references
710
- *
711
- * Each stage can produce errors which are collected and returned in the result.
712
- *
713
- * @param source - The source of tokens to process, either from memory or config
714
- * @returns An object containing the processed trees, resolved tokens, and any errors
715
- *
716
- * @example
717
- * const result = await loadAndResolveTokens({ type: "config", config });
718
- * if (result.errors.validation.length > 0) {
719
- * console.error("Validation failed:", result.errors.validation);
720
- * }
721
- */
722
- declare function loadAndResolveTokens(source: TokenPipelineSource): Promise<{
723
- trees: TokenTree[];
724
- resolved: ResolvedTokens;
725
- errors: PipelineResult["errors"];
726
- }>;
727
-
728
- type NamedUtilityValue = {
729
- kind: "named";
730
- value: string;
731
- fraction: string | null;
732
- };
733
- type ArbitraryUtilityValue = {
734
- kind: "arbitrary";
735
- value: string;
736
- };
737
- type UtilityValue = NamedUtilityValue | ArbitraryUtilityValue;
738
- type StaticVariant = {
739
- kind: "static";
740
- root: string;
741
- };
742
- type FunctionalVariant = {
743
- kind: "functional";
744
- root: string;
745
- value: UtilityValue;
746
- };
747
- type Variant = StaticVariant | FunctionalVariant;
748
- type StaticCandidate = {
749
- kind: "static";
750
- root: string;
751
- variants: Variant[];
752
- raw: string;
753
- };
754
- type FunctionalCandidate = {
755
- kind: "functional";
756
- root: string;
757
- value: UtilityValue | null;
758
- variants: Variant[];
759
- raw: string;
760
- };
761
- type Candidate = StaticCandidate | FunctionalCandidate;
762
- interface StaticUtilityPattern {
763
- properties: string[];
764
- validator: (candidate: Candidate) => boolean;
765
- generator: (candidate: Candidate) => string;
766
- }
767
-
768
563
  /**
769
564
  * Processes and converts token trees into CSS-ready format.
770
565
  * This pipeline:
771
566
  * 1. Processes trees with resolved tokens to create a unified structure
772
- * 2. Normalizes tokens into a collection-theme organization
567
+ * 2. Normalizes tokens into a context-based organization
773
568
  * 3. Converts tokens to their CSS representations with properties
774
569
  *
775
570
  *
@@ -781,12 +576,67 @@ interface StaticUtilityPattern {
781
576
  *
782
577
  * @example
783
578
  * const convertedTokens = await processAndConvertTokens(trees, resolved, config);
784
- * // convertedTokens = { collection: { theme: { "token.path": { $cssProperties: {...} } } } }
579
+ * // convertedTokens = { "default": { "token.path": { $cssProperties: {...} } }, "dark": {...} }
785
580
  */
786
581
  declare function processAndConvertTokens(trees: TokenTree[], resolved: ResolvedTokens, config: InternalConfig, validationErrors?: ValidationError[]): Promise<NormalizedConvertedTokens>;
787
582
 
788
- declare function generateIndex(stylesDir: string, config: InternalConfig): Promise<string>;
789
- declare function shouldRegenerateIndex(stylesDir: string, config: InternalConfig): Promise<boolean>;
583
+ /**
584
+ * Generate CSS variable files from converted tokens.
585
+ *
586
+ * @param convertedTokens - The normalized and converted tokens
587
+ * @param config - The configuration object
588
+ * @param modifiers - Optional modifier metadata for generating per-modifier attribute selectors
589
+ * @returns Array of CSS file outputs
590
+ */
591
+ declare function generateCSSVariables(convertedTokens: NormalizedConvertedTokens, config: InternalConfig, modifiers?: ModifierMeta[]): Promise<CSSFileOutput>;
592
+
593
+ type CSSObject = Record<string, string | number | undefined>;
594
+ /**
595
+ * Clears the token matching cache.
596
+ * Call this when tokens change (e.g., on hot reload in dev mode).
597
+ */
598
+ declare function clearMatchCache(): void;
599
+ /**
600
+ * Converts a utilities configuration into UnoCSS dynamic rules.
601
+ *
602
+ * @param utilitiesConfig - The utilities configuration from sugarcube.config
603
+ * @param tokens - The converted tokens to generate rules for
604
+ * @returns Array of UnoCSS dynamic rules [pattern, handler]
605
+ */
606
+ declare function convertConfigToUnoRules(utilitiesConfig: UtilitiesConfig, tokens: NormalizedConvertedTokens): Array<[RegExp, (m: RegExpMatchArray) => CSSObject]>;
607
+
608
+ /**
609
+ * Performance monitor for tracking memory usage and watcher events.
610
+ * Only active when SUGARCUBE_PERF=true environment variable is set.
611
+ */
612
+ declare class PerfMonitor implements Disposable {
613
+ #private;
614
+ private defaultFlush;
615
+ constructor(defaultFlush?: (message: string) => undefined);
616
+ log(message: string, data?: Record<string, unknown>): void;
617
+ trackWatcherEvent(file: string, moduleGraphSize: number): void;
618
+ logWatcherSetup(pattern: string, dir: string): void;
619
+ logModuleGraphStats(modules: number, urls: number, context: string): void;
620
+ startMemoryMonitor(): void;
621
+ stopMemoryMonitor(): void;
622
+ [Symbol.dispose](): void;
623
+ }
624
+
625
+ /**
626
+ * Instrumentation for tracking function call counts and execution times.
627
+ * Only active when DEBUG=true environment variable is set.
628
+ * Inspired by Tailwind CSS instrumentation.
629
+ */
630
+ declare class Instrumentation implements Disposable {
631
+ #private;
632
+ private defaultFlush;
633
+ constructor(defaultFlush?: (message: string) => undefined);
634
+ hit(label: string): void;
635
+ start(label: string): void;
636
+ end(label: string): void;
637
+ report(flush?: (message: string) => undefined): void;
638
+ [Symbol.dispose](): void;
639
+ }
790
640
 
791
641
  /**
792
642
  * Writes CSS files to disk, creating directories as needed.
@@ -828,293 +678,8 @@ declare function writeCSSVariablesToDisk(output: CSSFileOutput): Promise<CSSFile
828
678
  */
829
679
  declare function writeCSSUtilitiesToDisk(output: CSSFileOutput): Promise<CSSFileOutput>;
830
680
 
831
- declare function findConfigFile(basePath?: string): string | null;
832
- declare function configFileExists(basePath?: string): boolean;
833
- declare function loadTSConfig(configPath: string): Promise<unknown>;
834
- declare function loadUserConfig(configPath?: string): Promise<{
835
- config: UserConfig;
836
- configPath: string;
837
- }>;
838
- declare function loadInternalConfig(configPath?: string): Promise<LoadedConfig>;
839
-
840
- /**
841
- * Validates a user configuration object against the user schema.
842
- *
843
- * @param config - The user configuration object to validate
844
- * @returns The validated user configuration
845
- * @throws Error if the configuration is invalid
846
- */
847
- declare function validateUserConfig(config: Partial<UserConfig>): UserConfig;
848
- /**
849
- * Validates an internal configuration object against the internal schema and checks for duplicate filenames.
850
- *
851
- * @param config - The internal configuration object to validate
852
- * @returns The validated internal configuration
853
- * @throws Error if the configuration is invalid or contains duplicate filenames
854
- */
855
- declare function validateInternalConfig(config: InternalConfig): InternalConfig;
856
- /**
857
- * Validates a user configuration object against the schema and fills in defaults.
858
- *
859
- * This function:
860
- * 1. Validates the configuration structure using the user schema
861
- * 2. Fills in default values
862
- * 3. Validates the complete configuration using the internal schema
863
- * 4. Checks for duplicate filenames across collections
864
- * 5. Returns the validated configuration with defaults filled in
865
- *
866
- * @param config - The user configuration object to validate
867
- * @returns The validated configuration with defaults filled in
868
- * @throws Error if the configuration is invalid or contains duplicate filenames
869
- *
870
- * @example
871
- * const config = {
872
- * tokens: {
873
- * source: ["tokens.json"]
874
- * }
875
- * };
876
- * const validatedConfig = validateConfig(config);
877
- * // validatedConfig.output.css === "src/styles" (default filled in)
878
- */
879
- declare function validateConfig(config: Partial<UserConfig>): InternalConfig;
880
- /**
881
- * Parses and validates a JSON configuration string.
882
- *
883
- * This function:
884
- * 1. Parses the JSON string into a configuration object
885
- * 2. Validates and normalizes the configuration using validateConfig
886
- * 3. Returns the validated and normalized configuration
887
- *
888
- * @param configString - The JSON configuration string to parse and validate
889
- * @returns The validated and normalized configuration
890
- * @throws Error if the JSON is invalid or the configuration is invalid
891
- *
892
- * @example
893
- * const configString = `{
894
- * "tokens": {
895
- * "source": ["tokens.json"]
896
- * }
897
- * }`;
898
- * const config = parseAndValidateConfig(configString);
899
- * // config.output.css === "src/styles" (default filled in)
900
- */
901
- declare function parseAndValidateConfig(configString: string): InternalConfig;
902
-
903
- /**
904
- * Fills in default values for any omitted fields in a user configuration.
905
- *
906
- * This function takes a user config (with optional fields) and
907
- * returns a complete internal config (with all required fields filled in).
908
- *
909
- * @param userConfig - The user configuration with optional fields
910
- * @returns A complete configuration with all defaults filled in
911
- *
912
- * @example
913
- * const userConfig = {
914
- * tokens: { source: ["tokens/*.json"] }
915
- * };
916
- * const completeConfig = fillDefaults(userConfig);
917
- * // completeConfig.output.css === "src/styles"
918
- * // completeConfig.output.components === "src/ui/components"
919
- * // completeConfig.output.separate === false
920
- */
921
- declare function fillDefaults(userConfig: UserConfig): InternalConfig;
922
-
923
- interface CSSImport {
924
- path: string;
925
- layer: string;
926
- relativePath: string;
927
- }
928
- declare function discoverAllFiles(stylesDir: string, config: InternalConfig): Promise<CSSImport[]>;
929
-
930
- declare function generateIndexContent(files: CSSImport[]): string;
931
-
932
- declare class Instrumentation implements Disposable {
933
- #private;
934
- private defaultFlush;
935
- constructor(defaultFlush?: (message: string) => undefined);
936
- hit(label: string): void;
937
- start(label: string): void;
938
- end(label: string): void;
939
- report(flush?: (message: string) => undefined): void;
940
- [Symbol.dispose](): void;
941
- }
942
-
943
- type CSSObject = Record<string, string | number | undefined>;
944
- declare function convertConfigToUnoRules(utilitiesConfig: UtilitiesConfig, tokens: NormalizedConvertedTokens): Array<[RegExp, (m: RegExpMatchArray) => CSSObject]>;
945
-
946
- declare const SUGARCUBE_FILE = "_sugarcube.css";
947
- declare const GLOBAL_DIR = "global";
948
- declare const UTILITIES_DIR = "utilities";
949
- declare const VARIABLES_FILE_SUFFIX = ".variables.gen.css";
950
- declare const DEFAULT_VARIABLES_FILENAME = "tokens";
951
- declare const DEFAULT_UTILITIES_FILENAME = "utilities.gen.css";
952
- declare const DEFAULT_STYLES_PATH = "src/styles";
953
- declare const DEFAULT_DESIGN_TOKENS_PATH = "src/design-tokens";
954
- declare const SUGARCUBE_CONFIG_FILE = "sugarcube.config.ts";
955
-
956
- declare const DEFAULT_CONFIG: {
957
- readonly output: {
958
- readonly css: "src/styles";
959
- readonly components: "src/components/ui";
960
- readonly separate: false;
961
- readonly modeAttribute: "data-mode";
962
- readonly themeAttribute: "data-theme";
963
- };
964
- readonly transforms: {
965
- readonly fluid: {
966
- readonly min: 320;
967
- readonly max: 1200;
968
- };
969
- readonly colorFallbackStrategy: "native";
970
- };
971
- };
972
-
973
- declare const DEFAULT_COLLECTION = "default";
974
- declare const DEFAULT_THEME = "default";
975
- declare const DEFAULT_MODE = "default";
976
-
977
- declare const ErrorMessages: {
978
- readonly LOAD: {
979
- readonly NO_FILES_FOUND: (pattern: string) => string;
980
- readonly INVALID_JSON: (path: string, message: string) => string;
981
- readonly GLOB_ERROR: (pattern: string, error: string) => string;
982
- };
983
- readonly FLATTEN: {
984
- readonly INVALID_TOKEN_NAME: (name: string) => string;
985
- readonly MISSING_DOLLAR_PREFIX: (path: string) => string;
986
- readonly INVALID_TOKEN_NESTING: (path: string) => string;
987
- readonly COMPOSITE_TOKEN_MISSING_TYPE: (path: string) => string;
988
- readonly CONFLICT_TOKEN_VS_GROUP: (path: string) => string;
989
- readonly CONFLICT_INCOMPATIBLE_TYPES: (expected: string, received: string, path: string) => string;
990
- };
991
- readonly METADATA: {
992
- readonly COLLECTION_ERROR: (message: string) => string;
993
- readonly INVALID_EXTENSIONS: (path: string) => string;
994
- readonly INVALID_DESCRIPTION: (path: string) => string;
995
- };
996
- readonly VALIDATE: {
997
- readonly MISSING_TYPE: (path: string) => string;
998
- readonly UNKNOWN_TOKEN_TYPE: (type: string, path: string) => string;
999
- readonly INVALID_COLOR: (value: unknown, path: string) => string;
1000
- readonly INVALID_DIMENSION: (value: unknown, path: string) => string;
1001
- readonly INVALID_DIMENSION_UNIT: (unit: unknown, path: string) => string;
1002
- readonly INVALID_FONT_FAMILY: (value: unknown, path: string) => string;
1003
- readonly INVALID_FONT_WEIGHT: (value: unknown, path: string) => string;
1004
- readonly INVALID_DURATION: (value: unknown, path: string) => string;
1005
- readonly INVALID_DURATION_UNIT: (unit: unknown, path: string) => string;
1006
- readonly INVALID_CUBIC_BEZIER: (value: unknown, path: string) => string;
1007
- readonly INVALID_STROKE_STYLE: (value: unknown, path: string) => string;
1008
- readonly INVALID_STROKE_LINE_CAP: (value: unknown, path: string) => string;
1009
- readonly INVALID_BORDER: (value: unknown, path: string) => string;
1010
- readonly INVALID_SHADOW: (value: unknown, path: string) => string;
1011
- readonly INVALID_SHADOW_INSET: (value: unknown, path: string) => string;
1012
- readonly INVALID_TRANSITION: (value: unknown, path: string) => string;
1013
- readonly INVALID_GRADIENT: (value: unknown, path: string) => string;
1014
- readonly INVALID_GRADIENT_STOP_POSITION: (value: unknown, path: string) => string;
1015
- readonly INVALID_TYPOGRAPHY: (value: unknown, path: string) => string;
1016
- readonly MISSING_REQUIRED_PROPERTY: (prop: string, path: string) => string;
1017
- readonly INVALID_NUMBER: (value: unknown, path: string) => string;
1018
- readonly INVALID_ARRAY: (value: unknown, path: string) => string;
1019
- readonly MISSING_FLUID_CONFIG: (path: string) => string;
1020
- readonly INVALID_FLUID_DIMENSION: (value: unknown, path: string) => string;
1021
- readonly INVALID_VIEWPORT_CONFIG: (value: unknown, path: string) => string;
1022
- readonly MISMATCHED_UNITS: (unit1: unknown, unit2: unknown, path: string) => string;
1023
- readonly INVALID_FLUID_VALUE_RANGE: (path: string) => string;
1024
- readonly INVALID_TOKEN_TYPE: (expected: string, received: string, path: string) => string;
1025
- readonly INVALID_TYPE: (expected: string, value: unknown, path: string) => string;
1026
- readonly INVALID_ENUM_VALUE: (enumValues: unknown[], value: unknown, path: string) => string;
1027
- };
1028
- readonly RESOLVE: {
1029
- readonly CIRCULAR_REFERENCE: (path: string, ref: string) => string;
1030
- readonly REFERENCE_NOT_FOUND: (ref: string, path: string) => string;
1031
- readonly TYPE_MISMATCH: (path: string) => string;
1032
- };
1033
- readonly GENERATE: {
1034
- readonly INVALID_CSS_VALUE: (key: string, value: unknown) => string;
1035
- readonly INVALID_VARIABLE_NAME: (path: string, name: string) => string;
1036
- };
1037
- readonly CONFIG: {
1038
- readonly INVALID_JSON: (error: string) => string;
1039
- readonly INVALID_CONFIG: (path: string, message: string) => string;
1040
- readonly DUPLICATE_FILENAMES: (collection: string, filename: string, paths: string[]) => string;
1041
- readonly FILE_NOT_FOUND: (path: string) => string;
1042
- };
1043
- readonly UTILITIES: {
1044
- readonly RESERVED_PREFIX: (prefix: string, tokenType: string) => string;
1045
- readonly DUPLICATE_CLASS_NAME: (className: string, paths: string[]) => string;
1046
- readonly INVALID_PROPERTY_MAPPING: (tokenType: string) => string;
1047
- readonly DUPLICATE_PREFIX: (prefix: string, tokenType: string) => string;
1048
- readonly INVALID_COLLECTION: (property: string, collection: string, availableCollections: string[]) => string;
1049
- readonly TOKEN_PATH_CONFLICT: (tokenPath: string, collections: string) => string;
1050
- readonly MISSING_SOURCE: (property: string) => string;
1051
- readonly INVALID_SOURCE_PATTERN: (property: string, source: string) => string;
1052
- readonly INVALID_DIRECTIONS: (property: string) => string;
1053
- readonly INVALID_CONFIG_OBJECT: "utilitiesConfig must be an object";
1054
- readonly INVALID_TOKENS_OBJECT: "tokens must be an object";
1055
- };
1056
- };
1057
-
1058
681
  declare const userConfigSchema: z.ZodObject<{
1059
- tokens: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodObject<{
1060
- source: z.ZodArray<z.ZodString, "many">;
1061
- /** Mode variations (light/dark) - generates [data-mode="..."] selectors */
1062
- modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1063
- /** Theme variations (color schemes) - generates [data-theme="..."] selectors */
1064
- themes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodObject<{
1065
- source: z.ZodArray<z.ZodString, "many">;
1066
- modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1067
- }, "strip", z.ZodTypeAny, {
1068
- source: string[];
1069
- modes?: Record<string, string[]> | undefined;
1070
- }, {
1071
- source: string[];
1072
- modes?: Record<string, string[]> | undefined;
1073
- }>]>>>;
1074
- }, "strip", z.ZodTypeAny, {
1075
- source: string[];
1076
- modes?: Record<string, string[]> | undefined;
1077
- themes?: Record<string, string[] | {
1078
- source: string[];
1079
- modes?: Record<string, string[]> | undefined;
1080
- }> | undefined;
1081
- }, {
1082
- source: string[];
1083
- modes?: Record<string, string[]> | undefined;
1084
- themes?: Record<string, string[] | {
1085
- source: string[];
1086
- modes?: Record<string, string[]> | undefined;
1087
- }> | undefined;
1088
- }>>, z.ZodObject<{
1089
- source: z.ZodArray<z.ZodString, "many">;
1090
- /** Mode variations (light/dark) - generates [data-mode="..."] selectors */
1091
- modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1092
- /** Theme variations (color schemes) - generates [data-theme="..."] selectors */
1093
- themes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodObject<{
1094
- source: z.ZodArray<z.ZodString, "many">;
1095
- modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1096
- }, "strip", z.ZodTypeAny, {
1097
- source: string[];
1098
- modes?: Record<string, string[]> | undefined;
1099
- }, {
1100
- source: string[];
1101
- modes?: Record<string, string[]> | undefined;
1102
- }>]>>>;
1103
- }, "strip", z.ZodTypeAny, {
1104
- source: string[];
1105
- modes?: Record<string, string[]> | undefined;
1106
- themes?: Record<string, string[] | {
1107
- source: string[];
1108
- modes?: Record<string, string[]> | undefined;
1109
- }> | undefined;
1110
- }, {
1111
- source: string[];
1112
- modes?: Record<string, string[]> | undefined;
1113
- themes?: Record<string, string[] | {
1114
- source: string[];
1115
- modes?: Record<string, string[]> | undefined;
1116
- }> | undefined;
1117
- }>]>>;
682
+ resolver: z.ZodOptional<z.ZodString>;
1118
683
  transforms: z.ZodOptional<z.ZodObject<{
1119
684
  fluid: z.ZodOptional<z.ZodObject<{
1120
685
  min: z.ZodNumber;
@@ -1141,22 +706,28 @@ declare const userConfigSchema: z.ZodObject<{
1141
706
  colorFallbackStrategy?: "native" | "polyfill" | undefined;
1142
707
  }>>;
1143
708
  output: z.ZodOptional<z.ZodObject<{
1144
- css: z.ZodOptional<z.ZodString>;
709
+ cssRoot: z.ZodOptional<z.ZodString>;
710
+ variables: z.ZodOptional<z.ZodString>;
711
+ utilities: z.ZodOptional<z.ZodString>;
712
+ cube: z.ZodOptional<z.ZodString>;
1145
713
  components: z.ZodOptional<z.ZodString>;
1146
- separate: z.ZodOptional<z.ZodBoolean>;
1147
- modeAttribute: z.ZodOptional<z.ZodString>;
1148
714
  themeAttribute: z.ZodOptional<z.ZodString>;
715
+ defaultContext: z.ZodOptional<z.ZodString>;
1149
716
  }, "strip", z.ZodTypeAny, {
1150
- css?: string | undefined;
717
+ defaultContext?: string | undefined;
1151
718
  components?: string | undefined;
1152
- separate?: boolean | undefined;
1153
- modeAttribute?: string | undefined;
719
+ cssRoot?: string | undefined;
720
+ variables?: string | undefined;
721
+ utilities?: string | undefined;
722
+ cube?: string | undefined;
1154
723
  themeAttribute?: string | undefined;
1155
724
  }, {
1156
- css?: string | undefined;
725
+ defaultContext?: string | undefined;
1157
726
  components?: string | undefined;
1158
- separate?: boolean | undefined;
1159
- modeAttribute?: string | undefined;
727
+ cssRoot?: string | undefined;
728
+ variables?: string | undefined;
729
+ utilities?: string | undefined;
730
+ cube?: string | undefined;
1160
731
  themeAttribute?: string | undefined;
1161
732
  }>>;
1162
733
  utilities: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
@@ -1164,54 +735,34 @@ declare const userConfigSchema: z.ZodObject<{
1164
735
  directions: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["top", "right", "bottom", "left", "x", "y", "full", "all"]>, z.ZodArray<z.ZodEnum<["top", "right", "bottom", "left", "x", "y", "full", "all"]>, "many">]>>;
1165
736
  prefix: z.ZodOptional<z.ZodString>;
1166
737
  stripDuplicates: z.ZodOptional<z.ZodBoolean>;
1167
- collection: z.ZodOptional<z.ZodString>;
1168
738
  }, "strip", z.ZodTypeAny, {
1169
739
  source: string;
1170
740
  directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1171
741
  prefix?: string | undefined;
1172
742
  stripDuplicates?: boolean | undefined;
1173
- collection?: string | undefined;
1174
743
  }, {
1175
744
  source: string;
1176
745
  directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1177
746
  prefix?: string | undefined;
1178
747
  stripDuplicates?: boolean | undefined;
1179
- collection?: string | undefined;
1180
748
  }>, z.ZodArray<z.ZodObject<{
1181
749
  source: z.ZodString;
1182
750
  directions: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["top", "right", "bottom", "left", "x", "y", "full", "all"]>, z.ZodArray<z.ZodEnum<["top", "right", "bottom", "left", "x", "y", "full", "all"]>, "many">]>>;
1183
751
  prefix: z.ZodOptional<z.ZodString>;
1184
752
  stripDuplicates: z.ZodOptional<z.ZodBoolean>;
1185
- collection: z.ZodOptional<z.ZodString>;
1186
753
  }, "strip", z.ZodTypeAny, {
1187
754
  source: string;
1188
755
  directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1189
756
  prefix?: string | undefined;
1190
757
  stripDuplicates?: boolean | undefined;
1191
- collection?: string | undefined;
1192
758
  }, {
1193
759
  source: string;
1194
760
  directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1195
761
  prefix?: string | undefined;
1196
762
  stripDuplicates?: boolean | undefined;
1197
- collection?: string | undefined;
1198
763
  }>, "many">]>>>;
1199
764
  }, "strip", z.ZodTypeAny, {
1200
- tokens?: {
1201
- source: string[];
1202
- modes?: Record<string, string[]> | undefined;
1203
- themes?: Record<string, string[] | {
1204
- source: string[];
1205
- modes?: Record<string, string[]> | undefined;
1206
- }> | undefined;
1207
- } | Record<string, {
1208
- source: string[];
1209
- modes?: Record<string, string[]> | undefined;
1210
- themes?: Record<string, string[] | {
1211
- source: string[];
1212
- modes?: Record<string, string[]> | undefined;
1213
- }> | undefined;
1214
- }> | undefined;
765
+ resolver?: string | undefined;
1215
766
  transforms?: {
1216
767
  fluid?: {
1217
768
  min: number;
@@ -1219,42 +770,28 @@ declare const userConfigSchema: z.ZodObject<{
1219
770
  } | undefined;
1220
771
  colorFallbackStrategy?: "native" | "polyfill" | undefined;
1221
772
  } | undefined;
1222
- output?: {
1223
- css?: string | undefined;
1224
- components?: string | undefined;
1225
- separate?: boolean | undefined;
1226
- modeAttribute?: string | undefined;
1227
- themeAttribute?: string | undefined;
1228
- } | undefined;
1229
773
  utilities?: Record<string, {
1230
774
  source: string;
1231
775
  directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1232
776
  prefix?: string | undefined;
1233
777
  stripDuplicates?: boolean | undefined;
1234
- collection?: string | undefined;
1235
778
  } | {
1236
779
  source: string;
1237
780
  directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1238
781
  prefix?: string | undefined;
1239
782
  stripDuplicates?: boolean | undefined;
1240
- collection?: string | undefined;
1241
783
  }[]> | undefined;
784
+ output?: {
785
+ defaultContext?: string | undefined;
786
+ components?: string | undefined;
787
+ cssRoot?: string | undefined;
788
+ variables?: string | undefined;
789
+ utilities?: string | undefined;
790
+ cube?: string | undefined;
791
+ themeAttribute?: string | undefined;
792
+ } | undefined;
1242
793
  }, {
1243
- tokens?: {
1244
- source: string[];
1245
- modes?: Record<string, string[]> | undefined;
1246
- themes?: Record<string, string[] | {
1247
- source: string[];
1248
- modes?: Record<string, string[]> | undefined;
1249
- }> | undefined;
1250
- } | Record<string, {
1251
- source: string[];
1252
- modes?: Record<string, string[]> | undefined;
1253
- themes?: Record<string, string[] | {
1254
- source: string[];
1255
- modes?: Record<string, string[]> | undefined;
1256
- }> | undefined;
1257
- }> | undefined;
794
+ resolver?: string | undefined;
1258
795
  transforms?: {
1259
796
  fluid?: {
1260
797
  min: number;
@@ -1262,276 +799,26 @@ declare const userConfigSchema: z.ZodObject<{
1262
799
  } | undefined;
1263
800
  colorFallbackStrategy?: "native" | "polyfill" | undefined;
1264
801
  } | undefined;
1265
- output?: {
1266
- css?: string | undefined;
1267
- components?: string | undefined;
1268
- separate?: boolean | undefined;
1269
- modeAttribute?: string | undefined;
1270
- themeAttribute?: string | undefined;
1271
- } | undefined;
1272
802
  utilities?: Record<string, {
1273
803
  source: string;
1274
804
  directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1275
805
  prefix?: string | undefined;
1276
806
  stripDuplicates?: boolean | undefined;
1277
- collection?: string | undefined;
1278
807
  } | {
1279
808
  source: string;
1280
809
  directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1281
810
  prefix?: string | undefined;
1282
811
  stripDuplicates?: boolean | undefined;
1283
- collection?: string | undefined;
1284
- }[]> | undefined;
1285
- }>;
1286
- declare const internalConfigSchema: z.ZodObject<{
1287
- tokens: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodObject<{
1288
- source: z.ZodArray<z.ZodString, "many">;
1289
- /** Mode variations (light/dark) - generates [data-mode="..."] selectors */
1290
- modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1291
- /** Theme variations (color schemes) - generates [data-theme="..."] selectors */
1292
- themes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodObject<{
1293
- source: z.ZodArray<z.ZodString, "many">;
1294
- modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1295
- }, "strip", z.ZodTypeAny, {
1296
- source: string[];
1297
- modes?: Record<string, string[]> | undefined;
1298
- }, {
1299
- source: string[];
1300
- modes?: Record<string, string[]> | undefined;
1301
- }>]>>>;
1302
- }, "strip", z.ZodTypeAny, {
1303
- source: string[];
1304
- modes?: Record<string, string[]> | undefined;
1305
- themes?: Record<string, string[] | {
1306
- source: string[];
1307
- modes?: Record<string, string[]> | undefined;
1308
- }> | undefined;
1309
- }, {
1310
- source: string[];
1311
- modes?: Record<string, string[]> | undefined;
1312
- themes?: Record<string, string[] | {
1313
- source: string[];
1314
- modes?: Record<string, string[]> | undefined;
1315
- }> | undefined;
1316
- }>>, z.ZodObject<{
1317
- source: z.ZodArray<z.ZodString, "many">;
1318
- /** Mode variations (light/dark) - generates [data-mode="..."] selectors */
1319
- modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1320
- /** Theme variations (color schemes) - generates [data-theme="..."] selectors */
1321
- themes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodObject<{
1322
- source: z.ZodArray<z.ZodString, "many">;
1323
- modes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
1324
- }, "strip", z.ZodTypeAny, {
1325
- source: string[];
1326
- modes?: Record<string, string[]> | undefined;
1327
- }, {
1328
- source: string[];
1329
- modes?: Record<string, string[]> | undefined;
1330
- }>]>>>;
1331
- }, "strip", z.ZodTypeAny, {
1332
- source: string[];
1333
- modes?: Record<string, string[]> | undefined;
1334
- themes?: Record<string, string[] | {
1335
- source: string[];
1336
- modes?: Record<string, string[]> | undefined;
1337
- }> | undefined;
1338
- }, {
1339
- source: string[];
1340
- modes?: Record<string, string[]> | undefined;
1341
- themes?: Record<string, string[] | {
1342
- source: string[];
1343
- modes?: Record<string, string[]> | undefined;
1344
- }> | undefined;
1345
- }>]>>;
1346
- transforms: z.ZodObject<{
1347
- fluid: z.ZodObject<{
1348
- min: z.ZodNumber;
1349
- max: z.ZodNumber;
1350
- }, "strip", z.ZodTypeAny, {
1351
- min: number;
1352
- max: number;
1353
- }, {
1354
- min: number;
1355
- max: number;
1356
- }>;
1357
- colorFallbackStrategy: z.ZodEnum<["native", "polyfill"]>;
1358
- }, "strip", z.ZodTypeAny, {
1359
- fluid: {
1360
- min: number;
1361
- max: number;
1362
- };
1363
- colorFallbackStrategy: "native" | "polyfill";
1364
- }, {
1365
- fluid: {
1366
- min: number;
1367
- max: number;
1368
- };
1369
- colorFallbackStrategy: "native" | "polyfill";
1370
- }>;
1371
- output: z.ZodObject<{
1372
- css: z.ZodString;
1373
- components: z.ZodString;
1374
- separate: z.ZodBoolean;
1375
- modeAttribute: z.ZodString;
1376
- themeAttribute: z.ZodString;
1377
- }, "strip", z.ZodTypeAny, {
1378
- components: string;
1379
- css: string;
1380
- separate: boolean;
1381
- modeAttribute: string;
1382
- themeAttribute: string;
1383
- }, {
1384
- components: string;
1385
- css: string;
1386
- separate: boolean;
1387
- modeAttribute: string;
1388
- themeAttribute: string;
1389
- }>;
1390
- utilities: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
1391
- source: z.ZodString;
1392
- directions: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["top", "right", "bottom", "left", "x", "y", "full", "all"]>, z.ZodArray<z.ZodEnum<["top", "right", "bottom", "left", "x", "y", "full", "all"]>, "many">]>>;
1393
- prefix: z.ZodOptional<z.ZodString>;
1394
- stripDuplicates: z.ZodOptional<z.ZodBoolean>;
1395
- collection: z.ZodOptional<z.ZodString>;
1396
- }, "strip", z.ZodTypeAny, {
1397
- source: string;
1398
- directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1399
- prefix?: string | undefined;
1400
- stripDuplicates?: boolean | undefined;
1401
- collection?: string | undefined;
1402
- }, {
1403
- source: string;
1404
- directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1405
- prefix?: string | undefined;
1406
- stripDuplicates?: boolean | undefined;
1407
- collection?: string | undefined;
1408
- }>, z.ZodArray<z.ZodObject<{
1409
- source: z.ZodString;
1410
- directions: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["top", "right", "bottom", "left", "x", "y", "full", "all"]>, z.ZodArray<z.ZodEnum<["top", "right", "bottom", "left", "x", "y", "full", "all"]>, "many">]>>;
1411
- prefix: z.ZodOptional<z.ZodString>;
1412
- stripDuplicates: z.ZodOptional<z.ZodBoolean>;
1413
- collection: z.ZodOptional<z.ZodString>;
1414
- }, "strip", z.ZodTypeAny, {
1415
- source: string;
1416
- directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1417
- prefix?: string | undefined;
1418
- stripDuplicates?: boolean | undefined;
1419
- collection?: string | undefined;
1420
- }, {
1421
- source: string;
1422
- directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1423
- prefix?: string | undefined;
1424
- stripDuplicates?: boolean | undefined;
1425
- collection?: string | undefined;
1426
- }>, "many">]>>>;
1427
- }, "strip", z.ZodTypeAny, {
1428
- output: {
1429
- components: string;
1430
- css: string;
1431
- separate: boolean;
1432
- modeAttribute: string;
1433
- themeAttribute: string;
1434
- };
1435
- transforms: {
1436
- fluid: {
1437
- min: number;
1438
- max: number;
1439
- };
1440
- colorFallbackStrategy: "native" | "polyfill";
1441
- };
1442
- tokens?: {
1443
- source: string[];
1444
- modes?: Record<string, string[]> | undefined;
1445
- themes?: Record<string, string[] | {
1446
- source: string[];
1447
- modes?: Record<string, string[]> | undefined;
1448
- }> | undefined;
1449
- } | Record<string, {
1450
- source: string[];
1451
- modes?: Record<string, string[]> | undefined;
1452
- themes?: Record<string, string[] | {
1453
- source: string[];
1454
- modes?: Record<string, string[]> | undefined;
1455
- }> | undefined;
1456
- }> | undefined;
1457
- utilities?: Record<string, {
1458
- source: string;
1459
- directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1460
- prefix?: string | undefined;
1461
- stripDuplicates?: boolean | undefined;
1462
- collection?: string | undefined;
1463
- } | {
1464
- source: string;
1465
- directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1466
- prefix?: string | undefined;
1467
- stripDuplicates?: boolean | undefined;
1468
- collection?: string | undefined;
1469
- }[]> | undefined;
1470
- }, {
1471
- output: {
1472
- components: string;
1473
- css: string;
1474
- separate: boolean;
1475
- modeAttribute: string;
1476
- themeAttribute: string;
1477
- };
1478
- transforms: {
1479
- fluid: {
1480
- min: number;
1481
- max: number;
1482
- };
1483
- colorFallbackStrategy: "native" | "polyfill";
1484
- };
1485
- tokens?: {
1486
- source: string[];
1487
- modes?: Record<string, string[]> | undefined;
1488
- themes?: Record<string, string[] | {
1489
- source: string[];
1490
- modes?: Record<string, string[]> | undefined;
1491
- }> | undefined;
1492
- } | Record<string, {
1493
- source: string[];
1494
- modes?: Record<string, string[]> | undefined;
1495
- themes?: Record<string, string[] | {
1496
- source: string[];
1497
- modes?: Record<string, string[]> | undefined;
1498
- }> | undefined;
1499
- }> | undefined;
1500
- utilities?: Record<string, {
1501
- source: string;
1502
- directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1503
- prefix?: string | undefined;
1504
- stripDuplicates?: boolean | undefined;
1505
- collection?: string | undefined;
1506
- } | {
1507
- source: string;
1508
- directions?: "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all" | ("top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all")[] | undefined;
1509
- prefix?: string | undefined;
1510
- stripDuplicates?: boolean | undefined;
1511
- collection?: string | undefined;
1512
812
  }[]> | undefined;
813
+ output?: {
814
+ defaultContext?: string | undefined;
815
+ components?: string | undefined;
816
+ cssRoot?: string | undefined;
817
+ variables?: string | undefined;
818
+ utilities?: string | undefined;
819
+ cube?: string | undefined;
820
+ themeAttribute?: string | undefined;
821
+ } | undefined;
1513
822
  }>;
1514
823
 
1515
- /**
1516
- * Type guards for configuration objects.
1517
- * Functions to check the structure and type of configuration data.
1518
- */
1519
- /**
1520
- * Type guard to check if tokens is a single collection.
1521
- *
1522
- * @param tokens - The tokens configuration to check
1523
- * @returns True if tokens is a single collection, false if it's multiple collections
1524
- *
1525
- * @example
1526
- * if (isSingleCollection(config.tokens)) {
1527
- * // config.tokens is TokenCollection
1528
- * } else {
1529
- * // config.tokens is TokenCollections
1530
- * }
1531
- */
1532
- declare function isSingleCollection(tokens: TokenCollection | TokenCollections): tokens is TokenCollection;
1533
-
1534
- declare function isResolvedToken(token: unknown): token is ResolvedToken;
1535
- declare function isResolvedTokenOfType<T extends TokenType>(token: unknown, type: T): token is ResolvedToken<T>;
1536
-
1537
- export { type ArbitraryUtilityValue, type CSSFileOutput, type Candidate, DEFAULT_COLLECTION, DEFAULT_CONFIG, DEFAULT_DESIGN_TOKENS_PATH, DEFAULT_MODE, DEFAULT_STYLES_PATH, DEFAULT_THEME, DEFAULT_UTILITIES_FILENAME, DEFAULT_VARIABLES_FILENAME, ErrorMessages, type FunctionalCandidate, type FunctionalVariant, GLOBAL_DIR, Instrumentation, type InternalConfig, type LoadedConfig, type NamedUtilityValue, type NormalizedConvertedTokens, type OutputConfig, type PipelineResult, type ResolvedToken, type ResolvedTokens, SUGARCUBE_CONFIG_FILE, SUGARCUBE_FILE, type StaticCandidate, type StaticUtilityPattern, type StaticVariant, type ThemeConfig, type TokenCollection, type TokenCollections, type TokenLoader, type TokenPipelineSource, type TokenTree, UTILITIES_DIR, type UserConfig, type UserOutputConfig, type UtilitiesConfig, type UtilityValue, VARIABLES_FILE_SUFFIX, type Variant, configFileExists, convertConfigToUnoRules, discoverAllFiles, fillDefaults, findConfigFile, generateCSSVariables, generateIndex, generateIndexContent, internalConfigSchema, isResolvedToken, isResolvedTokenOfType, isSingleCollection, loadAndResolveTokens, loadInternalConfig, loadTSConfig, loadUserConfig, parseAndValidateConfig, processAndConvertTokens, shouldRegenerateIndex, userConfigSchema, validateConfig, validateInternalConfig, validateUserConfig, writeCSSUtilitiesToDisk, writeCSSVariablesToDisk };
824
+ export { type CSSFileOutput, DEFAULT_CONFIG, Instrumentation, type InternalConfig, type ModifierMeta, type NormalizedConvertedTokens, PerfMonitor, type ResolvedTokens, type SugarcubeConfig, type TokenPipelineSource, type TokenTree, clearMatchCache, configFileExists, convertConfigToUnoRules, fillDefaults, generateCSSVariables, loadAndResolveTokens, loadInternalConfig, loadSugarcubeConfig, processAndConvertTokens, userConfigSchema, validateConfig, writeCSSUtilitiesToDisk, writeCSSVariablesToDisk };