@adea-ai/themes 0.1.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/LICENSE +201 -0
- package/NOTICE +110 -0
- package/README.md +157 -0
- package/dist/adapters/base24.d.ts +117 -0
- package/dist/adapters/base24.d.ts.map +1 -0
- package/dist/adapters/base24.js +313 -0
- package/dist/adapters/base24.js.map +1 -0
- package/dist/adapters/css.d.ts +68 -0
- package/dist/adapters/css.d.ts.map +1 -0
- package/dist/adapters/css.js +107 -0
- package/dist/adapters/css.js.map +1 -0
- package/dist/adapters/shadcn.d.ts +43 -0
- package/dist/adapters/shadcn.d.ts.map +1 -0
- package/dist/adapters/shadcn.js +89 -0
- package/dist/adapters/shadcn.js.map +1 -0
- package/dist/adapters/shiki.d.ts +60 -0
- package/dist/adapters/shiki.d.ts.map +1 -0
- package/dist/adapters/shiki.js +135 -0
- package/dist/adapters/shiki.js.map +1 -0
- package/dist/adapters/tailwind.d.ts +35 -0
- package/dist/adapters/tailwind.d.ts.map +1 -0
- package/dist/adapters/tailwind.js +58 -0
- package/dist/adapters/tailwind.js.map +1 -0
- package/dist/adapters/xterm.d.ts +64 -0
- package/dist/adapters/xterm.d.ts.map +1 -0
- package/dist/adapters/xterm.js +112 -0
- package/dist/adapters/xterm.js.map +1 -0
- package/dist/catalogue.d.ts +66 -0
- package/dist/catalogue.d.ts.map +1 -0
- package/dist/catalogue.js +110 -0
- package/dist/catalogue.js.map +1 -0
- package/dist/derive.d.ts +89 -0
- package/dist/derive.d.ts.map +1 -0
- package/dist/derive.js +165 -0
- package/dist/derive.js.map +1 -0
- package/dist/generated/schemes.d.ts +16 -0
- package/dist/generated/schemes.d.ts.map +1 -0
- package/dist/generated/schemes.js +880 -0
- package/dist/generated/schemes.js.map +1 -0
- package/dist/generated/themes.d.ts +11 -0
- package/dist/generated/themes.d.ts.map +1 -0
- package/dist/generated/themes.js +1650 -0
- package/dist/generated/themes.js.map +1 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/normalize.d.ts +160 -0
- package/dist/normalize.d.ts.map +1 -0
- package/dist/normalize.js +795 -0
- package/dist/normalize.js.map +1 -0
- package/dist/oklch.d.ts +141 -0
- package/dist/oklch.d.ts.map +1 -0
- package/dist/oklch.js +306 -0
- package/dist/oklch.js.map +1 -0
- package/dist/schema.d.ts +178 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +69 -0
- package/dist/schema.js.map +1 -0
- package/dist/sources.d.ts +171 -0
- package/dist/sources.d.ts.map +1 -0
- package/dist/sources.js +559 -0
- package/dist/sources.js.map +1 -0
- package/dist/validate.d.ts +121 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +255 -0
- package/dist/validate.js.map +1 -0
- package/package.json +106 -0
- package/palettes/ayu-light.json +38 -0
- package/palettes/ayu-mirage.json +38 -0
- package/palettes/ayu.json +38 -0
- package/palettes/catppuccin-frappe.json +38 -0
- package/palettes/catppuccin-latte.json +38 -0
- package/palettes/catppuccin-macchiato.json +38 -0
- package/palettes/catppuccin-mocha.json +38 -0
- package/palettes/dracula.json +38 -0
- package/palettes/everforest-dark.json +38 -0
- package/palettes/everforest-light.json +38 -0
- package/palettes/gruvbox-dark.json +38 -0
- package/palettes/gruvbox-light.json +38 -0
- package/palettes/kanagawa.json +38 -0
- package/palettes/monokai.json +38 -0
- package/palettes/nord.json +38 -0
- package/palettes/one-dark.json +38 -0
- package/palettes/rosepine-dawn.json +38 -0
- package/palettes/rosepine-moon.json +38 -0
- package/palettes/rosepine.json +38 -0
- package/palettes/solarized-dark.json +38 -0
- package/palettes/solarized-light.json +38 -0
- package/palettes/tokyonight-day.json +38 -0
- package/palettes/tokyonight-night.json +38 -0
- package/palettes/tokyonight-storm.json +38 -0
- package/palettes/vesper.json +38 -0
- package/src/adapters/base24.ts +355 -0
- package/src/adapters/css.ts +149 -0
- package/src/adapters/shadcn.ts +99 -0
- package/src/adapters/shiki.ts +168 -0
- package/src/adapters/tailwind.ts +79 -0
- package/src/adapters/xterm.ts +159 -0
- package/src/catalogue.ts +129 -0
- package/src/derive.ts +203 -0
- package/src/generated/schemes.ts +882 -0
- package/src/generated/themes.ts +1652 -0
- package/src/index.ts +146 -0
- package/src/normalize.ts +1010 -0
- package/src/oklch.ts +366 -0
- package/src/schema.ts +222 -0
- package/src/sources.ts +682 -0
- package/src/validate.ts +325 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@adea-ai/themes`
|
|
3
|
+
*
|
|
4
|
+
* The Adea theme catalogue. Semantic OKLCH themes normalized from mature upstream
|
|
5
|
+
* palettes, with adapters for the places a theme has to arrive in a foreign shape:
|
|
6
|
+
* Base24 for interop, xterm for a shell, CSS and Tailwind for an application, and
|
|
7
|
+
* Shiki for a code view.
|
|
8
|
+
*
|
|
9
|
+
* The design is described in four decisions, and the rest of this package follows
|
|
10
|
+
* from them.
|
|
11
|
+
*
|
|
12
|
+
* **Adea owns the schema and the transformation, not the colours.** The seventeen
|
|
13
|
+
* surface roles in `schema.ts` are the contract, and no upstream project is asked
|
|
14
|
+
* to satisfy it. The palettes in `palettes/` are other people's, reproduced from a
|
|
15
|
+
* pinned revision, each recording the project it belongs to and the licence it is
|
|
16
|
+
* used under. Normalizing them is this package's job and it happens once, here.
|
|
17
|
+
*
|
|
18
|
+
* **OKLCH is the representation.** Every role is an `oklch()` string. Lightness in
|
|
19
|
+
* OKLCH is perceptually uniform, which is what lets a surface ladder be built by
|
|
20
|
+
* adding fixed steps, a contrast failure be repaired by moving one axis, and a
|
|
21
|
+
* theme be re-hued without re-deriving its ramp by eye.
|
|
22
|
+
*
|
|
23
|
+
* **Contrast is measured, not assumed.** Nothing enters the catalogue without
|
|
24
|
+
* clearing the floors in `validate.ts`; a palette that cannot is repaired by the
|
|
25
|
+
* least move that works, and reported. Several famous palettes fail on their own
|
|
26
|
+
* background, and the catalogue says so rather than shipping them.
|
|
27
|
+
*
|
|
28
|
+
* **Derived colours are derived.** Syntax roles, chart series and status fills are
|
|
29
|
+
* functions of the roles a theme does hold, computed in `derive.ts`, so two
|
|
30
|
+
* consumers cannot disagree about what colour a keyword is.
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { getTheme } from '@adea-ai/themes'
|
|
34
|
+
* import { themeCssVariables } from '@adea-ai/themes/adapters/css'
|
|
35
|
+
* import { toXtermTheme } from '@adea-ai/themes/adapters/xterm'
|
|
36
|
+
*
|
|
37
|
+
* const theme = getTheme('catppuccin-mocha')
|
|
38
|
+
* if (theme) {
|
|
39
|
+
* for (const [name, value] of Object.entries(themeCssVariables(theme))) {
|
|
40
|
+
* document.documentElement.style.setProperty(name, value)
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/* --- The schema, which is the contract ---------------------------------- */
|
|
47
|
+
export type {
|
|
48
|
+
AdeaAnsi,
|
|
49
|
+
AdeaTheme,
|
|
50
|
+
AdeaThemeColors,
|
|
51
|
+
AdeaThemeRecord,
|
|
52
|
+
AnsiKey,
|
|
53
|
+
ThemeAppearance,
|
|
54
|
+
ThemeColorKey,
|
|
55
|
+
ThemeFamily,
|
|
56
|
+
ThemeProvenance,
|
|
57
|
+
} from './schema'
|
|
58
|
+
export { ANSI_KEYS, THEME_COLOR_KEYS } from './schema'
|
|
59
|
+
|
|
60
|
+
/* --- The catalogue ------------------------------------------------------ */
|
|
61
|
+
export {
|
|
62
|
+
DEFAULT_THEME_IDS,
|
|
63
|
+
getBase24Scheme,
|
|
64
|
+
getTheme,
|
|
65
|
+
hasTheme,
|
|
66
|
+
resolveTheme,
|
|
67
|
+
themeCount,
|
|
68
|
+
themeFamilies,
|
|
69
|
+
themeIds,
|
|
70
|
+
themes,
|
|
71
|
+
themesByAppearance,
|
|
72
|
+
toTheme,
|
|
73
|
+
} from './catalogue'
|
|
74
|
+
|
|
75
|
+
/* --- The colour core ---------------------------------------------------- */
|
|
76
|
+
export type { ContrastRepair, Oklch } from './oklch'
|
|
77
|
+
export {
|
|
78
|
+
contrastRatio,
|
|
79
|
+
deltaEok,
|
|
80
|
+
formatOklch,
|
|
81
|
+
gamutMap,
|
|
82
|
+
hexToOklch,
|
|
83
|
+
inGamut,
|
|
84
|
+
mix,
|
|
85
|
+
oklchToHex,
|
|
86
|
+
parseColor,
|
|
87
|
+
parseOklch,
|
|
88
|
+
relativeLuminance,
|
|
89
|
+
repairContrast,
|
|
90
|
+
shiftLightness,
|
|
91
|
+
} from './oklch'
|
|
92
|
+
|
|
93
|
+
/* --- The gate ----------------------------------------------------------- */
|
|
94
|
+
export type { AnsiInvariant, ContrastFinding, Pairing } from './validate'
|
|
95
|
+
export {
|
|
96
|
+
REQUIRED_PAIRINGS,
|
|
97
|
+
STATUS_PAIRINGS,
|
|
98
|
+
checkAnsiRamp,
|
|
99
|
+
formatFindings,
|
|
100
|
+
validateCatalogue,
|
|
101
|
+
validateTheme,
|
|
102
|
+
} from './validate'
|
|
103
|
+
|
|
104
|
+
/* --- Normalization, for a consumer bringing its own palette ------------- */
|
|
105
|
+
export type { NormalizationFinding, NormalizedTheme, ThemeSourceSpec } from './normalize'
|
|
106
|
+
export { CONTRAST_FLOORS, normalizeTheme } from './normalize'
|
|
107
|
+
|
|
108
|
+
/* --- Derived colours --------------------------------------------------- */
|
|
109
|
+
export type { StatusRole, SyntaxRole } from './derive'
|
|
110
|
+
export {
|
|
111
|
+
CHART_SERIES,
|
|
112
|
+
STATUS_ROLES,
|
|
113
|
+
chartSeries,
|
|
114
|
+
statusForeground,
|
|
115
|
+
statusForegroundHex,
|
|
116
|
+
syntaxRoles,
|
|
117
|
+
syntaxRolesHex,
|
|
118
|
+
tint,
|
|
119
|
+
} from './derive'
|
|
120
|
+
|
|
121
|
+
/* --- Adapters ---------------------------------------------------------- */
|
|
122
|
+
export type { Base24Palette, Base24Scheme, Base24Slot } from './adapters/base24'
|
|
123
|
+
export {
|
|
124
|
+
BASE24_SLOTS,
|
|
125
|
+
BASE24_SLOT_MEANING,
|
|
126
|
+
BASE24_TO_ANSI,
|
|
127
|
+
Base24ParseError,
|
|
128
|
+
formatBase24Scheme,
|
|
129
|
+
parseBase24Palette,
|
|
130
|
+
parseBase24Scheme,
|
|
131
|
+
toBase24,
|
|
132
|
+
} from './adapters/base24'
|
|
133
|
+
|
|
134
|
+
export type { XtermTheme } from './adapters/xterm'
|
|
135
|
+
export { toXtermTheme } from './adapters/xterm'
|
|
136
|
+
|
|
137
|
+
export type { CssOptions } from './adapters/css'
|
|
138
|
+
export { catalogueCss, cssVariableName, themeCss, themeCssVariables } from './adapters/css'
|
|
139
|
+
|
|
140
|
+
export type { TailwindOptions } from './adapters/tailwind'
|
|
141
|
+
export { toTailwindTheme } from './adapters/tailwind'
|
|
142
|
+
|
|
143
|
+
export type { ShikiThemeRegistration, ShikiTokenSetting } from './adapters/shiki'
|
|
144
|
+
export { toShikiTheme, toShikiThemes } from './adapters/shiki'
|
|
145
|
+
|
|
146
|
+
export { SHADCN_MAPPING, shadcnCss, shadcnVariables } from './adapters/shadcn'
|