@cognitap/radiant 0.0.3 → 0.0.5

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.
Files changed (118) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +28 -15
  3. package/dist/library/Card.d.ts.map +1 -1
  4. package/dist/library/Card.js +8 -6
  5. package/dist/library/Card.js.map +1 -1
  6. package/dist/library/Checkbox.js +2 -2
  7. package/dist/library/Checkbox.js.map +1 -1
  8. package/dist/library/Collapsible.d.ts.map +1 -1
  9. package/dist/library/Collapsible.js +5 -4
  10. package/dist/library/Collapsible.js.map +1 -1
  11. package/dist/library/Dialog.d.ts.map +1 -1
  12. package/dist/library/Dialog.js +8 -6
  13. package/dist/library/Dialog.js.map +1 -1
  14. package/dist/library/Field.js +4 -4
  15. package/dist/library/Field.js.map +1 -1
  16. package/dist/library/Input.d.ts.map +1 -1
  17. package/dist/library/Input.js +4 -3
  18. package/dist/library/Input.js.map +1 -1
  19. package/dist/library/Link.d.ts.map +1 -1
  20. package/dist/library/Link.js +0 -1
  21. package/dist/library/Link.js.map +1 -1
  22. package/dist/library/RadioGroup.js +2 -2
  23. package/dist/library/RadioGroup.js.map +1 -1
  24. package/dist/library/ThemeScope.js +1 -1
  25. package/dist/library/ThemeScope.js.map +1 -1
  26. package/dist/library/actionStyles.js +2 -2
  27. package/dist/library/actionStyles.js.map +1 -1
  28. package/dist/library/cn.d.ts +2 -1
  29. package/dist/library/cn.d.ts.map +1 -1
  30. package/dist/library/cn.js +22 -1
  31. package/dist/library/cn.js.map +1 -1
  32. package/dist/library/color/colorFamilies.d.ts +3 -0
  33. package/dist/library/color/colorFamilies.d.ts.map +1 -0
  34. package/dist/library/color/colorFamilies.js +20 -0
  35. package/dist/library/color/colorFamilies.js.map +1 -0
  36. package/dist/library/color/generateColorWall.d.ts +54 -0
  37. package/dist/library/color/generateColorWall.d.ts.map +1 -0
  38. package/dist/library/color/generateColorWall.js +231 -0
  39. package/dist/library/color/generateColorWall.js.map +1 -0
  40. package/dist/library/color/index.d.ts +5 -0
  41. package/dist/library/color/index.d.ts.map +1 -0
  42. package/dist/library/color/index.js +3 -0
  43. package/dist/library/color/index.js.map +1 -0
  44. package/dist/library/color/oklch.d.ts +17 -0
  45. package/dist/library/color/oklch.d.ts.map +1 -0
  46. package/dist/library/color/oklch.js +79 -0
  47. package/dist/library/color/oklch.js.map +1 -0
  48. package/dist/library/color/recommendColorPalette.d.ts +65 -0
  49. package/dist/library/color/recommendColorPalette.d.ts.map +1 -0
  50. package/dist/library/color/recommendColorPalette.js +263 -0
  51. package/dist/library/color/recommendColorPalette.js.map +1 -0
  52. package/dist/library/index.d.ts +10 -2
  53. package/dist/library/index.d.ts.map +1 -1
  54. package/dist/library/index.js +5 -1
  55. package/dist/library/index.js.map +1 -1
  56. package/dist/library/styles.css +1 -1
  57. package/dist/library/themes/defineTheme.d.ts.map +1 -1
  58. package/dist/library/themes/defineTheme.js +5 -1
  59. package/dist/library/themes/defineTheme.js.map +1 -1
  60. package/dist/library/themes/index.d.ts +4 -0
  61. package/dist/library/themes/index.d.ts.map +1 -1
  62. package/dist/library/themes/index.js +2 -0
  63. package/dist/library/themes/index.js.map +1 -1
  64. package/dist/library/themes/themeDocument.d.ts +16 -0
  65. package/dist/library/themes/themeDocument.d.ts.map +1 -0
  66. package/dist/library/themes/themeDocument.js +332 -0
  67. package/dist/library/themes/themeDocument.js.map +1 -0
  68. package/dist/library/themes/themeDocumentTypes.d.ts +80 -0
  69. package/dist/library/themes/themeDocumentTypes.d.ts.map +1 -0
  70. package/dist/library/themes/themeDocumentTypes.js +2 -0
  71. package/dist/library/themes/themeDocumentTypes.js.map +1 -0
  72. package/dist/library/themes/tokens.d.ts +7 -0
  73. package/dist/library/themes/tokens.d.ts.map +1 -1
  74. package/dist/library/themes/tokens.js +99 -0
  75. package/dist/library/themes/tokens.js.map +1 -1
  76. package/dist/library/themes/updateThemeAppearance.d.ts +29 -0
  77. package/dist/library/themes/updateThemeAppearance.d.ts.map +1 -0
  78. package/dist/library/themes/updateThemeAppearance.js +138 -0
  79. package/dist/library/themes/updateThemeAppearance.js.map +1 -0
  80. package/dist/library/typography/index.d.ts +72 -0
  81. package/dist/library/typography/index.d.ts.map +1 -0
  82. package/dist/library/typography/index.js +160 -0
  83. package/dist/library/typography/index.js.map +1 -0
  84. package/dist/library/typography/types.d.ts +78 -0
  85. package/dist/library/typography/types.d.ts.map +1 -0
  86. package/dist/library/typography/types.js +2 -0
  87. package/dist/library/typography/types.js.map +1 -0
  88. package/docs/system.md +20 -0
  89. package/docs/theming.md +616 -0
  90. package/package.json +17 -5
  91. package/src/Card.tsx +8 -6
  92. package/src/Checkbox.tsx +2 -2
  93. package/src/Collapsible.tsx +5 -4
  94. package/src/Dialog.tsx +8 -6
  95. package/src/Field.tsx +4 -4
  96. package/src/Input.tsx +4 -3
  97. package/src/Link.tsx +0 -1
  98. package/src/RadioGroup.tsx +2 -2
  99. package/src/ThemeScope.tsx +1 -1
  100. package/src/actionStyles.ts +2 -2
  101. package/src/cn.ts +25 -1
  102. package/src/color/colorFamilies.ts +19 -0
  103. package/src/color/generateColorWall.ts +358 -0
  104. package/src/color/index.ts +11 -0
  105. package/src/color/oklch.ts +95 -0
  106. package/src/color/recommendColorPalette.ts +375 -0
  107. package/src/index.ts +40 -0
  108. package/src/styles.css +1 -0
  109. package/src/themes/baseline.css +131 -0
  110. package/src/themes/defineTheme.ts +5 -1
  111. package/src/themes/index.ts +25 -0
  112. package/src/themes/themeDocument.ts +370 -0
  113. package/src/themes/themeDocumentTypes.ts +88 -0
  114. package/src/themes/tokens.ts +137 -0
  115. package/src/themes/updateThemeAppearance.ts +172 -0
  116. package/src/typography/index.ts +199 -0
  117. package/src/typography/types.ts +92 -0
  118. package/src/typography.css +336 -0
