@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.
Files changed (109) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +110 -0
  3. package/README.md +157 -0
  4. package/dist/adapters/base24.d.ts +117 -0
  5. package/dist/adapters/base24.d.ts.map +1 -0
  6. package/dist/adapters/base24.js +313 -0
  7. package/dist/adapters/base24.js.map +1 -0
  8. package/dist/adapters/css.d.ts +68 -0
  9. package/dist/adapters/css.d.ts.map +1 -0
  10. package/dist/adapters/css.js +107 -0
  11. package/dist/adapters/css.js.map +1 -0
  12. package/dist/adapters/shadcn.d.ts +43 -0
  13. package/dist/adapters/shadcn.d.ts.map +1 -0
  14. package/dist/adapters/shadcn.js +89 -0
  15. package/dist/adapters/shadcn.js.map +1 -0
  16. package/dist/adapters/shiki.d.ts +60 -0
  17. package/dist/adapters/shiki.d.ts.map +1 -0
  18. package/dist/adapters/shiki.js +135 -0
  19. package/dist/adapters/shiki.js.map +1 -0
  20. package/dist/adapters/tailwind.d.ts +35 -0
  21. package/dist/adapters/tailwind.d.ts.map +1 -0
  22. package/dist/adapters/tailwind.js +58 -0
  23. package/dist/adapters/tailwind.js.map +1 -0
  24. package/dist/adapters/xterm.d.ts +64 -0
  25. package/dist/adapters/xterm.d.ts.map +1 -0
  26. package/dist/adapters/xterm.js +112 -0
  27. package/dist/adapters/xterm.js.map +1 -0
  28. package/dist/catalogue.d.ts +66 -0
  29. package/dist/catalogue.d.ts.map +1 -0
  30. package/dist/catalogue.js +110 -0
  31. package/dist/catalogue.js.map +1 -0
  32. package/dist/derive.d.ts +89 -0
  33. package/dist/derive.d.ts.map +1 -0
  34. package/dist/derive.js +165 -0
  35. package/dist/derive.js.map +1 -0
  36. package/dist/generated/schemes.d.ts +16 -0
  37. package/dist/generated/schemes.d.ts.map +1 -0
  38. package/dist/generated/schemes.js +880 -0
  39. package/dist/generated/schemes.js.map +1 -0
  40. package/dist/generated/themes.d.ts +11 -0
  41. package/dist/generated/themes.d.ts.map +1 -0
  42. package/dist/generated/themes.js +1650 -0
  43. package/dist/generated/themes.js.map +1 -0
  44. package/dist/index.d.ts +67 -0
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +58 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/normalize.d.ts +160 -0
  49. package/dist/normalize.d.ts.map +1 -0
  50. package/dist/normalize.js +795 -0
  51. package/dist/normalize.js.map +1 -0
  52. package/dist/oklch.d.ts +141 -0
  53. package/dist/oklch.d.ts.map +1 -0
  54. package/dist/oklch.js +306 -0
  55. package/dist/oklch.js.map +1 -0
  56. package/dist/schema.d.ts +178 -0
  57. package/dist/schema.d.ts.map +1 -0
  58. package/dist/schema.js +69 -0
  59. package/dist/schema.js.map +1 -0
  60. package/dist/sources.d.ts +171 -0
  61. package/dist/sources.d.ts.map +1 -0
  62. package/dist/sources.js +559 -0
  63. package/dist/sources.js.map +1 -0
  64. package/dist/validate.d.ts +121 -0
  65. package/dist/validate.d.ts.map +1 -0
  66. package/dist/validate.js +255 -0
  67. package/dist/validate.js.map +1 -0
  68. package/package.json +106 -0
  69. package/palettes/ayu-light.json +38 -0
  70. package/palettes/ayu-mirage.json +38 -0
  71. package/palettes/ayu.json +38 -0
  72. package/palettes/catppuccin-frappe.json +38 -0
  73. package/palettes/catppuccin-latte.json +38 -0
  74. package/palettes/catppuccin-macchiato.json +38 -0
  75. package/palettes/catppuccin-mocha.json +38 -0
  76. package/palettes/dracula.json +38 -0
  77. package/palettes/everforest-dark.json +38 -0
  78. package/palettes/everforest-light.json +38 -0
  79. package/palettes/gruvbox-dark.json +38 -0
  80. package/palettes/gruvbox-light.json +38 -0
  81. package/palettes/kanagawa.json +38 -0
  82. package/palettes/monokai.json +38 -0
  83. package/palettes/nord.json +38 -0
  84. package/palettes/one-dark.json +38 -0
  85. package/palettes/rosepine-dawn.json +38 -0
  86. package/palettes/rosepine-moon.json +38 -0
  87. package/palettes/rosepine.json +38 -0
  88. package/palettes/solarized-dark.json +38 -0
  89. package/palettes/solarized-light.json +38 -0
  90. package/palettes/tokyonight-day.json +38 -0
  91. package/palettes/tokyonight-night.json +38 -0
  92. package/palettes/tokyonight-storm.json +38 -0
  93. package/palettes/vesper.json +38 -0
  94. package/src/adapters/base24.ts +355 -0
  95. package/src/adapters/css.ts +149 -0
  96. package/src/adapters/shadcn.ts +99 -0
  97. package/src/adapters/shiki.ts +168 -0
  98. package/src/adapters/tailwind.ts +79 -0
  99. package/src/adapters/xterm.ts +159 -0
  100. package/src/catalogue.ts +129 -0
  101. package/src/derive.ts +203 -0
  102. package/src/generated/schemes.ts +882 -0
  103. package/src/generated/themes.ts +1652 -0
  104. package/src/index.ts +146 -0
  105. package/src/normalize.ts +1010 -0
  106. package/src/oklch.ts +366 -0
  107. package/src/schema.ts +222 -0
  108. package/src/sources.ts +682 -0
  109. 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'