dispersa 0.4.0 → 0.4.2

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.
@@ -3,6 +3,73 @@ import { B as BuildConfigBase, O as OutputConfigBase, P as Preprocessor, D as Di
3
3
  import { T as Transform } from './types-BAv39mum.cjs';
4
4
  import { R as ResolvedTokens } from './types-Bc0kA7De.cjs';
5
5
 
6
+ /**
7
+ * @fileoverview DTCG Resolver types (2025.10 specification)
8
+ *
9
+ * The resolver system allows defining token sources, modifiers (themes, modes),
10
+ * and the order in which they should be resolved and merged.
11
+ *
12
+ * ResolverDocument type is defined here to match DTCG 2025.10.
13
+ */
14
+ type ReferenceObject = {
15
+ $ref: string;
16
+ };
17
+ type TokenSource = ReferenceObject | Record<string, unknown>;
18
+ type Set = {
19
+ sources: TokenSource[];
20
+ description?: string;
21
+ $extensions?: Record<string, unknown>;
22
+ };
23
+ type Modifier = {
24
+ contexts: Record<string, TokenSource[]>;
25
+ description?: string;
26
+ default?: string;
27
+ $extensions?: Record<string, unknown>;
28
+ };
29
+ type InlineSet = Set & {
30
+ name: string;
31
+ type: 'set';
32
+ };
33
+ type InlineModifier = Modifier & {
34
+ name: string;
35
+ type: 'modifier';
36
+ };
37
+ type ResolverDocument = {
38
+ $schema?: string;
39
+ name?: string;
40
+ version: '2025.10';
41
+ description?: string;
42
+ sets?: Record<string, Set>;
43
+ modifiers?: Record<string, Modifier>;
44
+ resolutionOrder: (ReferenceObject | InlineSet | InlineModifier)[];
45
+ $defs?: Record<string, unknown>;
46
+ };
47
+ /**
48
+ * Map of modifier names to selected context values
49
+ *
50
+ * Used to specify which variation of each modifier to use when resolving tokens.
51
+ * Can be made type-safe by providing a generic type parameter.
52
+ *
53
+ * @template T - Optional specific type for modifier values (defaults to generic Record)
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * // Generic (default):
58
+ * const inputs: ModifierInputs = {
59
+ * theme: 'dark',
60
+ * platform: 'mobile'
61
+ * }
62
+ *
63
+ * // Type-safe:
64
+ * type MyModifiers = { theme: 'light' | 'dark', platform: 'web' | 'mobile' }
65
+ * const inputs: ModifierInputs<MyModifiers> = {
66
+ * theme: 'dark', // ✅ Autocomplete!
67
+ * platform: 'mobile'
68
+ * }
69
+ * ```
70
+ */
71
+ type ModifierInputs<T extends Record<string, string> = Record<string, string>> = T;
72
+
6
73
  /**
7
74
  * @license MIT
8
75
  * Copyright (c) 2025-present Dispersa Contributors
@@ -128,6 +195,11 @@ type AndroidRendererOptions = {
128
195
 
129
196
  /**
130
197
  * @fileoverview Renderer system types for token output generation
198
+ *
199
+ * Note: renderers/types and config have a mutual type-only dependency.
200
+ * RenderContext references OutputConfig, while OutputConfig references
201
+ * Renderer/FormatOptions. This is acceptable because type imports are
202
+ * erased at runtime and the coupling is genuine.
131
203
  */
132
204
 
133
205
  /**
@@ -325,7 +397,7 @@ type CssRendererOptions = {
325
397
  /**
326
398
  * Error code identifying the type of build error
327
399
  */
328
- type ErrorCode = 'TOKEN_REFERENCE' | 'CIRCULAR_REFERENCE' | 'VALIDATION' | 'COLOR_PARSE' | 'DIMENSION_FORMAT' | 'FILE_OPERATION' | 'CONFIGURATION' | 'BASE_PERMUTATION' | 'MODIFIER' | 'UNKNOWN';
400
+ type ErrorCode = 'TOKEN_REFERENCE' | 'CIRCULAR_REFERENCE' | 'VALIDATION' | 'FILE_OPERATION' | 'CONFIGURATION' | 'BASE_PERMUTATION' | 'MODIFIER' | 'UNKNOWN';
329
401
  /**
330
402
  * Structured error from a build operation
331
403
  *
@@ -355,73 +427,6 @@ type BuildResult = {
355
427
  errors?: BuildError[];
356
428
  };
357
429
 
358
- /**
359
- * @fileoverview DTCG Resolver types (2025.10 specification)
360
- *
361
- * The resolver system allows defining token sources, modifiers (themes, modes),
362
- * and the order in which they should be resolved and merged.
363
- *
364
- * ResolverDocument type is defined here to match DTCG 2025.10.
365
- */
366
- type ReferenceObject = {
367
- $ref: string;
368
- };
369
- type TokenSource = ReferenceObject | Record<string, unknown>;
370
- type Set = {
371
- sources: TokenSource[];
372
- description?: string;
373
- $extensions?: Record<string, unknown>;
374
- };
375
- type Modifier = {
376
- contexts: Record<string, TokenSource[]>;
377
- description?: string;
378
- default?: string;
379
- $extensions?: Record<string, unknown>;
380
- };
381
- type InlineSet = Set & {
382
- name: string;
383
- type: 'set';
384
- };
385
- type InlineModifier = Modifier & {
386
- name: string;
387
- type: 'modifier';
388
- };
389
- type ResolverDocument = {
390
- $schema?: string;
391
- name?: string;
392
- version: '2025.10';
393
- description?: string;
394
- sets?: Record<string, Set>;
395
- modifiers?: Record<string, Modifier>;
396
- resolutionOrder: (ReferenceObject | InlineSet | InlineModifier)[];
397
- $defs?: Record<string, unknown>;
398
- };
399
- /**
400
- * Map of modifier names to selected context values
401
- *
402
- * Used to specify which variation of each modifier to use when resolving tokens.
403
- * Can be made type-safe by providing a generic type parameter.
404
- *
405
- * @template T - Optional specific type for modifier values (defaults to generic Record)
406
- *
407
- * @example
408
- * ```typescript
409
- * // Generic (default):
410
- * const inputs: ModifierInputs = {
411
- * theme: 'dark',
412
- * platform: 'mobile'
413
- * }
414
- *
415
- * // Type-safe:
416
- * type MyModifiers = { theme: 'light' | 'dark', platform: 'web' | 'mobile' }
417
- * const inputs: ModifierInputs<MyModifiers> = {
418
- * theme: 'dark', // ✅ Autocomplete!
419
- * platform: 'mobile'
420
- * }
421
- * ```
422
- */
423
- type ModifierInputs<T extends Record<string, string> = Record<string, string>> = T;
424
-
425
430
  /**
426
431
  * @fileoverview Validation configuration types
427
432
  */
@@ -449,6 +454,12 @@ type ValidationOptions = {
449
454
 
450
455
  /**
451
456
  * @fileoverview Configuration types for Dispersa
457
+ *
458
+ * Note: config and renderers/types have a mutual type-only dependency.
459
+ * OutputConfig references Renderer/FormatOptions, while RenderContext
460
+ * references OutputConfig. This is acceptable because type imports are
461
+ * erased at runtime and the coupling is genuine (config describes how
462
+ * to drive renderers).
452
463
  */
453
464
 
454
465
  /**
@@ -472,7 +483,13 @@ type LifecycleHooks = {
472
483
  /** Called after all outputs have been processed (success or failure) */
473
484
  onBuildEnd?: (result: BuildResult) => void | Promise<void>;
474
485
  };
475
-
486
+ /**
487
+ * Function that generates an output file path based on modifier inputs.
488
+ *
489
+ * Used as the `file` property on `OutputConfig` and builder configs when
490
+ * the file name needs to vary per permutation.
491
+ */
492
+ type FileFunction = (modifierInputs: ModifierInputs) => string;
476
493
  /**
477
494
  * Output configuration for a single build target
478
495
  *
@@ -577,7 +594,7 @@ type OutputConfig<TOptions extends FormatOptions = FormatOptions> = Omit<OutputC
577
594
  * }
578
595
  * ```
579
596
  */
580
- file?: string | ((modifierInputs: ModifierInputs) => string);
597
+ file?: string | FileFunction;
581
598
  /**
582
599
  * Renderer-specific options passed to the formatter.
583
600
  */
@@ -683,11 +700,6 @@ type BuildConfig = Omit<BuildConfigBase, 'outputs' | 'filters' | 'transforms' |
683
700
  /** Global lifecycle hooks for the build process */
684
701
  hooks?: LifecycleHooks;
685
702
  };
