@adea-ai/ui 0.123.0 → 0.124.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/NOTICE +18 -0
- package/dist/components/layout/split-layout/resize-controller-core-retry.d.ts +13 -0
- package/dist/components/layout/split-layout/resize-controller-core-retry.d.ts.map +1 -0
- package/dist/components/layout/split-layout/resize-controller-core-retry.js +63 -0
- package/dist/components/layout/split-layout/resize-controller-core-retry.js.map +1 -0
- package/dist/components/layout/split-layout/resize-controller-core.d.ts +13 -0
- package/dist/components/layout/split-layout/resize-controller-core.d.ts.map +1 -0
- package/dist/components/layout/split-layout/resize-controller-core.js +63 -0
- package/dist/components/layout/split-layout/resize-controller-core.js.map +1 -0
- package/dist/components/layout/split-layout/resize-controller-retry-2.d.ts +3 -0
- package/dist/components/layout/split-layout/resize-controller-retry-2.d.ts.map +1 -0
- package/dist/components/layout/split-layout/resize-controller-retry-2.js +2 -0
- package/dist/components/layout/split-layout/resize-controller-retry.d.ts +2 -0
- package/dist/components/layout/split-layout/resize-controller-retry.d.ts.map +1 -0
- package/dist/components/layout/split-layout/resize-controller-retry.js +2 -0
- package/dist/components/layout/split-layout/resize-controller.d.ts +2 -0
- package/dist/components/layout/split-layout/resize-controller.d.ts.map +1 -0
- package/dist/components/layout/split-layout/resize-controller.js +2 -0
- package/dist/components/layout/split-layout/split-layout.d.ts.map +1 -1
- package/dist/components/layout/split-layout/split-layout.js +171 -60
- package/dist/components/layout/split-layout/split-layout.js.map +1 -1
- package/dist/components/theme/appearance-panel.js +1 -1
- package/dist/components/theme/index.d.ts +1 -1
- package/dist/components/theme/index.d.ts.map +1 -1
- package/dist/components/theme/index.js +5 -2
- package/dist/components/theme/theme-context.d.ts +13 -0
- package/dist/components/theme/theme-context.d.ts.map +1 -0
- package/dist/components/theme/theme-context.js +41 -0
- package/dist/components/theme/theme-context.js.map +1 -0
- package/dist/components/theme/theme-document.d.ts +76 -0
- package/dist/components/theme/theme-document.d.ts.map +1 -0
- package/dist/components/theme/theme-document.js +93 -0
- package/dist/components/theme/theme-document.js.map +1 -0
- package/dist/components/theme/theme-persistence.d.ts +50 -0
- package/dist/components/theme/theme-persistence.d.ts.map +1 -0
- package/dist/components/theme/theme-persistence.js +86 -0
- package/dist/components/theme/theme-persistence.js.map +1 -0
- package/dist/components/theme/theme-provider.d.ts +43 -75
- package/dist/components/theme/theme-provider.d.ts.map +1 -1
- package/dist/components/theme/theme-provider.js +50 -116
- package/dist/components/theme/theme-provider.js.map +1 -1
- package/dist/components/theme/theme-state.d.ts +142 -0
- package/dist/components/theme/theme-state.d.ts.map +1 -0
- package/dist/components/theme/theme-state.js +104 -0
- package/dist/components/theme/theme-state.js.map +1 -0
- package/dist/components/theme/theme-toggle.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/lib/appearance-font-settings.d.ts +1 -1
- package/dist/lib/appearance-font-settings.d.ts.map +1 -1
- package/dist/lib/appearance-font-settings.js.map +1 -1
- package/dist/lib/themes.d.ts +48 -0
- package/dist/lib/themes.d.ts.map +1 -1
- package/dist/lib/themes.js +150 -36
- package/dist/lib/themes.js.map +1 -1
- package/dist/r/registry.json +46 -0
- package/dist/r/split-layout.json +26 -0
- package/dist/r/src/components/layout/split-layout/resize-controller-core-retry.tsx +66 -0
- package/dist/r/src/components/layout/split-layout/resize-controller-core.tsx +66 -0
- package/dist/r/src/components/layout/split-layout/resize-controller-retry-2.tsx +2 -0
- package/dist/r/src/components/layout/split-layout/resize-controller-retry.tsx +1 -0
- package/dist/r/src/components/layout/split-layout/resize-controller.tsx +1 -0
- package/dist/r/src/components/layout/split-layout/split-layout.tsx +197 -49
- package/dist/r/src/components/theme/index.ts +3 -0
- package/dist/r/src/components/theme/theme-context.ts +43 -0
- package/dist/r/src/components/theme/theme-document.ts +168 -0
- package/dist/r/src/components/theme/theme-persistence.ts +140 -0
- package/dist/r/src/components/theme/theme-provider.tsx +126 -253
- package/dist/r/src/components/theme/theme-state.ts +225 -0
- package/dist/r/src/lib/appearance-font-settings.ts +1 -1
- package/dist/r/src/lib/themes.ts +181 -40
- package/dist/r/theming.json +20 -0
- package/package.json +1 -1
- package/registry.json +46 -0
- package/src/components/layout/split-layout/resize-controller-core-retry.tsx +66 -0
- package/src/components/layout/split-layout/resize-controller-core.tsx +66 -0
- package/src/components/layout/split-layout/resize-controller-retry-2.tsx +2 -0
- package/src/components/layout/split-layout/resize-controller-retry.tsx +1 -0
- package/src/components/layout/split-layout/resize-controller.tsx +1 -0
- package/src/components/layout/split-layout/split-layout.tsx +197 -49
- package/src/components/theme/index.ts +3 -0
- package/src/components/theme/theme-context.ts +43 -0
- package/src/components/theme/theme-document.ts +168 -0
- package/src/components/theme/theme-persistence.ts +140 -0
- package/src/components/theme/theme-provider.tsx +126 -253
- package/src/components/theme/theme-state.ts +225 -0
- package/src/index.ts +3 -0
- package/src/lib/appearance-font-settings.ts +1 -1
- package/src/lib/themes.ts +181 -40
package/dist/lib/themes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isThemeAccentId } from "./theme-accents.js";
|
|
2
2
|
import { accentForeground, accentRoles, chartSeries, contrastRatio, getAccent, getTheme, hasTheme, primaryHover, primarySubtleCss, shadcnDestructiveProjection, statusForeground, syntaxRoles, themeAccentPresets, themes, themesByAppearance, tint, validateCatalogue } from "@adea-ai/themes";
|
|
3
3
|
import { shadcnVariables } from "@adea-ai/themes/adapters/shadcn";
|
|
4
|
+
import { oklchToHex, parseColor } from "@adea-ai/themes/oklch";
|
|
4
5
|
//#region src/lib/themes.ts
|
|
5
6
|
/**
|
|
6
7
|
* The theme registry, now a bridge.
|
|
@@ -36,8 +37,13 @@ import { shadcnVariables } from "@adea-ai/themes/adapters/shadcn";
|
|
|
36
37
|
* the former, so it goes to `--primary`, and `--accent` is filled from
|
|
37
38
|
* `surfaceHover`, which is what shadcn components actually use it for.
|
|
38
39
|
*/
|
|
39
|
-
/**
|
|
40
|
-
|
|
40
|
+
/**
|
|
41
|
+
* The shadcn-vocabulary roles of one catalogue entry.
|
|
42
|
+
*
|
|
43
|
+
* The expensive half of a variant: `shadcnVariables` projects the whole palette
|
|
44
|
+
* (about 4 ms a theme), which is why {@link lazyVariant} defers it.
|
|
45
|
+
*/
|
|
46
|
+
function colorsOf(theme) {
|
|
41
47
|
const projected = shadcnVariables(theme);
|
|
42
48
|
const token = (name) => {
|
|
43
49
|
const value = projected[`--${name}`];
|
|
@@ -45,7 +51,7 @@ function toVariant(theme) {
|
|
|
45
51
|
return value;
|
|
46
52
|
};
|
|
47
53
|
const destructiveAction = shadcnDestructiveProjection(theme);
|
|
48
|
-
|
|
54
|
+
return {
|
|
49
55
|
background: token("background"),
|
|
50
56
|
foreground: token("foreground"),
|
|
51
57
|
card: token("card"),
|
|
@@ -83,7 +89,54 @@ function toVariant(theme) {
|
|
|
83
89
|
sidebarBorder: token("sidebar-border"),
|
|
84
90
|
sidebarMutedForeground: token("sidebar-muted-foreground")
|
|
85
91
|
};
|
|
92
|
+
}
|
|
93
|
+
function terminalOf(theme) {
|
|
94
|
+
return {
|
|
95
|
+
background: theme.colors.background,
|
|
96
|
+
foreground: theme.colors.foreground,
|
|
97
|
+
cursor: theme.cursor,
|
|
98
|
+
selection: theme.selection,
|
|
99
|
+
...theme.ansi
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function editorOf(theme) {
|
|
86
103
|
const syntax = syntaxRoles(theme);
|
|
104
|
+
return {
|
|
105
|
+
keyword: syntax.keyword,
|
|
106
|
+
string: syntax.string,
|
|
107
|
+
number: syntax.number,
|
|
108
|
+
comment: syntax.comment,
|
|
109
|
+
function: syntax.function,
|
|
110
|
+
variable: syntax.variable,
|
|
111
|
+
type: syntax.type,
|
|
112
|
+
tag: syntax.tag,
|
|
113
|
+
attribute: syntax.attribute,
|
|
114
|
+
operator: syntax.operator,
|
|
115
|
+
heading: syntax.heading,
|
|
116
|
+
link: syntax.link,
|
|
117
|
+
diffAdd: syntax.diffAdd,
|
|
118
|
+
diffDelete: syntax.diffDelete,
|
|
119
|
+
diffHunk: syntax.diffHunk,
|
|
120
|
+
searchMatch: syntax.searchMatch
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function provenanceOf(theme) {
|
|
124
|
+
return {
|
|
125
|
+
source: theme.provenance.project,
|
|
126
|
+
url: theme.provenance.url,
|
|
127
|
+
license: theme.provenance.license
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The design system's view of one catalogue record, built in full and at once.
|
|
132
|
+
*
|
|
133
|
+
* For a host that holds a record the catalogue does not — an imported theme, a
|
|
134
|
+
* reconstruction from stored data — and wants a variant it can hand to
|
|
135
|
+
* `ThemeProvider`'s `themes`. It throws for a record the shadcn projection cannot
|
|
136
|
+
* map, here and now, rather than on first paint. The catalogue itself goes through
|
|
137
|
+
* {@link lazyVariant} instead.
|
|
138
|
+
*/
|
|
139
|
+
function variantFromRecord(theme) {
|
|
87
140
|
return {
|
|
88
141
|
id: theme.id,
|
|
89
142
|
family: theme.family,
|
|
@@ -91,40 +144,55 @@ function toVariant(theme) {
|
|
|
91
144
|
label: theme.label,
|
|
92
145
|
appearance: theme.appearance,
|
|
93
146
|
description: theme.description,
|
|
94
|
-
colors,
|
|
95
|
-
terminal:
|
|
96
|
-
|
|
97
|
-
foreground: theme.colors.foreground,
|
|
98
|
-
cursor: theme.cursor,
|
|
99
|
-
selection: theme.selection,
|
|
100
|
-
...theme.ansi
|
|
101
|
-
},
|
|
102
|
-
editor: {
|
|
103
|
-
keyword: syntax.keyword,
|
|
104
|
-
string: syntax.string,
|
|
105
|
-
number: syntax.number,
|
|
106
|
-
comment: syntax.comment,
|
|
107
|
-
function: syntax.function,
|
|
108
|
-
variable: syntax.variable,
|
|
109
|
-
type: syntax.type,
|
|
110
|
-
tag: syntax.tag,
|
|
111
|
-
attribute: syntax.attribute,
|
|
112
|
-
operator: syntax.operator,
|
|
113
|
-
heading: syntax.heading,
|
|
114
|
-
link: syntax.link,
|
|
115
|
-
diffAdd: syntax.diffAdd,
|
|
116
|
-
diffDelete: syntax.diffDelete,
|
|
117
|
-
diffHunk: syntax.diffHunk,
|
|
118
|
-
searchMatch: syntax.searchMatch
|
|
119
|
-
},
|
|
147
|
+
colors: colorsOf(theme),
|
|
148
|
+
terminal: terminalOf(theme),
|
|
149
|
+
editor: editorOf(theme),
|
|
120
150
|
chart: chartSeries(theme),
|
|
121
|
-
provenance:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
151
|
+
provenance: provenanceOf(theme)
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/** Runs `build` on first call and returns that value from then on. A throw is not cached. */
|
|
155
|
+
function once(build) {
|
|
156
|
+
let built = false;
|
|
157
|
+
let value;
|
|
158
|
+
return () => {
|
|
159
|
+
if (!built) {
|
|
160
|
+
value = build();
|
|
161
|
+
built = true;
|
|
125
162
|
}
|
|
163
|
+
return value;
|
|
126
164
|
};
|
|
127
165
|
}
|
|
166
|
+
var lazy = (build) => ({
|
|
167
|
+
get: once(build),
|
|
168
|
+
enumerable: true
|
|
169
|
+
});
|
|
170
|
+
/**
|
|
171
|
+
* {@link variantFromRecord} with the four derived palettes built on first read.
|
|
172
|
+
*
|
|
173
|
+
* Evaluating this module used to project all 34 catalogue themes up front, about
|
|
174
|
+
* 155 ms before a single one was needed, on the hydration path of every consumer.
|
|
175
|
+
* A page paints one variant, and a picker's labels and appearance are plain
|
|
176
|
+
* fields, so only a variant whose `colors`, `terminal`, `editor` or `chart` is read
|
|
177
|
+
* pays for them, once. The properties stay enumerable data-shaped accessors, so
|
|
178
|
+
* spreading, `Object.entries` and JSON see the same object they always did.
|
|
179
|
+
*/
|
|
180
|
+
function lazyVariant(theme) {
|
|
181
|
+
return Object.defineProperties({
|
|
182
|
+
id: theme.id,
|
|
183
|
+
family: theme.family,
|
|
184
|
+
familyLabel: theme.familyLabel,
|
|
185
|
+
label: theme.label,
|
|
186
|
+
appearance: theme.appearance,
|
|
187
|
+
description: theme.description,
|
|
188
|
+
provenance: provenanceOf(theme)
|
|
189
|
+
}, {
|
|
190
|
+
colors: lazy(() => colorsOf(theme)),
|
|
191
|
+
terminal: lazy(() => terminalOf(theme)),
|
|
192
|
+
editor: lazy(() => editorOf(theme)),
|
|
193
|
+
chart: lazy(() => chartSeries(theme))
|
|
194
|
+
});
|
|
195
|
+
}
|
|
128
196
|
/**
|
|
129
197
|
* A variant's `--primary-subtle`: the tint over `var(--primary)` at the strength its
|
|
130
198
|
* catalogue record measures (`primarySubtleAlpha`). A variant that is not in the
|
|
@@ -135,11 +203,34 @@ function primarySubtleFor(theme) {
|
|
|
135
203
|
return record ? primarySubtleCss(record) : primarySubtleCss(theme.appearance);
|
|
136
204
|
}
|
|
137
205
|
/** The catalogue, in catalogue order. */
|
|
138
|
-
var builtinThemes = Object.freeze(themes.map(
|
|
206
|
+
var builtinThemes = Object.freeze(themes.map(lazyVariant));
|
|
139
207
|
function themeById(id) {
|
|
140
208
|
if (!hasTheme(id)) return void 0;
|
|
141
209
|
return builtinThemes.find((theme) => theme.id === id);
|
|
142
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* The variant a stored id means, or the default of the same appearance.
|
|
213
|
+
*
|
|
214
|
+
* An id the registry does not hold — an imported theme that was deleted, a
|
|
215
|
+
* catalogue entry that was renamed — must still paint *something of the appearance
|
|
216
|
+
* being shown*. Falling back to whichever variant happens to be first in the
|
|
217
|
+
* registry painted a dark palette under a light `color-scheme` for a light id, so
|
|
218
|
+
* the fallback is the appearance's own default, then any variant of that
|
|
219
|
+
* appearance, then the registry's first entry only when it holds nothing else.
|
|
220
|
+
*
|
|
221
|
+
* `registry` is the builtin catalogue plus whatever extras the host supplies; the
|
|
222
|
+
* stored id is never rewritten, only resolved, so a host that keeps an unknown id
|
|
223
|
+
* keeps resolving it if the theme comes back.
|
|
224
|
+
*
|
|
225
|
+
* The fallback order is translated from Zeron's `ThemeRegistry::resolve` (MIT,
|
|
226
|
+
* Copyright (c) 2026 Wing); see NOTICE.
|
|
227
|
+
*/
|
|
228
|
+
function resolveVariant(registry, id, appearance) {
|
|
229
|
+
const found = registry.find((variant) => variant.id === id);
|
|
230
|
+
if (found) return found;
|
|
231
|
+
const defaultId = appearance === "dark" ? defaultDarkThemeId : defaultLightThemeId;
|
|
232
|
+
return registry.find((variant) => variant.id === defaultId) ?? registry.find((variant) => variant.appearance === appearance) ?? registry[0];
|
|
233
|
+
}
|
|
143
234
|
/** The variants of one appearance, which is what a picker for that mode shows. */
|
|
144
235
|
function themesForAppearance(appearance) {
|
|
145
236
|
const ids = new Set(themesByAppearance(appearance).map((theme) => theme.id));
|
|
@@ -298,7 +389,7 @@ function themeCssVariables(theme) {
|
|
|
298
389
|
const c = theme.colors;
|
|
299
390
|
const t = theme.terminal;
|
|
300
391
|
const e = theme.editor;
|
|
301
|
-
|
|
392
|
+
const derived = {
|
|
302
393
|
"--background": c.background,
|
|
303
394
|
"--foreground": c.foreground,
|
|
304
395
|
"--card": c.card,
|
|
@@ -387,6 +478,29 @@ function themeCssVariables(theme) {
|
|
|
387
478
|
"--chart-5": theme.chart[4] ?? c.destructive,
|
|
388
479
|
"--chart-6": theme.chart[5] ?? c.mutedForeground
|
|
389
480
|
};
|
|
481
|
+
return theme.tokens ? {
|
|
482
|
+
...derived,
|
|
483
|
+
...theme.tokens
|
|
484
|
+
} : derived;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Token values with every `oklch()` colour written as `#rrggbb`.
|
|
488
|
+
*
|
|
489
|
+
* For a host whose stylesheet, tests or native shell speak hex: the catalogue's
|
|
490
|
+
* roles are `oklch()` strings, and this is the one conversion, gamut-mapped by the
|
|
491
|
+
* catalogue's own `oklchToHex`. A value that is already hex, carries alpha
|
|
492
|
+
* (`rgba()`), or is not a plain colour (`color-mix()`, `var()`) is left byte for
|
|
493
|
+
* byte, because converting would either lose the alpha or be a guess. Suitable as
|
|
494
|
+
* `ThemeProvider`'s `transformTokens`.
|
|
495
|
+
*/
|
|
496
|
+
function tokensAsHex(tokens) {
|
|
497
|
+
const converted = {};
|
|
498
|
+
for (const [name, value] of Object.entries(tokens)) {
|
|
499
|
+
const trimmed = value.trim();
|
|
500
|
+
const parsed = trimmed.startsWith("oklch(") && !trimmed.includes("/") ? parseColor(trimmed) : void 0;
|
|
501
|
+
converted[name] = parsed ? oklchToHex(parsed) : value;
|
|
502
|
+
}
|
|
503
|
+
return converted;
|
|
390
504
|
}
|
|
391
505
|
function toFinding(finding) {
|
|
392
506
|
return {
|
|
@@ -417,6 +531,6 @@ function validateThemeRegistry(themes$1 = builtinThemes) {
|
|
|
417
531
|
var defaultLightThemeId = "adea-light";
|
|
418
532
|
var defaultDarkThemeId = "adea-dark";
|
|
419
533
|
//#endregion
|
|
420
|
-
export { accentVariables, appearancePreviewThemes, builtinThemes, contrastRatio, defaultDarkThemeId, defaultLightThemeId, isThemeAccentId, primarySubtleFor, resolveAccentPreset, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themesForAppearance, validateTheme, validateThemeRegistry, withAccent };
|
|
534
|
+
export { accentVariables, appearancePreviewThemes, builtinThemes, contrastRatio, defaultDarkThemeId, defaultLightThemeId, isThemeAccentId, primarySubtleFor, resolveAccentPreset, resolveVariant, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themesForAppearance, tokensAsHex, validateTheme, validateThemeRegistry, variantFromRecord, withAccent };
|
|
421
535
|
|
|
422
536
|
//# sourceMappingURL=themes.js.map
|
package/dist/lib/themes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themes.js","names":["catalogue","themes"],"sources":["../../src/lib/themes.ts"],"sourcesContent":["/**\n * The theme registry, now a bridge.\n *\n * The catalogue itself lives in `@adea-ai/themes`. This module is what is left in\n * the design system: the translation between the catalogue's **canonical** role\n * names and the **shadcn** vocabulary every component here is written against, plus\n * the handful of custom properties this system declares that are presentations of\n * data the catalogue already holds — the `--terminal-*` ramp, the `--editor-*` ramp,\n * and `--chrome`.\n *\n * ## Why it is a bridge and not a copy\n *\n * This file used to hold thirteen themes as hand-written hex literal tables, with its\n * own contrast validator, its own terminal and editor palettes, and its own\n * provenance records. That is a lot of surface to maintain for one consumer of a\n * palette, and it meant every product that wanted the same themes — Adea, Cortana —\n * either imported this package or wrote its own. The catalogue moved out so that\n * there is one answer to \"what is Catppuccin Mocha\", and this file is the part that\n * genuinely belongs to the design system.\n *\n * It is deliberately thin. If you are looking for a colour, it is not here: see\n * `@adea-ai/themes`, whose README explains how the values are produced and whose\n * `NOTICE` records where every palette came from.\n *\n * ## The mapping, and the entry that is not a rename\n *\n * The package-owned `shadcnVariables` adapter maps canonical roles onto this\n * system's vocabulary. One entry will trip a reader: the catalogue's `accent`\n * becomes this system's `primary`, because in the shadcn vocabulary `--primary` is\n * the action colour — the fill of a primary button, the thing a focus ring is drawn\n * in — while `--accent` is a low-contrast hover wash. The catalogue's `accent` is\n * the former, so it goes to `--primary`, and `--accent` is filled from\n * `surfaceHover`, which is what shadcn components actually use it for.\n */\n\nimport {\n ACCENTS,\n accentForeground,\n accentRoles,\n chartSeries,\n getAccent,\n getTheme,\n hasTheme,\n shadcnDestructiveProjection,\n statusForeground,\n tint,\n primaryHover,\n primarySubtleCss,\n syntaxRoles,\n themes as catalogue,\n themesByAppearance,\n themeAccentPresets,\n validateCatalogue,\n type AccentPreset,\n type AdeaTheme,\n type AdeaThemeRecord,\n type ContrastFinding,\n} from '@adea-ai/themes'\nimport { shadcnVariables } from '@adea-ai/themes/adapters/shadcn'\nimport { isThemeAccentId } from './theme-accents'\n\nexport { isThemeAccentId } from './theme-accents'\n\nexport type ThemeAppearance = 'light' | 'dark'\n\n/**\n * The surface and text roles, in shadcn's vocabulary.\n *\n * Named to match the components below, which is why they differ from the\n * catalogue's: these are this system's variable names, and renaming them would mean\n * touching every component in the library for no gain.\n */\nexport type ThemeColors = {\n background: string\n foreground: string\n card: string\n cardForeground: string\n popover: string\n popoverForeground: string\n primary: string\n primaryForeground: string\n secondary: string\n secondaryForeground: string\n muted: string\n mutedForeground: string\n accent: string\n accentForeground: string\n destructive: string\n destructiveForeground: string\n destructiveSubtle: string\n /** Contrast-safe solid-action presentation, derived from the canonical error role. */\n destructiveAction: string\n destructiveActionForeground: string\n success: string\n successForeground: string\n successSubtle: string\n warning: string\n warningForeground: string\n warningSubtle: string\n info: string\n infoForeground: string\n infoSubtle: string\n border: string\n input: string\n ring: string\n sidebar: string\n sidebarForeground: string\n sidebarAccent: string\n sidebarBorder: string\n sidebarMutedForeground: string\n}\n\n/** The sixteen ANSI colours a terminal needs, plus its cursor and selection. */\nexport type ThemeTerminalPalette = {\n background: string\n foreground: string\n cursor: string\n selection: string\n black: string\n red: string\n green: string\n yellow: string\n blue: string\n magenta: string\n cyan: string\n white: string\n brightBlack: string\n brightRed: string\n brightGreen: string\n brightYellow: string\n brightBlue: string\n brightMagenta: string\n brightCyan: string\n brightWhite: string\n}\n\n/** The syntax roles a code view needs. */\nexport type ThemeEditorPalette = {\n keyword: string\n string: string\n number: string\n comment: string\n function: string\n variable: string\n type: string\n tag: string\n attribute: string\n operator: string\n heading: string\n link: string\n diffAdd: string\n diffDelete: string\n diffHunk: string\n searchMatch: string\n}\n\n/** Where a palette came from, and the terms it is used under. */\nexport type ThemeProvenance = {\n /** The project or person the palette belongs to. */\n source: string\n url: string\n /** An SPDX identifier. Every palette in this catalogue is permissive. */\n license: string\n}\n\nexport type ThemeVariant = {\n /** The `data-theme` value and the id a preference stores. */\n id: string\n /** Groups the variants that came from one project. */\n family: string\n familyLabel: string\n label: string\n appearance: ThemeAppearance\n /** One line, shown in a picker. */\n description: string\n colors: ThemeColors\n terminal: ThemeTerminalPalette\n editor: ThemeEditorPalette\n /** The categorical series, in order. */\n chart: readonly string[]\n provenance: ThemeProvenance\n}\n\n/** Builds the design system's view of one catalogue entry. */\nfunction toVariant(theme: AdeaThemeRecord): ThemeVariant {\n const projected = shadcnVariables(theme)\n const token = (name: string): string => {\n const value = projected[`--${name}`]\n if (!value) throw new Error(`${theme.id} has no shared shadcn projection for --${name}`)\n return value\n }\n const destructiveAction = shadcnDestructiveProjection(theme)\n const colors: ThemeColors = {\n background: token('background'),\n foreground: token('foreground'),\n card: token('card'),\n cardForeground: token('card-foreground'),\n popover: token('popover'),\n popoverForeground: token('popover-foreground'),\n primary: token('primary'),\n primaryForeground: token('primary-foreground'),\n secondary: token('secondary'),\n secondaryForeground: token('secondary-foreground'),\n muted: token('muted'),\n mutedForeground: token('muted-foreground'),\n accent: token('accent'),\n accentForeground: token('accent-foreground'),\n // Preserve the UI's semantic error token. The Themes projection uses its\n // contrast-safe solid-action fill for --destructive; UI keeps that fill in\n // the separate destructiveAction pair below.\n destructive: theme.colors.error,\n destructiveForeground: statusForeground(theme, 'error'),\n destructiveSubtle: tint(theme.colors.error, theme.colors.background),\n destructiveAction: destructiveAction.fill,\n destructiveActionForeground: destructiveAction.foreground,\n success: token('success'),\n successForeground: statusForeground(theme, 'success'),\n successSubtle: tint(theme.colors.success, theme.colors.background),\n warning: token('warning'),\n warningForeground: statusForeground(theme, 'warning'),\n warningSubtle: tint(theme.colors.warning, theme.colors.background),\n info: token('info'),\n infoForeground: statusForeground(theme, 'info'),\n infoSubtle: tint(theme.colors.info, theme.colors.background),\n border: token('border'),\n input: token('input'),\n ring: token('ring'),\n sidebar: token('sidebar'),\n sidebarForeground: token('sidebar-foreground'),\n sidebarAccent: token('sidebar-accent'),\n sidebarBorder: token('sidebar-border'),\n sidebarMutedForeground: token('sidebar-muted-foreground'),\n }\n const syntax = syntaxRoles(theme)\n\n return {\n id: theme.id,\n family: theme.family,\n familyLabel: theme.familyLabel,\n label: theme.label,\n appearance: theme.appearance,\n description: theme.description,\n colors,\n terminal: {\n // The embedded terminal uses the theme's own canvas rather than a palette of its\n // own. The ANSI colours came from the palette that produced the canvas, so they\n // were chosen against it; a terminal on a different background would be the one\n // surface in the application not lit by the active theme.\n background: theme.colors.background,\n foreground: theme.colors.foreground,\n cursor: theme.cursor,\n selection: theme.selection,\n ...theme.ansi,\n },\n editor: {\n keyword: syntax.keyword,\n string: syntax.string,\n number: syntax.number,\n comment: syntax.comment,\n function: syntax.function,\n variable: syntax.variable,\n type: syntax.type,\n tag: syntax.tag,\n attribute: syntax.attribute,\n operator: syntax.operator,\n heading: syntax.heading,\n link: syntax.link,\n diffAdd: syntax.diffAdd,\n diffDelete: syntax.diffDelete,\n diffHunk: syntax.diffHunk,\n searchMatch: syntax.searchMatch,\n },\n chart: chartSeries(theme),\n provenance: {\n source: theme.provenance.project,\n url: theme.provenance.url,\n license: theme.provenance.license,\n },\n }\n}\n\n/**\n * A variant's `--primary-subtle`: the tint over `var(--primary)` at the strength its\n * catalogue record measures (`primarySubtleAlpha`). A variant that is not in the\n * catalogue has nothing to measure, and gets its appearance's ceiling.\n */\nexport function primarySubtleFor(theme: Pick<ThemeVariant, 'id' | 'appearance'>): string {\n const record = getTheme(theme.id)\n return record ? primarySubtleCss(record) : primarySubtleCss(theme.appearance)\n}\n\n/** The catalogue, in catalogue order. */\nexport const builtinThemes: readonly ThemeVariant[] = Object.freeze(catalogue.map(toVariant))\n\nexport function themeById(id: string): ThemeVariant | undefined {\n if (!hasTheme(id)) return undefined\n return builtinThemes.find((theme) => theme.id === id)\n}\n\n/** The variants of one appearance, which is what a picker for that mode shows. */\nexport function themesForAppearance(appearance: ThemeAppearance): readonly ThemeVariant[] {\n const ids = new Set(themesByAppearance(appearance).map((theme) => theme.id))\n return builtinThemes.filter((theme) => ids.has(theme.id))\n}\n\n/** The families in the catalogue, in catalogue order. */\nexport function themeFamilies(): { family: string; label: string; themes: ThemeVariant[] }[] {\n const families = new Map<string, { family: string; label: string; themes: ThemeVariant[] }>()\n for (const theme of builtinThemes) {\n const entry = families.get(theme.family) ?? {\n family: theme.family,\n label: theme.familyLabel,\n themes: [],\n }\n entry.themes.push(theme)\n families.set(theme.family, entry)\n }\n return [...families.values()]\n}\n\n/** The accent presets, in the order a picker should show them. */\nexport const accents = ACCENTS\n\n/**\n * The canonical catalogue records, in catalogue order.\n *\n * {@link builtinThemes} is this system's projection of the catalogue onto the\n * shadcn vocabulary, which is what a document is painted with. A *preview* of a\n * theme — the miniatures `AppearanceEditor` and `ThemeMiniature` draw — reads the\n * catalogue's own roles instead (`surfaceActive`, `borderMuted`, `textSubtle`…),\n * several of which the projection folds together. These are those records, so a\n * consumer hands the editor exactly what it takes rather than reconstructing it\n * from the projection.\n */\nexport const themeRecords: readonly AdeaThemeRecord[] = catalogue\n\nexport function themeRecordById(id: string): AdeaThemeRecord | undefined {\n return getTheme(id)\n}\n\n/** A light/dark theme pair by id, with the defaults standing in for an unknown id. */\nfunction recordPair(lightThemeId: string, darkThemeId: string) {\n const light = getTheme(lightThemeId) ?? getTheme(defaultLightThemeId)!\n const dark = getTheme(darkThemeId) ?? getTheme(defaultDarkThemeId)!\n return { light, dark }\n}\n\n/**\n * The accents the selected light/dark pair carries — offered beside the presets.\n *\n * Computed per pair rather than per theme because a theme accent is a *pair* of\n * values, like a preset: a slot is offered only when both themes can offer it.\n */\nexport function themeAccentsFor(\n lightThemeId: string,\n darkThemeId: string\n): readonly AccentPreset[] {\n const { light, dark } = recordPair(lightThemeId, darkThemeId)\n return themeAccentPresets(light, dark)\n}\n\n/**\n * An accent id resolved against a theme pair: a preset, a theme accent the pair\n * offers, or `undefined` for `theme`, an unknown id, or a slot this pair cannot\n * offer — each of which means \"use the theme's own primary\".\n *\n * Theme accent ids are role-shaped (`ansi-blue`), so a stored one survives a theme\n * switch and resolves to the new theme's blue; when the new pair cannot offer the\n * slot it resolves to nothing, the same fallback a stale preset id gets.\n */\nexport function resolveAccentPreset(\n accentId: string,\n light: AdeaTheme,\n dark: AdeaTheme\n): AccentPreset | undefined {\n if (accentId === 'theme') return undefined\n const preset = getAccent(accentId)\n if (preset) return preset\n if (!isThemeAccentId(accentId)) return undefined\n return themeAccentPresets(light, dark).find((option) => option.id === accentId)\n}\n\n/**\n * A theme with an accent laid over it, in the catalogue's own shape.\n *\n * The accent replaces `accent` and its measured label, which is all an accent\n * changes about a theme; `undefined` returns the theme untouched. This is the\n * overlay a host needs for `AppearanceEditor`'s `lightTheme`/`darkTheme`.\n */\nexport function withAccent<T extends AdeaTheme>(theme: T, accent: AccentPreset | undefined): T {\n if (!accent) return theme\n const value = theme.appearance === 'dark' ? accent.dark : accent.light\n return {\n ...theme,\n colors: { ...theme.colors, accent: value, accentForeground: accentForeground(value) },\n }\n}\n\n/**\n * The two preview themes an appearance selection resolves to, accent applied.\n *\n * The adapter between a stored selection and `AppearanceEditor`: it takes ids —\n * what a preference holds — and returns the canonical records the editor's\n * `lightTheme` and `darkTheme` props take, so a host does not map roles by hand.\n * Unknown ids fall back to the defaults and an accent the pair cannot offer falls\n * back to the theme's own, exactly as `ThemeProvider` resolves them.\n */\nexport function appearancePreviewThemes(selection: {\n lightThemeId: string\n darkThemeId: string\n accent: string\n}): { lightTheme: AdeaThemeRecord; darkTheme: AdeaThemeRecord } {\n const { light, dark } = recordPair(selection.lightThemeId, selection.darkThemeId)\n const accent = resolveAccentPreset(selection.accent, light, dark)\n return { lightTheme: withAccent(light, accent), darkTheme: withAccent(dark, accent) }\n}\n\n/**\n * The properties an accent selection overrides, as CSS custom properties.\n *\n * ## Why this exists rather than relying on the `[data-accent]` blocks\n *\n * `theme.css` carries a `[data-accent='…']` block per preset, and those blocks are\n * correct — but they are unreachable at runtime. `ThemeProvider` writes a theme's\n * whole role set onto `<html>` as *inline* custom properties, and an inline\n * declaration outranks any stylesheet selector regardless of specificity. The\n * attribute was set, the rules existed, the values were right, and every one of the\n * seven accents rendered as the same blue.\n *\n * The blocks are kept, because they are what styles the window between the document\n * arriving and the provider mounting — which is the whole reason `themeScript`\n * exists. But the authoritative value has to be applied by the same code that\n * applies the theme, from the same source, or the two can drift again. So both the\n * provider and the CSS generator call `accentRoles` out of `@adea-ai/themes`, and\n * `tests/appearance-axes.test.ts` asserts the two agree value for value.\n *\n * A theme accent (`ansi-blue`) has no block: its value depends on the theme pair,\n * so it is resolved against `pair` — the selection's light and dark theme ids —\n * and only ever applied here. Without a pair it resolves against the defaults.\n *\n * Returns `undefined` for `theme` — the variant's own primary — for an id the\n * catalogue does not have, and for a theme accent the pair does not offer, so a\n * stale stored preference falls back to the theme rather than blanking the primary.\n */\nexport function accentVariables(\n accentId: string,\n appearance: ThemeAppearance,\n pair: { lightThemeId: string; darkThemeId: string } = {\n lightThemeId: defaultLightThemeId,\n darkThemeId: defaultDarkThemeId,\n }\n): Record<string, string> | undefined {\n if (accentId === 'theme') return undefined\n const { light, dark } = recordPair(pair.lightThemeId, pair.darkThemeId)\n const preset = resolveAccentPreset(accentId, light, dark)\n if (!preset) return undefined\n\n // `--primary-subtle` is deliberately not here. It is a `color-mix()` over\n // `var(--primary)`, so the theme's own declaration (`themeCssVariables`, or the\n // default block in `theme.css`) already follows the accent; and its strength is the\n // *theme's*, measured by `primarySubtleAlpha` to hold body text at 4.5:1 for every\n // accent the theme offers. Writing one here would replace that measured strength\n // with whatever this function was given, which is how an accent used to undo it.\n const roles = accentRoles(preset, appearance)\n return {\n '--primary': roles.primary,\n '--primary-foreground': roles.primaryForeground,\n '--primary-hover': roles.primaryHover,\n '--ring': roles.ring,\n }\n}\n\n/**\n * The roles a variant sets, as CSS custom properties.\n *\n * The one place that knows the mapping from a theme's roles to this system's variable\n * names. A provider applies this; nothing else repeats it. The `--terminal-*` and\n * `--editor-*` ramps are presentations of the catalogue's ANSI and syntax data rather\n * than separate roles, which is why they are built here and not in the catalogue.\n */\nexport function themeCssVariables(theme: ThemeVariant): Record<string, string> {\n const c = theme.colors\n const t = theme.terminal\n const e = theme.editor\n return {\n '--background': c.background,\n '--foreground': c.foreground,\n '--card': c.card,\n '--card-foreground': c.cardForeground,\n '--popover': c.popover,\n '--popover-foreground': c.popoverForeground,\n '--primary': c.primary,\n '--primary-foreground': c.primaryForeground,\n /*\n * The two tokens derived from the primary, and they are here rather than left to\n * `theme.css` because they must follow `--primary` — which this function writes\n * for *any* theme in the catalogue, not just the two defaults `theme.css` carries.\n *\n * `--primary-hover` is a resolved colour, not a `color-mix()`: a uniform hover\n * step cannot be expressed as a mix (see `primaryHover`). Left out, a theme switch\n * would keep the previous theme's hover on the new theme's primary.\n *\n * `--primary-subtle` is a mix over `--primary`, so it follows an accent on its\n * own, but its *strength* is per theme: `primarySubtleCss(record)` lowers the\n * appearance ceiling only as far as this theme needs for body text to clear 4.5:1\n * on the tint, over every surface, for every accent it offers. It has to be\n * written per theme for that reason — the appearance-wide value is not legible on\n * every palette.\n */\n '--primary-hover': primaryHover(c.primary, theme.appearance),\n '--primary-subtle': primarySubtleFor(theme),\n '--secondary': c.secondary,\n '--secondary-foreground': c.secondaryForeground,\n '--muted': c.muted,\n '--muted-foreground': c.mutedForeground,\n '--accent': c.accent,\n '--accent-foreground': c.accentForeground,\n '--destructive': c.destructive,\n '--destructive-foreground': c.destructiveForeground,\n '--destructive-subtle': c.destructiveSubtle,\n '--destructive-action': c.destructiveAction,\n '--destructive-action-foreground': c.destructiveActionForeground,\n '--success': c.success,\n '--success-foreground': c.successForeground,\n '--success-subtle': c.successSubtle,\n '--warning': c.warning,\n '--warning-foreground': c.warningForeground,\n '--warning-subtle': c.warningSubtle,\n '--info': c.info,\n '--info-foreground': c.infoForeground,\n '--info-subtle': c.infoSubtle,\n '--border': c.border,\n '--input': c.input,\n '--ring': c.ring,\n '--sidebar': c.sidebar,\n '--sidebar-foreground': c.sidebarForeground,\n '--sidebar-accent': c.sidebarAccent,\n '--sidebar-border': c.sidebarBorder,\n '--sidebar-primary': c.primary,\n '--sidebar-primary-foreground': c.primaryForeground,\n '--sidebar-ring': c.ring,\n '--sidebar-muted-foreground': c.sidebarMutedForeground,\n '--surface-sunken': c.muted,\n '--surface-hover': c.accent,\n '--surface-active': c.border,\n '--chrome': c.background,\n '--terminal-background': t.background,\n '--terminal-foreground': t.foreground,\n '--terminal-cursor': t.cursor,\n '--terminal-selection': t.selection,\n '--terminal-ansi-black': t.black,\n '--terminal-ansi-red': t.red,\n '--terminal-ansi-green': t.green,\n '--terminal-ansi-yellow': t.yellow,\n '--terminal-ansi-blue': t.blue,\n '--terminal-ansi-magenta': t.magenta,\n '--terminal-ansi-cyan': t.cyan,\n '--terminal-ansi-white': t.white,\n '--terminal-ansi-bright-black': t.brightBlack,\n '--terminal-ansi-bright-red': t.brightRed,\n '--terminal-ansi-bright-green': t.brightGreen,\n '--terminal-ansi-bright-yellow': t.brightYellow,\n '--terminal-ansi-bright-blue': t.brightBlue,\n '--terminal-ansi-bright-magenta': t.brightMagenta,\n '--terminal-ansi-bright-cyan': t.brightCyan,\n '--terminal-ansi-bright-white': t.brightWhite,\n '--editor-keyword': e.keyword,\n '--editor-string': e.string,\n '--editor-number': e.number,\n '--editor-comment': e.comment,\n '--editor-function': e.function,\n '--editor-variable': e.variable,\n '--editor-type': e.type,\n '--editor-tag': e.tag,\n '--editor-attribute': e.attribute,\n '--editor-operator': e.operator,\n '--editor-heading': e.heading,\n '--editor-link': e.link,\n '--editor-diff-add': e.diffAdd,\n '--editor-diff-delete': e.diffDelete,\n '--editor-diff-hunk': e.diffHunk,\n '--editor-search-match': e.searchMatch,\n '--chart-1': theme.chart[0] ?? c.primary,\n '--chart-2': theme.chart[1] ?? c.info,\n '--chart-3': theme.chart[2] ?? c.success,\n '--chart-4': theme.chart[3] ?? c.warning,\n '--chart-5': theme.chart[4] ?? c.destructive,\n '--chart-6': theme.chart[5] ?? c.mutedForeground,\n }\n}\n\n/* ---------------------------------------------------------------------------\n * Validation\n *\n * Delegated. The floors are the catalogue's, because they are what makes the\n * catalogue able to hold other people's palettes at all, and a second set of floors\n * here would be a second answer to the same question — and the one that drifts.\n * ------------------------------------------------------------------------- */\n\nexport type ThemeFinding = {\n themeId: string\n role: string\n message: string\n}\n\nfunction toFinding(finding: ContrastFinding): ThemeFinding {\n return { themeId: finding.themeId, role: finding.role, message: finding.message }\n}\n\n/** Validates one variant. The floors, and the reasoning behind them, live in the catalogue. */\nexport function validateTheme(theme: ThemeVariant): ThemeFinding[] {\n const record = catalogue.find((entry) => entry.id === theme.id)\n if (!record) {\n return [{ themeId: theme.id, role: 'id', message: `${theme.id} is not in the catalogue` }]\n }\n return validateCatalogue([record]).map(toFinding)\n}\n\n/** Validates the whole registry, including the catalogue-level invariants. */\nexport function validateThemeRegistry(\n themes: readonly ThemeVariant[] = builtinThemes\n): ThemeFinding[] {\n const records = themes\n .map((theme) => catalogue.find((entry) => entry.id === theme.id))\n .filter((record): record is AdeaThemeRecord => !!record)\n\n const orphaned = themes\n .filter((theme) => !hasTheme(theme.id))\n .map((theme) => ({\n themeId: theme.id,\n role: 'id',\n message: `${theme.id} is in the registry but not in the catalogue`,\n }))\n\n return [...orphaned, ...validateCatalogue(records).map(toFinding)]\n}\n\nexport const defaultLightThemeId = 'adea-light'\nexport const defaultDarkThemeId = 'adea-dark'\n\n/** Re-exported so a consumer measuring a colour does not need a second import. */\nexport { contrastRatio } from '@adea-ai/themes'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwLA,SAAS,UAAU,OAAsC;CACvD,MAAM,YAAY,gBAAgB,KAAK;CACvC,MAAM,SAAS,SAAyB;EACtC,MAAM,QAAQ,UAAU,KAAK;EAC7B,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,GAAG,MAAM,GAAG,yCAAyC,MAAM;EACvF,OAAO;CACT;CACA,MAAM,oBAAoB,4BAA4B,KAAK;CAC3D,MAAM,SAAsB;EAC1B,YAAY,MAAM,YAAY;EAC9B,YAAY,MAAM,YAAY;EAC9B,MAAM,MAAM,MAAM;EAClB,gBAAgB,MAAM,iBAAiB;EACvC,SAAS,MAAM,SAAS;EACxB,mBAAmB,MAAM,oBAAoB;EAC7C,SAAS,MAAM,SAAS;EACxB,mBAAmB,MAAM,oBAAoB;EAC7C,WAAW,MAAM,WAAW;EAC5B,qBAAqB,MAAM,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O,CAAC;EAAE,SAAS,MAAM;EAAI,MAAM;EAAM,SAAS,GAAG,MAAM,GAAG;CAA0B,CAAC;CAE3F,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,SAAS;AAClD;;AAGA,SAAgB,sBACd,WAAkC,eAClB;CAChB,MAAM,UAAUC,SACb,KAAK,UAAUD,OAAU,MAAM,UAAU,MAAM,OAAO,MAAM,EAAE,CAAC,CAAC,CAChE,QAAQ,WAAsC,CAAC,CAAC,MAAM;CAUzD,OAAO,CAAC,GARSC,SACd,QAAQ,UAAU,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC,CACtC,KAAK,WAAW;EACf,SAAS,MAAM;EACf,MAAM;EACN,SAAS,GAAG,MAAM,GAAG;CACvB,EAES,GAAU,GAAG,kBAAkB,OAAO,CAAC,CAAC,IAAI,SAAS,CAAC;AACnE;AAEA,IAAa,sBAAsB;AACnC,IAAa,qBAAqB"}
|
|
1
|
+
{"version":3,"file":"themes.js","names":["catalogue","themes"],"sources":["../../src/lib/themes.ts"],"sourcesContent":["/**\n * The theme registry, now a bridge.\n *\n * The catalogue itself lives in `@adea-ai/themes`. This module is what is left in\n * the design system: the translation between the catalogue's **canonical** role\n * names and the **shadcn** vocabulary every component here is written against, plus\n * the handful of custom properties this system declares that are presentations of\n * data the catalogue already holds — the `--terminal-*` ramp, the `--editor-*` ramp,\n * and `--chrome`.\n *\n * ## Why it is a bridge and not a copy\n *\n * This file used to hold thirteen themes as hand-written hex literal tables, with its\n * own contrast validator, its own terminal and editor palettes, and its own\n * provenance records. That is a lot of surface to maintain for one consumer of a\n * palette, and it meant every product that wanted the same themes — Adea, Cortana —\n * either imported this package or wrote its own. The catalogue moved out so that\n * there is one answer to \"what is Catppuccin Mocha\", and this file is the part that\n * genuinely belongs to the design system.\n *\n * It is deliberately thin. If you are looking for a colour, it is not here: see\n * `@adea-ai/themes`, whose README explains how the values are produced and whose\n * `NOTICE` records where every palette came from.\n *\n * ## The mapping, and the entry that is not a rename\n *\n * The package-owned `shadcnVariables` adapter maps canonical roles onto this\n * system's vocabulary. One entry will trip a reader: the catalogue's `accent`\n * becomes this system's `primary`, because in the shadcn vocabulary `--primary` is\n * the action colour — the fill of a primary button, the thing a focus ring is drawn\n * in — while `--accent` is a low-contrast hover wash. The catalogue's `accent` is\n * the former, so it goes to `--primary`, and `--accent` is filled from\n * `surfaceHover`, which is what shadcn components actually use it for.\n */\n\nimport {\n ACCENTS,\n accentForeground,\n accentRoles,\n chartSeries,\n getAccent,\n getTheme,\n hasTheme,\n shadcnDestructiveProjection,\n statusForeground,\n tint,\n primaryHover,\n primarySubtleCss,\n syntaxRoles,\n themes as catalogue,\n themesByAppearance,\n themeAccentPresets,\n validateCatalogue,\n type AccentPreset,\n type AdeaTheme,\n type AdeaThemeRecord,\n type ContrastFinding,\n} from '@adea-ai/themes'\nimport { shadcnVariables } from '@adea-ai/themes/adapters/shadcn'\nimport { oklchToHex, parseColor } from '@adea-ai/themes/oklch'\nimport { isThemeAccentId } from './theme-accents'\n\nexport { isThemeAccentId } from './theme-accents'\n\nexport type ThemeAppearance = 'light' | 'dark'\n\n/**\n * The surface and text roles, in shadcn's vocabulary.\n *\n * Named to match the components below, which is why they differ from the\n * catalogue's: these are this system's variable names, and renaming them would mean\n * touching every component in the library for no gain.\n */\nexport type ThemeColors = {\n background: string\n foreground: string\n card: string\n cardForeground: string\n popover: string\n popoverForeground: string\n primary: string\n primaryForeground: string\n secondary: string\n secondaryForeground: string\n muted: string\n mutedForeground: string\n accent: string\n accentForeground: string\n destructive: string\n destructiveForeground: string\n destructiveSubtle: string\n /** Contrast-safe solid-action presentation, derived from the canonical error role. */\n destructiveAction: string\n destructiveActionForeground: string\n success: string\n successForeground: string\n successSubtle: string\n warning: string\n warningForeground: string\n warningSubtle: string\n info: string\n infoForeground: string\n infoSubtle: string\n border: string\n input: string\n ring: string\n sidebar: string\n sidebarForeground: string\n sidebarAccent: string\n sidebarBorder: string\n sidebarMutedForeground: string\n}\n\n/** The sixteen ANSI colours a terminal needs, plus its cursor and selection. */\nexport type ThemeTerminalPalette = {\n background: string\n foreground: string\n cursor: string\n selection: string\n black: string\n red: string\n green: string\n yellow: string\n blue: string\n magenta: string\n cyan: string\n white: string\n brightBlack: string\n brightRed: string\n brightGreen: string\n brightYellow: string\n brightBlue: string\n brightMagenta: string\n brightCyan: string\n brightWhite: string\n}\n\n/** The syntax roles a code view needs. */\nexport type ThemeEditorPalette = {\n keyword: string\n string: string\n number: string\n comment: string\n function: string\n variable: string\n type: string\n tag: string\n attribute: string\n operator: string\n heading: string\n link: string\n diffAdd: string\n diffDelete: string\n diffHunk: string\n searchMatch: string\n}\n\n/** Where a palette came from, and the terms it is used under. */\nexport type ThemeProvenance = {\n /** The project or person the palette belongs to. */\n source: string\n url: string\n /** An SPDX identifier. Every palette in this catalogue is permissive. */\n license: string\n}\n\nexport type ThemeVariant = {\n /** The `data-theme` value and the id a preference stores. */\n id: string\n /** Groups the variants that came from one project. */\n family: string\n familyLabel: string\n label: string\n appearance: ThemeAppearance\n /** One line, shown in a picker. */\n description: string\n colors: ThemeColors\n terminal: ThemeTerminalPalette\n editor: ThemeEditorPalette\n /** The categorical series, in order. */\n chart: readonly string[]\n provenance: ThemeProvenance\n /**\n * Custom properties written verbatim over {@link themeCssVariables}, last.\n *\n * For a variant a host built from data it does not control the derivation of —\n * an imported theme whose painted colours must stay exactly what the user\n * imported. The catalogue's own variants never carry it, so the derived roles\n * stay the only source of truth for them.\n */\n tokens?: Readonly<Record<string, string>>\n}\n\n/**\n * The shadcn-vocabulary roles of one catalogue entry.\n *\n * The expensive half of a variant: `shadcnVariables` projects the whole palette\n * (about 4 ms a theme), which is why {@link lazyVariant} defers it.\n */\nfunction colorsOf(theme: AdeaThemeRecord): ThemeColors {\n const projected = shadcnVariables(theme)\n const token = (name: string): string => {\n const value = projected[`--${name}`]\n if (!value) throw new Error(`${theme.id} has no shared shadcn projection for --${name}`)\n return value\n }\n const destructiveAction = shadcnDestructiveProjection(theme)\n return {\n background: token('background'),\n foreground: token('foreground'),\n card: token('card'),\n cardForeground: token('card-foreground'),\n popover: token('popover'),\n popoverForeground: token('popover-foreground'),\n primary: token('primary'),\n primaryForeground: token('primary-foreground'),\n secondary: token('secondary'),\n secondaryForeground: token('secondary-foreground'),\n muted: token('muted'),\n mutedForeground: token('muted-foreground'),\n accent: token('accent'),\n accentForeground: token('accent-foreground'),\n // Preserve the UI's semantic error token. The Themes projection uses its\n // contrast-safe solid-action fill for --destructive; UI keeps that fill in\n // the separate destructiveAction pair below.\n destructive: theme.colors.error,\n destructiveForeground: statusForeground(theme, 'error'),\n destructiveSubtle: tint(theme.colors.error, theme.colors.background),\n destructiveAction: destructiveAction.fill,\n destructiveActionForeground: destructiveAction.foreground,\n success: token('success'),\n successForeground: statusForeground(theme, 'success'),\n successSubtle: tint(theme.colors.success, theme.colors.background),\n warning: token('warning'),\n warningForeground: statusForeground(theme, 'warning'),\n warningSubtle: tint(theme.colors.warning, theme.colors.background),\n info: token('info'),\n infoForeground: statusForeground(theme, 'info'),\n infoSubtle: tint(theme.colors.info, theme.colors.background),\n border: token('border'),\n input: token('input'),\n ring: token('ring'),\n sidebar: token('sidebar'),\n sidebarForeground: token('sidebar-foreground'),\n sidebarAccent: token('sidebar-accent'),\n sidebarBorder: token('sidebar-border'),\n sidebarMutedForeground: token('sidebar-muted-foreground'),\n }\n}\n\n// The embedded terminal uses the theme's own canvas rather than a palette of its\n// own. The ANSI colours came from the palette that produced the canvas, so they\n// were chosen against it; a terminal on a different background would be the one\n// surface in the application not lit by the active theme.\nfunction terminalOf(theme: AdeaThemeRecord): ThemeTerminalPalette {\n return {\n background: theme.colors.background,\n foreground: theme.colors.foreground,\n cursor: theme.cursor,\n selection: theme.selection,\n ...theme.ansi,\n }\n}\n\nfunction editorOf(theme: AdeaThemeRecord): ThemeEditorPalette {\n const syntax = syntaxRoles(theme)\n return {\n keyword: syntax.keyword,\n string: syntax.string,\n number: syntax.number,\n comment: syntax.comment,\n function: syntax.function,\n variable: syntax.variable,\n type: syntax.type,\n tag: syntax.tag,\n attribute: syntax.attribute,\n operator: syntax.operator,\n heading: syntax.heading,\n link: syntax.link,\n diffAdd: syntax.diffAdd,\n diffDelete: syntax.diffDelete,\n diffHunk: syntax.diffHunk,\n searchMatch: syntax.searchMatch,\n }\n}\n\nfunction provenanceOf(theme: AdeaThemeRecord): ThemeProvenance {\n return {\n source: theme.provenance.project,\n url: theme.provenance.url,\n license: theme.provenance.license,\n }\n}\n\n/**\n * The design system's view of one catalogue record, built in full and at once.\n *\n * For a host that holds a record the catalogue does not — an imported theme, a\n * reconstruction from stored data — and wants a variant it can hand to\n * `ThemeProvider`'s `themes`. It throws for a record the shadcn projection cannot\n * map, here and now, rather than on first paint. The catalogue itself goes through\n * {@link lazyVariant} instead.\n */\nexport function variantFromRecord(theme: AdeaThemeRecord): ThemeVariant {\n return {\n id: theme.id,\n family: theme.family,\n familyLabel: theme.familyLabel,\n label: theme.label,\n appearance: theme.appearance,\n description: theme.description,\n colors: colorsOf(theme),\n terminal: terminalOf(theme),\n editor: editorOf(theme),\n chart: chartSeries(theme),\n provenance: provenanceOf(theme),\n }\n}\n\n/** Runs `build` on first call and returns that value from then on. A throw is not cached. */\nfunction once<T>(build: () => T): () => T {\n let built = false\n let value: T\n return () => {\n if (!built) {\n value = build()\n built = true\n }\n return value\n }\n}\n\nconst lazy = <T>(build: () => T): PropertyDescriptor => ({\n get: once(build),\n enumerable: true,\n})\n\n/**\n * {@link variantFromRecord} with the four derived palettes built on first read.\n *\n * Evaluating this module used to project all 34 catalogue themes up front, about\n * 155 ms before a single one was needed, on the hydration path of every consumer.\n * A page paints one variant, and a picker's labels and appearance are plain\n * fields, so only a variant whose `colors`, `terminal`, `editor` or `chart` is read\n * pays for them, once. The properties stay enumerable data-shaped accessors, so\n * spreading, `Object.entries` and JSON see the same object they always did.\n */\nfunction lazyVariant(theme: AdeaThemeRecord): ThemeVariant {\n return Object.defineProperties(\n {\n id: theme.id,\n family: theme.family,\n familyLabel: theme.familyLabel,\n label: theme.label,\n appearance: theme.appearance,\n description: theme.description,\n provenance: provenanceOf(theme),\n },\n {\n colors: lazy(() => colorsOf(theme)),\n terminal: lazy(() => terminalOf(theme)),\n editor: lazy(() => editorOf(theme)),\n chart: lazy(() => chartSeries(theme)),\n }\n ) as ThemeVariant\n}\n\n/**\n * A variant's `--primary-subtle`: the tint over `var(--primary)` at the strength its\n * catalogue record measures (`primarySubtleAlpha`). A variant that is not in the\n * catalogue has nothing to measure, and gets its appearance's ceiling.\n */\nexport function primarySubtleFor(theme: Pick<ThemeVariant, 'id' | 'appearance'>): string {\n const record = getTheme(theme.id)\n return record ? primarySubtleCss(record) : primarySubtleCss(theme.appearance)\n}\n\n/** The catalogue, in catalogue order. */\nexport const builtinThemes: readonly ThemeVariant[] = Object.freeze(catalogue.map(lazyVariant))\n\nexport function themeById(id: string): ThemeVariant | undefined {\n if (!hasTheme(id)) return undefined\n return builtinThemes.find((theme) => theme.id === id)\n}\n\n/**\n * The variant a stored id means, or the default of the same appearance.\n *\n * An id the registry does not hold — an imported theme that was deleted, a\n * catalogue entry that was renamed — must still paint *something of the appearance\n * being shown*. Falling back to whichever variant happens to be first in the\n * registry painted a dark palette under a light `color-scheme` for a light id, so\n * the fallback is the appearance's own default, then any variant of that\n * appearance, then the registry's first entry only when it holds nothing else.\n *\n * `registry` is the builtin catalogue plus whatever extras the host supplies; the\n * stored id is never rewritten, only resolved, so a host that keeps an unknown id\n * keeps resolving it if the theme comes back.\n *\n * The fallback order is translated from Zeron's `ThemeRegistry::resolve` (MIT,\n * Copyright (c) 2026 Wing); see NOTICE.\n */\nexport function resolveVariant(\n registry: readonly ThemeVariant[],\n id: string,\n appearance: ThemeAppearance\n): ThemeVariant {\n const found = registry.find((variant) => variant.id === id)\n if (found) return found\n const defaultId = appearance === 'dark' ? defaultDarkThemeId : defaultLightThemeId\n return (\n registry.find((variant) => variant.id === defaultId) ??\n registry.find((variant) => variant.appearance === appearance) ??\n registry[0]!\n )\n}\n\n/** The variants of one appearance, which is what a picker for that mode shows. */\nexport function themesForAppearance(appearance: ThemeAppearance): readonly ThemeVariant[] {\n const ids = new Set(themesByAppearance(appearance).map((theme) => theme.id))\n return builtinThemes.filter((theme) => ids.has(theme.id))\n}\n\n/** The families in the catalogue, in catalogue order. */\nexport function themeFamilies(): { family: string; label: string; themes: ThemeVariant[] }[] {\n const families = new Map<string, { family: string; label: string; themes: ThemeVariant[] }>()\n for (const theme of builtinThemes) {\n const entry = families.get(theme.family) ?? {\n family: theme.family,\n label: theme.familyLabel,\n themes: [],\n }\n entry.themes.push(theme)\n families.set(theme.family, entry)\n }\n return [...families.values()]\n}\n\n/** The accent presets, in the order a picker should show them. */\nexport const accents = ACCENTS\n\n/**\n * The canonical catalogue records, in catalogue order.\n *\n * {@link builtinThemes} is this system's projection of the catalogue onto the\n * shadcn vocabulary, which is what a document is painted with. A *preview* of a\n * theme — the miniatures `AppearanceEditor` and `ThemeMiniature` draw — reads the\n * catalogue's own roles instead (`surfaceActive`, `borderMuted`, `textSubtle`…),\n * several of which the projection folds together. These are those records, so a\n * consumer hands the editor exactly what it takes rather than reconstructing it\n * from the projection.\n */\nexport const themeRecords: readonly AdeaThemeRecord[] = catalogue\n\nexport function themeRecordById(id: string): AdeaThemeRecord | undefined {\n return getTheme(id)\n}\n\n/** A light/dark theme pair by id, with the defaults standing in for an unknown id. */\nfunction recordPair(lightThemeId: string, darkThemeId: string) {\n const light = getTheme(lightThemeId) ?? getTheme(defaultLightThemeId)!\n const dark = getTheme(darkThemeId) ?? getTheme(defaultDarkThemeId)!\n return { light, dark }\n}\n\n/**\n * The accents the selected light/dark pair carries — offered beside the presets.\n *\n * Computed per pair rather than per theme because a theme accent is a *pair* of\n * values, like a preset: a slot is offered only when both themes can offer it.\n */\nexport function themeAccentsFor(\n lightThemeId: string,\n darkThemeId: string\n): readonly AccentPreset[] {\n const { light, dark } = recordPair(lightThemeId, darkThemeId)\n return themeAccentPresets(light, dark)\n}\n\n/**\n * An accent id resolved against a theme pair: a preset, a theme accent the pair\n * offers, or `undefined` for `theme`, an unknown id, or a slot this pair cannot\n * offer — each of which means \"use the theme's own primary\".\n *\n * Theme accent ids are role-shaped (`ansi-blue`), so a stored one survives a theme\n * switch and resolves to the new theme's blue; when the new pair cannot offer the\n * slot it resolves to nothing, the same fallback a stale preset id gets.\n */\nexport function resolveAccentPreset(\n accentId: string,\n light: AdeaTheme,\n dark: AdeaTheme\n): AccentPreset | undefined {\n if (accentId === 'theme') return undefined\n const preset = getAccent(accentId)\n if (preset) return preset\n if (!isThemeAccentId(accentId)) return undefined\n return themeAccentPresets(light, dark).find((option) => option.id === accentId)\n}\n\n/**\n * A theme with an accent laid over it, in the catalogue's own shape.\n *\n * The accent replaces `accent` and its measured label, which is all an accent\n * changes about a theme; `undefined` returns the theme untouched. This is the\n * overlay a host needs for `AppearanceEditor`'s `lightTheme`/`darkTheme`.\n */\nexport function withAccent<T extends AdeaTheme>(theme: T, accent: AccentPreset | undefined): T {\n if (!accent) return theme\n const value = theme.appearance === 'dark' ? accent.dark : accent.light\n return {\n ...theme,\n colors: { ...theme.colors, accent: value, accentForeground: accentForeground(value) },\n }\n}\n\n/**\n * The two preview themes an appearance selection resolves to, accent applied.\n *\n * The adapter between a stored selection and `AppearanceEditor`: it takes ids —\n * what a preference holds — and returns the canonical records the editor's\n * `lightTheme` and `darkTheme` props take, so a host does not map roles by hand.\n * Unknown ids fall back to the defaults and an accent the pair cannot offer falls\n * back to the theme's own, exactly as `ThemeProvider` resolves them.\n */\nexport function appearancePreviewThemes(selection: {\n lightThemeId: string\n darkThemeId: string\n accent: string\n}): { lightTheme: AdeaThemeRecord; darkTheme: AdeaThemeRecord } {\n const { light, dark } = recordPair(selection.lightThemeId, selection.darkThemeId)\n const accent = resolveAccentPreset(selection.accent, light, dark)\n return { lightTheme: withAccent(light, accent), darkTheme: withAccent(dark, accent) }\n}\n\n/**\n * The properties an accent selection overrides, as CSS custom properties.\n *\n * ## Why this exists rather than relying on the `[data-accent]` blocks\n *\n * `theme.css` carries a `[data-accent='…']` block per preset, and those blocks are\n * correct — but they are unreachable at runtime. `ThemeProvider` writes a theme's\n * whole role set onto `<html>` as *inline* custom properties, and an inline\n * declaration outranks any stylesheet selector regardless of specificity. The\n * attribute was set, the rules existed, the values were right, and every one of the\n * seven accents rendered as the same blue.\n *\n * The blocks are kept, because they are what styles the window between the document\n * arriving and the provider mounting — which is the whole reason `themeScript`\n * exists. But the authoritative value has to be applied by the same code that\n * applies the theme, from the same source, or the two can drift again. So both the\n * provider and the CSS generator call `accentRoles` out of `@adea-ai/themes`, and\n * `tests/appearance-axes.test.ts` asserts the two agree value for value.\n *\n * A theme accent (`ansi-blue`) has no block: its value depends on the theme pair,\n * so it is resolved against `pair` — the selection's light and dark theme ids —\n * and only ever applied here. Without a pair it resolves against the defaults.\n *\n * Returns `undefined` for `theme` — the variant's own primary — for an id the\n * catalogue does not have, and for a theme accent the pair does not offer, so a\n * stale stored preference falls back to the theme rather than blanking the primary.\n */\nexport function accentVariables(\n accentId: string,\n appearance: ThemeAppearance,\n pair: { lightThemeId: string; darkThemeId: string } = {\n lightThemeId: defaultLightThemeId,\n darkThemeId: defaultDarkThemeId,\n }\n): Record<string, string> | undefined {\n if (accentId === 'theme') return undefined\n const { light, dark } = recordPair(pair.lightThemeId, pair.darkThemeId)\n const preset = resolveAccentPreset(accentId, light, dark)\n if (!preset) return undefined\n\n // `--primary-subtle` is deliberately not here. It is a `color-mix()` over\n // `var(--primary)`, so the theme's own declaration (`themeCssVariables`, or the\n // default block in `theme.css`) already follows the accent; and its strength is the\n // *theme's*, measured by `primarySubtleAlpha` to hold body text at 4.5:1 for every\n // accent the theme offers. Writing one here would replace that measured strength\n // with whatever this function was given, which is how an accent used to undo it.\n const roles = accentRoles(preset, appearance)\n return {\n '--primary': roles.primary,\n '--primary-foreground': roles.primaryForeground,\n '--primary-hover': roles.primaryHover,\n '--ring': roles.ring,\n }\n}\n\n/**\n * The roles a variant sets, as CSS custom properties.\n *\n * The one place that knows the mapping from a theme's roles to this system's variable\n * names. A provider applies this; nothing else repeats it. The `--terminal-*` and\n * `--editor-*` ramps are presentations of the catalogue's ANSI and syntax data rather\n * than separate roles, which is why they are built here and not in the catalogue.\n */\nexport function themeCssVariables(theme: ThemeVariant): Record<string, string> {\n const c = theme.colors\n const t = theme.terminal\n const e = theme.editor\n const derived = {\n '--background': c.background,\n '--foreground': c.foreground,\n '--card': c.card,\n '--card-foreground': c.cardForeground,\n '--popover': c.popover,\n '--popover-foreground': c.popoverForeground,\n '--primary': c.primary,\n '--primary-foreground': c.primaryForeground,\n /*\n * The two tokens derived from the primary, and they are here rather than left to\n * `theme.css` because they must follow `--primary` — which this function writes\n * for *any* theme in the catalogue, not just the two defaults `theme.css` carries.\n *\n * `--primary-hover` is a resolved colour, not a `color-mix()`: a uniform hover\n * step cannot be expressed as a mix (see `primaryHover`). Left out, a theme switch\n * would keep the previous theme's hover on the new theme's primary.\n *\n * `--primary-subtle` is a mix over `--primary`, so it follows an accent on its\n * own, but its *strength* is per theme: `primarySubtleCss(record)` lowers the\n * appearance ceiling only as far as this theme needs for body text to clear 4.5:1\n * on the tint, over every surface, for every accent it offers. It has to be\n * written per theme for that reason — the appearance-wide value is not legible on\n * every palette.\n */\n '--primary-hover': primaryHover(c.primary, theme.appearance),\n '--primary-subtle': primarySubtleFor(theme),\n '--secondary': c.secondary,\n '--secondary-foreground': c.secondaryForeground,\n '--muted': c.muted,\n '--muted-foreground': c.mutedForeground,\n '--accent': c.accent,\n '--accent-foreground': c.accentForeground,\n '--destructive': c.destructive,\n '--destructive-foreground': c.destructiveForeground,\n '--destructive-subtle': c.destructiveSubtle,\n '--destructive-action': c.destructiveAction,\n '--destructive-action-foreground': c.destructiveActionForeground,\n '--success': c.success,\n '--success-foreground': c.successForeground,\n '--success-subtle': c.successSubtle,\n '--warning': c.warning,\n '--warning-foreground': c.warningForeground,\n '--warning-subtle': c.warningSubtle,\n '--info': c.info,\n '--info-foreground': c.infoForeground,\n '--info-subtle': c.infoSubtle,\n '--border': c.border,\n '--input': c.input,\n '--ring': c.ring,\n '--sidebar': c.sidebar,\n '--sidebar-foreground': c.sidebarForeground,\n '--sidebar-accent': c.sidebarAccent,\n '--sidebar-border': c.sidebarBorder,\n '--sidebar-primary': c.primary,\n '--sidebar-primary-foreground': c.primaryForeground,\n '--sidebar-ring': c.ring,\n '--sidebar-muted-foreground': c.sidebarMutedForeground,\n '--surface-sunken': c.muted,\n '--surface-hover': c.accent,\n '--surface-active': c.border,\n '--chrome': c.background,\n '--terminal-background': t.background,\n '--terminal-foreground': t.foreground,\n '--terminal-cursor': t.cursor,\n '--terminal-selection': t.selection,\n '--terminal-ansi-black': t.black,\n '--terminal-ansi-red': t.red,\n '--terminal-ansi-green': t.green,\n '--terminal-ansi-yellow': t.yellow,\n '--terminal-ansi-blue': t.blue,\n '--terminal-ansi-magenta': t.magenta,\n '--terminal-ansi-cyan': t.cyan,\n '--terminal-ansi-white': t.white,\n '--terminal-ansi-bright-black': t.brightBlack,\n '--terminal-ansi-bright-red': t.brightRed,\n '--terminal-ansi-bright-green': t.brightGreen,\n '--terminal-ansi-bright-yellow': t.brightYellow,\n '--terminal-ansi-bright-blue': t.brightBlue,\n '--terminal-ansi-bright-magenta': t.brightMagenta,\n '--terminal-ansi-bright-cyan': t.brightCyan,\n '--terminal-ansi-bright-white': t.brightWhite,\n '--editor-keyword': e.keyword,\n '--editor-string': e.string,\n '--editor-number': e.number,\n '--editor-comment': e.comment,\n '--editor-function': e.function,\n '--editor-variable': e.variable,\n '--editor-type': e.type,\n '--editor-tag': e.tag,\n '--editor-attribute': e.attribute,\n '--editor-operator': e.operator,\n '--editor-heading': e.heading,\n '--editor-link': e.link,\n '--editor-diff-add': e.diffAdd,\n '--editor-diff-delete': e.diffDelete,\n '--editor-diff-hunk': e.diffHunk,\n '--editor-search-match': e.searchMatch,\n '--chart-1': theme.chart[0] ?? c.primary,\n '--chart-2': theme.chart[1] ?? c.info,\n '--chart-3': theme.chart[2] ?? c.success,\n '--chart-4': theme.chart[3] ?? c.warning,\n '--chart-5': theme.chart[4] ?? c.destructive,\n '--chart-6': theme.chart[5] ?? c.mutedForeground,\n }\n return theme.tokens ? { ...derived, ...theme.tokens } : derived\n}\n\n/**\n * Token values with every `oklch()` colour written as `#rrggbb`.\n *\n * For a host whose stylesheet, tests or native shell speak hex: the catalogue's\n * roles are `oklch()` strings, and this is the one conversion, gamut-mapped by the\n * catalogue's own `oklchToHex`. A value that is already hex, carries alpha\n * (`rgba()`), or is not a plain colour (`color-mix()`, `var()`) is left byte for\n * byte, because converting would either lose the alpha or be a guess. Suitable as\n * `ThemeProvider`'s `transformTokens`.\n */\nexport function tokensAsHex(tokens: Readonly<Record<string, string>>): Record<string, string> {\n const converted: Record<string, string> = {}\n for (const [name, value] of Object.entries(tokens)) {\n const trimmed = value.trim()\n // `parseOklch` discards alpha, so a translucent oklch() stays as written.\n const opaque = trimmed.startsWith('oklch(') && !trimmed.includes('/')\n const parsed = opaque ? parseColor(trimmed) : undefined\n converted[name] = parsed ? oklchToHex(parsed) : value\n }\n return converted\n}\n\n/* ---------------------------------------------------------------------------\n * Validation\n *\n * Delegated. The floors are the catalogue's, because they are what makes the\n * catalogue able to hold other people's palettes at all, and a second set of floors\n * here would be a second answer to the same question — and the one that drifts.\n * ------------------------------------------------------------------------- */\n\nexport type ThemeFinding = {\n themeId: string\n role: string\n message: string\n}\n\nfunction toFinding(finding: ContrastFinding): ThemeFinding {\n return { themeId: finding.themeId, role: finding.role, message: finding.message }\n}\n\n/** Validates one variant. The floors, and the reasoning behind them, live in the catalogue. */\nexport function validateTheme(theme: ThemeVariant): ThemeFinding[] {\n const record = catalogue.find((entry) => entry.id === theme.id)\n if (!record) {\n return [{ themeId: theme.id, role: 'id', message: `${theme.id} is not in the catalogue` }]\n }\n return validateCatalogue([record]).map(toFinding)\n}\n\n/** Validates the whole registry, including the catalogue-level invariants. */\nexport function validateThemeRegistry(\n themes: readonly ThemeVariant[] = builtinThemes\n): ThemeFinding[] {\n const records = themes\n .map((theme) => catalogue.find((entry) => entry.id === theme.id))\n .filter((record): record is AdeaThemeRecord => !!record)\n\n const orphaned = themes\n .filter((theme) => !hasTheme(theme.id))\n .map((theme) => ({\n themeId: theme.id,\n role: 'id',\n message: `${theme.id} is in the registry but not in the catalogue`,\n }))\n\n return [...orphaned, ...validateCatalogue(records).map(toFinding)]\n}\n\nexport const defaultLightThemeId = 'adea-light'\nexport const defaultDarkThemeId = 'adea-dark'\n\n/** Re-exported so a consumer measuring a colour does not need a second import. */\nexport { contrastRatio } from '@adea-ai/themes'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuMA,SAAS,SAAS,OAAqC;CACrD,MAAM,YAAY,gBAAgB,KAAK;CACvC,MAAM,SAAS,SAAyB;EACtC,MAAM,QAAQ,UAAU,KAAK;EAC7B,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,GAAG,MAAM,GAAG,yCAAyC,MAAM;EACvF,OAAO;CACT;CACA,MAAM,oBAAoB,4BAA4B,KAAK;CAC3D,OAAO;EACL,YAAY,MAAM,YAAY;EAC9B,YAAY,MAAM,YAAY;EAC9B,MAAM,MAAM,MAAM;EAClB,gBAAgB,MAAM,iBAAiB;EACvC,SAAS,MAAM,SAAS;EACxB,mBAAmB,MAAM,oBAAoB;EAC7C,SAAS,MAAM,SAAS;EACxB,mBAAmB,MAAM,oBAAoB;EAC7C,WAAW,MAAM,WAAW;EAC5B,qBAAqB,MAAM,sBAAsB;EACjD,OAAO,MAAM,OAAO;EACpB,iBAAiB,MAAM,kBAAkB;EACzC,QAAQ,MAAM,QAAQ;EACtB,kBAAkB,MAAM,mBAAmB;EAI3C,aAAa,MAAM,OAAO;EAC1B,uBAAuB,iBAAiB,OAAO,OAAO;EACtD,mBAAmB,KAAK,MAAM,OAAO,OAAO,MAAM,OAAO,UAAU;EACnE,mBAAmB,kBAAk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ACH,OAAO,CAAC;EAAE,SAAS,MAAM;EAAI,MAAM;EAAM,SAAS,GAAG,MAAM,GAAG;CAA0B,CAAC;CAE3F,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,SAAS;AAClD;;AAGA,SAAgB,sBACd,WAAkC,eAClB;CAChB,MAAM,UAAUC,SACb,KAAK,UAAUD,OAAU,MAAM,UAAU,MAAM,OAAO,MAAM,EAAE,CAAC,CAAC,CAChE,QAAQ,WAAsC,CAAC,CAAC,MAAM;CAUzD,OAAO,CAAC,GARSC,SACd,QAAQ,UAAU,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC,CACtC,KAAK,WAAW;EACf,SAAS,MAAM;EACf,MAAM;EACN,SAAS,GAAG,MAAM,GAAG;CACvB,EAES,GAAU,GAAG,kBAAkB,OAAO,CAAC,CAAC,IAAI,SAAS,CAAC;AACnE;AAEA,IAAa,sBAAsB;AACnC,IAAa,qBAAqB"}
|
package/dist/r/registry.json
CHANGED
|
@@ -1811,6 +1811,7 @@
|
|
|
1811
1811
|
],
|
|
1812
1812
|
"registryDependencies": [
|
|
1813
1813
|
"@adea-ai/ui/action-button",
|
|
1814
|
+
"@adea-ai/ui/button",
|
|
1814
1815
|
"lib"
|
|
1815
1816
|
],
|
|
1816
1817
|
"files": [
|
|
@@ -1834,6 +1835,31 @@
|
|
|
1834
1835
|
"type": "registry:ui",
|
|
1835
1836
|
"target": "components/layout/split-layout/model.ts"
|
|
1836
1837
|
},
|
|
1838
|
+
{
|
|
1839
|
+
"path": "src/components/layout/split-layout/resize-controller-core-retry.tsx",
|
|
1840
|
+
"type": "registry:ui",
|
|
1841
|
+
"target": "components/layout/split-layout/resize-controller-core-retry.tsx"
|
|
1842
|
+
},
|
|
1843
|
+
{
|
|
1844
|
+
"path": "src/components/layout/split-layout/resize-controller-core.tsx",
|
|
1845
|
+
"type": "registry:ui",
|
|
1846
|
+
"target": "components/layout/split-layout/resize-controller-core.tsx"
|
|
1847
|
+
},
|
|
1848
|
+
{
|
|
1849
|
+
"path": "src/components/layout/split-layout/resize-controller-retry-2.tsx",
|
|
1850
|
+
"type": "registry:ui",
|
|
1851
|
+
"target": "components/layout/split-layout/resize-controller-retry-2.tsx"
|
|
1852
|
+
},
|
|
1853
|
+
{
|
|
1854
|
+
"path": "src/components/layout/split-layout/resize-controller-retry.tsx",
|
|
1855
|
+
"type": "registry:ui",
|
|
1856
|
+
"target": "components/layout/split-layout/resize-controller-retry.tsx"
|
|
1857
|
+
},
|
|
1858
|
+
{
|
|
1859
|
+
"path": "src/components/layout/split-layout/resize-controller.tsx",
|
|
1860
|
+
"type": "registry:ui",
|
|
1861
|
+
"target": "components/layout/split-layout/resize-controller.tsx"
|
|
1862
|
+
},
|
|
1837
1863
|
{
|
|
1838
1864
|
"path": "src/components/layout/split-layout/split-layout.tsx",
|
|
1839
1865
|
"type": "registry:ui",
|
|
@@ -2501,11 +2527,26 @@
|
|
|
2501
2527
|
"type": "registry:ui",
|
|
2502
2528
|
"target": "components/theming/index.ts"
|
|
2503
2529
|
},
|
|
2530
|
+
{
|
|
2531
|
+
"path": "src/components/theme/theme-context.ts",
|
|
2532
|
+
"type": "registry:ui",
|
|
2533
|
+
"target": "components/theming/theme-context.ts"
|
|
2534
|
+
},
|
|
2535
|
+
{
|
|
2536
|
+
"path": "src/components/theme/theme-document.ts",
|
|
2537
|
+
"type": "registry:ui",
|
|
2538
|
+
"target": "components/theming/theme-document.ts"
|
|
2539
|
+
},
|
|
2504
2540
|
{
|
|
2505
2541
|
"path": "src/components/theme/theme-mode-toggle.tsx",
|
|
2506
2542
|
"type": "registry:ui",
|
|
2507
2543
|
"target": "components/theming/theme-mode-toggle.tsx"
|
|
2508
2544
|
},
|
|
2545
|
+
{
|
|
2546
|
+
"path": "src/components/theme/theme-persistence.ts",
|
|
2547
|
+
"type": "registry:ui",
|
|
2548
|
+
"target": "components/theming/theme-persistence.ts"
|
|
2549
|
+
},
|
|
2509
2550
|
{
|
|
2510
2551
|
"path": "src/components/theme/theme-picker.tsx",
|
|
2511
2552
|
"type": "registry:ui",
|
|
@@ -2516,6 +2557,11 @@
|
|
|
2516
2557
|
"type": "registry:ui",
|
|
2517
2558
|
"target": "components/theming/theme-provider.tsx"
|
|
2518
2559
|
},
|
|
2560
|
+
{
|
|
2561
|
+
"path": "src/components/theme/theme-state.ts",
|
|
2562
|
+
"type": "registry:ui",
|
|
2563
|
+
"target": "components/theming/theme-state.ts"
|
|
2564
|
+
},
|
|
2519
2565
|
{
|
|
2520
2566
|
"path": "src/components/theme/theme-toggle.tsx",
|
|
2521
2567
|
"type": "registry:ui",
|
package/dist/r/split-layout.json
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"registryDependencies": [
|
|
11
11
|
"@adea-ai/ui/action-button",
|
|
12
|
+
"@adea-ai/ui/button",
|
|
12
13
|
"lib"
|
|
13
14
|
],
|
|
14
15
|
"files": [
|
|
@@ -32,6 +33,31 @@
|
|
|
32
33
|
"type": "registry:ui",
|
|
33
34
|
"target": "components/layout/split-layout/model.ts"
|
|
34
35
|
},
|
|
36
|
+
{
|
|
37
|
+
"path": "src/components/layout/split-layout/resize-controller-core-retry.tsx",
|
|
38
|
+
"type": "registry:ui",
|
|
39
|
+
"target": "components/layout/split-layout/resize-controller-core-retry.tsx"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "src/components/layout/split-layout/resize-controller-core.tsx",
|
|
43
|
+
"type": "registry:ui",
|
|
44
|
+
"target": "components/layout/split-layout/resize-controller-core.tsx"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"path": "src/components/layout/split-layout/resize-controller-retry-2.tsx",
|
|
48
|
+
"type": "registry:ui",
|
|
49
|
+
"target": "components/layout/split-layout/resize-controller-retry-2.tsx"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"path": "src/components/layout/split-layout/resize-controller-retry.tsx",
|
|
53
|
+
"type": "registry:ui",
|
|
54
|
+
"target": "components/layout/split-layout/resize-controller-retry.tsx"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"path": "src/components/layout/split-layout/resize-controller.tsx",
|
|
58
|
+
"type": "registry:ui",
|
|
59
|
+
"target": "components/layout/split-layout/resize-controller.tsx"
|
|
60
|
+
},
|
|
35
61
|
{
|
|
36
62
|
"path": "src/components/layout/split-layout/split-layout.tsx",
|
|
37
63
|
"type": "registry:ui",
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import Resizable from '@corvu/resizable'
|
|
2
|
+
import { type Accessor, type JSX } from 'solid-js'
|
|
3
|
+
import {
|
|
4
|
+
listLeaves,
|
|
5
|
+
MIN_SPLIT_RATIO,
|
|
6
|
+
MAX_SPLIT_RATIO,
|
|
7
|
+
type SplitLayoutBranch,
|
|
8
|
+
type SplitLayoutLeaf,
|
|
9
|
+
} from './model'
|
|
10
|
+
|
|
11
|
+
export type SplitLayoutResizeControllerProps<L extends SplitLayoutLeaf> = {
|
|
12
|
+
branch: Accessor<SplitLayoutBranch<L>>
|
|
13
|
+
rect: Accessor<JSX.CSSProperties>
|
|
14
|
+
domId: (id: string) => string
|
|
15
|
+
root: () => HTMLDivElement | undefined
|
|
16
|
+
labelForSeparator?: (branch: SplitLayoutBranch<L>) => string
|
|
17
|
+
onResize: (splitId: string, ratio: number) => void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Corvu stays behind the first real split while the pane owners remain mounted. */
|
|
21
|
+
export default function SplitLayoutResizeController<L extends SplitLayoutLeaf>(
|
|
22
|
+
props: SplitLayoutResizeControllerProps<L>
|
|
23
|
+
) {
|
|
24
|
+
const id = () => props.branch().id
|
|
25
|
+
return (
|
|
26
|
+
<Resizable
|
|
27
|
+
orientation={props.branch().direction === 'row' ? 'horizontal' : 'vertical'}
|
|
28
|
+
sizes={[props.branch().ratio, 1 - props.branch().ratio]}
|
|
29
|
+
keyboardDelta={0.05}
|
|
30
|
+
onSizesChange={(sizes) => {
|
|
31
|
+
// Corvu also reports panel registration/unregistration while
|
|
32
|
+
// mounting or disposing a controller. Those incomplete or
|
|
33
|
+
// hidden-host sizes are not user resize intent.
|
|
34
|
+
const root = props.root()
|
|
35
|
+
if (!root?.isConnected || root.getClientRects().length === 0) return
|
|
36
|
+
if (
|
|
37
|
+
sizes.length !== 2 ||
|
|
38
|
+
sizes.some((size) => !Number.isFinite(size)) ||
|
|
39
|
+
Math.abs(sizes[0]! + sizes[1]! - 1) > 0.000001
|
|
40
|
+
)
|
|
41
|
+
return
|
|
42
|
+
if (sizes[0] !== undefined && Math.abs(sizes[0] - props.branch().ratio) > 0.000001)
|
|
43
|
+
props.onResize(id(), sizes[0])
|
|
44
|
+
}}
|
|
45
|
+
style={props.rect()}
|
|
46
|
+
class="pointer-events-none absolute flex min-h-0 min-w-0 data-[orientation=vertical]:flex-col"
|
|
47
|
+
>
|
|
48
|
+
<Resizable.Panel minSize={MIN_SPLIT_RATIO} maxSize={MAX_SPLIT_RATIO} aria-hidden="true" />
|
|
49
|
+
<Resizable.Handle
|
|
50
|
+
aria-label={
|
|
51
|
+
props.labelForSeparator?.(props.branch()) ??
|
|
52
|
+
(props.branch().direction === 'row' ? 'Resize pane columns' : 'Resize pane rows')
|
|
53
|
+
}
|
|
54
|
+
aria-orientation={props.branch().direction === 'row' ? 'vertical' : 'horizontal'}
|
|
55
|
+
aria-controls={listLeaves(props.branch())
|
|
56
|
+
.map((leaf) => props.domId(leaf.id))
|
|
57
|
+
.join(' ')}
|
|
58
|
+
aria-valuemin={10}
|
|
59
|
+
aria-valuemax={90}
|
|
60
|
+
aria-valuenow={Math.round(props.branch().ratio * 100)}
|
|
61
|
+
class="pointer-events-auto relative w-px shrink-0 bg-border after:absolute after:inset-y-0 after:-inset-x-1 after:w-3 focus-visible:bg-primary focus-visible:outline-none hover:bg-primary data-[orientation=vertical]:h-px data-[orientation=vertical]:w-full data-[orientation=vertical]:after:inset-x-0 data-[orientation=vertical]:after:-inset-y-1 data-[orientation=vertical]:after:h-3 data-[orientation=vertical]:after:w-full"
|
|
62
|
+
/>
|
|
63
|
+
<Resizable.Panel minSize={MIN_SPLIT_RATIO} maxSize={MAX_SPLIT_RATIO} aria-hidden="true" />
|
|
64
|
+
</Resizable>
|
|
65
|
+
)
|
|
66
|
+
}
|