@@ -0,0 +1,231 @@
1
+ import { colorFamilies as families } from './colorFamilies.js';
2
+ import { freezeTree } from '../themes/tokens.js';
3
+ import { clamp, hueDifference, measureHex, srgbMapper, wrapHue } from './oklch.js';
4
+ /** Stable IDs for independently choosing the full wall and exact-brand ramp. */
5
+ export const colorCalibrationPresets = freezeTree([
6
+ {
7
+ id: 'classic',
8
+ name: 'Classic',
9
+ description: 'Original hue-aware curves and linear anchor reshaping.'
10
+ },
11
+ {
12
+ id: 'balanced',
13
+ name: 'Balanced',
14
+ description: 'Restrained brand shades, coordinated families and smooth anchor reshaping.'
15
+ },
16
+ {
17
+ id: 'expressive',
18
+ name: 'Expressive',
19
+ description: 'Fuller color families and a more vivid, smoothly reshaped brand ramp.'
20
+ }
21
+ ]);
22
+ const profiles = {
23
+ classic: {
24
+ center: 0.7,
25
+ slope: 0.7,
26
+ low: 0.6,
27
+ high: 0.86,
28
+ exponent: 1,
29
+ cap: 0.255,
30
+ envelope: 0.8,
31
+ tint: 0.012,
32
+ alignment: 0.6,
33
+ radius: 2.2
34
+ },
35
+ balanced: {
36
+ center: 0.7,
37
+ slope: 0.75,
38
+ low: 0.62,
39
+ high: 0.9,
40
+ exponent: 0.95,
41
+ cap: 0.26,
42
+ envelope: 0.4,
43
+ tint: 0.008,
44
+ alignment: 0.25,
45
+ radius: 2.2
46
+ },
47
+ expressive: {
48
+ center: 0.62,
49
+ slope: 0.9,
50
+ low: 0.6,
51
+ high: 0.92,
52
+ exponent: 1.05,
53
+ cap: 0.32,
54
+ envelope: 0.3,
55
+ tint: 0.016,
56
+ alignment: 0.5,
57
+ radius: 2.6
58
+ }
59
+ };
60
+ const stops = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
61
+ const lightness = [0.985, 0.965, 0.93, 0.87, 0.79, 0.7, 0.61, 0.52, 0.43, 0.34, 0.24];
62
+ function option(value, fallback, allowed, key) {
63
+ if (value === undefined)
64
+ return fallback;
65
+ if (!allowed.includes(value))
66
+ throw new TypeError(`colorWall.${key} must be one of: ${allowed.join(', ')}.`);
67
+ return value;
68
+ }
69
+ function number(value, fallback, low, high, key) {
70
+ if (value === undefined)
71
+ return fallback;
72
+ if (typeof value !== 'number' || !Number.isFinite(value) || value < low || value > high) {
73
+ throw new TypeError(`colorWall.${key} must be a finite number from ${low} to ${high}.`);
74
+ }
75
+ return value === 0 ? 0 : value;
76
+ }
77
+ /** Three-point monotone Hermite mapping; endpoints also cover exact black/white. */
78
+ function reshapeLightness(x0, x1, x2, y0, y1, y2, x, endpoint) {
79
+ if (endpoint)
80
+ return y0 + ((x - x0) / (x2 - x0)) * (y2 - y0);
81
+ const h0 = x1 - x0, h1 = x2 - x1;
82
+ const d0 = (y1 - y0) / h0, d1 = (y2 - y1) / h1;
83
+ const m0 = clamp(((2 * h0 + h1) * d0 - h0 * d1) / (h0 + h1), 0, 3 * d0);
84
+ const m2 = clamp(((2 * h1 + h0) * d1 - h1 * d0) / (h0 + h1), 0, 3 * d1);
85
+ const w1 = 2 * h1 + h0, w2 = h1 + 2 * h0;
86
+ const m1 = d0 <= 0 || d1 <= 0 ? 0 : (w1 + w2) / (w1 / d0 + w2 / d1);
87
+ const upper = x > x1;
88
+ const lo = upper ? x1 : x0, hi = upper ? x2 : x1;
89
+ const a = upper ? y1 : y0, b = upper ? y2 : y1;
90
+ const ma = upper ? m1 : m0, mb = upper ? m2 : m1;
91
+ const t = clamp((x - lo) / (hi - lo)), span = hi - lo;
92
+ return ((2 * t ** 3 - 3 * t ** 2 + 1) * a +
93
+ (t ** 3 - 2 * t ** 2 + t) * span * ma +
94
+ (-2 * t ** 3 + 3 * t ** 2) * b +
95
+ (t ** 3 - t ** 2) * span * mb);
96
+ }
97
+ /** Deterministic, sRGB-first calibration v1. No browser, React, AI or semantic-role selection. */
98
+ export function generateColorWall(input) {
99
+ if (!input || typeof input !== 'object' || Array.isArray(input))
100
+ throw new TypeError('colorWall input must be an object.');
101
+ const allowed = [
102
+ 'version',
103
+ 'brand',
104
+ 'gamut',
105
+ 'fidelity',
106
+ 'wallPreset',
107
+ 'rampPreset',
108
+ 'vividness',
109
+ 'brandVividness',
110
+ 'lightness',
111
+ 'distribution',
112
+ 'neutralTint',
113
+ 'hueAlignment',
114
+ 'neutralHue'
115
+ ];
116
+ for (const key of Object.keys(input)) {
117
+ if (!allowed.includes(key))
118
+ throw new TypeError(`Unknown colorWall input: ${key}.`);
119
+ }
120
+ if (typeof input.brand !== 'string' || !/^#[0-9a-f]{6}$/i.test(input.brand)) {
121
+ throw new TypeError('colorWall.brand must be an opaque six-digit sRGB hex color, such as #7C3AED. Alpha and wide-gamut sources are not supported by version 1.');
122
+ }
123
+ const source = measureHex(input.brand), mapper = srgbMapper();
124
+ const neutralInput = source.C < 0.02;
125
+ const wallPreset = option(input.wallPreset, 'balanced', ['classic', 'balanced', 'expressive'], 'wallPreset');
126
+ const rampPreset = option(input.rampPreset, 'balanced', ['classic', 'balanced', 'expressive'], 'rampPreset');
127
+ const wallProfile = profiles[wallPreset], brandProfile = profiles[rampPreset];
128
+ const mood = Math.sqrt(clamp(source.C / 0.28));
129
+ const classicVividness = neutralInput
130
+ ? 0.35
131
+ : clamp(source.C / Math.max(0.001, mapper.maxChroma(source.L, source.h)), 0.1, 0.92);
132
+ const settings = {
133
+ version: option(input.version, 1, [1], 'version'),
134
+ brand: input.brand,
135
+ gamut: option(input.gamut, 'srgb', ['srgb'], 'gamut'),
136
+ fidelity: option(input.fidelity, 'anchored', ['anchored', 'unanchored'], 'fidelity'),
137
+ wallPreset,
138
+ rampPreset,
139
+ vividness: number(input.vividness, wallPreset === 'classic'
140
+ ? classicVividness
141
+ : wallPreset === 'balanced'
142
+ ? 0.45 + 0.4 * mood
143
+ : 0.6 + 0.3 * mood, 0, 1, 'vividness'),
144
+ brandVividness: number(input.brandVividness, rampPreset === 'classic'
145
+ ? classicVividness
146
+ : rampPreset === 'balanced'
147
+ ? 0.18 + 0.65 * mood
148
+ : 0.28 + 0.62 * mood, 0, 1, 'brandVividness'),
149
+ lightness: option(input.lightness, 'hue-aware', ['hue-aware', 'shared'], 'lightness'),
150
+ distribution: number(input.distribution, 1, 0.75, 1.35, 'distribution'),
151
+ neutralTint: number(input.neutralTint, wallProfile.tint, 0, 0.035, 'neutralTint'),
152
+ hueAlignment: number(input.hueAlignment, wallProfile.alignment, 0, 1, 'hueAlignment'),
153
+ neutralHue: wrapHue(number(input.neutralHue, 255, -Number.MAX_VALUE, Number.MAX_VALUE, 'neutralHue'))
154
+ };
155
+ const hue = neutralInput ? settings.neutralHue : source.h;
156
+ const nearestFamily = families.reduce((a, b) => Math.abs(hueDifference(hue, a[1])) < Math.abs(hueDifference(hue, b[1])) ? a : b);
157
+ const rotation = hueDifference(hue, nearestFamily[1]) * settings.hueAlignment;
158
+ function tone(base, h, profile) {
159
+ const middle = settings.lightness === 'shared'
160
+ ? 0.7
161
+ : clamp(profile.center + profile.slope * (mapper.cuspLightness(h) - profile.center), profile.low, profile.high);
162
+ return base >= 0.7
163
+ ? middle +
164
+ (0.985 - middle) *
165
+ ((base - 0.7) / (0.985 - 0.7)) ** (settings.distribution * profile.exponent)
166
+ : middle -
167
+ (middle - 0.24) *
168
+ ((0.7 - base) / (0.7 - 0.24)) ** (settings.distribution * profile.exponent);
169
+ }
170
+ function ramp(h, kind, profile = wallProfile, strength = settings.vividness) {
171
+ return lightness.map((base, i) => {
172
+ const L = kind === 'chromatic' ? tone(base, h, profile) : base;
173
+ const envelope = Math.sin(Math.PI * (1 - L));
174
+ const C = kind === 'neutral'
175
+ ? settings.neutralTint * envelope ** 0.8
176
+ : kind === 'achromatic'
177
+ ? 0
178
+ : Math.min(mapper.maxChroma(L, h) * strength, profile.cap * envelope ** profile.envelope);
179
+ return { ...mapper.map(L, C, h), stop: stops[i] };
180
+ });
181
+ }
182
+ const regular = ramp(hue, neutralInput ? 'achromatic' : 'chromatic', brandProfile, settings.brandVividness);
183
+ const closest = regular.reduce((a, b) => Math.abs(a.L - source.L) <= Math.abs(b.L - source.L) ? a : b);
184
+ const anchor = regular.indexOf(closest);
185
+ const brand = regular.map((color, i) => {
186
+ if (settings.fidelity === 'unanchored')
187
+ return color;
188
+ if (i === anchor)
189
+ return { ...source, stop: stops[i] };
190
+ const top = Math.max(regular[0].L, source.L), bottom = Math.min(regular.at(-1).L, source.L);
191
+ const L = settings.rampPreset === 'classic'
192
+ ? i < anchor
193
+ ? source.L + ((top - source.L) * (color.L - closest.L)) / (regular[0].L - closest.L)
194
+ : source.L -
195
+ ((source.L - bottom) * (closest.L - color.L)) / (closest.L - regular.at(-1).L)
196
+ : reshapeLightness(regular.at(-1).L, closest.L, regular[0].L, bottom, source.L, top, color.L, anchor === 0 || anchor === regular.length - 1);
197
+ const weight = Math.exp(-(((i - anchor) / brandProfile.radius) ** 2));
198
+ const C = settings.rampPreset === 'classic'
199
+ ? Math.max(0, color.C + (source.C - closest.C) * weight)
200
+ : neutralInput
201
+ ? 0
202
+ : mapper.maxChroma(L, hue) *
203
+ clamp((color.C / Math.max(0.001, mapper.maxChroma(color.L, hue))) * (1 - weight) +
204
+ (source.C / Math.max(0.001, mapper.maxChroma(source.L, hue))) * weight);
205
+ return { ...mapper.map(L, C, hue), stop: color.stop };
206
+ });
207
+ function palette(name, colors) {
208
+ return {
209
+ id: name.toLowerCase(),
210
+ name,
211
+ swatches: colors.map(({ stop, value }) => ({ stop, value }))
212
+ };
213
+ }
214
+ return freezeTree({
215
+ input: settings,
216
+ neutralInput,
217
+ color: {
218
+ brand: { value: input.brand, gamut: 'srgb' },
219
+ fidelity: settings.fidelity,
220
+ ...(settings.fidelity === 'anchored'
221
+ ? { anchor: { paletteId: 'brand', stop: stops[anchor] } }
222
+ : {}),
223
+ palettes: [
224
+ palette('Brand', brand),
225
+ ...families.map(([name, h]) => palette(name, ramp(wrapHue(h + rotation), 'chromatic'))),
226
+ palette('Neutral', ramp(hue, 'neutral'))
227
+ ]
228
+ }
229
+ });
230
+ }
231
+ //# sourceMappingURL=generateColorWall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateColorWall.js","sourceRoot":"","sources":["../../../src/color/generateColorWall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE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AAY;QACZ,KAAK,EAAE;YACL,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,MAAe,EAAE;YACrD,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,GAAG,CAAC,QAAQ,CAAC,QAAQ,KAAK,UAAU;gBAClC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE;gBACzD,CAAC,CAAC,EAAE,CAAC;YACP,QAAQ,EAAE;gBACR,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC;gBACvB,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;gBACvF,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;aACzC;SACF;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { colorFamilies as families } from './colorFamilies.js'\nimport type {\n ThemeBrandSource,\n ThemeColorSection,\n ThemePalette\n} from '../themes/themeDocumentTypes.js'\nimport { freezeTree } from '../themes/tokens.js'\nimport { clamp, hueDifference, measureHex, srgbMapper, wrapHue } from './oklch.js'\n\nexport type ColorCalibrationPreset = 'classic' | 'balanced' | 'expressive'\n/** Stable IDs for independently choosing the full wall and exact-brand ramp. */\nexport const colorCalibrationPresets = freezeTree([\n {\n id: 'classic',\n name: 'Classic',\n description: 'Original hue-aware curves and linear anchor reshaping.'\n },\n {\n id: 'balanced',\n name: 'Balanced',\n description: 'Restrained brand shades, coordinated families and smooth anchor reshaping.'\n },\n {\n id: 'expressive',\n name: 'Expressive',\n description: 'Fuller color families and a more vivid, smoothly reshaped brand ramp.'\n }\n] as const)\nconst profiles = {\n classic: {\n center: 0.7,\n slope: 0.7,\n low: 0.6,\n high: 0.86,\n exponent: 1,\n cap: 0.255,\n envelope: 0.8,\n tint: 0.012,\n alignment: 0.6,\n radius: 2.2\n },\n balanced: {\n center: 0.7,\n slope: 0.75,\n low: 0.62,\n high: 0.9,\n exponent: 0.95,\n cap: 0.26,\n envelope: 0.4,\n tint: 0.008,\n alignment: 0.25,\n radius: 2.2\n },\n expressive: {\n center: 0.62,\n slope: 0.9,\n low: 0.6,\n high: 0.92,\n exponent: 1.05,\n cap: 0.32,\n envelope: 0.3,\n tint: 0.016,\n alignment: 0.5,\n radius: 2.6\n }\n} as const\n\nexport interface ColorWallInput {\n readonly version?: 1\n /** Original opaque six-digit sRGB hex; retained verbatim at the exact anchor. */\n readonly brand: string\n readonly gamut?: 'srgb'\n readonly fidelity?: 'anchored' | 'unanchored'\n /** Independently select coordinated families and the brand ramp. Both default to balanced. */\n readonly wallPreset?: ColorCalibrationPreset\n readonly rampPreset?: ColorCalibrationPreset\n /** 0–1 wall chroma. Omit to derive restraint from the source. */\n readonly vividness?: number\n /** 0–1 brand-ramp chroma, independent of wall vividness; never changes the exact anchor. */\n readonly brandVividness?: number\n readonly lightness?: 'hue-aware' | 'shared'\n /** 0.75–1.35. */\n readonly distribution?: number\n /** 0–0.035 peak OKLCH chroma. */\n readonly neutralTint?: number\n /** 0–1 alignment of the nearest named hue family toward the brand. */\n readonly hueAlignment?: number\n /** Finite degrees, wrapped to [0, 360); used when source C < 0.02. */\n readonly neutralHue?: number\n}\nexport interface ColorWall {\n /** Materialised, JSON-safe inputs; replay with generateColorWall(wall.input). */\n readonly input: Required<ColorWallInput>\n readonly neutralInput: boolean\n /** Color authoring data; semantic values and modes remain independently owned. */\n readonly color: {\n readonly brand: ThemeBrandSource\n readonly fidelity: 'anchored' | 'unanchored'\n readonly palettes: readonly ThemePalette[]\n readonly anchor?: ThemeColorSection['anchor']\n }\n}\n\nconst stops = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950] as const\nconst lightness = [0.985, 0.965, 0.93, 0.87, 0.79, 0.7, 0.61, 0.52, 0.43, 0.34, 0.24]\n\nfunction option<T>(value: unknown, fallback: T, allowed: readonly T[], key: string): T {\n if (value === undefined) return fallback\n if (!allowed.includes(value as T))\n throw new TypeError(`colorWall.${key} must be one of: ${allowed.join(', ')}.`)\n return value as T\n}\nfunction number(value: unknown, fallback: number, low: number, high: number, key: string): number {\n if (value === undefined) return fallback\n if (typeof value !== 'number' || !Number.isFinite(value) || value < low || value > high) {\n throw new TypeError(`colorWall.${key} must be a finite number from ${low} to ${high}.`)\n }\n return value === 0 ? 0 : value\n}\n\n/** Three-point monotone Hermite mapping; endpoints also cover exact black/white. */\nfunction reshapeLightness(\n x0: number,\n x1: number,\n x2: number,\n y0: number,\n y1: number,\n y2: number,\n x: number,\n endpoint: boolean\n) {\n if (endpoint) return y0 + ((x - x0) / (x2 - x0)) * (y2 - y0)\n const h0 = x1 - x0,\n h1 = x2 - x1\n const d0 = (y1 - y0) / h0,\n d1 = (y2 - y1) / h1\n const m0 = clamp(((2 * h0 + h1) * d0 - h0 * d1) / (h0 + h1), 0, 3 * d0)\n const m2 = clamp(((2 * h1 + h0) * d1 - h1 * d0) / (h0 + h1), 0, 3 * d1)\n const w1 = 2 * h1 + h0,\n w2 = h1 + 2 * h0\n const m1 = d0 <= 0 || d1 <= 0 ? 0 : (w1 + w2) / (w1 / d0 + w2 / d1)\n const upper = x > x1\n const lo = upper ? x1 : x0,\n hi = upper ? x2 : x1\n const a = upper ? y1 : y0,\n b = upper ? y2 : y1\n const ma = upper ? m1 : m0,\n mb = upper ? m2 : m1\n const t = clamp((x - lo) / (hi - lo)),\n span = hi - lo\n return (\n (2 * t ** 3 - 3 * t ** 2 + 1) * a +\n (t ** 3 - 2 * t ** 2 + t) * span * ma +\n (-2 * t ** 3 + 3 * t ** 2) * b +\n (t ** 3 - t ** 2) * span * mb\n )\n}\n\n/** Deterministic, sRGB-first calibration v1. No browser, React, AI or semantic-role selection. */\nexport function generateColorWall(input: ColorWallInput): ColorWall {\n if (!input || typeof input !== 'object' || Array.isArray(input))\n throw new TypeError('colorWall input must be an object.')\n const allowed = [\n 'version',\n 'brand',\n 'gamut',\n 'fidelity',\n 'wallPreset',\n 'rampPreset',\n 'vividness',\n 'brandVividness',\n 'lightness',\n 'distribution',\n 'neutralTint',\n 'hueAlignment',\n 'neutralHue'\n ]\n for (const key of Object.keys(input)) {\n if (!allowed.includes(key)) throw new TypeError(`Unknown colorWall input: ${key}.`)\n }\n if (typeof input.brand !== 'string' || !/^#[0-9a-f]{6}$/i.test(input.brand)) {\n throw new TypeError(\n 'colorWall.brand must be an opaque six-digit sRGB hex color, such as #7C3AED. Alpha and wide-gamut sources are not supported by version 1.'\n )\n }\n const source = measureHex(input.brand),\n mapper = srgbMapper()\n const neutralInput = source.C < 0.02\n const wallPreset = option(\n input.wallPreset,\n 'balanced',\n ['classic', 'balanced', 'expressive'] as const,\n 'wallPreset'\n )\n const rampPreset = option(\n input.rampPreset,\n 'balanced',\n ['classic', 'balanced', 'expressive'] as const,\n 'rampPreset'\n )\n const wallProfile = profiles[wallPreset],\n brandProfile = profiles[rampPreset]\n const mood = Math.sqrt(clamp(source.C / 0.28))\n const classicVividness = neutralInput\n ? 0.35\n : clamp(source.C / Math.max(0.001, mapper.maxChroma(source.L, source.h)), 0.1, 0.92)\n const settings: Required<ColorWallInput> = {\n version: option(input.version, 1, [1], 'version'),\n brand: input.brand,\n gamut: option(input.gamut, 'srgb', ['srgb'], 'gamut'),\n fidelity: option(input.fidelity, 'anchored', ['anchored', 'unanchored'], 'fidelity'),\n wallPreset,\n rampPreset,\n vividness: number(\n input.vividness,\n wallPreset === 'classic'\n ? classicVividness\n : wallPreset === 'balanced'\n ? 0.45 + 0.4 * mood\n : 0.6 + 0.3 * mood,\n 0,\n 1,\n 'vividness'\n ),\n brandVividness: number(\n input.brandVividness,\n rampPreset === 'classic'\n ? classicVividness\n : rampPreset === 'balanced'\n ? 0.18 + 0.65 * mood\n : 0.28 + 0.62 * mood,\n 0,\n 1,\n 'brandVividness'\n ),\n lightness: option(input.lightness, 'hue-aware', ['hue-aware', 'shared'], 'lightness'),\n distribution: number(input.distribution, 1, 0.75, 1.35, 'distribution'),\n neutralTint: number(input.neutralTint, wallProfile.tint, 0, 0.035, 'neutralTint'),\n hueAlignment: number(input.hueAlignment, wallProfile.alignment, 0, 1, 'hueAlignment'),\n neutralHue: wrapHue(\n number(input.neutralHue, 255, -Number.MAX_VALUE, Number.MAX_VALUE, 'neutralHue')\n )\n }\n const hue = neutralInput ? settings.neutralHue : source.h\n const nearestFamily = families.reduce((a, b) =>\n Math.abs(hueDifference(hue, a[1])) < Math.abs(hueDifference(hue, b[1])) ? a : b\n )\n const rotation = hueDifference(hue, nearestFamily[1]) * settings.hueAlignment\n function tone(\n base: number,\n h: number,\n profile: (typeof profiles)[ColorCalibrationPreset]\n ): number {\n const middle =\n settings.lightness === 'shared'\n ? 0.7\n : clamp(\n profile.center + profile.slope * (mapper.cuspLightness(h) - profile.center),\n profile.low,\n profile.high\n )\n return base >= 0.7\n ? middle +\n (0.985 - middle) *\n ((base - 0.7) / (0.985 - 0.7)) ** (settings.distribution * profile.exponent)\n : middle -\n (middle - 0.24) *\n ((0.7 - base) / (0.7 - 0.24)) ** (settings.distribution * profile.exponent)\n }\n function ramp(\n h: number,\n kind: 'chromatic' | 'neutral' | 'achromatic',\n profile = wallProfile,\n strength = settings.vividness\n ) {\n return lightness.map((base, i) => {\n const L = kind === 'chromatic' ? tone(base, h, profile) : base\n const envelope = Math.sin(Math.PI * (1 - L))\n const C =\n kind === 'neutral'\n ? settings.neutralTint * envelope ** 0.8\n : kind === 'achromatic'\n ? 0\n : Math.min(\n mapper.maxChroma(L, h) * strength,\n profile.cap * envelope ** profile.envelope\n )\n return { ...mapper.map(L, C, h), stop: stops[i] }\n })\n }\n const regular = ramp(\n hue,\n neutralInput ? 'achromatic' : 'chromatic',\n brandProfile,\n settings.brandVividness\n )\n const closest = regular.reduce((a, b) =>\n Math.abs(a.L - source.L) <= Math.abs(b.L - source.L) ? a : b\n )\n const anchor = regular.indexOf(closest)\n const brand = regular.map((color, i) => {\n if (settings.fidelity === 'unanchored') return color\n if (i === anchor) return { ...source, stop: stops[i] }\n const top = Math.max(regular[0].L, source.L),\n bottom = Math.min(regular.at(-1)!.L, source.L)\n const L =\n settings.rampPreset === 'classic'\n ? i < anchor\n ? source.L + ((top - source.L) * (color.L - closest.L)) / (regular[0].L - closest.L)\n : source.L -\n ((source.L - bottom) * (closest.L - color.L)) / (closest.L - regular.at(-1)!.L)\n : reshapeLightness(\n regular.at(-1)!.L,\n closest.L,\n regular[0].L,\n bottom,\n source.L,\n top,\n color.L,\n anchor === 0 || anchor === regular.length - 1\n )\n const weight = Math.exp(-(((i - anchor) / brandProfile.radius) ** 2))\n const C =\n settings.rampPreset === 'classic'\n ? Math.max(0, color.C + (source.C - closest.C) * weight)\n : neutralInput\n ? 0\n : mapper.maxChroma(L, hue) *\n clamp(\n (color.C / Math.max(0.001, mapper.maxChroma(color.L, hue))) * (1 - weight) +\n (source.C / Math.max(0.001, mapper.maxChroma(source.L, hue))) * weight\n )\n return { ...mapper.map(L, C, hue), stop: color.stop }\n })\n function palette(name: string, colors: typeof regular): ThemePalette {\n return {\n id: name.toLowerCase(),\n name,\n swatches: colors.map(({ stop, value }) => ({ stop, value }))\n }\n }\n return freezeTree({\n input: settings,\n neutralInput,\n color: {\n brand: { value: input.brand, gamut: 'srgb' as const },\n fidelity: settings.fidelity,\n ...(settings.fidelity === 'anchored'\n ? { anchor: { paletteId: 'brand', stop: stops[anchor] } }\n : {}),\n palettes: [\n palette('Brand', brand),\n ...families.map(([name, h]) => palette(name, ramp(wrapHue(h + rotation), 'chromatic'))),\n palette('Neutral', ramp(hue, 'neutral'))\n ]\n }\n })\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export { generateColorWall, colorCalibrationPresets } from './generateColorWall.js';
2
+ export type { ColorWall, ColorWallInput, ColorCalibrationPreset } from './generateColorWall.js';
3
+ export { recommendColorPalette } from './recommendColorPalette.js';
4
+ export type { ColorPalette, ColorPaletteOptions, PaletteModeColors, PaletteColorPair, PaletteContrastCheck, WorkingPaletteRole } from './recommendColorPalette.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/color/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AACnF,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,YAAY,EACV,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,4BAA4B,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { generateColorWall, colorCalibrationPresets } from './generateColorWall.js';
2
+ export { recommendColorPalette } from './recommendColorPalette.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/color/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AAEnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA","sourcesContent":["export { generateColorWall, colorCalibrationPresets } from './generateColorWall.js'\nexport type { ColorWall, ColorWallInput, ColorCalibrationPreset } from './generateColorWall.js'\nexport { recommendColorPalette } from './recommendColorPalette.js'\nexport type {\n ColorPalette,\n ColorPaletteOptions,\n PaletteModeColors,\n PaletteColorPair,\n PaletteContrastCheck,\n WorkingPaletteRole\n} from './recommendColorPalette.js'\n"]}
@@ -0,0 +1,17 @@
1
+ export interface OklchColor {
2
+ readonly value: string;
3
+ readonly L: number;
4
+ readonly C: number;
5
+ readonly h: number;
6
+ }
7
+ export declare const clamp: (n: number, low?: number, high?: number) => number;
8
+ export declare const wrapHue: (h: number) => number;
9
+ export declare const hueDifference: (a: number, b: number) => number;
10
+ export declare function measureHex(hex: string): OklchColor;
11
+ /** Per-generation caches: bounded by this wall, without history-dependent global state. */
12
+ export declare function srgbMapper(): {
13
+ maxChroma: (L: number, h: number) => number;
14
+ cuspLightness: (h: number) => number;
15
+ map: (L: number, C: number, h: number) => OklchColor;
16
+ };
17
+ //# sourceMappingURL=oklch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oklch.d.ts","sourceRoot":"","sources":["../../../src/color/oklch.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;CACnB;AACD,eAAO,MAAM,KAAK,GAAI,GAAG,MAAM,EAAE,YAAO,EAAE,aAAQ,WAAqC,CAAA;AACvF,eAAO,MAAM,OAAO,GAAI,GAAG,MAAM,WAA4B,CAAA;AAC7D,eAAO,MAAM,aAAa,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,WAA+B,CAAA;AAKjF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAUlD;AAgBD,2FAA2F;AAC3F,wBAAgB,UAAU;mBAGF,MAAM,KAAK,MAAM,KAAG,MAAM;uBAetB,MAAM,KAAG,MAAM;aAiBzB,MAAM,KAAK,MAAM,KAAK,MAAM,KAAG,UAAU;EAe1D"}
@@ -0,0 +1,79 @@
1
+ export const clamp = (n, low = 0, high = 1) => Math.max(low, Math.min(high, n));
2
+ export const wrapHue = (h) => ((h % 360) + 360) % 360;
3
+ export const hueDifference = (a, b) => wrapHue(a - b + 180) - 180;
4
+ const linear = (n) => (n <= 0.04045 ? n / 12.92 : ((n + 0.055) / 1.055) ** 2.4);
5
+ const encoded = (n) => n <= 0.0031308 ? 12.92 * n : 1.055 * Math.max(0, n) ** (1 / 2.4) - 0.055;
6
+ export function measureHex(hex) {
7
+ const [r, g, b] = [1, 3, 5].map(i => linear(parseInt(hex.slice(i, i + 2), 16) / 255));
8
+ const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
9
+ const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
10
+ const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
11
+ const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s;
12
+ const a = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;
13
+ const bAxis = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;
14
+ const C = Math.hypot(a, bAxis);
15
+ return { value: hex, L, C, h: C < 1e-6 ? 0 : wrapHue((Math.atan2(bAxis, a) * 180) / Math.PI) };
16
+ }
17
+ function linearRgb(L, C, h) {
18
+ const angle = (h * Math.PI) / 180;
19
+ const a = C * Math.cos(angle), b = C * Math.sin(angle);
20
+ const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
21
+ const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
22
+ const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
23
+ return [
24
+ 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
25
+ -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
26
+ -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s
27
+ ];
28
+ }
29
+ /** Per-generation caches: bounded by this wall, without history-dependent global state. */
30
+ export function srgbMapper() {
31
+ const chromas = new Map(), cusps = new Map();
32
+ function maxChroma(L, h) {
33
+ if (L <= 0 || L >= 1)
34
+ return 0;
35
+ const key = `${L},${h}`;
36
+ const cached = chromas.get(key);
37
+ if (cached !== undefined)
38
+ return cached;
39
+ let low = 0, high = 0.5;
40
+ for (let i = 0; i < 25; i++) {
41
+ const mid = (low + high) / 2;
42
+ if (linearRgb(L, mid, h).every(n => n >= -1e-8 && n <= 1 + 1e-8))
43
+ low = mid;
44
+ else
45
+ high = mid;
46
+ }
47
+ chromas.set(key, low);
48
+ return low;
49
+ }
50
+ function cuspLightness(h) {
51
+ const cached = cusps.get(h);
52
+ if (cached !== undefined)
53
+ return cached;
54
+ let bestL = 0.7, bestC = 0;
55
+ // Fixed sample locations and tie order are part of algorithm version 1.
56
+ for (let i = 20; i <= 98; i++) {
57
+ const L = i / 100, C = maxChroma(L, h);
58
+ if (C > bestC) {
59
+ bestC = C;
60
+ bestL = L;
61
+ }
62
+ }
63
+ cusps.set(h, bestL);
64
+ return bestL;
65
+ }
66
+ function map(L, C, h) {
67
+ const rgb = linearRgb(clamp(L), Math.min(C, maxChroma(L, h)), h);
68
+ const value = '#' +
69
+ rgb
70
+ .map(n => Math.round(clamp(encoded(n)) * 255)
71
+ .toString(16)
72
+ .padStart(2, '0'))
73
+ .join('')
74
+ .toUpperCase();
75
+ return measureHex(value);
76
+ }
77
+ return { maxChroma, cuspLightness, map };
78
+ }
79
+ //# sourceMappingURL=oklch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oklch.js","sourceRoot":"","sources":["../../../src/color/oklch.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,GAAG,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AACvF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA;AAC7D,MAAM,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ACR,WAAW,EAAE,CAAA;QAClB,OAAO,UAAU,CAAC,KAAK,CAAC,CAAA;IAC1B,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,EAAE,CAAA;AAC1C,CAAC","sourcesContent":["// sRGB ↔ Oklab matrices: https://bottosson.github.io/posts/oklab/\n// Transfer functions: https://www.w3.org/TR/css-color-4/#color-conversion-code\n// This mapper deliberately reduces chroma at fixed L/h; it is not browser gamut mapping.\ntype Triple = readonly [number, number, number]\nexport interface OklchColor {\n readonly value: string\n readonly L: number\n readonly C: number\n readonly h: number\n}\nexport const clamp = (n: number, low = 0, high = 1) => Math.max(low, Math.min(high, n))\nexport const wrapHue = (h: number) => ((h % 360) + 360) % 360\nexport const hueDifference = (a: number, b: number) => wrapHue(a - b + 180) - 180\nconst linear = (n: number) => (n <= 0.04045 ? n / 12.92 : ((n + 0.055) / 1.055) ** 2.4)\nconst encoded = (n: number) =>\n n <= 0.0031308 ? 12.92 * n : 1.055 * Math.max(0, n) ** (1 / 2.4) - 0.055\n\nexport function measureHex(hex: string): OklchColor {\n const [r, g, b] = [1, 3, 5].map(i => linear(parseInt(hex.slice(i, i + 2), 16) / 255))\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b)\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b)\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b)\n const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s\n const a = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s\n const bAxis = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s\n const C = Math.hypot(a, bAxis)\n return { value: hex, L, C, h: C < 1e-6 ? 0 : wrapHue((Math.atan2(bAxis, a) * 180) / Math.PI) }\n}\n\nfunction linearRgb(L: number, C: number, h: number): Triple {\n const angle = (h * Math.PI) / 180\n const a = C * Math.cos(angle),\n b = C * Math.sin(angle)\n const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3\n const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3\n const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3\n return [\n 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s\n ]\n}\n\n/** Per-generation caches: bounded by this wall, without history-dependent global state. */\nexport function srgbMapper() {\n const chromas = new Map<string, number>(),\n cusps = new Map<number, number>()\n function maxChroma(L: number, h: number): number {\n if (L <= 0 || L >= 1) return 0\n const key = `${L},${h}`\n const cached = chromas.get(key)\n if (cached !== undefined) return cached\n let low = 0,\n high = 0.5\n for (let i = 0; i < 25; i++) {\n const mid = (low + high) / 2\n if (linearRgb(L, mid, h).every(n => n >= -1e-8 && n <= 1 + 1e-8)) low = mid\n else high = mid\n }\n chromas.set(key, low)\n return low\n }\n function cuspLightness(h: number): number {\n const cached = cusps.get(h)\n if (cached !== undefined) return cached\n let bestL = 0.7,\n bestC = 0\n // Fixed sample locations and tie order are part of algorithm version 1.\n for (let i = 20; i <= 98; i++) {\n const L = i / 100,\n C = maxChroma(L, h)\n if (C > bestC) {\n bestC = C\n bestL = L\n }\n }\n cusps.set(h, bestL)\n return bestL\n }\n function map(L: number, C: number, h: number): OklchColor {\n const rgb = linearRgb(clamp(L), Math.min(C, maxChroma(L, h)), h)\n const value =\n '#' +\n rgb\n .map(n =>\n Math.round(clamp(encoded(n)) * 255)\n .toString(16)\n .padStart(2, '0')\n )\n .join('')\n .toUpperCase()\n return measureHex(value)\n }\n return { maxChroma, cuspLightness, map }\n}\n"]}
@@ -0,0 +1,65 @@
1
+ import type { SharedTokens } from '../themes/tokens.js';
2
+ import type { ThemeColorSection } from '../themes/themeDocumentTypes.js';
3
+ import type { ColorWall } from './generateColorWall.js';
4
+ export type WorkingPaletteRole = 'primary' | 'support' | 'neutral' | 'success' | 'warning' | 'danger';
5
+ type Mode = 'light' | 'dark';
6
+ type Colors = Readonly<SharedTokens['color']>;
7
+ export type PaletteModeColors = Colors & {
8
+ readonly canvas: string;
9
+ };
10
+ export interface ColorPaletteOptions {
11
+ readonly version?: 1;
12
+ /** Existing wall palette IDs; originals and swatches are never rewritten. */
13
+ readonly working?: Readonly<Partial<Record<WorkingPaletteRole, string>>>;
14
+ /** Explicit opaque sRGB overrides are retained, even when contrast fails. */
15
+ readonly modes?: {
16
+ readonly light?: Partial<PaletteModeColors>;
17
+ readonly dark?: Partial<PaletteModeColors>;
18
+ };
19
+ }
20
+ export interface PaletteColorPair {
21
+ readonly background: string;
22
+ readonly foreground: string;
23
+ }
24
+ export interface PaletteContrastCheck {
25
+ readonly mode: Mode;
26
+ readonly foregroundRole: string;
27
+ readonly backgroundRole: string;
28
+ readonly foreground: string;
29
+ readonly background: string;
30
+ readonly ratio: number;
31
+ /** null marks an inactive-control exception, not a passing contrast requirement. */
32
+ readonly minimum: 3 | 4.5 | null;
33
+ readonly pass: boolean | null;
34
+ readonly message: string;
35
+ }
36
+ export interface ColorPalette {
37
+ readonly version: 1;
38
+ readonly working: Readonly<Record<WorkingPaletteRole, {
39
+ readonly paletteId: string;
40
+ readonly light: PaletteColorPair;
41
+ readonly dark: PaletteColorPair;
42
+ }>>;
43
+ readonly color: ThemeColorSection & {
44
+ readonly modes: {
45
+ readonly light: Colors;
46
+ readonly dark: Colors;
47
+ };
48
+ };
49
+ readonly surface: {
50
+ readonly modes: {
51
+ readonly light: {
52
+ readonly canvas: string;
53
+ };
54
+ readonly dark: {
55
+ readonly canvas: string;
56
+ };
57
+ };
58
+ };
59
+ readonly checks: readonly PaletteContrastCheck[];
60
+ readonly pass: boolean;
61
+ }
62
+ /** Recommend a six-family working set and audit actual opaque semantic pairs. */
63
+ export declare function recommendColorPalette(wall: ColorWall, options?: ColorPaletteOptions): ColorPalette;
64
+ export {};
65
+ //# sourceMappingURL=recommendColorPalette.d.ts.map
@@ -0,0 +1 @@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