@gridui/palette 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,310 @@
1
+ import {
2
+ accentRoles,
3
+ black,
4
+ builtInPaletteEngines,
5
+ colorFromOklch,
6
+ colorRoles,
7
+ colorToOklch,
8
+ colorVariantNames,
9
+ complementary,
10
+ contrast,
11
+ contrastPolicy,
12
+ defaultColorSeed,
13
+ foregroundFor,
14
+ fromLch,
15
+ hex,
16
+ indicatorRoles,
17
+ isBuiltInPaletteEngineName,
18
+ modes,
19
+ monochromatic,
20
+ normalizeThemeColor,
21
+ paletteNames,
22
+ parseColor,
23
+ readable,
24
+ runPaletteEngine,
25
+ scaleSteps,
26
+ statusNames,
27
+ surfaceAppearance,
28
+ surfaceRoles,
29
+ textRoles,
30
+ toLch,
31
+ white
32
+ } from "./chunk-5VHUBXDO.js";
33
+
34
+ // src/diagnostics.ts
35
+ var diagnose = (colorVariants) => {
36
+ const pairs = [];
37
+ const similarities = [];
38
+ for (const colorVariant of colorVariantNames) {
39
+ for (const appearance of modes) {
40
+ const scheme = colorVariants[colorVariant][appearance].palettes;
41
+ for (const name of paletteNames) {
42
+ const palette = scheme[name];
43
+ const rgb = Object.fromEntries(Object.entries(palette).map(([role, value]) => [role, parseColor(value)]));
44
+ const measure = (foreground, background, minimum) => {
45
+ const ratio = contrast(rgb[foreground], rgb[background]);
46
+ pairs.push({ colorVariant, appearance, palette: name, foreground, background, ratio, minimum });
47
+ };
48
+ for (const background of surfaceRoles) {
49
+ measure("accent-background", background, contrastPolicy.indicator);
50
+ for (const role of textRoles) {
51
+ measure(role, background, contrastPolicy.text);
52
+ }
53
+ for (const role of indicatorRoles) {
54
+ measure(role, background, contrastPolicy.indicator);
55
+ }
56
+ }
57
+ for (const background of accentRoles) {
58
+ measure("accent-foreground", background, contrastPolicy.text);
59
+ }
60
+ }
61
+ for (const name of ["brand", "secondary"]) {
62
+ const color = toLch(parseColor(scheme[name].background));
63
+ for (const status of statusNames) {
64
+ const anchor = toLch(parseColor(scheme[status].link));
65
+ const difference = Math.abs(color.h - anchor.h);
66
+ const hueDistance = Math.min(difference, 360 - difference);
67
+ if (color.c >= 0.04 && anchor.c >= 0.04 && hueDistance <= 25) {
68
+ similarities.push({ colorVariant, appearance, palette: name, status, hueDistance });
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+ return { contrast: pairs, failures: pairs.filter((pair) => pair.ratio < pair.minimum), similarities };
75
+ };
76
+ var assertColorTheme = (theme) => {
77
+ const first = theme.diagnostics.failures[0];
78
+ if (first) {
79
+ throw new RangeError(`Insufficient contrast at colorVariants.${first.colorVariant}.${first.appearance}.palettes.${first.palette}: ${first.foreground} on ${first.background} (${first.ratio.toFixed(2)} < ${first.minimum}); ${theme.diagnostics.failures.length} failing pairs.`);
80
+ }
81
+ };
82
+
83
+ // src/configuration.ts
84
+ var keys = (input, allowed, path) => {
85
+ if (input === void 0) {
86
+ return;
87
+ }
88
+ if (!input || typeof input !== "object" || Array.isArray(input)) {
89
+ throw new TypeError(`${path} must be an object.`);
90
+ }
91
+ for (const key of Object.keys(input)) {
92
+ if (!allowed.includes(key)) {
93
+ throw new TypeError(`Unknown color configuration: ${path}.${key}`);
94
+ }
95
+ }
96
+ };
97
+ var colors = (input) => {
98
+ for (const value of Object.values(input ?? {})) {
99
+ normalizeThemeColor(value);
100
+ }
101
+ };
102
+ var validateConfig = (config) => {
103
+ keys(config, ["seed", "engine", "sources", "scales", "colorVariants", "strict"], "theme");
104
+ if (config.strict !== void 0 && typeof config.strict !== "boolean") {
105
+ throw new TypeError("strict must be boolean.");
106
+ }
107
+ keys(config.sources, paletteNames.filter((name) => name !== "brand"), "sources");
108
+ colors(config.sources);
109
+ keys(config.scales, paletteNames, "scales");
110
+ for (const [name, scale] of Object.entries(config.scales ?? {})) {
111
+ keys(scale, ["key", ...scaleSteps.map(String)], `scales.${name}`);
112
+ colors(scale);
113
+ }
114
+ keys(config.colorVariants, colorVariantNames, "colorVariants");
115
+ for (const [colorVariant, appearances] of Object.entries(config.colorVariants ?? {})) {
116
+ keys(appearances, modes, `colorVariants.${colorVariant}`);
117
+ for (const [mode, scope] of Object.entries(appearances)) {
118
+ keys(scope, ["base", "roles", "palettes"], `colorVariants.${colorVariant}.${mode}`);
119
+ keys(scope.palettes, paletteNames, "palettes");
120
+ for (const overrides of [scope, ...Object.values(scope.palettes ?? {})]) {
121
+ keys(overrides, overrides === scope ? ["base", "roles", "palettes"] : ["base", "roles"], "overrides");
122
+ keys(overrides.base, ["background", "surface", "accent"], "base");
123
+ colors(overrides.base);
124
+ keys(overrides.roles, colorRoles, "roles");
125
+ colors(overrides.roles);
126
+ }
127
+ }
128
+ }
129
+ };
130
+
131
+ // src/scales.ts
132
+ var resolveScales = (sources, overrides) => Object.fromEntries(paletteNames.map((name) => {
133
+ const input = overrides?.[name];
134
+ const key = normalizeThemeColor(input?.key ?? sources[name]);
135
+ const color = toLch(parseColor(key));
136
+ const chroma = name === "neutral" ? Math.min(color.c * 0.1, 0.025) : color.c;
137
+ const scale = Object.fromEntries(scaleSteps.map((step) => [
138
+ step,
139
+ normalizeThemeColor(input?.[step] ?? hex(fromLch({ ...color, c: chroma, l: step / 100 })))
140
+ ]));
141
+ return [name, { ...scale, key }];
142
+ }));
143
+
144
+ // src/bases.ts
145
+ var moveSurface = (value, amount) => {
146
+ const rgb = parseColor(value);
147
+ const color = toLch(rgb);
148
+ const toward = foregroundFor(rgb) === black ? 0 : 1;
149
+ return hex(readable({ ...color, l: color.l + (toward - color.l) * amount }, [foregroundFor(rgb)], 1 - toward, 4.5));
150
+ };
151
+ var resolveBase = (scales, colorVariant, mode, palette, input) => {
152
+ const dark = colorVariant === "deep" || mode === "dark";
153
+ const scale = scales[palette];
154
+ let background;
155
+ if (palette === "neutral") {
156
+ background = colorVariant === "deep" ? scales.brand[mode === "dark" ? 10 : 20] : colorVariant === "plain" ? dark ? "#121212" : "#ffffff" : scales.neutral[dark ? 10 : 98];
157
+ } else if (palette === "brand" || palette === "secondary") {
158
+ background = dark ? scale[20] : scale.key;
159
+ } else {
160
+ background = scale[dark ? 10 : 98];
161
+ }
162
+ background = normalizeThemeColor(input.roles?.background ?? input.base?.background ?? background);
163
+ const surface = normalizeThemeColor(input.roles?.surface ?? input.base?.surface ?? moveSurface(background, dark ? 0.07 : 0.04));
164
+ const action = palette === "neutral" ? scales.brand : scale;
165
+ const accent = palette === "brand" || palette === "secondary" ? hex(foregroundFor(parseColor(background))) : dark ? action[70] : action.key;
166
+ return { background, surface, accent: normalizeThemeColor(input.roles?.["accent-background"] ?? input.base?.accent ?? accent) };
167
+ };
168
+
169
+ // src/roles.ts
170
+ var solve = (candidate, backgrounds, minimum) => {
171
+ const key = toLch(parseColor(candidate));
172
+ const preferred = foregroundFor(backgrounds[0] ?? white) === black ? 0 : 1;
173
+ for (const direction of [preferred, 1 - preferred]) {
174
+ try {
175
+ return hex(readable(key, backgrounds, direction, minimum));
176
+ } catch (error) {
177
+ if (!(error instanceof RangeError)) {
178
+ throw error;
179
+ }
180
+ }
181
+ }
182
+ const score = (color) => Math.min(...backgrounds.map((background) => contrast(color, background)));
183
+ return hex(score(black) >= score(white) ? black : white);
184
+ };
185
+ var resolveRoles = (base, scales, overrides = {}, palette = "neutral", pinnedAccent = false) => {
186
+ const ink = palette === "neutral" ? scales.neutral : scales[palette];
187
+ const action = palette === "neutral" ? scales.brand : scales[palette];
188
+ const role = (name, fallback) => normalizeThemeColor(overrides[name] ?? fallback());
189
+ const background = base.background;
190
+ const surface = base.surface;
191
+ const fills = {
192
+ background,
193
+ surface,
194
+ "surface-hover": role("surface-hover", () => moveSurface(surface, 0.04)),
195
+ "surface-pressed": role("surface-pressed", () => moveSurface(surface, 0.08)),
196
+ "selection-background": role("selection-background", () => moveSurface(surface, 0.06))
197
+ };
198
+ const backgrounds = surfaceRoles.map((name) => parseColor(fills[name]));
199
+ const foreground = role("foreground", () => solve(ink[20], backgrounds, 7));
200
+ const muted = role("muted", () => solve(ink[50], backgrounds, 4.5));
201
+ const accent = pinnedAccent ? base.accent : solve(base.accent, backgrounds, 3);
202
+ const accentLight = foregroundFor(parseColor(accent)) === black;
203
+ const state = (amount) => {
204
+ const key = toLch(parseColor(accent));
205
+ return hex(fromLch({ ...key, l: key.l + ((accentLight ? 1 : 0) - key.l) * amount }));
206
+ };
207
+ const accentHover = role("accent-hover", () => state(0.08));
208
+ const accentPressed = role("accent-pressed", () => state(0.16));
209
+ const onAccent = role("accent-foreground", () => solve(hex(foregroundFor(parseColor(accent))), [accent, accentHover, accentPressed].map(parseColor), 4.5));
210
+ const link = role("link", () => solve(action[50], backgrounds, 4.5));
211
+ const indicator = () => solve(action[50], backgrounds, 3);
212
+ const statuses = Object.fromEntries(statusNames.flatMap((name) => ["text", "border"].map((kind) => {
213
+ const key = `status-${name}-${kind}`;
214
+ return [key, role(key, () => solve(scales[name][50], backgrounds, kind === "text" ? 4.5 : 3))];
215
+ })));
216
+ return {
217
+ ...fills,
218
+ ...statuses,
219
+ foreground,
220
+ muted,
221
+ link,
222
+ backdrop: role("backdrop", () => scales.neutral[0]),
223
+ "accent-background": accent,
224
+ "accent-hover": accentHover,
225
+ "accent-pressed": accentPressed,
226
+ "accent-foreground": onAccent,
227
+ "control-border": role("control-border", () => solve(ink[50], backgrounds, 3)),
228
+ "focus-color": role("focus-color", indicator),
229
+ "selection-indicator": role("selection-indicator", indicator),
230
+ border: role("border", () => moveSurface(surface, 0.2)),
231
+ decoration: role("decoration", () => moveSurface(surface, 0.1)),
232
+ "selection-tint": role("selection-tint", () => fills["selection-background"])
233
+ };
234
+ };
235
+
236
+ // src/scheme.ts
237
+ var createScheme = (scales, colorVariant, mode, config = {}) => {
238
+ const bases = {};
239
+ const palettes = {};
240
+ for (const name of paletteNames) {
241
+ const local = config.palettes?.[name];
242
+ const input = name === "neutral" ? { base: { ...config.base, ...local?.base }, roles: { ...config.roles, ...local?.roles } } : local ?? {};
243
+ const base = resolveBase(scales, colorVariant, mode, name, input);
244
+ palettes[name] = resolveRoles(base, scales, input.roles, name, input.base?.accent !== void 0 || input.roles?.["accent-background"] !== void 0);
245
+ bases[name] = { ...base, accent: palettes[name]["accent-background"] };
246
+ }
247
+ return {
248
+ base: bases.neutral,
249
+ roles: palettes.neutral,
250
+ bases,
251
+ palettes,
252
+ nativeScheme: surfaceAppearance(bases.neutral.background),
253
+ brandArt: palettes.neutral.link
254
+ };
255
+ };
256
+
257
+ // src/create-palette.ts
258
+ function createPalette(config = {}) {
259
+ validateConfig(config);
260
+ const { sources, mappings } = runPaletteEngine(config.seed === void 0 ? defaultColorSeed : config.seed, config.engine);
261
+ for (const name of paletteNames) {
262
+ if (name === "brand") {
263
+ continue;
264
+ }
265
+ const override = config.sources?.[name];
266
+ if (override !== void 0) {
267
+ sources[name] = normalizeThemeColor(override);
268
+ }
269
+ }
270
+ const scales = resolveScales(sources, config.scales);
271
+ const colorVariants = Object.fromEntries(colorVariantNames.map((colorVariant) => [
272
+ colorVariant,
273
+ Object.fromEntries(modes.map((mode) => [mode, createScheme(scales, colorVariant, mode, config.colorVariants?.[colorVariant]?.[mode])]))
274
+ ]));
275
+ const diagnostics = diagnose(colorVariants);
276
+ const statusConflicts = statusNames.filter((status) => diagnostics.similarities.some((item) => item.status === status));
277
+ const theme = {
278
+ seed: sources.brand,
279
+ sources,
280
+ scales,
281
+ colorVariants,
282
+ diagnostics,
283
+ statusConflicts,
284
+ mappings
285
+ };
286
+ if (config.strict) {
287
+ assertColorTheme(theme);
288
+ }
289
+ return theme;
290
+ }
291
+ export {
292
+ assertColorTheme,
293
+ builtInPaletteEngines,
294
+ colorFromOklch,
295
+ colorRoles,
296
+ colorToOklch,
297
+ colorVariantNames,
298
+ complementary,
299
+ createPalette,
300
+ defaultColorSeed,
301
+ isBuiltInPaletteEngineName,
302
+ modes,
303
+ monochromatic,
304
+ normalizeThemeColor,
305
+ paletteNames,
306
+ runPaletteEngine,
307
+ scaleSteps,
308
+ surfaceAppearance
309
+ };
310
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/diagnostics.ts", "../src/configuration.ts", "../src/scales.ts", "../src/bases.ts", "../src/roles.ts", "../src/scheme.ts", "../src/create-palette.ts"],
4
+ "sourcesContent": ["/**\n * @author WMXPY\n * @package Palette\n * @namespace ColorTheme\n * @description Diagnostics\n */\n\nimport { contrast, parseColor, toLch } from \"./color\";\nimport { accentRoles, contrastPolicy, indicatorRoles, modes, paletteNames, statusNames, surfaceRoles, colorVariantNames, textRoles } from \"./contract\";\nimport type { ColorVariants, ColorThemeContrast, ColorThemeDiagnostics, ColorThemeRole, ColorThemeSimilarity } from \"./types\";\n\nexport const diagnose = (colorVariants: ColorVariants): ColorThemeDiagnostics => {\n const pairs: ColorThemeContrast[] = [];\n const similarities: ColorThemeSimilarity[] = [];\n for (const colorVariant of colorVariantNames) { for (const appearance of modes) {\n const scheme = colorVariants[colorVariant][appearance].palettes;\n for (const name of paletteNames) {\n const palette = scheme[name];\n const rgb = Object.fromEntries(Object.entries(palette).map(([role, value]) => [role, parseColor(value)]));\n const measure = (foreground: ColorThemeRole, background: ColorThemeRole, minimum: number): void => {\n const ratio = contrast(rgb[foreground]!, rgb[background]!);\n pairs.push({ colorVariant, appearance, palette: name, foreground, background, ratio, minimum });\n };\n for (const background of surfaceRoles) {\n measure(\"accent-background\", background, contrastPolicy.indicator);\n for (const role of textRoles) { measure(role, background, contrastPolicy.text); }\n for (const role of indicatorRoles) { measure(role, background, contrastPolicy.indicator); }\n }\n for (const background of accentRoles) { measure(\"accent-foreground\", background, contrastPolicy.text); }\n }\n for (const name of [\"brand\", \"secondary\"] as const) {\n const color = toLch(parseColor(scheme[name].background));\n for (const status of statusNames) {\n const anchor = toLch(parseColor(scheme[status].link));\n const difference = Math.abs(color.h - anchor.h);\n const hueDistance = Math.min(difference, 360 - difference);\n if (color.c >= 0.04 && anchor.c >= 0.04 && hueDistance <= 25) {\n similarities.push({ colorVariant, appearance, palette: name, status, hueDistance });\n }\n }\n }\n }}\n return { contrast: pairs, failures: pairs.filter((pair) => pair.ratio < pair.minimum), similarities };\n};\n\nexport const assertColorTheme = (theme: { diagnostics: ColorThemeDiagnostics }): void => {\n const first = theme.diagnostics.failures[0];\n if (first) {\n throw new RangeError(`Insufficient contrast at colorVariants.${first.colorVariant}.${first.appearance}.palettes.${first.palette}: ${first.foreground} on ${first.background} (${first.ratio.toFixed(2)} < ${first.minimum}); ${theme.diagnostics.failures.length} failing pairs.`);\n }\n};\n", "import { normalizeThemeColor } from \"./color\";\nimport { colorRoles, modes, paletteNames, scaleSteps, colorVariantNames } from \"./contract\";\nimport type { PaletteConfig } from \"./types\";\n\nconst keys = (input: unknown, allowed: readonly string[], path: string): void => {\n if (input === undefined) { return; }\n if (!input || typeof input !== \"object\" || Array.isArray(input)) { throw new TypeError(`${path} must be an object.`); }\n for (const key of Object.keys(input)) {\n if (!allowed.includes(key)) { throw new TypeError(`Unknown color configuration: ${path}.${key}`); }\n }\n};\nconst colors = (input: object | undefined): void => {\n for (const value of Object.values(input ?? {})) { normalizeThemeColor(value as string); }\n};\nexport const validateConfig = (config: PaletteConfig): void => {\n keys(config, [\"seed\", \"engine\", \"sources\", \"scales\", \"colorVariants\", \"strict\"], \"theme\");\n if (config.strict !== undefined && typeof config.strict !== \"boolean\") { throw new TypeError(\"strict must be boolean.\"); }\n keys(config.sources, paletteNames.filter((name) => name !== \"brand\"), \"sources\"); colors(config.sources);\n keys(config.scales, paletteNames, \"scales\");\n for (const [name, scale] of Object.entries(config.scales ?? {})) {\n keys(scale, [\"key\", ...scaleSteps.map(String)], `scales.${name}`); colors(scale);\n }\n keys(config.colorVariants, colorVariantNames, \"colorVariants\");\n for (const [colorVariant, appearances] of Object.entries(config.colorVariants ?? {})) {\n keys(appearances, modes, `colorVariants.${colorVariant}`);\n for (const [mode, scope] of Object.entries(appearances)) {\n keys(scope, [\"base\", \"roles\", \"palettes\"], `colorVariants.${colorVariant}.${mode}`);\n keys(scope.palettes, paletteNames, \"palettes\");\n for (const overrides of [scope, ...Object.values(scope.palettes ?? {})]) {\n keys(overrides, overrides === scope ? [\"base\", \"roles\", \"palettes\"] : [\"base\", \"roles\"], \"overrides\");\n keys(overrides.base, [\"background\", \"surface\", \"accent\"], \"base\"); colors(overrides.base);\n keys(overrides.roles, colorRoles, \"roles\"); colors(overrides.roles);\n }\n }\n }\n};\n", "import { normalizeThemeColor, fromLch, hex, parseColor, toLch } from \"./color\";\nimport { paletteNames, scaleSteps } from \"./contract\";\nimport type { ColorScale, ColorScales, ColorSources, PaletteConfig } from \"./types\";\n\nexport const resolveScales = (sources: ColorSources, overrides: PaletteConfig[\"scales\"]): ColorScales =>\n Object.fromEntries(paletteNames.map((name) => {\n const input = overrides?.[name];\n const key = normalizeThemeColor(input?.key ?? sources[name]);\n const color = toLch(parseColor(key));\n const chroma = name === \"neutral\" ? Math.min(color.c * 0.1, 0.025) : color.c;\n const scale = Object.fromEntries(scaleSteps.map((step) => [step,\n normalizeThemeColor(input?.[step] ?? hex(fromLch({ ...color, c: chroma, l: step / 100 }))),\n ])) as Record<typeof scaleSteps[number], string>;\n return [name, { ...scale, key } satisfies ColorScale];\n })) as ColorScales;\n", "import { normalizeThemeColor, black, foregroundFor, hex, parseColor, readable, toLch } from \"./color\";\nimport type { ColorBase, ColorMode, ColorOverrides, ColorScales, ColorVariant, ColorThemePaletteName } from \"./types\";\n\nexport const moveSurface = (value: string, amount: number): string => {\n const rgb = parseColor(value);\n const color = toLch(rgb);\n const toward = foregroundFor(rgb) === black ? 0 : 1;\n return hex(readable({ ...color, l: color.l + (toward - color.l) * amount }, [foregroundFor(rgb)], (1 - toward) as 0 | 1, 4.5));\n};\nexport const resolveBase = (scales: ColorScales, colorVariant: ColorVariant, mode: ColorMode, palette: ColorThemePaletteName, input: ColorOverrides): ColorBase => {\n const dark = colorVariant === \"deep\" || mode === \"dark\";\n const scale = scales[palette];\n let background: string;\n if (palette === \"neutral\") {\n background = colorVariant === \"deep\" ? scales.brand[mode === \"dark\" ? 10 : 20]\n : colorVariant === \"plain\" ? (dark ? \"#121212\" : \"#ffffff\")\n : scales.neutral[dark ? 10 : 98];\n } else if (palette === \"brand\" || palette === \"secondary\") {\n background = dark ? scale[20] : scale.key;\n } else {\n background = scale[dark ? 10 : 98];\n }\n background = normalizeThemeColor(input.roles?.background ?? input.base?.background ?? background);\n const surface = normalizeThemeColor(input.roles?.surface ?? input.base?.surface ?? moveSurface(background, dark ? 0.07 : 0.04));\n const action = palette === \"neutral\" ? scales.brand : scale;\n const accent = palette === \"brand\" || palette === \"secondary\" ? hex(foregroundFor(parseColor(background))) : dark ? action[70] : action.key;\n return { background, surface, accent: normalizeThemeColor(input.roles?.[\"accent-background\"] ?? input.base?.accent ?? accent) };\n};\n", "import { normalizeThemeColor, black, contrast, foregroundFor, fromLch, hex, parseColor, readable, toLch, white, type RGB } from \"./color\";\nimport { statusNames, surfaceRoles } from \"./contract\";\nimport { moveSurface } from \"./bases\";\nimport type { ColorBase, ColorScales, ColorThemePalette, ColorThemeRole, ColorThemePaletteName } from \"./types\";\n\n// Try both luminance directions. Impossible explicit combinations remain inspectable;\n// final diagnostics report their failing pairs instead of mutating caller colors.\nconst solve = (candidate: string, backgrounds: readonly RGB[], minimum: number): string => {\n const key = toLch(parseColor(candidate));\n const preferred = foregroundFor(backgrounds[0] ?? white) === black ? 0 : 1;\n for (const direction of [preferred, 1 - preferred] as const) {\n try { return hex(readable(key, backgrounds, direction as 0 | 1, minimum)); }\n catch (error) { if (!(error instanceof RangeError)) { throw error; } }\n }\n const score = (color: RGB) => Math.min(...backgrounds.map((background) => contrast(color, background)));\n return hex(score(black) >= score(white) ? black : white);\n};\nexport const resolveRoles = (base: ColorBase, scales: ColorScales, overrides: Partial<ColorThemePalette> = {}, palette: ColorThemePaletteName = \"neutral\", pinnedAccent = false): ColorThemePalette => {\n const ink = palette === \"neutral\" ? scales.neutral : scales[palette];\n const action = palette === \"neutral\" ? scales.brand : scales[palette];\n const role = (name: ColorThemeRole, fallback: () => string): string => normalizeThemeColor(overrides[name] ?? fallback());\n const background = base.background;\n const surface = base.surface;\n const fills = {\n background, surface,\n \"surface-hover\": role(\"surface-hover\", () => moveSurface(surface, 0.04)),\n \"surface-pressed\": role(\"surface-pressed\", () => moveSurface(surface, 0.08)),\n \"selection-background\": role(\"selection-background\", () => moveSurface(surface, 0.06)),\n };\n const backgrounds = surfaceRoles.map((name) => parseColor(fills[name]));\n const foreground = role(\"foreground\", () => solve(ink[20], backgrounds, 7));\n const muted = role(\"muted\", () => solve(ink[50], backgrounds, 4.5));\n const accent = pinnedAccent ? base.accent : solve(base.accent, backgrounds, 3);\n const accentLight = foregroundFor(parseColor(accent)) === black;\n const state = (amount: number) => {\n const key = toLch(parseColor(accent));\n return hex(fromLch({ ...key, l: key.l + ((accentLight ? 1 : 0) - key.l) * amount }));\n };\n const accentHover = role(\"accent-hover\", () => state(0.08));\n const accentPressed = role(\"accent-pressed\", () => state(0.16));\n const onAccent = role(\"accent-foreground\", () => solve(hex(foregroundFor(parseColor(accent))), [accent, accentHover, accentPressed].map(parseColor), 4.5));\n const link = role(\"link\", () => solve(action[50], backgrounds, 4.5));\n const indicator = () => solve(action[50], backgrounds, 3);\n const statuses = Object.fromEntries(statusNames.flatMap((name) => ([\"text\", \"border\"] as const).map((kind) => {\n const key = `status-${name}-${kind}` as const;\n return [key, role(key, () => solve(scales[name][50], backgrounds, kind === \"text\" ? 4.5 : 3))];\n }))) as Pick<ColorThemePalette, `status-${typeof statusNames[number]}-${\"text\" | \"border\"}`>;\n return {\n ...fills, ...statuses, foreground, muted, link,\n backdrop: role(\"backdrop\", () => scales.neutral[0]),\n \"accent-background\": accent, \"accent-hover\": accentHover, \"accent-pressed\": accentPressed, \"accent-foreground\": onAccent,\n \"control-border\": role(\"control-border\", () => solve(ink[50], backgrounds, 3)),\n \"focus-color\": role(\"focus-color\", indicator), \"selection-indicator\": role(\"selection-indicator\", indicator),\n border: role(\"border\", () => moveSurface(surface, 0.2)),\n decoration: role(\"decoration\", () => moveSurface(surface, 0.1)),\n \"selection-tint\": role(\"selection-tint\", () => fills[\"selection-background\"]),\n };\n};\n", "/**\n * @author WMXPY\n * @package Palette\n * @namespace ColorTheme\n * @description Scheme\n */\n\nimport { surfaceAppearance } from \"./color\";\nimport { paletteNames } from \"./contract\";\nimport { resolveBase } from \"./bases\";\nimport { resolveRoles } from \"./roles\";\nimport type { ColorBase, ColorMode, ColorOverrides, ColorScales, ColorVariant, ColorVariantConfig, ColorThemePalette, ColorThemePaletteName, ResolvedColorVariant } from \"./types\";\n\nexport const createScheme = (scales: ColorScales, colorVariant: ColorVariant, mode: ColorMode, config: ColorVariantConfig = {}): ResolvedColorVariant => {\n const bases = {} as Record<ColorThemePaletteName, ColorBase>;\n const palettes = {} as Record<ColorThemePaletteName, ColorThemePalette>;\n for (const name of paletteNames) {\n const local = config.palettes?.[name];\n const input: ColorOverrides = name === \"neutral\"\n ? { base: { ...config.base, ...local?.base }, roles: { ...config.roles, ...local?.roles } }\n : local ?? {};\n const base = resolveBase(scales, colorVariant, mode, name, input);\n palettes[name] = resolveRoles(base, scales, input.roles, name, input.base?.accent !== undefined || input.roles?.[\"accent-background\"] !== undefined);\n bases[name] = { ...base, accent: palettes[name][\"accent-background\"] };\n }\n return { base: bases.neutral, roles: palettes.neutral, bases, palettes,\n nativeScheme: surfaceAppearance(bases.neutral.background),\n brandArt: palettes.neutral.link,\n };\n};\n", "import { runPaletteEngine } from \"./engine\";\nimport { normalizeThemeColor } from \"./color\";\nimport { defaultColorSeed, paletteNames, modes, statusNames, colorVariantNames } from \"./contract\";\nimport { assertColorTheme, diagnose } from \"./diagnostics\";\nimport { validateConfig } from \"./configuration\";\nimport { resolveScales } from \"./scales\";\nimport { createScheme } from \"./scheme\";\nimport type { ColorVariants, PaletteConfig, ResolvedPalette } from \"./types\";\n\nexport function createPalette(config: PaletteConfig = {}): ResolvedPalette {\n validateConfig(config);\n const { sources, mappings } = runPaletteEngine(config.seed === undefined ? defaultColorSeed : config.seed, config.engine);\n for (const name of paletteNames) {\n if (name === \"brand\") { continue; }\n const override = config.sources?.[name];\n if (override !== undefined) { sources[name] = normalizeThemeColor(override); }\n }\n const scales = resolveScales(sources, config.scales);\n const colorVariants = Object.fromEntries(colorVariantNames.map((colorVariant) => [colorVariant,\n Object.fromEntries(modes.map((mode) => [mode, createScheme(scales, colorVariant, mode, config.colorVariants?.[colorVariant]?.[mode])])),\n ])) as ColorVariants;\n const diagnostics = diagnose(colorVariants);\n const statusConflicts = statusNames.filter((status) => diagnostics.similarities.some((item) => item.status === status));\n const theme: ResolvedPalette = {\n seed: sources.brand, sources, scales, colorVariants, diagnostics, statusConflicts,\n mappings,\n };\n if (config.strict) { assertColorTheme(theme); }\n return theme;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWO,IAAM,WAAW,CAAC,kBAAwD;AAC7E,QAAM,QAA8B,CAAC;AACrC,QAAM,eAAuC,CAAC;AAC9C,aAAW,gBAAgB,mBAAmB;AAAE,eAAW,cAAc,OAAO;AAC5E,YAAM,SAAS,cAAc,YAAY,EAAE,UAAU,EAAE;AACvD,iBAAW,QAAQ,cAAc;AAC7B,cAAM,UAAU,OAAO,IAAI;AAC3B,cAAM,MAAM,OAAO,YAAY,OAAO,QAAQ,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,WAAW,KAAK,CAAC,CAAC,CAAC;AACxG,cAAM,UAAU,CAAC,YAA4B,YAA4B,YAA0B;AAC/F,gBAAM,QAAQ,SAAS,IAAI,UAAU,GAAI,IAAI,UAAU,CAAE;AACzD,gBAAM,KAAK,EAAE,cAAc,YAAY,SAAS,MAAM,YAAY,YAAY,OAAO,QAAQ,CAAC;AAAA,QAClG;AACA,mBAAW,cAAc,cAAc;AACnC,kBAAQ,qBAAqB,YAAY,eAAe,SAAS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M;AACxH,aAAW,QAAQ,cAAc;AAC7B,QAAI,SAAS,SAAS;AAAE;AAAA,IAAU;AAClC,UAAM,WAAW,OAAO,UAAU,IAAI;AACtC,QAAI,aAAa,QAAW;AAAE,cAAQ,IAAI,IAAI,oBAAoB,QAAQ;AAAA,IAAG;AAAA,EACjF;AACA,QAAM,SAAS,cAAc,SAAS,OAAO,MAAM;AACnD,QAAM,gBAAgB,OAAO,YAAY,kBAAkB,IAAI,CAAC,iBAAiB;AAAA,IAAC;AAAA,IAC9E,OAAO,YAAY,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,aAAa,QAAQ,cAAc,MAAM,OAAO,gBAAgB,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;AAAA,EAC1I,CAAC,CAAC;AACF,QAAM,cAAc,SAAS,aAAa;AAC1C,QAAM,kBAAkB,YAAY,OAAO,CAAC,WAAW,YAAY,aAAa,KAAK,CAAC,SAAS,KAAK,WAAW,MAAM,CAAC;AACtH,QAAM,QAAyB;AAAA,IAC3B,MAAM,QAAQ;AAAA,IAAO;AAAA,IAAS;AAAA,IAAQ;AAAA,IAAe;AAAA,IAAa;AAAA,IAClE;AAAA,EACJ;AACA,MAAI,OAAO,QAAQ;AAAE,qBAAiB,KAAK;AAAA,EAAG;AAC9C,SAAO;AACX;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { ColorBase, ColorScales, ColorThemePalette, ColorThemePaletteName } from "./types";
2
+ export declare const resolveRoles: (base: ColorBase, scales: ColorScales, overrides?: Partial<ColorThemePalette>, palette?: ColorThemePaletteName, pinnedAccent?: boolean) => ColorThemePalette;
@@ -0,0 +1,2 @@
1
+ import type { ColorScales, ColorSources, PaletteConfig } from "./types";
2
+ export declare const resolveScales: (sources: ColorSources, overrides: PaletteConfig["scales"]) => ColorScales;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @package Palette
4
+ * @namespace ColorTheme
5
+ * @description Scheme
6
+ */
7
+ import type { ColorMode, ColorScales, ColorVariant, ColorVariantConfig, ResolvedColorVariant } from "./types";
8
+ export declare const createScheme: (scales: ColorScales, colorVariant: ColorVariant, mode: ColorMode, config?: ColorVariantConfig) => ResolvedColorVariant;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @package Palette
4
+ * @namespace ColorTheme
5
+ * @description Types
6
+ */
7
+ import type { colorRoles, paletteNames, statusNames, scaleSteps, colorVariantNames, modes } from "./contract";
8
+ export type ColorThemeRole = typeof colorRoles[number];
9
+ export type ColorThemePaletteName = typeof paletteNames[number];
10
+ export type ColorThemeStatus = typeof statusNames[number];
11
+ export type ColorVariant = typeof colorVariantNames[number];
12
+ export type ColorMode = typeof modes[number];
13
+ export type ColorThemePalette = Record<ColorThemeRole, string>;
14
+ export interface PaletteMapping {
15
+ /** The seed (brand) or a target introduced by a previous mapping. */
16
+ readonly from: ColorThemePaletteName;
17
+ /** A fresh source name. Each target may be derived once. */
18
+ readonly to: Exclude<ColorThemePaletteName, "brand">;
19
+ /** Suggested opaque #RGB or #RRGGBB before caller overrides. */
20
+ readonly color: string;
21
+ }
22
+ /** Synchronously derive ordered suggestions from a normalized lowercase #rrggbb seed.
23
+ * Return an empty array to keep the default sources. The same seed should produce the same mappings.
24
+ */
25
+ export type PaletteEngine = (seed: string) => readonly PaletteMapping[];
26
+ export interface PaletteEngineResult {
27
+ readonly seed: string;
28
+ /** All six source colors, including defaults for omitted targets. */
29
+ readonly sources: ColorSources;
30
+ /** Normalized suggestions in the engine's original order. */
31
+ readonly mappings: readonly PaletteMapping[];
32
+ }
33
+ export type ColorScaleStep = typeof scaleSteps[number];
34
+ export type ColorScale = Record<ColorScaleStep | "key", string>;
35
+ export type ColorScales = Record<ColorThemePaletteName, ColorScale>;
36
+ export type ColorSources = Record<ColorThemePaletteName, string>;
37
+ export interface ColorBase {
38
+ background: string;
39
+ surface: string;
40
+ accent: string;
41
+ }
42
+ export interface ColorOverrides {
43
+ base?: Partial<ColorBase>;
44
+ roles?: Partial<ColorThemePalette>;
45
+ }
46
+ export interface ColorVariantConfig extends ColorOverrides {
47
+ palettes?: Partial<Record<ColorThemePaletteName, ColorOverrides>>;
48
+ }
49
+ export interface PaletteConfig {
50
+ seed?: string;
51
+ engine?: PaletteEngine;
52
+ sources?: Partial<Omit<ColorSources, "brand">>;
53
+ scales?: Partial<Record<ColorThemePaletteName, Partial<ColorScale>>>;
54
+ colorVariants?: Partial<Record<ColorVariant, Partial<Record<ColorMode, ColorVariantConfig>>>>;
55
+ /** Reject final contrast conflicts instead of returning them for an editor. */
56
+ strict?: boolean;
57
+ }
58
+ export interface ResolvedColorVariant {
59
+ base: ColorBase;
60
+ roles: ColorThemePalette;
61
+ palettes: Record<ColorThemePaletteName, ColorThemePalette>;
62
+ bases: Record<ColorThemePaletteName, ColorBase>;
63
+ nativeScheme: ColorMode;
64
+ brandArt: string;
65
+ }
66
+ export type ColorVariants = Record<ColorVariant, Record<ColorMode, ResolvedColorVariant>>;
67
+ export interface ColorThemeContrast {
68
+ colorVariant: ColorVariant;
69
+ appearance: ColorMode;
70
+ palette: ColorThemePaletteName;
71
+ foreground: ColorThemeRole;
72
+ background: ColorThemeRole;
73
+ ratio: number;
74
+ minimum: number;
75
+ }
76
+ export interface ColorThemeSimilarity {
77
+ colorVariant: ColorVariant;
78
+ appearance: ColorMode;
79
+ palette: "brand" | "secondary";
80
+ status: ColorThemeStatus;
81
+ hueDistance: number;
82
+ }
83
+ export interface ColorThemeDiagnostics {
84
+ contrast: readonly ColorThemeContrast[];
85
+ failures: readonly ColorThemeContrast[];
86
+ similarities: readonly ColorThemeSimilarity[];
87
+ }
88
+ export interface ResolvedPalette {
89
+ seed: string;
90
+ sources: ColorSources;
91
+ scales: ColorScales;
92
+ colorVariants: ColorVariants;
93
+ statusConflicts: readonly ColorThemeStatus[];
94
+ diagnostics: ColorThemeDiagnostics;
95
+ mappings: readonly PaletteMapping[];
96
+ }