686
- /**
687
- * Global options for Dispersa instance behavior
688
- *
689
- * Uses the generated base type from schemas - all properties match exactly.
690
- */
691
703
  /**
692
704
  * Dispersa options with runtime-only validation helpers
693
705
  *
@@ -701,4 +713,4 @@ type DispersaOptions = Omit<DispersaOptionsBase, 'validation'> & {
701
713
  validation?: ValidationOptions;
702
714
  };
703
715
 
704
- export { type AndroidRendererOptions as A, type BuildConfig as B, type CssRendererOptions as C, type DispersaOptions as D, type ErrorCode as E, type FormatOptions as F, type IosRendererOptions as I, type LifecycleHooks as L, type ModifierInputs as M, type OutputConfig as O, type PermutationData as P, type ResolverDocument as R, type SelectorFunction as S, type TailwindRendererOptions as T, type ValidationOptions as V, type BuildResult as a, type ValidationMode as b, type BuildError as c, type BuildOutput as d, type MediaQueryFunction as e, type OutputTree as f, type Renderer as g, type RenderContext as h, type RenderMeta as i, type RenderOutput as j, defineRenderer as k };
716
+ export { type AndroidRendererOptions as A, type BuildConfig as B, type CssRendererOptions as C, type DispersaOptions as D, type ErrorCode as E, type FileFunction as F, type IosRendererOptions as I, type LifecycleHooks as L, type ModifierInputs as M, type OutputConfig as O, type PermutationData as P, type ResolverDocument as R, type SelectorFunction as S, type TailwindRendererOptions as T, type ValidationMode as V, type BuildResult as a, type ValidationOptions as b, type BuildError as c, type BuildOutput as d, type FormatOptions as e, type MediaQueryFunction as f, type OutputTree as g, type Renderer as h, type RenderContext as i, type RenderMeta as j, type RenderOutput as k, defineRenderer as l };
@@ -3,6 +3,73 @@ import { B as BuildConfigBase, O as OutputConfigBase, P as Preprocessor, D as Di
3
3
  import { T as Transform } from './types-CzHa7YkW.js';
4
4
  import { R as ResolvedTokens } from './types-Bc0kA7De.js';
5
5
 
6
+ /**
7
+ * @fileoverview DTCG Resolver types (2025.10 specification)
8
+ *
9
+ * The resolver system allows defining token sources, modifiers (themes, modes),
10
+ * and the order in which they should be resolved and merged.
11
+ *
12
+ * ResolverDocument type is defined here to match DTCG 2025.10.
13
+ */
14
+ type ReferenceObject = {
15
+ $ref: string;
16
+ };
17
+ type TokenSource = ReferenceObject | Record<string, unknown>;
18
+ type Set = {
19
+ sources: TokenSource[];
20
+ description?: string;
21
+ $extensions?: Record<string, unknown>;
22
+ };
23
+ type Modifier = {
24
+ contexts: Record<string, TokenSource[]>;
25
+ description?: string;
26
+ default?: string;
27
+ $extensions?: Record<string, unknown>;
28
+ };
29
+ type InlineSet = Set & {
30
+ name: string;
31
+ type: 'set';
32
+ };
33
+ type InlineModifier = Modifier & {
34
+ name: string;
35
+ type: 'modifier';
36
+ };
37
+ type ResolverDocument = {
38
+ $schema?: string;
39
+ name?: string;
40
+ version: '2025.10';
41
+ description?: string;
42
+ sets?: Record<string, Set>;
43
+ modifiers?: Record<string, Modifier>;
44
+ resolutionOrder: (ReferenceObject | InlineSet | InlineModifier)[];
45
+ $defs?: Record<string, unknown>;
46
+ };
47
+ /**
48
+ * Map of modifier names to selected context values
49
+ *
50
+ * Used to specify which variation of each modifier to use when resolving tokens.
51
+ * Can be made type-safe by providing a generic type parameter.
52
+ *
53
+ * @template T - Optional specific type for modifier values (defaults to generic Record)
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * // Generic (default):
58
+ * const inputs: ModifierInputs = {
59
+ * theme: 'dark',
60
+ * platform: 'mobile'
61
+ * }
62
+ *
63
+ * // Type-safe:
64
+ * type MyModifiers = { theme: 'light' | 'dark', platform: 'web' | 'mobile' }
65
+ * const inputs: ModifierInputs<MyModifiers> = {
66
+ * theme: 'dark', // ✅ Autocomplete!
67
+ * platform: 'mobile'
68
+ * }
69
+ * ```
70
+ */
71
+ type ModifierInputs<T extends Record<string, string> = Record<string, string>> = T;
72
+
6
73
  /**
7
74
  * @license MIT
8
75
  * Copyright (c) 2025-present Dispersa Contributors
@@ -128,6 +195,11 @@ type AndroidRendererOptions = {
128
195
 
129
196
  /**
130
197
  * @fileoverview Renderer system types for token output generation
198
+ *
199
+ * Note: renderers/types and config have a mutual type-only dependency.
200
+ * RenderContext references OutputConfig, while OutputConfig references
201
+ * Renderer/FormatOptions. This is acceptable because type imports are
202
+ * erased at runtime and the coupling is genuine.
131
203
  */
