@adea-ai/themes 0.3.2 → 0.4.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 (67) hide show
  1. package/package.json +1 -1
  2. package/src/accents.ts +249 -0
  3. package/src/index.ts +15 -0
  4. package/dist/adapters/base24.d.ts +0 -117
  5. package/dist/adapters/base24.d.ts.map +0 -1
  6. package/dist/adapters/base24.js +0 -313
  7. package/dist/adapters/base24.js.map +0 -1
  8. package/dist/adapters/css.d.ts +0 -68
  9. package/dist/adapters/css.d.ts.map +0 -1
  10. package/dist/adapters/css.js +0 -107
  11. package/dist/adapters/css.js.map +0 -1
  12. package/dist/adapters/shadcn.d.ts +0 -51
  13. package/dist/adapters/shadcn.d.ts.map +0 -1
  14. package/dist/adapters/shadcn.js +0 -120
  15. package/dist/adapters/shadcn.js.map +0 -1
  16. package/dist/adapters/shiki.d.ts +0 -60
  17. package/dist/adapters/shiki.d.ts.map +0 -1
  18. package/dist/adapters/shiki.js +0 -139
  19. package/dist/adapters/shiki.js.map +0 -1
  20. package/dist/adapters/tailwind.d.ts +0 -35
  21. package/dist/adapters/tailwind.d.ts.map +0 -1
  22. package/dist/adapters/tailwind.js +0 -58
  23. package/dist/adapters/tailwind.js.map +0 -1
  24. package/dist/adapters/xterm.d.ts +0 -64
  25. package/dist/adapters/xterm.d.ts.map +0 -1
  26. package/dist/adapters/xterm.js +0 -112
  27. package/dist/adapters/xterm.js.map +0 -1
  28. package/dist/catalogue.d.ts +0 -66
  29. package/dist/catalogue.d.ts.map +0 -1
  30. package/dist/catalogue.js +0 -110
  31. package/dist/catalogue.js.map +0 -1
  32. package/dist/derive.d.ts +0 -89
  33. package/dist/derive.d.ts.map +0 -1
  34. package/dist/derive.js +0 -172
  35. package/dist/derive.js.map +0 -1
  36. package/dist/generated/schemes.d.ts +0 -16
  37. package/dist/generated/schemes.d.ts.map +0 -1
  38. package/dist/generated/schemes.js +0 -880
  39. package/dist/generated/schemes.js.map +0 -1
  40. package/dist/generated/themes.d.ts +0 -11
  41. package/dist/generated/themes.d.ts.map +0 -1
  42. package/dist/generated/themes.js +0 -1658
  43. package/dist/generated/themes.js.map +0 -1
  44. package/dist/index.d.ts +0 -67
  45. package/dist/index.d.ts.map +0 -1
  46. package/dist/index.js +0 -58
  47. package/dist/index.js.map +0 -1
  48. package/dist/normalize.d.ts +0 -192
  49. package/dist/normalize.d.ts.map +0 -1
  50. package/dist/normalize.js +0 -958
  51. package/dist/normalize.js.map +0 -1
  52. package/dist/oklch.d.ts +0 -141
  53. package/dist/oklch.d.ts.map +0 -1
  54. package/dist/oklch.js +0 -311
  55. package/dist/oklch.js.map +0 -1
  56. package/dist/schema.d.ts +0 -178
  57. package/dist/schema.d.ts.map +0 -1
  58. package/dist/schema.js +0 -69
  59. package/dist/schema.js.map +0 -1
  60. package/dist/sources.d.ts +0 -296
  61. package/dist/sources.d.ts.map +0 -1
  62. package/dist/sources.js +0 -634
  63. package/dist/sources.js.map +0 -1
  64. package/dist/validate.d.ts +0 -121
  65. package/dist/validate.d.ts.map +0 -1
  66. package/dist/validate.js +0 -255
  67. package/dist/validate.js.map +0 -1
