@tenphi/glaze 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -261,7 +261,8 @@ interface RegularColorDef {
261
261
  * Whether to flip out-of-bounds results to the opposite side instead of
262
262
  * clamping to the extreme. Affects both:
263
263
  * - relative `tone`: when `base ± delta` exceeds `[0, 100]`, mirror the
264
- * delta to the other side of the base.
264
+ * delta to the other side of the base. If the mirrored target is also
265
+ * out of range, keep the original delta and clamp on the authored side.
265
266
  * - `contrast`: when the requested direction can't meet the floor, try the
266
267
  * opposite side (same as the global `autoFlip`).
267
268
  *
@@ -280,8 +281,8 @@ interface RegularColorDef {
280
281
  /**
281
282
  * Per-color override for the hue-independent "safe" chroma limit used in
282
283
  * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
283
- * Falls through to the global / per-theme `pastel` config when omitted.
284
- * @see GlazeConfig.pastel
284
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
285
+ * @see GlazeConfigOverride.pastel
285
286
  */
286
287
  pastel?: boolean;
287
288
  /**
@@ -346,8 +347,8 @@ interface ShadowColorDef {
346
347
  /**
347
348
  * Per-color override for the hue-independent "safe" chroma limit used in
348
349
  * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
349
- * Falls through to the global / per-theme `pastel` config when omitted.
350
- * @see GlazeConfig.pastel
350
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
351
+ * @see GlazeConfigOverride.pastel
351
352
  */
352
353
  pastel?: boolean;
353
354
  /**
@@ -393,8 +394,8 @@ interface MixColorDef {
393
394
  /**
394
395
  * Per-color override for the hue-independent "safe" chroma limit used in
395
396
  * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
396
- * Falls through to the global / per-theme `pastel` config when omitted.
397
- * @see GlazeConfig.pastel
397
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
398
+ * @see GlazeConfigOverride.pastel
398
399
  */
399
400
  pastel?: boolean;
400
401
  /**
@@ -493,13 +494,6 @@ interface GlazeConfig {
493
494
  * falls back to the originally requested tone).
494
495
  */
495
496
  autoFlip?: boolean;
496
- /**
497
- * If true, uses a hue-independent "safe" chroma limit across all colors
498
- * so that scaling saturation never exceeds the sRGB boundary at any hue
499
- * for the given lightness.
500
- * @default false
501
- */
502
- pastel?: boolean;
503
497
  /**
504
498
  * If true (default), infer a color's `role` from its name when no explicit
505
499
  * `role` is set. Set to `false` to opt out of name-based inference (the
@@ -519,13 +513,19 @@ interface GlazeConfigResolved {
519
513
  modes: Required<GlazeOutputModes>;
520
514
  shadowTuning?: ShadowTuning;
521
515
  autoFlip: boolean;
516
+ /**
517
+ * Instance-level pastel default (`def.pastel ?? config.pastel`).
518
+ * Not set via `glaze.configure()` — only via per-theme / per-token
519
+ * `GlazeConfigOverride` (default `false`).
520
+ */
522
521
  pastel: boolean;
523
522
  inferRole: boolean;
524
523
  }
525
524
  /**
526
525
  * Per-instance config override for `glaze.color()` and `glaze()` themes.
527
526
  * Fields that are set take priority over the live global config. Fields
528
- * that are omitted fall through to the live global at resolve time.
527
+ * that are omitted fall through to the live global at resolve time
528
+ * (`pastel` is instance-only and defaults to `false` when omitted).
529
529
  *
530
530
  * `false` for a tone window disables clamping (full range at reference eps).
531
531
  */
@@ -539,9 +539,9 @@ interface GlazeConfigOverride {
539
539
  /** Whether to auto-flip tone when contrast can't be met. */
540
540
  autoFlip?: boolean;
541
541
  /**
542
- * If true, uses a hue-independent "safe" chroma limit across all colors
543
- * so that scaling saturation never exceeds the sRGB boundary at any hue
544
- * for the given lightness.
542
+ * Instance-level pastel default for colors that omit per-color `pastel`.
543
+ * Not available on `glaze.configure()` set here or per-color.
544
+ * @default false
545
545
  */
546
546
  pastel?: boolean;
547
547
  /**
@@ -555,12 +555,29 @@ interface GlazeConfigOverride {
555
555
  */
556
556
  shadowTuning?: ShadowTuning;
557
557
  }
558
+ /**
559
+ * Current authoring-export schema version. Bump when the export shape
560
+ * changes in a non-compatible way. Written on every `.export()` snapshot.
561
+ */
562
+ declare const GLAZE_EXPORT_VERSION: 1;
563
+ /** Literal type of {@link GLAZE_EXPORT_VERSION}. */
564
+ type GlazeExportVersion = typeof GLAZE_EXPORT_VERSION;
565
+ /** Discriminator for authoring export snapshots. */
566
+ type GlazeExportKind = 'theme' | 'color' | 'palette';
558
567
  /** Serialized theme configuration (no resolved values). */
559
568
  interface GlazeThemeExport {
569
+ /** Snapshot kind. Always written by `theme.export()`; optional on legacy hand-written configs. */
570
+ kind?: 'theme';
571
+ /** Schema version. Always written by `theme.export()`; optional on legacy configs. */
572
+ version?: number;
560
573
  hue: number;
561
574
  saturation: number;
562
575
  colors: ColorMap;
563
- /** Per-theme config override, if any. */
576
+ /**
577
+ * Effective config freeze from `.export()` —
578
+ * `getConfig() ∪ instance local ∪ exportArg`. May be sparse on legacy
579
+ * snapshots (omitted fields fall through to the live global at restore).
580
+ */
564
581
  config?: GlazeConfigOverride;
565
582
  }
566
583
  /** Input for `glaze.shadow()` standalone factory. */
@@ -616,8 +633,8 @@ interface GlazeColorInput {
616
633
  /**
617
634
  * Per-color override for the hue-independent "safe" chroma limit used in
618
635
  * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
619
- * Falls through to the global / per-theme `pastel` config when omitted.
620
- * @see GlazeConfig.pastel
636
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
637
+ * @see GlazeConfigOverride.pastel
621
638
  */
622
639
  pastel?: boolean;
623
640
  /**
@@ -668,11 +685,11 @@ interface GlazeColorOverrides {
668
685
  /**
669
686
  * Adaptation mode. Defaults to `'auto'` for every input form, so
670
687
  * colors automatically adapt between light and dark like an ordinary
671
- * theme color. All value-shorthand inputs (strings and literal objects)
672
- * preserve light tone (`lightTone: false`) and snapshot
673
- * `globalConfig.darkTone` on the dark side. Only the structured
674
- * `{ hue, saturation, tone }` form also snapshots
675
- * `globalConfig.lightTone`.
688
+ * theme color. Value-shorthand inputs (strings and literal objects)
689
+ * preserve light tone via a local `lightTone: false` default; other
690
+ * omitted config fields fall through to the live global at resolve
691
+ * time. Structured `{ hue, saturation, tone }` form also falls
692
+ * through for both tone windows unless overridden.
676
693
  *
677
694
  * Pass `'fixed'` explicitly to opt back into the linear, non-
678
695
  * inverting mapping; pass `'static'` to pin the same tone
@@ -731,8 +748,8 @@ interface GlazeColorOverrides {
731
748
  /**
732
749
  * Per-color override for the hue-independent "safe" chroma limit used in
733
750
  * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
734
- * Falls through to the global / per-theme `pastel` config when omitted.
735
- * @see GlazeConfig.pastel
751
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
752
+ * @see GlazeConfigOverride.pastel
736
753
  */
737
754
  pastel?: boolean;
738
755
  /**
@@ -815,14 +832,19 @@ interface GlazeColorToken {
815
832
  * Serialize the token as a JSON-safe object. Captures the original
816
833
  * input value, overrides, and config so it can be rehydrated via
817
834
  * `glaze.colorFrom(...)`. `base` is recursively serialized.
835
+ * Optional `override` is merged over the instance local at export time.
818
836
  */
819
- export(): GlazeColorTokenExport;
837
+ export(override?: GlazeConfigOverride): GlazeColorTokenExport;
820
838
  }
821
839
  /**
822
840
  * JSON-safe serialization of a `glaze.color()` token. Pass to
823
841
  * `glaze.colorFrom(...)` to rehydrate.
824
842
  */
825
843
  interface GlazeColorTokenExport {
844
+ /** Snapshot kind. Always written by `token.export()`; optional on legacy snapshots. */
845
+ kind?: 'color';
846
+ /** Schema version. Always written by `token.export()`; optional on legacy snapshots. */
847
+ version?: number;
826
848
  /**
827
849
  * Discriminator for the source overload that created the token.
828
850
  * - `'value'`: created via `glaze.color(value)` or `glaze.color({ from, ...overrides })`.
@@ -837,14 +859,26 @@ interface GlazeColorTokenExport {
837
859
  */
838
860
  overrides?: GlazeColorOverridesExport;
839
861
  /**
840
- * Effective config snapshot at creation time captures the merged
841
- * result of the global config + any per-call override at the moment
842
- * the token was created. Only fields that differ from their
843
- * post-merge defaults are present. Used by `glaze.colorFrom()` to
844
- * reproduce deterministic behavior across `configure()` calls.
862
+ * Effective config freeze from `.export()``getConfig() local ∪
863
+ * exportArg` at call time. Used by `glaze.colorFrom()` to pin
864
+ * deterministic behavior across later `configure()` calls.
845
865
  */
846
866
  config?: GlazeConfigOverride;
847
867
  }
868
+ /**
869
+ * JSON-safe serialization of a `glaze.palette()` composition.
870
+ * Pass to `glaze.paletteFrom(...)` to rehydrate.
871
+ */
872
+ interface GlazePaletteExport {
873
+ /** Snapshot kind. Always written by `palette.export()`. */
874
+ kind?: 'palette';
875
+ /** Schema version. Always written by `palette.export()`. */
876
+ version?: number;
877
+ /** Per-theme authoring snapshots keyed by theme name. */
878
+ themes: Record<string, GlazeThemeExport>;
879
+ /** Primary theme name, if set on the palette. */
880
+ primary?: string;
881
+ }
848
882
  /**
849
883
  * Serializable shape of a structured `glaze.color({...})` input.
850
884
  * Differs from `GlazeColorInput` only in that `base` is replaced by an
@@ -904,7 +938,7 @@ interface GlazeTheme {
904
938
  /** Clear all color definitions. */
905
939
  reset(): void;
906
940
  /** Export the theme configuration as a JSON-safe object. */
907
- export(): GlazeThemeExport;
941
+ export(override?: GlazeConfigOverride): GlazeThemeExport;
908
942
  /** Create a child theme inheriting all color definitions. */
909
943
  extend(options: GlazeExtendOptions): GlazeTheme;
910
944
  /** Resolve all colors and return the result map. */
@@ -1224,6 +1258,24 @@ interface GlazePaletteExportOptions {
1224
1258
  splitHue?: boolean;
1225
1259
  }
1226
1260
  interface GlazePalette {
1261
+ /** Theme names in insertion order. */
1262
+ list(): string[];
1263
+ /** Primary theme name, if set at palette creation. */
1264
+ readonly primary: string | undefined;
1265
+ /** Get a theme by name. Returns the live instance held by the palette. */
1266
+ theme(name: string): GlazeTheme | undefined;
1267
+ /**
1268
+ * Shallow copy of the theme map (same instances the palette holds).
1269
+ * Mutating a returned theme affects subsequent palette exports.
1270
+ */
1271
+ themes(): Record<string, GlazeTheme>;
1272
+ /**
1273
+ * Export the palette authoring configuration as a JSON-safe object.
1274
+ * Restorable via `glaze.paletteFrom(...)`. Distinct from `json()`, which
1275
+ * emits resolved color strings. Optional `override` is forwarded to each
1276
+ * nested `theme.export(override)`.
1277
+ */
1278
+ export(override?: GlazeConfigOverride): GlazePaletteExport;
1227
1279
  /**
1228
1280
  * Export all themes as a flat token map grouped by scheme variant.
1229
1281
  * Prefix defaults to `true` — all tokens are prefixed with the theme name.
@@ -1270,6 +1322,14 @@ interface GlazePalette {
1270
1322
  tailwind(options?: GlazeTailwindOptions & GlazePaletteExportOptions): string;
1271
1323
  }
1272
1324
  //#endregion
1325
+ //#region src/serialize.d.ts
1326
+ /** Type guard for theme authoring snapshots (prefers `kind`, falls back to shape). */
1327
+ declare function isThemeExport(data: unknown): data is GlazeThemeExport;
1328
+ /** Type guard for color-token authoring snapshots. */
1329
+ declare function isColorTokenExport(data: unknown): data is GlazeColorTokenExport;
1330
+ /** Type guard for palette authoring snapshots. */
1331
+ declare function isPaletteExport(data: unknown): data is GlazePaletteExport;
1332
+ //#endregion
1273
1333
  //#region src/glaze.d.ts
1274
1334
  type PaletteInput = Record<string, GlazeTheme>;
1275
1335
  /**
@@ -1297,6 +1357,7 @@ declare function glaze(hueOrOptions: number | {
1297
1357
  declare namespace glaze {
1298
1358
  var configure: (config: GlazeConfig) => void;
1299
1359
  var palette: (themes: PaletteInput, options?: GlazePaletteOptions) => GlazePalette;
1360
+ var themeFrom: (data: GlazeThemeExport) => GlazeTheme;
1300
1361
  var from: (data: GlazeThemeExport) => GlazeTheme;
1301
1362
  var color: (input: GlazeFromInput | GlazeColorInput | GlazeColorValue, config?: GlazeConfigOverride) => GlazeColorToken;
1302
1363
  var shadow: (input: GlazeShadowInput) => ResolvedColorVariant;
@@ -1304,6 +1365,10 @@ declare namespace glaze {
1304
1365
  var fromHex: (hex: string) => GlazeTheme;
1305
1366
  var fromRgb: (r: number, g: number, b: number) => GlazeTheme;
1306
1367
  var colorFrom: (data: GlazeColorTokenExport) => GlazeColorToken;
1368
+ var paletteFrom: (data: GlazePaletteExport) => GlazePalette;
1369
+ var isThemeExport: typeof isThemeExport;
1370
+ var isColorTokenExport: typeof isColorTokenExport;
1371
+ var isPaletteExport: typeof isPaletteExport;
1307
1372
  var getConfig: () => GlazeConfigResolved;
1308
1373
  var resetConfig: () => void;
1309
1374
  }
@@ -1567,5 +1632,5 @@ declare function srgbToHex(rgb: [number, number, number]): `#${string}`;
1567
1632
  */
1568
1633
  declare function okhslToOklch(h: number, s: number, l: number, pastel?: boolean): [number, number, number];
1569
1634
  //#endregion
1570
- export { APCA_HC_ENHANCEMENT, APCA_MAX_LC, APCA_PRESETS, type AdaptationMode, type ApcaPreset, type ChannelCtx, type ColorDef, type ColorMap, type ContrastPreset, type ContrastSpec, type DtcgColorSpace, type DtcgColorToken, type DtcgColorValue, type DtcgDocument, type DtcgOklchColorValue, type DtcgResolverModifier, type DtcgResolverRef, type DtcgResolverSet, type DtcgSrgbColorValue, type DtcgTokenTree, type ExtremeValue, type FindToneForContrastOptions, type FindToneForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorCssOptions, type GlazeColorDtcgResolverOptions, type GlazeColorDtcgResult, type GlazeColorFormat, type GlazeColorInput, type GlazeColorInputExport, type GlazeColorOverrides, type GlazeColorOverridesExport, type GlazeColorTailwindOptions, type GlazeColorToken, type GlazeColorTokenExport, type GlazeColorValue, type GlazeConfig, type GlazeConfigOverride, type GlazeConfigResolved, type GlazeCssOptions, type GlazeCssResult, type GlazeDtcgOptions, type GlazeDtcgResolverContextNames, type GlazeDtcgResolverDocument, type GlazeDtcgResolverOptions, type GlazeDtcgResult, type GlazeExtendOptions, type GlazeFromInput, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExportOptions, type GlazePaletteOptions, type GlazeShadowInput, type GlazeTailwindOptions, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type HueDeclaration, type HuePlan, type MinContrast, type MixColorDef, type OkhslColor, type OkhstColor, type OklchColor, type Polarity, REF_EPS, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type ResolvedContrast, type RgbColor, type Role, type RoleInput, type ShadowColorDef, type ShadowTuning, type ToneValue, type ToneWindow, apcaContrast, assertAllPastel, assertNativeFormat, contrastRatioFromLuminance, cuspLightness, findToneForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOkhst, formatOklch, formatRgb, fromTone, gamutClampedLuminance, glaze, hslToSrgb, inferRoleFromName, normalizeRole, okhslToLinearSrgb, okhslToOkhst, okhslToOklab, okhslToOklch, okhslToSrgb, okhstToOkhsl, oklabToOkhsl, oppositeRole, parseHex, parseHexAlpha, relativeLuminanceFromLinearRgb, resolveApcaTarget, resolveContrastForMode, resolveMinContrast, roleToPolarity, srgbToHex, srgbToOkhsl, toTone, toneFromY, variantToOkhsl, yFromTone };
1635
+ export { APCA_HC_ENHANCEMENT, APCA_MAX_LC, APCA_PRESETS, type AdaptationMode, type ApcaPreset, type ChannelCtx, type ColorDef, type ColorMap, type ContrastPreset, type ContrastSpec, type DtcgColorSpace, type DtcgColorToken, type DtcgColorValue, type DtcgDocument, type DtcgOklchColorValue, type DtcgResolverModifier, type DtcgResolverRef, type DtcgResolverSet, type DtcgSrgbColorValue, type DtcgTokenTree, type ExtremeValue, type FindToneForContrastOptions, type FindToneForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, GLAZE_EXPORT_VERSION, type GlazeColorCssOptions, type GlazeColorDtcgResolverOptions, type GlazeColorDtcgResult, type GlazeColorFormat, type GlazeColorInput, type GlazeColorInputExport, type GlazeColorOverrides, type GlazeColorOverridesExport, type GlazeColorTailwindOptions, type GlazeColorToken, type GlazeColorTokenExport, type GlazeColorValue, type GlazeConfig, type GlazeConfigOverride, type GlazeConfigResolved, type GlazeCssOptions, type GlazeCssResult, type GlazeDtcgOptions, type GlazeDtcgResolverContextNames, type GlazeDtcgResolverDocument, type GlazeDtcgResolverOptions, type GlazeDtcgResult, type GlazeExportKind, type GlazeExportVersion, type GlazeExtendOptions, type GlazeFromInput, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExport, type GlazePaletteExportOptions, type GlazePaletteOptions, type GlazeShadowInput, type GlazeTailwindOptions, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type HueDeclaration, type HuePlan, type MinContrast, type MixColorDef, type OkhslColor, type OkhstColor, type OklchColor, type Polarity, REF_EPS, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type ResolvedContrast, type RgbColor, type Role, type RoleInput, type ShadowColorDef, type ShadowTuning, type ToneValue, type ToneWindow, apcaContrast, assertAllPastel, assertNativeFormat, contrastRatioFromLuminance, cuspLightness, findToneForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOkhst, formatOklch, formatRgb, fromTone, gamutClampedLuminance, glaze, hslToSrgb, inferRoleFromName, isColorTokenExport, isPaletteExport, isThemeExport, normalizeRole, okhslToLinearSrgb, okhslToOkhst, okhslToOklab, okhslToOklch, okhslToSrgb, okhstToOkhsl, oklabToOkhsl, oppositeRole, parseHex, parseHexAlpha, relativeLuminanceFromLinearRgb, resolveApcaTarget, resolveContrastForMode, resolveMinContrast, roleToPolarity, srgbToHex, srgbToOkhsl, toTone, toneFromY, variantToOkhsl, yFromTone };
1571
1636
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -261,7 +261,8 @@ interface RegularColorDef {
261
261
  * Whether to flip out-of-bounds results to the opposite side instead of
262
262
  * clamping to the extreme. Affects both:
263
263
  * - relative `tone`: when `base ± delta` exceeds `[0, 100]`, mirror the
264
- * delta to the other side of the base.
264
+ * delta to the other side of the base. If the mirrored target is also
265
+ * out of range, keep the original delta and clamp on the authored side.
265
266
  * - `contrast`: when the requested direction can't meet the floor, try the
266
267
  * opposite side (same as the global `autoFlip`).
267
268
  *
@@ -280,8 +281,8 @@ interface RegularColorDef {
280
281
  /**
281
282
  * Per-color override for the hue-independent "safe" chroma limit used in
282
283
  * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
283
- * Falls through to the global / per-theme `pastel` config when omitted.
284
- * @see GlazeConfig.pastel
284
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
285
+ * @see GlazeConfigOverride.pastel
285
286
  */
286
287
  pastel?: boolean;
287
288
  /**
@@ -346,8 +347,8 @@ interface ShadowColorDef {
346
347
  /**
347
348
  * Per-color override for the hue-independent "safe" chroma limit used in
348
349
  * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
349
- * Falls through to the global / per-theme `pastel` config when omitted.
350
- * @see GlazeConfig.pastel
350
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
351
+ * @see GlazeConfigOverride.pastel
351
352
  */
352
353
  pastel?: boolean;
353
354
  /**
@@ -393,8 +394,8 @@ interface MixColorDef {
393
394
  /**
394
395
  * Per-color override for the hue-independent "safe" chroma limit used in
395
396
  * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
396
- * Falls through to the global / per-theme `pastel` config when omitted.
397
- * @see GlazeConfig.pastel
397
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
398
+ * @see GlazeConfigOverride.pastel
398
399
  */
399
400
  pastel?: boolean;
400
401
  /**
@@ -493,13 +494,6 @@ interface GlazeConfig {
493
494
  * falls back to the originally requested tone).
494
495
  */
495
496
  autoFlip?: boolean;
496
- /**
497
- * If true, uses a hue-independent "safe" chroma limit across all colors
498
- * so that scaling saturation never exceeds the sRGB boundary at any hue
499
- * for the given lightness.
500
- * @default false
501
- */
502
- pastel?: boolean;
503
497
  /**
504
498
  * If true (default), infer a color's `role` from its name when no explicit
505
499
  * `role` is set. Set to `false` to opt out of name-based inference (the
@@ -519,13 +513,19 @@ interface GlazeConfigResolved {
519
513
  modes: Required<GlazeOutputModes>;
520
514
  shadowTuning?: ShadowTuning;
521
515
  autoFlip: boolean;
516
+ /**
517
+ * Instance-level pastel default (`def.pastel ?? config.pastel`).
518
+ * Not set via `glaze.configure()` — only via per-theme / per-token
519
+ * `GlazeConfigOverride` (default `false`).
520
+ */
522
521
  pastel: boolean;
523
522
  inferRole: boolean;
524
523
  }
525
524
  /**
526
525
  * Per-instance config override for `glaze.color()` and `glaze()` themes.
527
526
  * Fields that are set take priority over the live global config. Fields
528
- * that are omitted fall through to the live global at resolve time.
527
+ * that are omitted fall through to the live global at resolve time
528
+ * (`pastel` is instance-only and defaults to `false` when omitted).
529
529
  *
530
530
  * `false` for a tone window disables clamping (full range at reference eps).
531
531
  */
@@ -539,9 +539,9 @@ interface GlazeConfigOverride {
539
539
  /** Whether to auto-flip tone when contrast can't be met. */
540
540
  autoFlip?: boolean;
541
541
  /**
542
- * If true, uses a hue-independent "safe" chroma limit across all colors
543
- * so that scaling saturation never exceeds the sRGB boundary at any hue
544
- * for the given lightness.
542
+ * Instance-level pastel default for colors that omit per-color `pastel`.
543
+ * Not available on `glaze.configure()` set here or per-color.
544
+ * @default false
545
545
  */
546
546
  pastel?: boolean;
547
547
  /**
@@ -555,12 +555,29 @@ interface GlazeConfigOverride {
555
555
  */
556
556
  shadowTuning?: ShadowTuning;
557
557
  }
558
+ /**
559
+ * Current authoring-export schema version. Bump when the export shape
560
+ * changes in a non-compatible way. Written on every `.export()` snapshot.
561
+ */
562
+ declare const GLAZE_EXPORT_VERSION: 1;
563
+ /** Literal type of {@link GLAZE_EXPORT_VERSION}. */
564
+ type GlazeExportVersion = typeof GLAZE_EXPORT_VERSION;
565
+ /** Discriminator for authoring export snapshots. */
566
+ type GlazeExportKind = 'theme' | 'color' | 'palette';
558
567
  /** Serialized theme configuration (no resolved values). */
559
568
  interface GlazeThemeExport {
569
+ /** Snapshot kind. Always written by `theme.export()`; optional on legacy hand-written configs. */
570
+ kind?: 'theme';
571
+ /** Schema version. Always written by `theme.export()`; optional on legacy configs. */
572
+ version?: number;
560
573
  hue: number;
561
574
  saturation: number;
562
575
  colors: ColorMap;
563
- /** Per-theme config override, if any. */
576
+ /**
577
+ * Effective config freeze from `.export()` —
578
+ * `getConfig() ∪ instance local ∪ exportArg`. May be sparse on legacy
579
+ * snapshots (omitted fields fall through to the live global at restore).
580
+ */
564
581
  config?: GlazeConfigOverride;
565
582
  }
566
583
  /** Input for `glaze.shadow()` standalone factory. */
@@ -616,8 +633,8 @@ interface GlazeColorInput {
616
633
  /**
617
634
  * Per-color override for the hue-independent "safe" chroma limit used in
618
635
  * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
619
- * Falls through to the global / per-theme `pastel` config when omitted.
620
- * @see GlazeConfig.pastel
636
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
637
+ * @see GlazeConfigOverride.pastel
621
638
  */
622
639
  pastel?: boolean;
623
640
  /**
@@ -668,11 +685,11 @@ interface GlazeColorOverrides {
668
685
  /**
669
686
  * Adaptation mode. Defaults to `'auto'` for every input form, so
670
687
  * colors automatically adapt between light and dark like an ordinary
671
- * theme color. All value-shorthand inputs (strings and literal objects)
672
- * preserve light tone (`lightTone: false`) and snapshot
673
- * `globalConfig.darkTone` on the dark side. Only the structured
674
- * `{ hue, saturation, tone }` form also snapshots
675
- * `globalConfig.lightTone`.
688
+ * theme color. Value-shorthand inputs (strings and literal objects)
689
+ * preserve light tone via a local `lightTone: false` default; other
690
+ * omitted config fields fall through to the live global at resolve
691
+ * time. Structured `{ hue, saturation, tone }` form also falls
692
+ * through for both tone windows unless overridden.
676
693
  *
677
694
  * Pass `'fixed'` explicitly to opt back into the linear, non-
678
695
  * inverting mapping; pass `'static'` to pin the same tone
@@ -731,8 +748,8 @@ interface GlazeColorOverrides {
731
748
  /**
732
749
  * Per-color override for the hue-independent "safe" chroma limit used in
733
750
  * OKHSL↔sRGB conversions (luminance, contrast solving, output formatting).
734
- * Falls through to the global / per-theme `pastel` config when omitted.
735
- * @see GlazeConfig.pastel
751
+ * Falls through to the per-theme / per-token `pastel` override when omitted.
752
+ * @see GlazeConfigOverride.pastel
736
753
  */
737
754
  pastel?: boolean;
738
755
  /**
@@ -815,14 +832,19 @@ interface GlazeColorToken {
815
832
  * Serialize the token as a JSON-safe object. Captures the original
816
833
  * input value, overrides, and config so it can be rehydrated via
817
834
  * `glaze.colorFrom(...)`. `base` is recursively serialized.
835
+ * Optional `override` is merged over the instance local at export time.
818
836
  */
819
- export(): GlazeColorTokenExport;
837
+ export(override?: GlazeConfigOverride): GlazeColorTokenExport;
820
838
  }
821
839
  /**
822
840
  * JSON-safe serialization of a `glaze.color()` token. Pass to
823
841
  * `glaze.colorFrom(...)` to rehydrate.
824
842
  */
825
843
  interface GlazeColorTokenExport {
844
+ /** Snapshot kind. Always written by `token.export()`; optional on legacy snapshots. */
845
+ kind?: 'color';
846
+ /** Schema version. Always written by `token.export()`; optional on legacy snapshots. */
847
+ version?: number;
826
848
  /**
827
849
  * Discriminator for the source overload that created the token.
828
850
  * - `'value'`: created via `glaze.color(value)` or `glaze.color({ from, ...overrides })`.
@@ -837,14 +859,26 @@ interface GlazeColorTokenExport {
837
859
  */
838
860
  overrides?: GlazeColorOverridesExport;
839
861
  /**
840
- * Effective config snapshot at creation time captures the merged
841
- * result of the global config + any per-call override at the moment
842
- * the token was created. Only fields that differ from their
843
- * post-merge defaults are present. Used by `glaze.colorFrom()` to
844
- * reproduce deterministic behavior across `configure()` calls.
862
+ * Effective config freeze from `.export()``getConfig() local ∪
863
+ * exportArg` at call time. Used by `glaze.colorFrom()` to pin
864
+ * deterministic behavior across later `configure()` calls.
845
865
  */
846
866
  config?: GlazeConfigOverride;
847
867
  }
868
+ /**
869
+ * JSON-safe serialization of a `glaze.palette()` composition.
870
+ * Pass to `glaze.paletteFrom(...)` to rehydrate.
871
+ */
872
+ interface GlazePaletteExport {
873
+ /** Snapshot kind. Always written by `palette.export()`. */
874
+ kind?: 'palette';
875
+ /** Schema version. Always written by `palette.export()`. */
876
+ version?: number;
877
+ /** Per-theme authoring snapshots keyed by theme name. */
878
+ themes: Record<string, GlazeThemeExport>;
879
+ /** Primary theme name, if set on the palette. */
880
+ primary?: string;
881
+ }
848
882
  /**
849
883
  * Serializable shape of a structured `glaze.color({...})` input.
850
884
  * Differs from `GlazeColorInput` only in that `base` is replaced by an
@@ -904,7 +938,7 @@ interface GlazeTheme {
904
938
  /** Clear all color definitions. */
905
939
  reset(): void;
906
940
  /** Export the theme configuration as a JSON-safe object. */
907
- export(): GlazeThemeExport;
941
+ export(override?: GlazeConfigOverride): GlazeThemeExport;
908
942
  /** Create a child theme inheriting all color definitions. */
909
943
  extend(options: GlazeExtendOptions): GlazeTheme;
910
944
  /** Resolve all colors and return the result map. */
@@ -1224,6 +1258,24 @@ interface GlazePaletteExportOptions {
1224
1258
  splitHue?: boolean;
1225
1259
  }
1226
1260
  interface GlazePalette {
1261
+ /** Theme names in insertion order. */
1262
+ list(): string[];
1263
+ /** Primary theme name, if set at palette creation. */
1264
+ readonly primary: string | undefined;
1265
+ /** Get a theme by name. Returns the live instance held by the palette. */
1266
+ theme(name: string): GlazeTheme | undefined;
1267
+ /**
1268
+ * Shallow copy of the theme map (same instances the palette holds).
1269
+ * Mutating a returned theme affects subsequent palette exports.
1270
+ */
1271
+ themes(): Record<string, GlazeTheme>;
1272
+ /**
1273
+ * Export the palette authoring configuration as a JSON-safe object.
1274
+ * Restorable via `glaze.paletteFrom(...)`. Distinct from `json()`, which
1275
+ * emits resolved color strings. Optional `override` is forwarded to each
1276
+ * nested `theme.export(override)`.
1277
+ */
1278
+ export(override?: GlazeConfigOverride): GlazePaletteExport;
1227
1279
  /**
1228
1280
  * Export all themes as a flat token map grouped by scheme variant.
1229
1281
  * Prefix defaults to `true` — all tokens are prefixed with the theme name.
@@ -1270,6 +1322,14 @@ interface GlazePalette {
1270
1322
  tailwind(options?: GlazeTailwindOptions & GlazePaletteExportOptions): string;
1271
1323
  }
1272
1324
  //#endregion
1325
+ //#region src/serialize.d.ts
1326
+ /** Type guard for theme authoring snapshots (prefers `kind`, falls back to shape). */
1327
+ declare function isThemeExport(data: unknown): data is GlazeThemeExport;
1328
+ /** Type guard for color-token authoring snapshots. */
1329
+ declare function isColorTokenExport(data: unknown): data is GlazeColorTokenExport;
1330
+ /** Type guard for palette authoring snapshots. */
1331
+ declare function isPaletteExport(data: unknown): data is GlazePaletteExport;
1332
+ //#endregion
1273
1333
  //#region src/glaze.d.ts
1274
1334
  type PaletteInput = Record<string, GlazeTheme>;
1275
1335
  /**
@@ -1297,6 +1357,7 @@ declare function glaze(hueOrOptions: number | {
1297
1357
  declare namespace glaze {
1298
1358
  var configure: (config: GlazeConfig) => void;
1299
1359
  var palette: (themes: PaletteInput, options?: GlazePaletteOptions) => GlazePalette;
1360
+ var themeFrom: (data: GlazeThemeExport) => GlazeTheme;
1300
1361
  var from: (data: GlazeThemeExport) => GlazeTheme;
1301
1362
  var color: (input: GlazeFromInput | GlazeColorInput | GlazeColorValue, config?: GlazeConfigOverride) => GlazeColorToken;
1302
1363
  var shadow: (input: GlazeShadowInput) => ResolvedColorVariant;
@@ -1304,6 +1365,10 @@ declare namespace glaze {
1304
1365
  var fromHex: (hex: string) => GlazeTheme;
1305
1366
  var fromRgb: (r: number, g: number, b: number) => GlazeTheme;
1306
1367
  var colorFrom: (data: GlazeColorTokenExport) => GlazeColorToken;
1368
+ var paletteFrom: (data: GlazePaletteExport) => GlazePalette;
1369
+ var isThemeExport: typeof isThemeExport;
1370
+ var isColorTokenExport: typeof isColorTokenExport;
1371
+ var isPaletteExport: typeof isPaletteExport;
1307
1372
  var getConfig: () => GlazeConfigResolved;
1308
1373
  var resetConfig: () => void;
1309
1374
  }
@@ -1567,5 +1632,5 @@ declare function srgbToHex(rgb: [number, number, number]): `#${string}`;
1567
1632
  */
1568
1633
  declare function okhslToOklch(h: number, s: number, l: number, pastel?: boolean): [number, number, number];
1569
1634
  //#endregion
1570
- export { APCA_HC_ENHANCEMENT, APCA_MAX_LC, APCA_PRESETS, type AdaptationMode, type ApcaPreset, type ChannelCtx, type ColorDef, type ColorMap, type ContrastPreset, type ContrastSpec, type DtcgColorSpace, type DtcgColorToken, type DtcgColorValue, type DtcgDocument, type DtcgOklchColorValue, type DtcgResolverModifier, type DtcgResolverRef, type DtcgResolverSet, type DtcgSrgbColorValue, type DtcgTokenTree, type ExtremeValue, type FindToneForContrastOptions, type FindToneForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorCssOptions, type GlazeColorDtcgResolverOptions, type GlazeColorDtcgResult, type GlazeColorFormat, type GlazeColorInput, type GlazeColorInputExport, type GlazeColorOverrides, type GlazeColorOverridesExport, type GlazeColorTailwindOptions, type GlazeColorToken, type GlazeColorTokenExport, type GlazeColorValue, type GlazeConfig, type GlazeConfigOverride, type GlazeConfigResolved, type GlazeCssOptions, type GlazeCssResult, type GlazeDtcgOptions, type GlazeDtcgResolverContextNames, type GlazeDtcgResolverDocument, type GlazeDtcgResolverOptions, type GlazeDtcgResult, type GlazeExtendOptions, type GlazeFromInput, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExportOptions, type GlazePaletteOptions, type GlazeShadowInput, type GlazeTailwindOptions, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type HueDeclaration, type HuePlan, type MinContrast, type MixColorDef, type OkhslColor, type OkhstColor, type OklchColor, type Polarity, REF_EPS, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type ResolvedContrast, type RgbColor, type Role, type RoleInput, type ShadowColorDef, type ShadowTuning, type ToneValue, type ToneWindow, apcaContrast, assertAllPastel, assertNativeFormat, contrastRatioFromLuminance, cuspLightness, findToneForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOkhst, formatOklch, formatRgb, fromTone, gamutClampedLuminance, glaze, hslToSrgb, inferRoleFromName, normalizeRole, okhslToLinearSrgb, okhslToOkhst, okhslToOklab, okhslToOklch, okhslToSrgb, okhstToOkhsl, oklabToOkhsl, oppositeRole, parseHex, parseHexAlpha, relativeLuminanceFromLinearRgb, resolveApcaTarget, resolveContrastForMode, resolveMinContrast, roleToPolarity, srgbToHex, srgbToOkhsl, toTone, toneFromY, variantToOkhsl, yFromTone };
1635
+ export { APCA_HC_ENHANCEMENT, APCA_MAX_LC, APCA_PRESETS, type AdaptationMode, type ApcaPreset, type ChannelCtx, type ColorDef, type ColorMap, type ContrastPreset, type ContrastSpec, type DtcgColorSpace, type DtcgColorToken, type DtcgColorValue, type DtcgDocument, type DtcgOklchColorValue, type DtcgResolverModifier, type DtcgResolverRef, type DtcgResolverSet, type DtcgSrgbColorValue, type DtcgTokenTree, type ExtremeValue, type FindToneForContrastOptions, type FindToneForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, GLAZE_EXPORT_VERSION, type GlazeColorCssOptions, type GlazeColorDtcgResolverOptions, type GlazeColorDtcgResult, type GlazeColorFormat, type GlazeColorInput, type GlazeColorInputExport, type GlazeColorOverrides, type GlazeColorOverridesExport, type GlazeColorTailwindOptions, type GlazeColorToken, type GlazeColorTokenExport, type GlazeColorValue, type GlazeConfig, type GlazeConfigOverride, type GlazeConfigResolved, type GlazeCssOptions, type GlazeCssResult, type GlazeDtcgOptions, type GlazeDtcgResolverContextNames, type GlazeDtcgResolverDocument, type GlazeDtcgResolverOptions, type GlazeDtcgResult, type GlazeExportKind, type GlazeExportVersion, type GlazeExtendOptions, type GlazeFromInput, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExport, type GlazePaletteExportOptions, type GlazePaletteOptions, type GlazeShadowInput, type GlazeTailwindOptions, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type HueDeclaration, type HuePlan, type MinContrast, type MixColorDef, type OkhslColor, type OkhstColor, type OklchColor, type Polarity, REF_EPS, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type ResolvedContrast, type RgbColor, type Role, type RoleInput, type ShadowColorDef, type ShadowTuning, type ToneValue, type ToneWindow, apcaContrast, assertAllPastel, assertNativeFormat, contrastRatioFromLuminance, cuspLightness, findToneForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOkhst, formatOklch, formatRgb, fromTone, gamutClampedLuminance, glaze, hslToSrgb, inferRoleFromName, isColorTokenExport, isPaletteExport, isThemeExport, normalizeRole, okhslToLinearSrgb, okhslToOkhst, okhslToOklab, okhslToOklch, okhslToSrgb, okhstToOkhsl, oklabToOkhsl, oppositeRole, parseHex, parseHexAlpha, relativeLuminanceFromLinearRgb, resolveApcaTarget, resolveContrastForMode, resolveMinContrast, roleToPolarity, srgbToHex, srgbToOkhsl, toTone, toneFromY, variantToOkhsl, yFromTone };
1571
1636
  //# sourceMappingURL=index.d.mts.map