132
204
 
133
205
  /**
@@ -325,7 +397,7 @@ type CssRendererOptions = {
325
397
  /**
326
398
  * Error code identifying the type of build error
327
399
  */
328
- type ErrorCode = 'TOKEN_REFERENCE' | 'CIRCULAR_REFERENCE' | 'VALIDATION' | 'COLOR_PARSE' | 'DIMENSION_FORMAT' | 'FILE_OPERATION' | 'CONFIGURATION' | 'BASE_PERMUTATION' | 'MODIFIER' | 'UNKNOWN';
400
+ type ErrorCode = 'TOKEN_REFERENCE' | 'CIRCULAR_REFERENCE' | 'VALIDATION' | 'FILE_OPERATION' | 'CONFIGURATION' | 'BASE_PERMUTATION' | 'MODIFIER' | 'UNKNOWN';
329
401
  /**
330
402
  * Structured error from a build operation
331
403
  *
@@ -355,73 +427,6 @@ type BuildResult = {
355
427
  errors?: BuildError[];
356
428
  };
357
429
 
358
- /**
359
- * @fileoverview DTCG Resolver types (2025.10 specification)
360
- *
361
- * The resolver system allows defining token sources, modifiers (themes, modes),
362
- * and the order in which they should be resolved and merged.
363
- *
364
- * ResolverDocument type is defined here to match DTCG 2025.10.
365
- */
366
- type ReferenceObject = {
367
- $ref: string;
368
- };
369
- type TokenSource = ReferenceObject | Record<string, unknown>;
370
- type Set = {
371
- sources: TokenSource[];
372
- description?: string;
373
- $extensions?: Record<string, unknown>;
374
- };
375
- type Modifier = {
376
- contexts: Record<string, TokenSource[]>;
377
- description?: string;
378
- default?: string;
379
- $extensions?: Record<string, unknown>;
380
- };
381
- type InlineSet = Set & {
382
- name: string;
383
- type: 'set';
384
- };
385
- type InlineModifier = Modifier & {
386
- name: string;
387
- type: 'modifier';
388
- };
389
- type ResolverDocument = {
390
- $schema?: string;
391
- name?: string;
392
- version: '2025.10';
393
- description?: string;
394
- sets?: Record<string, Set>;
395
- modifiers?: Record<string, Modifier>;
396
- resolutionOrder: (ReferenceObject | InlineSet | InlineModifier)[];
397
- $defs?: Record<string, unknown>;
398
- };
399
- /**
400
- * Map of modifier names to selected context values
401
- *
402
- * Used to specify which variation of each modifier to use when resolving tokens.
403
- * Can be made type-safe by providing a generic type parameter.
404
- *
405
- * @template T - Optional specific type for modifier values (defaults to generic Record)
406
- *
407
- * @example
408
- * ```typescript
409
- * // Generic (default):
410
- * const inputs: ModifierInputs = {
411
- * theme: 'dark',
412
- * platform: 'mobile'
413
- * }
414
- *
415
- * // Type-safe:
416
- * type MyModifiers = { theme: 'light' | 'dark', platform: 'web' | 'mobile' }
417
- * const inputs: ModifierInputs<MyModifiers> = {
418
- * theme: 'dark', // ✅ Autocomplete!
419
- * platform: 'mobile'
420
- * }
421
- * ```
422
- */
423
- type ModifierInputs<T extends Record<string, string> = Record<string, string>> = T;
424
-
425
430
  /**
426
431
  * @fileoverview Validation configuration types
427
432
  */