@@ -1,120 +0,0 @@
1
- /**
2
- * The shadcn bridge.
3
- *
4
- * This organisation's components are written against shadcn's vocabulary —
5
- * `--background`, `--card`, `--muted-foreground`, `--primary`, `--ring` — and that
6
- * vocabulary is not the canonical schema. Rather than rename every component, the
7
- * two are bridged here, in one place, from one theme object.
8
- *
9
- * The mapping is not a rename and the two places it is not are worth reading:
10
- *
11
- * - **Adea's `accent` becomes shadcn's `primary`.** In shadcn, `--primary` is the
12
- * main action colour and `--accent` is a *subtle hover background*. Adea's
13
- * `accent` is the interactive colour — what a primary button is filled with,
14
- * what a focus ring is drawn in — so it is shadcn's `primary`. Mapping it to
15
- * `--accent` instead would turn every primary button into a hover wash. The
16
- * shadcn `accent` slot is filled from `surfaceHover`, which is what it is
17
- * actually used for.
18
- * - **Adea's `surface` ladder becomes `card` and `popover`.** shadcn has two
19
- * surfaces rather than four, so `surface` maps to `card` and `surfaceElevated`
20
- * to `popover`, and the remaining two rungs keep their own names.
21
- *
22
- * A table of the whole mapping is in `docs/shadcn-bridge.md`.
23
- */
24
- import { STATUS_ROLES, statusForeground } from '../derive';
25
- /**
26
- * Canonical role → shadcn custom-property name.
27
- *
28
- * Every entry is a deliberate correspondence, and the ones that are not a plain
29
- * rename carry the reason here rather than in the output.
30
- */
31
- export const SHADCN_MAPPING = Object.freeze({
32
- background: 'background',
33
- foreground: 'foreground',
34
- // The first two rungs are the two surfaces shadcn names.
35
- surface: 'card',
36
- surfaceElevated: 'popover',
37
- surfaceHover: 'surface-hover',
38
- surfaceActive: 'surface-active',
39
- border: 'border',
40
- borderMuted: 'border-muted',
41
- // `text` is `foreground` in shadcn; `--foreground` is what body text reads.
42
- text: 'foreground',
43
- textMuted: 'muted-foreground',
44
- textSubtle: 'subtle-foreground',
45
- // See the header: the interactive colour is shadcn's `primary`.
46
- accent: 'primary',
47
- accentForeground: 'primary-foreground',
48
- success: 'success',
49
- warning: 'warning',
50
- // shadcn's destructive slot is in the same position as Adea's error.
51
- error: 'destructive',
52
- info: 'info',
53
- });
54
- /**
55
- * The shadcn roles as an object, keyed by role name without the `--` prefix.
56
- *
57
- * For a consumer that keeps a theme as data — a picker showing swatches, a settings
58
- * screen, a component reading `theme.colors.card` — rather than writing it straight
59
- * to the document.
60
- */
61
- export function shadcnRoles(theme) {
62
- return Object.fromEntries(Object.entries(shadcnVariables(theme)).map(([name, value]) => [
63
- name.replace(/^--/, ''),
64
- value,
65
- ]));
66
- }
67
- /**
68
- * The shadcn custom properties for a theme.
69
- *
70
- * `--accent` is filled from `surfaceHover` because that is what shadcn components
71
- * use it for — the background of a hovered menu item — and `--ring` from the
72
- * accent, because that is what a focus ring must be drawn in for the focus state
73
- * to be visible.
74
- */
75
- export function shadcnVariables(theme) {
76
- const variables = {};
77
- for (const [role, name] of Object.entries(SHADCN_MAPPING)) {
78
- variables[`--${name}`] = theme.colors[role];
79
- }
80
- variables['--accent'] = theme.colors.surfaceHover;
81
- variables['--accent-foreground'] = theme.colors.text;
82
- variables['--ring'] = theme.colors.accent;
83
- variables['--input'] = theme.colors.border;
84
- // The rest of shadcn's default vocabulary. These are not in `SHADCN_MAPPING`
85
- // because they are not new *roles* — shadcn's `secondary` and `muted` are both the
86
- // first surface rung used as a fill, and its `card-foreground` is the body text —
87
- // so they are filled from the roles that already exist rather than getting
88
- // second-class entries of their own.
89
- variables['--card-foreground'] = theme.colors.text;
90
- variables['--popover-foreground'] = theme.colors.text;
91
- variables['--secondary'] = theme.colors.surface;
92
- variables['--secondary-foreground'] = theme.colors.text;
93
- variables['--muted'] = theme.colors.surface;
94
- variables['--sidebar'] = theme.colors.surface;
95
- variables['--sidebar-foreground'] = theme.colors.text;
96
- variables['--sidebar-accent'] = theme.colors.surfaceHover;
97
- variables['--sidebar-border'] = theme.colors.border;
98
- variables['--sidebar-primary'] = theme.colors.accent;
99
- variables['--sidebar-primary-foreground'] = theme.colors.accentForeground;
100
- variables['--sidebar-ring'] = theme.colors.accent;
101
- variables['--sidebar-muted-foreground'] = theme.colors.textMuted;
102
- for (const role of STATUS_ROLES) {
103
- variables[`--${role}-foreground`] = statusForeground(theme, role);
104
- variables[`--${role}-subtle`] = `color-mix(in oklch, var(--${role}) 12%, transparent)`;
105
- }
106
- variables['--surface-sunken'] = theme.colors.background;
107
- variables['--surface-raised'] = theme.colors.surfaceElevated;
108
- variables['--surface-overlay'] = theme.colors.surfaceElevated;
109
- variables['--cursor'] = theme.cursor;
110
- variables['--selection'] = theme.selection;
111
- return variables;
112
- }
113
- /** The shadcn variables as a CSS rule. */
114
- export function shadcnCss(theme, selector = ':root') {
115
- const body = Object.entries(shadcnVariables(theme))
116
- .map(([name, value]) => ` ${name}: ${value};`)
117
- .join('\n');
118
- return `${selector} {\n${body}\n}`;
119
- }
120
- //# sourceMappingURL=shadcn.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shadc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**
2
- * The code adapter: a theme as a Shiki theme registration.
3
- *
4
- * Shiki drives the code views and diffs in Adea's editor and conversation surfaces,
5
- * and its theme contract is an editor contract: a `colors` map for the chrome and a
6
- * `settings` list of scope selectors. Neither is in the canonical schema, so both
7
- * are derived — the chrome from the semantic roles, the scopes from the ANSI
8
- * colours via `derive.syntaxRoles`.
9
- *
10
- * ## Hex, not OKLCH
11
- *
12
- * Shiki is the one adapter that gets hex. Its colour resolution runs through a
13
- * syntax highlighter that does not evaluate CSS colour functions, and its output is
14
- * used to build inline styles and a text-mate scopes map — places where an
15
- * `oklch()` string is not a colour but a string. The conversion gamut-maps rather
16
- * than clipping, so an out-of-gamut accent becomes a slightly less saturated real
17
- * colour instead of a broken channel.
18
- *
19
- * ## Why a registration and not a bundled theme
20
- *
21
- * `themeToShikiTheme` returns the object; it does not call `loadTheme`, and it does
22
- * not import Shiki. That keeps this package free of a dependency on a library that
23
- * is an application's choice, and it means a consumer can register the result
24
- * however it likes — synchronously, into a custom highlighter, or inside a worker.
25
- */
26
- import type { AdeaTheme } from '../schema';
27
- /**
28
- * A Shiki theme registration.
29
- *
30
- * Structurally compatible with `ThemeRegistration` from `shiki`; declared here so
31
- * this package needs no dependency on it.
32
- */
33
- export interface ShikiThemeRegistration {
34
- name: string;
35
- type: 'dark' | 'light';
36
- colors: Record<string, string>;
37
- settings: ShikiTokenSetting[];
38
- }
39
- /** One entry in Shiki's `settings` list. */
40
- export interface ShikiTokenSetting {
41
- scope?: string | readonly string[];
42
- settings: {
43
- foreground?: string;
44
- background?: string;
45
- fontStyle?: string;
46
- };
47
- }
48
- /**
49
- * Converts a theme to a Shiki registration.
50
- *
51
- * Order matters in Shiki's `settings` list: later entries win, and the scopes here
52
- * overlap by design (`keyword.operator` is claimed by both `keyword` and
53
- * `operator`). `operator` is emitted last so its narrower claim wins, which is what
54
- * every editor does and what makes `+` and `=` read differently from `if` and
55
- * `return`.
56
- */
57
- export declare function toShikiTheme(theme: AdeaTheme): ShikiThemeRegistration;
58
- /** Every theme as a registration list, ready for `createHighlighter({ themes })`. */
59
- export declare function toShikiThemes(themes: readonly AdeaTheme[]): ShikiThemeRegistration[];
60
- //# sourceMappingURL=shiki.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shiki.d.ts","sourceRoot":"","sources":["../../src/adapters/shiki.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAK1C;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,QAAQ,EAAE,iBAAiB,EAAE,CAAA;CAC9B;AAED,4CAA4C;AAC5C,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAA;IAClC,QAAQ,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;CACF;AA6CD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,sBAAsB,CAsDrE;AAQD,qFAAqF;AACrF,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,sBAAsB,EAAE,CAEpF"}
@@ -1,139 +0,0 @@
1
- /**
2
- * The code adapter: a theme as a Shiki theme registration.
3
- *
4
- * Shiki drives the code views and diffs in Adea's editor and conversation surfaces,
5
- * and its theme contract is an editor contract: a `colors` map for the chrome and a
6
- * `settings` list of scope selectors. Neither is in the canonical schema, so both
7
- * are derived — the chrome from the semantic roles, the scopes from the ANSI
8
- * colours via `derive.syntaxRoles`.
9
- *
10
- * ## Hex, not OKLCH
11
- *
12
- * Shiki is the one adapter that gets hex. Its colour resolution runs through a
13
- * syntax highlighter that does not evaluate CSS colour functions, and its output is
14
- * used to build inline styles and a text-mate scopes map — places where an
15
- * `oklch()` string is not a colour but a string. The conversion gamut-maps rather
16
- * than clipping, so an out-of-gamut accent becomes a slightly less saturated real
17
- * colour instead of a broken channel.
18
- *
19
- * ## Why a registration and not a bundled theme
20
- *
21
- * `themeToShikiTheme` returns the object; it does not call `loadTheme`, and it does
22
- * not import Shiki. That keeps this package free of a dependency on a library that
23
- * is an application's choice, and it means a consumer can register the result
24
- * however it likes — synchronously, into a custom highlighter, or inside a worker.
25
- */
26
- import { syntaxRolesHex } from '../derive';
27
- import { oklchToHex, parseColor } from '../oklch';
28
- /**
29
- * Syntax role → the TextMate scopes it colours.
30
- *
31
- * The scope lists are the ones an editor grammar actually emits, and several roles
32
- * claim more than one scope because grammars disagree: a type annotation may arrive
33
- * as `entity.name.type`, as `support.type`, or as `storage.type` depending on the
34
- * language, and a theme that names only one of them renders that language
35
- * unhighlighted. The lists are conservative — they claim the scopes that mean the
36
- * role unambiguously, and leave the rest to the editor's default.
37
- */
38
- const SHIKI_SCOPES = Object.freeze({
39
- keyword: [
40
- 'keyword',
41
- 'keyword.control',
42
- 'keyword.operator.new',
43
- 'storage',
44
- 'storage.type',
45
- 'storage.modifier',
46
- ],
47
- string: ['string', 'string.quoted', 'string.template', 'punctuation.definition.string'],
48
- number: ['constant.numeric', 'constant.language', 'constant.other'],
49
- comment: ['comment', 'punctuation.definition.comment'],
50
- function: [
51
- 'entity.name.function',
52
- 'support.function',
53
- 'meta.function-call',
54
- 'variable.function',
55
- ],
56
- variable: ['variable', 'variable.other', 'variable.parameter', 'meta.definition.variable'],
57
- type: ['entity.name.type', 'entity.name.class', 'support.type', 'support.class'],
58
- tag: ['entity.name.tag', 'meta.tag'],
59
- attribute: ['entity.other.attribute-name'],
60
- operator: ['keyword.operator'],
61
- heading: ['markup.heading', 'entity.name.section'],
62
- link: ['markup.underline.link', 'string.other.link'],
63
- constant: ['constant', 'support.constant', 'variable.language'],
64
- punctuation: ['punctuation', 'meta.brace', 'punctuation.separator'],
65
- diffAdd: ['markup.inserted', 'meta.diff.header.to-file', 'punctuation.definition.inserted'],
66
- diffDelete: ['markup.deleted', 'meta.diff.header.from-file', 'punctuation.definition.deleted'],
67
- diffHunk: ['meta.diff.range', 'meta.diff.index', 'punctuation.definition.range.diff'],
68
- searchMatch: ['markup.highlight', 'markup.underline.match'],
69
- });
70
- /**
71
- * Converts a theme to a Shiki registration.
72
- *
73
- * Order matters in Shiki's `settings` list: later entries win, and the scopes here
74
- * overlap by design (`keyword.operator` is claimed by both `keyword` and
75
- * `operator`). `operator` is emitted last so its narrower claim wins, which is what
76
- * every editor does and what makes `+` and `=` read differently from `if` and
77
- * `return`.
78
- */
79
- export function toShikiTheme(theme) {
80
- const roles = syntaxRolesHex(theme);
81
- const colors = {
82
- 'editor.background': hex(theme.colors.background),
83
- 'editor.foreground': hex(theme.colors.text),
84
- 'editorCursor.foreground': hex(theme.cursor),
85
- 'editor.selectionBackground': hex(theme.selection),
86
- 'editor.lineHighlightBackground': hex(theme.colors.surface),
87
- 'editorLineNumber.foreground': hex(theme.colors.textSubtle),
88
- 'editorLineNumber.activeForeground': hex(theme.colors.textMuted),
89
- 'editorIndentGuide.background': hex(theme.colors.borderMuted),
90
- 'editorIndentGuide.activeBackground': hex(theme.colors.border),
91
- 'editorWhitespace.foreground': hex(theme.colors.border),
92
- 'editorWidget.background': hex(theme.colors.surfaceElevated),
93
- 'editorWidget.border': hex(theme.colors.border),
94
- // Diff surfaces read the semantic status roles rather than a separate scale,
95
- // so a diff in the editor and a diff in the conversation use one palette.
96
- 'diffEditor.insertedTextBackground': hex(theme.colors.surface),
97
- 'diffEditor.removedTextBackground': hex(theme.colors.surface),
98
- 'terminal.ansiRed': hex(theme.ansi.red),
99
- 'terminal.ansiGreen': hex(theme.ansi.green),
100
- 'terminal.ansiYellow': hex(theme.ansi.yellow),
101
- 'terminal.ansiBlue': hex(theme.ansi.blue),
102
- 'terminal.ansiMagenta': hex(theme.ansi.magenta),
103
- 'terminal.ansiCyan': hex(theme.ansi.cyan),
104
- 'terminal.ansiWhite': hex(theme.ansi.white),
105
- };
106
- const settings = [
107
- { settings: { foreground: hex(theme.colors.text), background: hex(theme.colors.background) } },
108
- ];
109
- // Everything except `operator`, which is emitted last and narrows the claim.
110
- for (const [role, scopes] of Object.entries(SHIKI_SCOPES)) {
111
- if (role === 'operator')
112
- continue;
113
- settings.push({
114
- scope: scopes,
115
- settings: {
116
- foreground: roles[role],
117
- ...(role === 'comment' ? { fontStyle: 'italic' } : {}),
118
- ...(role === 'heading' ? { fontStyle: 'bold' } : {}),
119
- },
120
- });
121
- }
122
- settings.push({ scope: SHIKI_SCOPES.operator, settings: { foreground: roles.operator } });
123
- return {
124
- name: `adea-${theme.id}`,
125
- type: theme.appearance,
126
- colors,
127
- settings,
128
- };
129
- }
130
- /** Formats a colour as hex, leaving it alone if it cannot be parsed. */
131
- function hex(value) {
132
- const parsed = parseColor(value);
133
- return parsed ? oklchToHex(parsed) : value;
134
- }
135
- /** Every theme as a registration list, ready for `createHighlighter({ themes })`. */
136
- export function toShikiThemes(themes) {
137
- return themes.map(toShikiTheme);
138
- }
139
- //# sourceMappingURL=shiki.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shiki.js","sourceRoot":"","sources":["../../src/adapters/shiki.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAyBjD;;;;;;;;;GASG;AACH,MAAM,YAAY,GAAoD,MAAM,CAAC,MAAM,CAAC;IAClF,OAAO,EAAE;QACP,SAAS;QACT,iBAAiB;QACjB,sBAAsB;QACtB,SAAS;QACT,cAAc;QACd,kBAAkB;KACnB;IACD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AAM;QACN,QAAQ;KACT,CAAA;AACH,CAAC;AAED,wEAAwE;AACxE,SAAS,GAAG,CAAC,KAAa;IACxB,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;IAChC,OAAO,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;AAC5C,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,aAAa,CAAC,MAA4B;IACxD,OAAO,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AACjC,CAAC"}
@@ -1,35 +0,0 @@
1
- /**
2
- * The Tailwind adapter.
3
- *
4
- * Tailwind v4 reads its design tokens from the stylesheet, not from a JavaScript
5
- * config, so a theme becomes utilities by writing `@theme inline` declarations that
6
- * point at the custom properties `adapters/css.ts` produces. `inline` is the
7
- * important word: it makes Tailwind emit `var(--adea-background)` in the generated
8
- * utility rather than baking the value in, which is what allows one stylesheet to
9
- * serve every theme and a theme switch to cost nothing but an attribute change.
10
- *
11
- * Emitting this from the theme rather than hand-maintaining a `@theme` block per
12
- * application is the point of the adapter: a new role in the schema becomes a
13
- * utility in every consumer, and a consumer cannot silently fall behind.
14
- */
15
- export interface TailwindOptions {
16
- /** The custom-property namespace the CSS adapter used. Defaults to `adea`. */
17
- prefix?: string;
18
- /**
19
- * Extra utility namespaces for roles this schema does not hold but the consumer
20
- * does, mapped to a custom property. Used to keep an application's existing
21
- * vocabulary alive without duplicating the values.
22
- */
23
- extra?: Readonly<Record<string, string>>;
24
- }
25
- /**
26
- * The `--color-*` namespace, which is what makes `bg-surface` a valid utility.
27
- *
28
- * Takes no theme, and that is the point rather than an oversight. Every declaration
29
- * this emits is a `var()` reference, so the block is identical for all twenty-seven
30
- * themes and one stylesheet serves every one of them. Accepting a theme would imply
31
- * the output depended on which theme was passed, and the first person to notice would
32
- * reasonably conclude they needed one block per theme.
33
- */
34
- export declare function toTailwindTheme(options?: TailwindOptions): string;
35
- //# sourceMappingURL=tailwind.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tailwind.d.ts","sourceRoot":"","sources":["../../src/adapters/tailwind.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACzC;AAMD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,eAAoB,GAAG,MAAM,CAoCrE"}
@@ -1,58 +0,0 @@
1
- /**
2
- * The Tailwind adapter.
3
- *
4
- * Tailwind v4 reads its design tokens from the stylesheet, not from a JavaScript
5
- * config, so a theme becomes utilities by writing `@theme inline` declarations that
6
- * point at the custom properties `adapters/css.ts` produces. `inline` is the
7
- * important word: it makes Tailwind emit `var(--adea-background)` in the generated
8
- * utility rather than baking the value in, which is what allows one stylesheet to
9
- * serve every theme and a theme switch to cost nothing but an attribute change.
10
- *
11
- * Emitting this from the theme rather than hand-maintaining a `@theme` block per
12
- * application is the point of the adapter: a new role in the schema becomes a
13
- * utility in every consumer, and a consumer cannot silently fall behind.
14
- */
15
- import { ANSI_KEYS, THEME_COLOR_KEYS } from '../schema';
16
- import { STATUS_ROLES } from '../derive';
17
- function kebab(name) {
18
- return name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
19
- }
20
- /**
21
- * The `--color-*` namespace, which is what makes `bg-surface` a valid utility.
22
- *
23
- * Takes no theme, and that is the point rather than an oversight. Every declaration
24
- * this emits is a `var()` reference, so the block is identical for all twenty-seven
25
- * themes and one stylesheet serves every one of them. Accepting a theme would imply
26
- * the output depended on which theme was passed, and the first person to notice would
27
- * reasonably conclude they needed one block per theme.
28
- */
29
- export function toTailwindTheme(options = {}) {
30
- const prefix = options.prefix ?? 'adea';
31
- const property = (name) => (prefix ? `--${prefix}-${name}` : `--${name}`);
32
- const lines = [];
33
- // `inline` so the utility resolves the variable at use time rather than at build
34
- // time. Without it, every theme would need its own stylesheet.
35
- lines.push('@theme inline {');
36
- for (const role of THEME_COLOR_KEYS) {
37
- lines.push(` --color-${kebab(role)}: var(${property(kebab(role))});`);
38
- }
39
- lines.push(` --color-surface-sunken: var(${property('surface-sunken')});`);
40
- lines.push(` --color-cursor: var(${property('cursor')});`);
41
- lines.push(` --color-selection: var(${property('selection')});`);
42
- for (const role of STATUS_ROLES) {
43
- lines.push(` --color-${role}-subtle: var(${property(`${role}-subtle`)});`);
44
- lines.push(` --color-${role}-foreground: var(${property(`${role}-foreground`)});`);
45
- }
46
- for (let index = 1; index <= 6; index += 1) {
47
- lines.push(` --color-chart-${index}: var(${property(`chart-${index}`)});`);
48
- }
49
- for (const key of ANSI_KEYS) {
50
- lines.push(` --color-ansi-${kebab(key)}: var(${property(`ansi-${kebab(key)}`)});`);
51
- }
52
- for (const [name, value] of Object.entries(options.extra ?? {})) {
53
- lines.push(` --color-${name}: ${value};`);
54
- }
55
- lines.push('}');
56
- return lines.join('\n');
57
- }
58
- //# sourceMappingURL=tailwind.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tailwind.js","sourceRoot":"","sources":["../../src/adapters/tailwind.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAaxC,SAAS,KAAK,CAAC,IAAY;IACzB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AACvE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,UAA2B,EAAE;IAC3D,MAAM,MAAM,GAAG,OAAO,CAAC,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AAC;IAED,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC5B,KAAK,CAAC,IAAI,CAAC,kBAAkB,KAAK,CAAC,GAAG,CAAC,SAAS,QAAQ,CAAC,QAAQ,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;IACrF,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;QAChE,KAAK,CAAC,IAAI,CAAC,aAAa,IAAI,KAAK,KAAK,GAAG,CAAC,CAAA;IAC5C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
@@ -1,64 +0,0 @@
1
- /**
2
- * The terminal adapter.
3
- *
4
- * xterm.js is the reason this adapter exists and the reason it works the way it
5
- * does: its theme contract takes **hex strings only**, and it takes a
6
- * `selectionForeground` and a `cursorAccent` that no palette publishes. Both gaps
7
- * have to be closed here rather than at the call site, because the call site is a
8
- * terminal emulator that will happily render invisible text if handed a
9
- * foreground that matches its own background.
10
- *
11
- * The type is declared structurally rather than imported from `@xterm/xterm`. This
12
- * package has no runtime dependencies and does not want one for a type that both
13
- * sides already agree on; anything assignable to this shape can be passed
14
- * straight to `terminal.options.theme`.
15
- */
16
- import type { AdeaTheme } from '../schema';
17
- /**
18
- * The shape xterm.js's `ITheme` requires.
19
- *
20
- * Field names are xterm's, including its `brightBlack`-style camel case, so this
21
- * can be spread directly into `terminal.options.theme`.
22
- */
23
- export interface XtermTheme {
24
- background: string;
25
- foreground: string;
26
- cursor: string;
27
- cursorAccent: string;
28
- selectionBackground: string;
29
- selectionForeground: string;
30
- black: string;
31
- red: string;
32
- green: string;
33
- yellow: string;
34
- blue: string;
35
- magenta: string;
36
- cyan: string;
37
- white: string;
38
- brightBlack: string;
39
- brightRed: string;
40
- brightGreen: string;
41
- brightYellow: string;
42
- brightBlue: string;
43
- brightMagenta: string;
44
- brightCyan: string;
45
- brightWhite: string;
46
- }
47
- /**
48
- * Converts a theme to xterm's shape.
49
- *
50
- * The two derived fields are the whole point:
51
- *
52
- * - **`cursorAccent`** is the glyph *under* the block cursor. xterm draws it in
53
- * this colour, so it must contrast with `cursor` — not with the background.
54
- * Palettes frequently set their cursor to the foreground colour, which puts the
55
- * accent at the far end of the canvas.
56
- * - **`selectionForeground`** is text inside a selection. Base24's `base02` is
57
- * whatever the palette's author chose for a terminal selection, and several
58
- * themes in the catalogue set it to a near-white; under near-white body text the
59
- * selection would erase its own contents. Deriving the foreground from whichever
60
- * of the canvas or the text measures better fixes that without discarding the
61
- * author's selection colour.
62
- */
63
- export declare function toXtermTheme(theme: AdeaTheme): XtermTheme;
64
- //# sourceMappingURL=xterm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"xterm.d.ts","sourceRoot":"","sources":["../../src/adapters/xterm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAI1C;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,CAAA;IACpB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;CACpB;AAqBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,CAwCzD"}
@@ -1,112 +0,0 @@
1
- /**
2
- * The terminal adapter.
3
- *
4
- * xterm.js is the reason this adapter exists and the reason it works the way it
5
- * does: its theme contract takes **hex strings only**, and it takes a
6
- * `selectionForeground` and a `cursorAccent` that no palette publishes. Both gaps
7
- * have to be closed here rather than at the call site, because the call site is a
8
- * terminal emulator that will happily render invisible text if handed a
9
- * foreground that matches its own background.
10
- *
11
- * The type is declared structurally rather than imported from `@xterm/xterm`. This
12
- * package has no runtime dependencies and does not want one for a type that both
13
- * sides already agree on; anything assignable to this shape can be passed
14
- * straight to `terminal.options.theme`.
15
- */
16
- import { contrastRatio, oklchToHex, parseColor, repairContrast } from '../oklch';
17
- /**
18
- * The floor for text drawn inside a selection.
19
- *
20
- * Selected text is text, so it takes the body floor.
21
- */
22
- const SELECTION_FLOOR = 4.5;
23
- /**
24
- * The floor for the glyph under the cursor.
25
- *
26
- * Lower than the selection's, and deliberately. A cursor accent is a UI affordance
27
- * rather than text, and it is derived from a colour the palette did not choose for
28
- * this purpose: Solarized Light's cursor is a mid grey on a near-white canvas, and
29
- * nothing in that palette reaches 4.5:1 against it except near-black, which would
30
- * put a black glyph in a mid-grey cursor and lose the cursor's own shape. 3:1 is
31
- * WCAG's non-text floor and is what a caret needs.
32
- */
33
- const CURSOR_FLOOR = 3;
34
- /**
35
- * Converts a theme to xterm's shape.
36
- *
37
- * The two derived fields are the whole point:
38
- *
39
- * - **`cursorAccent`** is the glyph *under* the block cursor. xterm draws it in
40
- * this colour, so it must contrast with `cursor` — not with the background.
41
- * Palettes frequently set their cursor to the foreground colour, which puts the
42
- * accent at the far end of the canvas.
43
- * - **`selectionForeground`** is text inside a selection. Base24's `base02` is
44
- * whatever the palette's author chose for a terminal selection, and several
45
- * themes in the catalogue set it to a near-white; under near-white body text the
46
- * selection would erase its own contents. Deriving the foreground from whichever
47
- * of the canvas or the text measures better fixes that without discarding the
48
- * author's selection colour.
49
- */
50
- export function toXtermTheme(theme) {
51
- const background = parseColor(theme.colors.background);
52
- const foreground = parseColor(theme.colors.foreground);
53
- const cursor = parseColor(theme.cursor) ?? foreground;
54
- const selection = parseColor(theme.selection) ?? background;
55
- // The ANSI extremes are candidates alongside the canvas and the text. On a theme
56
- // whose cursor or selection is a mid tone, both of those measure poorly against
57
- // it and the palette's own near-black or near-white is the right answer.
58
- const extremes = [parseColor(theme.ansi.black), parseColor(theme.ansi.white)].filter((candidate) => !!candidate);
59
- const candidates = [background, foreground, ...extremes].filter((candidate) => !!candidate);
60
- return {
61
- background: hex(theme.colors.background),
62
- foreground: hex(theme.colors.foreground),
63
- cursor: cursor ? oklchToHex(cursor) : hex(theme.colors.foreground),
64
- cursorAccent: pickForeground(cursor, candidates, CURSOR_FLOOR),
65
- selectionBackground: selection ? oklchToHex(selection) : hex(theme.colors.background),
66
- selectionForeground: pickForeground(selection, candidates, SELECTION_FLOOR),
67
- black: hex(theme.ansi.black),
68
- red: hex(theme.ansi.red),
69
- green: hex(theme.ansi.green),
70
- yellow: hex(theme.ansi.yellow),
71
- blue: hex(theme.ansi.blue),
72
- magenta: hex(theme.ansi.magenta),
73
- cyan: hex(theme.ansi.cyan),
74
- white: hex(theme.ansi.white),
75
- brightBlack: hex(theme.ansi.brightBlack),
76
- brightRed: hex(theme.ansi.brightRed),
77
- brightGreen: hex(theme.ansi.brightGreen),
78
- brightYellow: hex(theme.ansi.brightYellow),
79
- brightBlue: hex(theme.ansi.brightBlue),
80
- brightMagenta: hex(theme.ansi.brightMagenta),
81
- brightCyan: hex(theme.ansi.brightCyan),
82
- brightWhite: hex(theme.ansi.brightWhite),
83
- };
84
- }
85
- /**
86
- * The better of the canvas and the text as a foreground for `surface`.
87
- *
88
- * Repaired if neither clears the floor, which happens when a palette picks a
89
- * selection colour that sits exactly between its background and its text. The
90
- * repair is bounded so it cannot drift into a colour the palette does not contain
91
- * by more than a perceptible step.
92
- */
93
- function pickForeground(surface, candidates, floor) {
94
- if (!surface)
95
- return candidates[0] ? oklchToHex(candidates[0]) : '#000000';
96
- if (candidates.length === 0)
97
- return '#000000';
98
- let best = candidates[0];
99
- for (const candidate of candidates.slice(1)) {
100
- if (contrastRatio(candidate, surface) > contrastRatio(best, surface))
101
- best = candidate;
102
- }
103
- // A generous budget: the alternative to a large lightness move here is an
104
- // invisible glyph, and the colour is already one of the palette's own.
105
- const repaired = repairContrast(best, surface, floor, 0.9);
106
- return oklchToHex(repaired.color);
107
- }
108
- function hex(value) {
109
- const parsed = parseColor(value);
110
- return parsed ? oklchToHex(parsed) : value;
111
- }
112
- //# sourceMappingURL=xterm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"xterm.js","sourceRoot":"","sources":["../../src/adapters/xterm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAiChF;;;;GAIG;AACH,MAAM,eAAe,GAAG,GAAG,CAAA;AAE3B;;;;;;;;;GASG;AACH,MAAM,YAAY,GAAG,CAAC,CAAA;AAEtB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY,CAAC,KAAgB;IAC3C,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IACtD,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IACtD,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,MAA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