@@ -449,6 +454,12 @@ type ValidationOptions = {
449
454
 
450
455
  /**
451
456
  * @fileoverview Configuration types for Dispersa
457
+ *
458
+ * Note: config and renderers/types have a mutual type-only dependency.
459
+ * OutputConfig references Renderer/FormatOptions, while RenderContext
460
+ * references OutputConfig. This is acceptable because type imports are
461
+ * erased at runtime and the coupling is genuine (config describes how
462
+ * to drive renderers).
452
463
  */
453
464
 
454
465
  /**
@@ -472,7 +483,13 @@ type LifecycleHooks = {
472
483
  /** Called after all outputs have been processed (success or failure) */
473
484
  onBuildEnd?: (result: BuildResult) => void | Promise<void>;
474
485
  };
475
-
486
+ /**
487
+ * Function that generates an output file path based on modifier inputs.
488
+ *
489
+ * Used as the `file` property on `OutputConfig` and builder configs when
490
+ * the file name needs to vary per permutation.
491
+ */
492
+ type FileFunction = (modifierInputs: ModifierInputs) => string;
476
493
  /**
477
494
  * Output configuration for a single build target
478
495
  *
@@ -577,7 +594,7 @@ type OutputConfig<TOptions extends FormatOptions = FormatOptions> = Omit<OutputC
577
594
  * }
578
595
  * ```
579
596
  */
580
- file?: string | ((modifierInputs: ModifierInputs) => string);
597
+ file?: string | FileFunction;
581
598
  /**
582
599
  * Renderer-specific options passed to the formatter.
583
600
  */
@@ -683,11 +700,6 @@ type BuildConfig = Omit<BuildConfigBase, 'outputs' | 'filters' | 'transforms' |
683
700
  /** Global lifecycle hooks for the build process */
684
701
  hooks?: LifecycleHooks;
685
702
  };
686
- /**
687
- * Global options for Dispersa instance behavior
688
- *
689
- * Uses the generated base type from schemas - all properties match exactly.
690
- */
691
703
  /**
692
704
  * Dispersa options with runtime-only validation helpers
693
705
  *
@@ -701,4 +713,4 @@ type DispersaOptions = Omit<DispersaOptionsBase, 'validation'> & {
701
713
  validation?: ValidationOptions;
702
714
  };
703
715
 
704
- export { type AndroidRendererOptions as A, type BuildConfig as B, type CssRendererOptions as C, type DispersaOptions as D, type ErrorCode as E, type FormatOptions as F, type IosRendererOptions as I, type LifecycleHooks as L, type ModifierInputs as M, type OutputConfig as O, type PermutationData as P, type ResolverDocument as R, type SelectorFunction as S, type TailwindRendererOptions as T, type ValidationOptions as V, type BuildResult as a, type ValidationMode as b, type BuildError as c, type BuildOutput as d, type MediaQueryFunction as e, type OutputTree as f, type Renderer as g, type RenderContext as h, type RenderMeta as i, type RenderOutput as j, defineRenderer as k };
716
+ export { type AndroidRendererOptions as A, type BuildConfig as B, type CssRendererOptions as C, type DispersaOptions as D, type ErrorCode as E, type FileFunction as F, type IosRendererOptions as I, type LifecycleHooks as L, type ModifierInputs as M, type OutputConfig as O, type PermutationData as P, type ResolverDocument as R, type SelectorFunction as S, type TailwindRendererOptions as T, type ValidationMode as V, type BuildResult as a, type ValidationOptions as b, type BuildError as c, type BuildOutput as d, type FormatOptions as e, type MediaQueryFunction as f, type OutputTree as g, type Renderer as h, type RenderContext as i, type RenderMeta as j, type RenderOutput as k, defineRenderer as l };