silvery 0.18.2 → 0.19.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 (156) hide show
  1. package/dist/{animation-DhINOJk8.mjs → animation-Cn64yepo.mjs} +1 -1
  2. package/dist/{animation-DhINOJk8.mjs.map → animation-Cn64yepo.mjs.map} +1 -1
  3. package/dist/{ansi-C6Qs1Wn2.mjs → ansi-CLOitHKx.mjs} +1 -1
  4. package/dist/ansi-CLOitHKx.mjs.map +1 -0
  5. package/dist/{ansi-CsjnZtAw.d.mts → ansi-Cc33mW54.d.mts} +1 -1
  6. package/dist/{ansi-CsjnZtAw.d.mts.map → ansi-Cc33mW54.d.mts.map} +1 -1
  7. package/dist/{chunk-BSw8zbkd.mjs → chunk-Vs_PY4HZ.mjs} +1 -1
  8. package/dist/cli-BKp0YtBD.mjs +4 -0
  9. package/dist/{context-BjWgrikx.mjs → context-BU5LkkIy.mjs} +8 -7
  10. package/dist/context-BU5LkkIy.mjs.map +1 -0
  11. package/dist/devtools-9QY4teqI.mjs +2 -0
  12. package/dist/{devtools-CeO9X_uv.mjs → devtools-DxkSLXDA.mjs} +4 -5
  13. package/dist/devtools-DxkSLXDA.mjs.map +1 -0
  14. package/dist/{eta-BnQSZcWf.mjs → eta-Bb3RH3wh.mjs} +1 -1
  15. package/dist/{eta-BnQSZcWf.mjs.map → eta-Bb3RH3wh.mjs.map} +1 -1
  16. package/dist/{flexily-zero-adapter-BOM0cl8R.mjs → flexily-zero-adapter-BlQa46nr.mjs} +21 -64
  17. package/dist/flexily-zero-adapter-BlQa46nr.mjs.map +1 -0
  18. package/dist/{flexily-zero-adapter-V8R3HQtK.mjs → flexily-zero-adapter-CMxXhdOL.mjs} +1 -1
  19. package/dist/{image-B0zMbVUr.mjs → image-CTII5QWI.mjs} +3 -3
  20. package/dist/image-CTII5QWI.mjs.map +1 -0
  21. package/dist/{index-Bh3U1K09.d.mts → index-BXslOebb.d.mts} +547 -137
  22. package/dist/index-BXslOebb.d.mts.map +1 -0
  23. package/dist/{index-C4vrhbud.d.mts → index-BnA7mNpo.d.mts} +1 -1
  24. package/dist/{index-C4vrhbud.d.mts.map → index-BnA7mNpo.d.mts.map} +1 -1
  25. package/dist/index-D3saHouR.d.mts +1392 -0
  26. package/dist/index-D3saHouR.d.mts.map +1 -0
  27. package/dist/index.d.mts +5 -33
  28. package/dist/index.d.mts.map +1 -1
  29. package/dist/index.mjs +13 -13
  30. package/dist/{layout-engine--drvrWjD.mjs → layout-engine-B6Cdz1yZ.mjs} +1 -1
  31. package/dist/{layout-engine-Dr3cY5U4.mjs → layout-engine-ClUgv6jB.mjs} +3 -3
  32. package/dist/{layout-engine-Dr3cY5U4.mjs.map → layout-engine-ClUgv6jB.mjs.map} +1 -1
  33. package/dist/{multi-progress-CcdqJFlf.mjs → multi-progress-Bq9Oi_WI.mjs} +3 -3
  34. package/dist/{multi-progress-CcdqJFlf.mjs.map → multi-progress-Bq9Oi_WI.mjs.map} +1 -1
  35. package/dist/{multi-progress-DQ-uUzLf.d.mts → multi-progress-DAQC7eap.d.mts} +2 -2
  36. package/dist/{multi-progress-DQ-uUzLf.d.mts.map → multi-progress-DAQC7eap.d.mts.map} +1 -1
  37. package/dist/{node-CP5WChgr.mjs → node-BeWlnCPY.mjs} +4 -4
  38. package/dist/node-BeWlnCPY.mjs.map +1 -0
  39. package/dist/{progress-bar-IrUjkLfU.mjs → progress-bar-CXE5Qfkd.mjs} +4 -4
  40. package/dist/progress-bar-CXE5Qfkd.mjs.map +1 -0
  41. package/dist/reconciler-Cwgm8hRR.mjs +8459 -0
  42. package/dist/reconciler-Cwgm8hRR.mjs.map +1 -0
  43. package/dist/{render-string-DVfgc8xr.mjs → render-string-Cbuf63Ya.mjs} +936 -136
  44. package/dist/render-string-Cbuf63Ya.mjs.map +1 -0
  45. package/dist/{render-string-BwLG7rIX.mjs → render-string-Tv-jqM16.mjs} +1 -1
  46. package/dist/runtime.d.mts +2 -2
  47. package/dist/runtime.mjs +3 -3
  48. package/dist/{spinner-BRkaJI0N.d.mts → spinner-CGo34vyR.d.mts} +2 -2
  49. package/dist/{spinner-BRkaJI0N.d.mts.map → spinner-CGo34vyR.d.mts.map} +1 -1
  50. package/dist/{spinner-BmldKx0M.mjs → spinner-CeOmcuw_.mjs} +3 -3
  51. package/dist/spinner-CeOmcuw_.mjs.map +1 -0
  52. package/dist/src-B5GjfG7g.mjs +4305 -0
  53. package/dist/src-B5GjfG7g.mjs.map +1 -0
  54. package/dist/{src-CJPXf3fC.mjs → src-C2uvC-r0.mjs} +7535 -6467
  55. package/dist/src-C2uvC-r0.mjs.map +1 -0
  56. package/dist/{src-D8kLrQBT.mjs → src-CChwjk0Z.mjs} +8 -86
  57. package/dist/src-CChwjk0Z.mjs.map +1 -0
  58. package/dist/{src-D_BS-as7.mjs → src-NCKb8kE5.mjs} +777 -776
  59. package/dist/src-NCKb8kE5.mjs.map +1 -0
  60. package/dist/theme.d.mts +2 -130
  61. package/dist/theme.mjs +3 -8
  62. package/dist/{types-B4A8Ebba.d.mts → types-BH_v3iMT.d.mts} +1 -1
  63. package/dist/{types-B4A8Ebba.d.mts.map → types-BH_v3iMT.d.mts.map} +1 -1
  64. package/dist/{types-e4dpfbSa.mjs → types-Bk2yw9Qj.mjs} +3 -3
  65. package/dist/types-Bk2yw9Qj.mjs.map +1 -0
  66. package/dist/ui/animation.d.mts +1 -1
  67. package/dist/ui/animation.mjs +1 -1
  68. package/dist/ui/ansi.d.mts +1 -1
  69. package/dist/ui/ansi.mjs +1 -1
  70. package/dist/ui/cli.d.mts +3 -3
  71. package/dist/ui/cli.mjs +5 -5
  72. package/dist/ui/display.d.mts +1 -1
  73. package/dist/ui/display.mjs.map +1 -1
  74. package/dist/ui/image.d.mts +1 -1
  75. package/dist/ui/image.mjs +1 -1
  76. package/dist/ui/input.d.mts +1 -1
  77. package/dist/ui/input.d.mts.map +1 -1
  78. package/dist/ui/input.mjs +2 -4
  79. package/dist/ui/input.mjs.map +1 -1
  80. package/dist/ui/progress.d.mts +3 -3
  81. package/dist/ui/progress.d.mts.map +1 -1
  82. package/dist/ui/progress.mjs +3 -3
  83. package/dist/ui/progress.mjs.map +1 -1
  84. package/dist/ui/react.d.mts +1 -1
  85. package/dist/ui/react.d.mts.map +1 -1
  86. package/dist/ui/react.mjs +2 -2
  87. package/dist/ui/react.mjs.map +1 -1
  88. package/dist/ui/utils.mjs +1 -1
  89. package/dist/ui/wrappers.d.mts +2 -2
  90. package/dist/ui/wrappers.mjs +1 -1
  91. package/dist/ui.d.mts +5 -5
  92. package/dist/ui.mjs +6 -6
  93. package/dist/{useLatest-6xqnGIU6.d.mts → useLatest-Bg2x4bfP.d.mts} +1 -1
  94. package/dist/{useLatest-6xqnGIU6.d.mts.map → useLatest-Bg2x4bfP.d.mts.map} +1 -1
  95. package/dist/{with-text-input-lUh9gYAG.d.mts → with-text-input-CRfoiFFG.d.mts} +3 -3
  96. package/dist/with-text-input-CRfoiFFG.d.mts.map +1 -0
  97. package/dist/{wrappers-JrEYTuKA.mjs → wrappers-UTADQkSY.mjs} +4 -4
  98. package/dist/wrappers-UTADQkSY.mjs.map +1 -0
  99. package/dist/{yoga-adapter-Bc8XT9cN.mjs → yoga-adapter-8oRGRw8V.mjs} +2 -2
  100. package/dist/{yoga-adapter-Bc8XT9cN.mjs.map → yoga-adapter-8oRGRw8V.mjs.map} +1 -1
  101. package/dist/yoga-adapter-D_CcxSt5.mjs +2 -0
  102. package/package.json +54 -45
  103. package/dist/UPNG-DvKjM6wE.mjs +0 -5076
  104. package/dist/UPNG-DvKjM6wE.mjs.map +0 -1
  105. package/dist/__vite-browser-external-2447137e-DPKHHqQK.mjs +0 -6
  106. package/dist/__vite-browser-external-2447137e-DPKHHqQK.mjs.map +0 -1
  107. package/dist/ansi-C6Qs1Wn2.mjs.map +0 -1
  108. package/dist/apng-CvSlLBtc.mjs +0 -3
  109. package/dist/apng-DFFVOItr.mjs +0 -70
  110. package/dist/apng-DFFVOItr.mjs.map +0 -1
  111. package/dist/assets/resvgjs.darwin-arm64-BtufyGW1.node +0 -0
  112. package/dist/backend-DU0Y938U.mjs +0 -13396
  113. package/dist/backend-DU0Y938U.mjs.map +0 -1
  114. package/dist/backends-BihMKFY_.mjs +0 -1181
  115. package/dist/backends-BihMKFY_.mjs.map +0 -1
  116. package/dist/backends-Dk_5G_gC.mjs +0 -3
  117. package/dist/cli-GwJ0S2In.mjs +0 -4
  118. package/dist/context-BjWgrikx.mjs.map +0 -1
  119. package/dist/derive-O_Kb1Bk_.d.mts +0 -28
  120. package/dist/derive-O_Kb1Bk_.d.mts.map +0 -1
  121. package/dist/devtools-CeO9X_uv.mjs.map +0 -1
  122. package/dist/devtools-nX4tj6OH.mjs +0 -2
  123. package/dist/flexily-zero-adapter-BOM0cl8R.mjs.map +0 -1
  124. package/dist/gif-B9Uq4qZA.mjs +0 -73
  125. package/dist/gif-B9Uq4qZA.mjs.map +0 -1
  126. package/dist/gif-BdrLRBmM.mjs +0 -3
  127. package/dist/gifenc-DfhOb4xr.mjs +0 -730
  128. package/dist/gifenc-DfhOb4xr.mjs.map +0 -1
  129. package/dist/image-B0zMbVUr.mjs.map +0 -1
  130. package/dist/index-Bh3U1K09.d.mts.map +0 -1
  131. package/dist/index-dehZ18K-.d.mts +0 -679
  132. package/dist/index-dehZ18K-.d.mts.map +0 -1
  133. package/dist/key-mapping-7k2ufK2b.mjs +0 -3
  134. package/dist/key-mapping-WLUmxjx1.mjs +0 -132
  135. package/dist/key-mapping-WLUmxjx1.mjs.map +0 -1
  136. package/dist/node-CP5WChgr.mjs.map +0 -1
  137. package/dist/progress-bar-IrUjkLfU.mjs.map +0 -1
  138. package/dist/reconciler-B8uxQxaU.mjs +0 -16482
  139. package/dist/reconciler-B8uxQxaU.mjs.map +0 -1
  140. package/dist/render-string-DVfgc8xr.mjs.map +0 -1
  141. package/dist/resvg-js-Cwipz-_J.mjs +0 -203
  142. package/dist/resvg-js-Cwipz-_J.mjs.map +0 -1
  143. package/dist/spinner-BmldKx0M.mjs.map +0 -1
  144. package/dist/src-C0sOQW-t.mjs +0 -3866
  145. package/dist/src-C0sOQW-t.mjs.map +0 -1
  146. package/dist/src-CJPXf3fC.mjs.map +0 -1
  147. package/dist/src-D8kLrQBT.mjs.map +0 -1
  148. package/dist/src-D_BS-as7.mjs.map +0 -1
  149. package/dist/theme.d.mts.map +0 -1
  150. package/dist/theme.mjs.map +0 -1
  151. package/dist/types-e4dpfbSa.mjs.map +0 -1
  152. package/dist/with-text-input-lUh9gYAG.d.mts.map +0 -1
  153. package/dist/wrapper-CE6GQ27z.mjs +0 -3527
  154. package/dist/wrapper-CE6GQ27z.mjs.map +0 -1
  155. package/dist/wrappers-JrEYTuKA.mjs.map +0 -1
  156. package/dist/yoga-adapter-B8LZpQcE.mjs +0 -2
@@ -0,0 +1,1392 @@
1
+ //#region packages/ansi/src/detection.d.ts
2
+ interface TerminalCaps {
3
+ /** Terminal program name (from TERM_PROGRAM) */
4
+ program: string;
5
+ /** TERM value */
6
+ term: string;
7
+ /** Color support level */
8
+ colorLevel: "none" | "basic" | "256" | "truecolor";
9
+ /** Kitty keyboard protocol supported */
10
+ kittyKeyboard: boolean;
11
+ /** Kitty graphics protocol (inline images) */
12
+ kittyGraphics: boolean;
13
+ /** Sixel graphics supported */
14
+ sixel: boolean;
15
+ /** OSC 52 clipboard */
16
+ osc52: boolean;
17
+ /** OSC 8 hyperlinks */
18
+ hyperlinks: boolean;
19
+ /** OSC 9/99 notifications */
20
+ notifications: boolean;
21
+ /** Bracketed paste mode */
22
+ bracketedPaste: boolean;
23
+ /** SGR mouse tracking */
24
+ mouse: boolean;
25
+ /** Synchronized output (DEC 2026) */
26
+ syncOutput: boolean;
27
+ /** Unicode/emoji support */
28
+ unicode: boolean;
29
+ /** SGR 4:x underline style subparameters (curly, dotted, dashed) */
30
+ underlineStyles: boolean;
31
+ /** SGR 58 underline color */
32
+ underlineColor: boolean;
33
+ /** Text-presentation emoji (⚠, ☑, ⭐) rendered as 2-wide.
34
+ * Modern terminals (Ghostty, iTerm, Kitty) render these at emoji width (2 cells).
35
+ * Terminal.app renders them at text width (1 cell). */
36
+ textEmojiWide: boolean;
37
+ /** OSC 66 text sizing protocol likely supported (Kitty 0.40+, Ghostty) */
38
+ textSizingSupported: boolean;
39
+ /** Heuristic: likely dark background (for theme selection) */
40
+ darkBackground: boolean;
41
+ /** Heuristic: likely has Nerd Font installed (for icon selection) */
42
+ nerdfont: boolean;
43
+ }
44
+ /**
45
+ * Default capabilities (assumes modern terminal with full support).
46
+ */
47
+ declare function defaultCaps(): TerminalCaps;
48
+ /** Detect terminal capabilities from environment variables.
49
+ * Synchronous. Minimal I/O: may run `defaults` on macOS for Apple_Terminal.
50
+ */
51
+ declare function detectTerminalCaps(): TerminalCaps;
52
+ //#endregion
53
+ //#region packages/ansi/src/types.d.ts
54
+ /**
55
+ * Type definitions for @silvery/ansi
56
+ */
57
+ /**
58
+ * Color level supported by terminal.
59
+ * - 'basic': 16 colors (SGR 30-37, 40-47)
60
+ * - '256': 256 colors (SGR 38;5;n)
61
+ * - 'truecolor': 16M colors (SGR 38;2;r;g;b)
62
+ */
63
+ type ColorLevel = "basic" | "256" | "truecolor";
64
+ //#endregion
65
+ //#region packages/ansi/src/color-maps.d.ts
66
+ /**
67
+ * Color tier for preview quantization.
68
+ *
69
+ * Mirrors the tiers a real terminal would resolve to when the output phase
70
+ * emits ANSI: `truecolor` (pass-through), `256` (6×6×6 cube + grayscale ramp),
71
+ * `ansi16` (nearest of 16 slots), `mono` (luminance → black/white).
72
+ */
73
+ type ColorTier = "truecolor" | "256" | "ansi16" | "mono";
74
+ /**
75
+ * Hex-in / hex-out quantization for previews.
76
+ *
77
+ * Takes any hex color and returns the hex a real terminal at that tier would
78
+ * actually emit. Used by the Sterling storybook to make the `1/2/3/4` tier
79
+ * toggle visibly different in-process — the output phase already does this
80
+ * when writing to a real TTY, but preview surfaces (theme swatches, rendered
81
+ * components inside a storybook app) bypass output-phase quantization. Apply
82
+ * `quantizeHex` at render time to mimic tier-specific terminal output.
83
+ *
84
+ * - `truecolor`: returns the input unchanged (normalized to `#rrggbb`).
85
+ * - `256`: snaps to the nearest xterm-256 slot, then returns that slot's hex.
86
+ * - `ansi16`: snaps to one of the 16 standard slots (canonical xterm RGB).
87
+ * - `mono`: luminance threshold (>= 0.5 → `#ffffff`, else `#000000`).
88
+ *
89
+ * Returns the input unchanged if it cannot be parsed as a hex color.
90
+ */
91
+ declare function quantizeHex(hex: string, tier: ColorTier): string;
92
+ /**
93
+ * Pre-quantize every hex leaf in a Theme (or any object tree) to the
94
+ * requested color tier.
95
+ *
96
+ * Walks the input recursively — each string leaf matching `#rgb` / `#rrggbb`
97
+ * is passed through {@link quantizeHex}; all other values (numbers, booleans,
98
+ * non-hex strings like `"Nord"`, null/undefined, arrays of non-hex values)
99
+ * pass through unchanged. Arrays and nested objects are rebuilt with
100
+ * quantized leaves.
101
+ *
102
+ * Works on both the legacy ANSI Theme (flat hex tokens + `palette` array)
103
+ * and the Sterling Theme (nested roles + flat tokens) — the structural rule
104
+ * "any leaf that looks like a hex is a color value" holds for both.
105
+ *
106
+ * @example Pre-cache tier variants
107
+ * ```ts
108
+ * import { pickColorLevel } from "silvery"
109
+ *
110
+ * const themes = {
111
+ * truecolor: theme,
112
+ * ansi16: pickColorLevel(theme, "ansi16"),
113
+ * mono: pickColorLevel(theme, "mono"),
114
+ * }
115
+ * ```
116
+ *
117
+ * @example Storybook — show multiple tiers simultaneously
118
+ * ```tsx
119
+ * <ThemeProvider theme={pickColorLevel(theme, "ansi16")}>
120
+ * <AlertPreview />
121
+ * </ThemeProvider>
122
+ * ```
123
+ *
124
+ * Notes:
125
+ * - `truecolor` is a no-op — returns the input unchanged (identity).
126
+ * - The result is structurally identical to the input (same keys, same
127
+ * nesting); only hex leaves are remapped.
128
+ * - Idempotent per tier: `pickColorLevel(pickColorLevel(t, "ansi16"), "ansi16")`
129
+ * yields the same hex values as `pickColorLevel(t, "ansi16")`.
130
+ * - Does not freeze the returned object. Callers that want immutability
131
+ * should `Object.freeze()` (or deep-freeze) the result themselves.
132
+ */
133
+ declare function pickColorLevel<T>(theme: T, tier: ColorTier): T;
134
+ //#endregion
135
+ //#region packages/ansi/src/flatten.d.ts
136
+ /**
137
+ * Generic flat-projection helper for design-system Themes.
138
+ *
139
+ * Any DesignSystem whose Theme is a nested POJO of hex-string leaves can
140
+ * project those leaves as hyphen-keyed siblings on the SAME object — the
141
+ * "flat form" — with no copy and no Proxy. Both paths reference the same
142
+ * string. The object is frozen at the end.
143
+ *
144
+ * ```ts
145
+ * const theme = bakeFlat({
146
+ * accent: { fg: "#0969da", bg: "#0969da", fgOn: "#ffffff",
147
+ * hover: { fg: "#0550ae", bg: "#0550ae" } },
148
+ * surface: { default: "#ffffff", subtle: "#f6f8fa" },
149
+ * cursor: { fg: "#ffffff", bg: "#0969da" },
150
+ * })
151
+ *
152
+ * theme.accent.bg === theme["bg-accent"] // true — same reference
153
+ * theme["bg-accent-hover"] // "#0550ae"
154
+ * theme["bg-surface-subtle"] // "#f6f8fa"
155
+ * ```
156
+ *
157
+ * Consumed by:
158
+ * - Sterling (`@silvery/theme/sterling`) via `defineDesignSystem({ flatten: true })`
159
+ * - Any alternative DesignSystem that wants flat-projection for free
160
+ *
161
+ * @see defaultFlattenRule — the channel-role-state rule Sterling uses
162
+ * @see FlattenRule — bring-your-own rule for non-Sterling conventions
163
+ */
164
+ /**
165
+ * Given a nested path to a hex leaf, return the flat-key sibling to write
166
+ * onto the root object. Return `null` to skip that leaf (no flat alias).
167
+ *
168
+ * Paths are arrays of segment names as they appear in the nested object,
169
+ * e.g. `["accent", "hover", "bg"]`.
170
+ */
171
+ type FlattenRule = (path: readonly string[]) => string | null;
172
+ /**
173
+ * Channel-role-state default rule. Matches Sterling / Primer / CSS-var
174
+ * conventions: `{kind}-{role}[-{state}]`, with `fg-on-{role}` for `fgOn`,
175
+ * and implicit-kind collapse for the `surface` / `border` roles.
176
+ *
177
+ * Mapping examples:
178
+ * | Path | Flat key |
179
+ * | ---------------------------- | --------------------------- |
180
+ * | `accent.fg` | `fg-accent` |
181
+ * | `accent.bg` | `bg-accent` |
182
+ * | `accent.fgOn` | `fg-on-accent` |
183
+ * | `accent.border` | `border-accent` |
184
+ * | `accent.hover.bg` | `bg-accent-hover` |
185
+ * | `accent.active.fg` | `fg-accent-active` |
186
+ * | `info.hover.bg` | `bg-info-hover` |
187
+ * | `cursor.fg` | `fg-cursor` |
188
+ * | `muted.bg` | `bg-muted` |
189
+ * | `surface.default` | `bg-surface-default` |
190
+ * | `surface.subtle` | `bg-surface-subtle` |
191
+ * | `surface.hover` | `bg-surface-hover` |
192
+ * | `border.default` | `border-default` |
193
+ * | `border.focus` | `border-focus` |
194
+ * | `border.muted` | `border-muted` |
195
+ *
196
+ * Returns `null` for depth-1 leaves (e.g. `mode`, `name` — not role-scoped)
197
+ * so metadata doesn't get flattened. The caller (`bakeFlat`) already filters
198
+ * non-hex leaves, but the rule also guards paths shorter than 2 segments.
199
+ */
200
+ declare const defaultFlattenRule: FlattenRule;
201
+ /**
202
+ * Populate flat hyphen-keys onto `theme` in-place by walking hex leaves and
203
+ * asking `rule` where each leaf should also live at the root.
204
+ *
205
+ * Both the nested and flat forms reference the SAME string (not copies) —
206
+ * `bakeFlat({...}).accent.bg === bakeFlat({...})["bg-accent"]`.
207
+ *
208
+ * `rule` defaults to {@link defaultFlattenRule} (channel-role-state).
209
+ * Rules returning `null` for a path skip that leaf — useful for suppressing
210
+ * metadata or implementing partial projections.
211
+ *
212
+ * The returned object is deep-frozen. The input object is mutated in place
213
+ * and returned; callers that want an unfrozen copy should `structuredClone`
214
+ * before calling.
215
+ *
216
+ * @param theme nested POJO of hex-string leaves (plus optional metadata)
217
+ * @param rule how to compute flat keys from nested paths
218
+ * @returns the same object, with flat keys added and frozen
219
+ */
220
+ declare function bakeFlat<T extends object>(theme: T, rule?: FlattenRule): T;
221
+ //#endregion
222
+ //#region packages/ansi/src/terminal-control.d.ts
223
+ /**
224
+ * Enable mouse tracking with full hover support.
225
+ *
226
+ * Uses two modes:
227
+ * - **1003** (any-event tracking): Reports ALL mouse motion — clicks, drags, AND hover.
228
+ * This is what makes onMouseEnter/onMouseLeave work. Without it, only clicks are reported.
229
+ * - **1006** (SGR encoding): Decimal coordinates with no 223-column limit.
230
+ *
231
+ * WARNING: Do NOT replace 1003 with 1000+1002. The xterm mouse modes form a hierarchy:
232
+ * 1000 = clicks only
233
+ * 1002 = clicks + drag (motion while button held)
234
+ * 1003 = clicks + drag + hover (ALL motion, even without button)
235
+ * Mode 1003 supersedes 1000 and 1002. Using 1000+1002 instead of 1003 silently
236
+ * disables hover — onMouseEnter/onMouseLeave stop firing with no error.
237
+ */
238
+ declare function enableMouse(): string;
239
+ /**
240
+ * Disable mouse tracking. Disables in reverse order of enabling.
241
+ */
242
+ declare function disableMouse(): string;
243
+ /**
244
+ * Enable the Kitty keyboard protocol (push mode).
245
+ *
246
+ * Sends CSI > flags u to opt into the specified modes.
247
+ * Supported by: Ghostty, Kitty, WezTerm, foot. Ignored by unsupported terminals.
248
+ *
249
+ * Flags are a bitfield:
250
+ *
251
+ * | Flag | Bit | Description |
252
+ * | ---- | --- | ----------------------------------------- |
253
+ * | 1 | 0 | Disambiguate escape codes |
254
+ * | 2 | 1 | Report event types (press/repeat/release) |
255
+ * | 4 | 2 | Report alternate keys |
256
+ * | 8 | 3 | Report all keys as escape codes |
257
+ * | 16 | 4 | Report associated text |
258
+ *
259
+ * @param flags Bitfield of Kitty keyboard flags
260
+ */
261
+ declare function enableKittyKeyboard(flags?: number): string;
262
+ /**
263
+ * Disable the Kitty keyboard protocol (pop mode stack).
264
+ * Sends CSI < u to restore the previous keyboard mode.
265
+ */
266
+ declare function disableKittyKeyboard(): string;
267
+ //#endregion
268
+ //#region packages/ansi/src/style/style.d.ts
269
+ /**
270
+ * Resolve a color value against a theme — the canonical token resolver.
271
+ *
272
+ * If the color starts with `$`, looks up the token in the theme.
273
+ * Supports `$primary`, `$surface-bg` (hyphens stripped), `$color0`–`$color15` (palette).
274
+ * Non-`$` strings pass through unchanged. Returns undefined if no theme or unknown token.
275
+ *
276
+ * Compatible with @silvery/theme's Theme type (or any object with string properties).
277
+ */
278
+ declare function resolveThemeColor(name: string | undefined, theme: object | undefined): string | undefined;
279
+ //#endregion
280
+ //#region packages/ansi/src/theme/types.d.ts
281
+ /**
282
+ * Core type definitions for the theme system.
283
+ *
284
+ * Two-layer architecture:
285
+ * Layer 1: ColorScheme — 22 terminal colors (what schemes expose; auto-detectable)
286
+ * Layer 2: Theme — ~33 semantic tokens (what UI apps consume)
287
+ *
288
+ * Pipeline: Scheme catalog → ColorScheme (22) → deriveTheme() → Theme (33)
289
+ */
290
+ interface ColorScheme {
291
+ name?: string;
292
+ dark?: boolean;
293
+ primary?: string;
294
+ black: string;
295
+ red: string;
296
+ green: string;
297
+ yellow: string;
298
+ blue: string;
299
+ magenta: string;
300
+ cyan: string;
301
+ white: string;
302
+ brightBlack: string;
303
+ brightRed: string;
304
+ brightGreen: string;
305
+ brightYellow: string;
306
+ brightBlue: string;
307
+ brightMagenta: string;
308
+ brightCyan: string;
309
+ brightWhite: string;
310
+ foreground: string;
311
+ background: string;
312
+ cursorColor: string;
313
+ cursorText: string;
314
+ selectionBackground: string;
315
+ selectionForeground: string;
316
+ }
317
+ declare const COLOR_SCHEME_FIELDS: readonly ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "brightBlack", "brightRed", "brightGreen", "brightYellow", "brightBlue", "brightMagenta", "brightCyan", "brightWhite", "foreground", "background", "cursorColor", "cursorText", "selectionBackground", "selectionForeground"];
318
+ interface Theme$1 {
319
+ name: string;
320
+ bg: string;
321
+ fg: string;
322
+ muted: string;
323
+ mutedbg: string;
324
+ surface: string;
325
+ surfacebg: string;
326
+ popover: string;
327
+ popoverbg: string;
328
+ inverse: string;
329
+ inversebg: string;
330
+ cursor: string;
331
+ cursorbg: string;
332
+ selection: string;
333
+ selectionbg: string;
334
+ primary: string;
335
+ primaryfg: string;
336
+ secondary: string;
337
+ secondaryfg: string;
338
+ accent: string;
339
+ accentfg: string;
340
+ error: string;
341
+ errorfg: string;
342
+ warning: string;
343
+ warningfg: string;
344
+ success: string;
345
+ successfg: string;
346
+ info: string;
347
+ infofg: string;
348
+ border: string;
349
+ inputborder: string;
350
+ focusborder: string;
351
+ link: string;
352
+ disabledfg: string;
353
+ palette: string[];
354
+ brand: string;
355
+ /** Kebab key for $brand-hover. Hover lightness shift (+0.04L OKLCH). */
356
+ "brand-hover": string;
357
+ /** Kebab key for $brand-active. Active lightness shift (+0.08L OKLCH). */
358
+ "brand-active": string;
359
+ /** Kebab key for $primary-hover. */
360
+ "primary-hover": string;
361
+ /** Kebab key for $primary-active. */
362
+ "primary-active": string;
363
+ /** Kebab key for $accent-hover. */
364
+ "accent-hover": string;
365
+ /** Kebab key for $accent-active. */
366
+ "accent-active": string;
367
+ /** Kebab key for $fg-hover. */
368
+ "fg-hover": string;
369
+ /** Kebab key for $fg-active. */
370
+ "fg-active": string;
371
+ /** Kebab key for $bg-selected-hover. */
372
+ "bg-selected-hover": string;
373
+ /** Kebab key for $bg-surface-hover. */
374
+ "bg-surface-hover": string;
375
+ red: string;
376
+ orange: string;
377
+ yellow: string;
378
+ green: string;
379
+ teal: string;
380
+ blue: string;
381
+ purple: string;
382
+ pink: string;
383
+ /**
384
+ * Named typography variants — resolved by `<Text variant="h1">`.
385
+ *
386
+ * Each variant is a bundle of visual defaults (color, bold, italic, dim,
387
+ * underlineStyle). Caller props always win over variant values — the variant
388
+ * is the *default*, not an override.
389
+ *
390
+ * Apps extend variants via:
391
+ * ```tsx
392
+ * <ThemeProvider tokens={{ variants: { hero: { color: "$brand", bold: true } } }}>
393
+ * ```
394
+ */
395
+ variants: Record<string, Variant$1>;
396
+ }
397
+ /**
398
+ * Metadata describing how the active color scheme was determined.
399
+ *
400
+ * Returned by `detectScheme()` and surfaced at runtime via `useActiveScheme()`.
401
+ * Lets apps log how the theme was detected ("catppuccin-mocha at 87% confidence via
402
+ * fingerprint") or render a debug badge without re-running detection.
403
+ *
404
+ * @example
405
+ * ```tsx
406
+ * const scheme = useActiveScheme()
407
+ * if (scheme?.source === "fingerprint") {
408
+ * console.log(`detected ${scheme.matchedName} at ${Math.round((scheme.confidence ?? 0) * 100)}%`)
409
+ * }
410
+ * ```
411
+ */
412
+ interface ActiveScheme {
413
+ /** Scheme name pulled from Theme.name or the override. */
414
+ name: string;
415
+ /** How the active theme was determined. */
416
+ source: "probe" | "fingerprint" | "fallback" | "override";
417
+ /** Confidence [0,1] — only meaningful for "fingerprint" source. */
418
+ confidence?: number;
419
+ /** Catalog scheme name matched (only for "fingerprint" source). */
420
+ matchedName?: string;
421
+ }
422
+ type AnsiPrimary = "yellow" | "cyan" | "magenta" | "green" | "red" | "blue" | "white";
423
+ type HueName = "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "purple" | "pink";
424
+ /**
425
+ * A typography variant — a named bundle of visual properties that can be
426
+ * applied to a Text component via `variant="h1"`. The variant acts as a
427
+ * *default*: caller props always win over variant values.
428
+ *
429
+ * Color values follow the same syntax as `TextColor` — `$token` strings,
430
+ * hex values, ANSI names, or any string accepted by the color system.
431
+ */
432
+ interface Variant$1 {
433
+ color?: string;
434
+ backgroundColor?: string;
435
+ bold?: boolean;
436
+ italic?: boolean;
437
+ dim?: boolean;
438
+ underlineStyle?: "single" | "double" | "curly" | "dotted" | "dashed";
439
+ }
440
+ //#endregion
441
+ //#region packages/ansi/src/theme/derive.d.ts
442
+ interface ThemeAdjustment {
443
+ token: string;
444
+ from: string;
445
+ to: string;
446
+ against: string;
447
+ target: number;
448
+ ratioBefore: number;
449
+ ratioAfter: number;
450
+ }
451
+ declare function deriveTheme$1(palette: ColorScheme, mode?: "ansi16" | "truecolor", adjustments?: ThemeAdjustment[]): Theme$1;
452
+ //#endregion
453
+ //#region packages/ansi/src/theme/orchestrator.d.ts
454
+ /** How the final scheme was decided. */
455
+ type DetectSource = "override" | "fingerprint" | "probed" | "bg-mode" | "fallback";
456
+ /** Where each slot's value came from. */
457
+ type SlotSource = "probed" | "catalog" | "fallback";
458
+ interface DetectSchemeResult {
459
+ /** The resolved 22-slot color scheme. */
460
+ scheme: ColorScheme;
461
+ /** The derived, validated Theme (via loadTheme). */
462
+ theme: Theme$1;
463
+ /** How the scheme was determined overall. */
464
+ source: DetectSource;
465
+ /** 0–1 confidence heuristic (exact override = 1, fingerprint = match score, fallback = 0). */
466
+ confidence: number;
467
+ /** Per-slot provenance. Keys are ColorScheme field names. */
468
+ slotSources: Partial<Record<keyof ColorScheme, SlotSource>>;
469
+ /** If fingerprint matched, the catalog scheme name. */
470
+ matchedName?: string;
471
+ }
472
+ interface DetectSchemeOptions {
473
+ /** Explicit override — if provided, skips all probing. */
474
+ override?: ColorScheme;
475
+ /** Catalog to fingerprint against. If empty or undefined, skip fingerprinting. */
476
+ catalog?: readonly ColorScheme[];
477
+ /** OSC probe timeout (ms). Default 150. */
478
+ timeoutMs?: number;
479
+ /** Force dark/light inference when no bg is probed. */
480
+ darkFallback?: boolean;
481
+ /**
482
+ * Apply strict invariant validation to the loaded Theme. Default `lenient`.
483
+ * See `loadTheme`'s `enforce` parameter.
484
+ */
485
+ enforce?: "strict" | "lenient" | "off";
486
+ /** Add WCAG contrast check to the invariant validation. Default `false`. */
487
+ wcag?: boolean;
488
+ }
489
+ //#endregion
490
+ //#region packages/ansi/src/theme/tokens.d.ts
491
+ /**
492
+ * Built-in variant names — the standard typography presets shipped by silvery.
493
+ * These are the default keys in `Theme.variants`.
494
+ */
495
+ type VariantName = "h1" | "h2" | "h3" | "body" | "body-muted" | "fine-print" | "strong" | "em" | "link" | "key" | "code" | "kbd";
496
+ /**
497
+ * Any variant name — built-in or app-defined. The `(string & {})` tail is the
498
+ * Tailwind trick: preserves IDE autocomplete for the literal union while still
499
+ * accepting any runtime string value.
500
+ */
501
+ type KnownVariant = VariantName | (string & {});
502
+ //#endregion
503
+ //#region packages/ansi/src/theme/detect.d.ts
504
+ interface DetectedScheme {
505
+ fg: string | null;
506
+ bg: string | null;
507
+ ansi: (string | null)[];
508
+ dark: boolean;
509
+ palette: Partial<ColorScheme>;
510
+ }
511
+ declare function detectTerminalScheme(timeoutMs?: number): Promise<DetectedScheme | null>;
512
+ interface DetectThemeOptions {
513
+ /** Fallback ColorScheme when detection fails or returns partial data.
514
+ * Detected colors override matching fallback fields.
515
+ * When omitted, defaults based on dark/light detection:
516
+ * dark → `fallbackDark` (if set) or built-in defaultDarkScheme
517
+ * light → `fallbackLight` (if set) or built-in defaultLightScheme */
518
+ fallback?: ColorScheme;
519
+ /** Fallback for dark terminals (overrides `fallback` for dark mode). */
520
+ fallbackDark?: ColorScheme;
521
+ /** Fallback for light terminals (overrides `fallback` for light mode). */
522
+ fallbackLight?: ColorScheme;
523
+ /** Timeout per OSC query in ms (default 150). */
524
+ timeoutMs?: number;
525
+ /** Terminal capabilities (from detectTerminalCaps). When provided:
526
+ * - colorLevel "none"/"basic" skips OSC detection and returns ANSI 16 theme
527
+ * - darkBackground informs fallback selection when detection fails */
528
+ caps?: {
529
+ colorLevel?: string;
530
+ darkBackground?: boolean;
531
+ };
532
+ }
533
+ //#endregion
534
+ //#region packages/ansi/src/osc-palette.d.ts
535
+ /**
536
+ * OSC 4 Terminal Color Palette Query/Set — pure ANSI protocol.
537
+ */
538
+ declare function queryPaletteColor(index: number, write: (data: string) => void): void;
539
+ declare function queryMultiplePaletteColors(indices: number[], write: (data: string) => void): void;
540
+ declare function setPaletteColor(index: number, color: string, write: (data: string) => void): void;
541
+ declare function parsePaletteResponse(input: string): {
542
+ index: number;
543
+ color: string;
544
+ } | null;
545
+ //#endregion
546
+ //#region packages/ansi/src/osc-colors.d.ts
547
+ /**
548
+ * OSC 10/11/12 Terminal Color Queries — pure ANSI protocol.
549
+ */
550
+ declare function queryForegroundColor(write: (data: string) => void, read: (timeoutMs: number) => Promise<string | null>, timeoutMs?: number): Promise<string | null>;
551
+ declare function queryBackgroundColor(write: (data: string) => void, read: (timeoutMs: number) => Promise<string | null>, timeoutMs?: number): Promise<string | null>;
552
+ declare function queryCursorColor(write: (data: string) => void, read: (timeoutMs: number) => Promise<string | null>, timeoutMs?: number): Promise<string | null>;
553
+ declare function setForegroundColor(write: (data: string) => void, color: string): void;
554
+ declare function setBackgroundColor(write: (data: string) => void, color: string): void;
555
+ declare function setCursorColor(write: (data: string) => void, color: string): void;
556
+ declare function resetForegroundColor(write: (data: string) => void): void;
557
+ declare function resetBackgroundColor(write: (data: string) => void): void;
558
+ declare function resetCursorColor(write: (data: string) => void): void;
559
+ declare function detectColorScheme(write: (data: string) => void, read: (timeoutMs: number) => Promise<string | null>, timeoutMs?: number): Promise<"light" | "dark" | null>;
560
+ //#endregion
561
+ //#region packages/ansi/src/theme/generate.d.ts
562
+ /**
563
+ * Generate a complete ANSI 16 theme from a primary color + dark/light preference.
564
+ *
565
+ * All token values are ANSI color names (e.g. "yellow", "blueBright").
566
+ */
567
+ declare function generateTheme$1(primary: AnsiPrimary, dark: boolean): Theme$1;
568
+ //#endregion
569
+ //#region packages/theme/src/generate.d.ts
570
+ /**
571
+ * Generate a complete ANSI 16 theme from a primary color + dark/light preference.
572
+ *
573
+ * All token values are hex strings (e.g. "#808000" for yellow).
574
+ * Terminal rendering quantizes these to 4-bit ANSI codes at paint time
575
+ * when colorLevel === "basic".
576
+ */
577
+ declare function generateTheme(primary: AnsiPrimary, dark: boolean): Theme$1;
578
+ //#endregion
579
+ //#region packages/theme/src/generators.d.ts
580
+ /** Find which hue slot the primary color best matches by OKLCH hue angle proximity. */
581
+ declare function assignPrimaryToSlot(primary: string): HueName;
582
+ /**
583
+ * Generate a ColorScheme from a Base16 YAML scheme.
584
+ *
585
+ * Maps base00–base0F to ANSI palette colors, derives special colors.
586
+ */
587
+ declare function fromBase16(yamlOrJson: string): ColorScheme;
588
+ interface FromColorsOptions {
589
+ /** Background color (infers dark/light). */
590
+ background?: string;
591
+ /** Foreground/text color. Generated if omitted. */
592
+ foreground?: string;
593
+ /** Primary accent color. Generated if omitted. */
594
+ primary?: string;
595
+ /** Force dark mode. */
596
+ dark?: boolean;
597
+ /** Theme name. */
598
+ name?: string;
599
+ }
600
+ /**
601
+ * Generate a full ColorScheme from 1-3 hex colors.
602
+ *
603
+ * At minimum, provide `background` or `primary`. Missing colors are
604
+ * generated via surface ramp (from bg) and hue rotation (from primary).
605
+ */
606
+ declare function fromColors(opts: FromColorsOptions): ColorScheme;
607
+ /**
608
+ * Look up a built-in palette by name.
609
+ *
610
+ * @returns The ColorScheme, or undefined if not found.
611
+ */
612
+ declare function fromPreset(name: string): ColorScheme | undefined;
613
+ //#endregion
614
+ //#region packages/theme/src/builder.d.ts
615
+ interface ThemeBuilder {
616
+ /** Set background color. */
617
+ bg(color: string): ThemeBuilder;
618
+ /** Set foreground color. */
619
+ fg(color: string): ThemeBuilder;
620
+ /** Set primary accent color. */
621
+ primary(color: string): ThemeBuilder;
622
+ /** Alias for `.primary()`. */
623
+ accent(color: string): ThemeBuilder;
624
+ /** Force dark mode. */
625
+ dark(): ThemeBuilder;
626
+ /** Force light mode. */
627
+ light(): ThemeBuilder;
628
+ /** Set any palette color by name. */
629
+ color(name: keyof Omit<ColorScheme, "name" | "dark">, value: string): ThemeBuilder;
630
+ /** Set full palette at once. */
631
+ palette(p: ColorScheme): ThemeBuilder;
632
+ /** Load a built-in palette by name. */
633
+ preset(name: string): ThemeBuilder;
634
+ /** Derive the final Theme from accumulated state. */
635
+ build(): Theme$1;
636
+ }
637
+ /** Create a chainable theme builder. */
638
+ declare function createTheme(): ThemeBuilder;
639
+ /**
640
+ * Quick theme from a primary color or color name.
641
+ *
642
+ * @example
643
+ * ```typescript
644
+ * quickTheme('#EBCB8B', 'dark') // yellow primary, dark mode
645
+ * quickTheme('blue') // blue primary, default dark
646
+ * ```
647
+ */
648
+ declare function quickTheme(primaryOrHex: string, mode?: "dark" | "light"): Theme$1;
649
+ /**
650
+ * Create a theme from a built-in preset name.
651
+ *
652
+ * @example
653
+ * ```typescript
654
+ * presetTheme('catppuccin-mocha')
655
+ * presetTheme('nord')
656
+ * ```
657
+ */
658
+ declare function presetTheme(name: string): Theme$1;
659
+ //#endregion
660
+ //#region packages/theme/src/auto-generate.d.ts
661
+ /**
662
+ * Generate a complete Theme from a single primary color.
663
+ *
664
+ * Derives a full ColorScheme using OKLCH color manipulation:
665
+ * - Background/foreground from lightness endpoints using the primary's hue
666
+ * - Complementary and analogous accent colors from hue rotation
667
+ * - Surface ramp from bg lightness offsets
668
+ * - Status colors (error, warning, success, info) from standard hue positions
669
+ *
670
+ * @param primaryColor - A hex color string (e.g. "#5E81AC")
671
+ * @param mode - "dark" or "light" theme mode
672
+ * @returns A complete Theme with all 33 semantic tokens
673
+ *
674
+ * @example
675
+ * ```typescript
676
+ * const theme = autoGenerateTheme("#5E81AC", "dark")
677
+ * // Generates a full dark theme with blue as the primary accent
678
+ *
679
+ * const light = autoGenerateTheme("#E06C75", "light")
680
+ * // Generates a full light theme with red/rose as the primary accent
681
+ * ```
682
+ */
683
+ declare function autoGenerateTheme(primaryColor: string, mode: "dark" | "light"): Theme$1;
684
+ //#endregion
685
+ //#region packages/theme/src/validate.d.ts
686
+ /** Validation result from validateColorScheme(). */
687
+ interface ValidationResult {
688
+ valid: boolean;
689
+ errors: string[];
690
+ warnings: string[];
691
+ }
692
+ /**
693
+ * Validate a ColorScheme.
694
+ *
695
+ * Checks:
696
+ * - All 22 color fields are present and non-empty hex strings
697
+ * - Warns on low-contrast foreground/background combinations
698
+ */
699
+ declare function validateColorScheme(p: ColorScheme): ValidationResult;
700
+ //#endregion
701
+ //#region packages/theme/src/validate-theme.d.ts
702
+ /**
703
+ * Theme validation — checks that all required semantic tokens are present.
704
+ *
705
+ * Complements validateColorScheme() which validates the lower-level
706
+ * ColorScheme. This validates the derived Theme object.
707
+ */
708
+ /** All 33 required semantic token keys on Theme (excludes `name` and `palette`). */
709
+ declare const THEME_TOKEN_KEYS: readonly string[];
710
+ /** Result of theme validation. */
711
+ interface ThemeValidationResult {
712
+ /** Whether the theme has all required tokens. */
713
+ valid: boolean;
714
+ /** Token keys that are required but missing or empty. */
715
+ missing: string[];
716
+ /** Token keys that exist on the object but are not recognized theme tokens. */
717
+ extra: string[];
718
+ }
719
+ /**
720
+ * Validate a Theme object — check that all required tokens are present.
721
+ *
722
+ * @param theme - The theme object to validate
723
+ * @returns Validation result with missing and extra token lists
724
+ *
725
+ * @example
726
+ * ```typescript
727
+ * const result = validateTheme(myTheme)
728
+ * if (!result.valid) {
729
+ * console.log("Missing tokens:", result.missing)
730
+ * }
731
+ * ```
732
+ */
733
+ declare function validateTheme(theme: Record<string, unknown>): ThemeValidationResult;
734
+ //#endregion
735
+ //#region packages/theme/src/alias.d.ts
736
+ /**
737
+ * Resolve all token aliases in a theme.
738
+ *
739
+ * Token values that start with `$` are treated as references to other tokens.
740
+ * Alias chains are followed until a concrete (non-$) value is reached.
741
+ * Circular references are detected via a depth limit and left unresolved.
742
+ *
743
+ * @param theme - A theme-like object where values may reference other tokens via `$name`
744
+ * @returns A new object with all aliases resolved to concrete values
745
+ *
746
+ * @example
747
+ * ```typescript
748
+ * const themed = resolveAliases({
749
+ * ...baseTheme,
750
+ * button: "$primary", // resolves to the value of 'primary'
751
+ * buttonHover: "$button", // chain: buttonHover -> button -> primary -> hex
752
+ * })
753
+ * ```
754
+ */
755
+ declare function resolveAliases(theme: Record<string, string>): Record<string, string>;
756
+ /**
757
+ * Resolve a single alias value against a Theme.
758
+ *
759
+ * Useful for resolving individual values without processing the entire theme.
760
+ *
761
+ * @param value - The value to resolve (may be "$tokenName" or a concrete value)
762
+ * @param theme - The theme to resolve against
763
+ * @returns The resolved concrete value
764
+ */
765
+ declare function resolveTokenAlias(value: string, theme: Theme$1): string;
766
+ //#endregion
767
+ //#region packages/theme/src/css.d.ts
768
+ /**
769
+ * Convert a Theme to CSS custom properties.
770
+ *
771
+ * Token names mirror Sterling's flat grammar with a `--` prefix:
772
+ * - `bg-surface-default` → `--bg-surface-default`
773
+ * - `fg-accent` → `--fg-accent`
774
+ * - `border-focus` → `--border-focus`
775
+ * - Palette entries: `--color0` through `--color15`
776
+ *
777
+ * @param theme - The theme to convert (Sterling flat tokens must be populated)
778
+ * @returns A record mapping CSS custom property names to color values
779
+ *
780
+ * @example
781
+ * ```typescript
782
+ * const vars = themeToCSSVars(myTheme)
783
+ * // { "--bg-surface-default": "#1E1E2E", "--fg-accent": "#F9E2AF", ... }
784
+ *
785
+ * // Apply to an element:
786
+ * Object.assign(element.style, vars)
787
+ * ```
788
+ */
789
+ declare function themeToCSSVars(theme: Theme$1): Record<string, string>;
790
+ //#endregion
791
+ //#region packages/theme/src/import/types.d.ts
792
+ /**
793
+ * Base16 scheme type — the 16-color format used by hundreds of community themes.
794
+ *
795
+ * @see https://github.com/chriskempson/base16
796
+ */
797
+ /** A parsed Base16 color scheme. All hex values are WITHOUT `#` prefix. */
798
+ interface Base16Scheme {
799
+ scheme: string;
800
+ author: string;
801
+ base00: string;
802
+ base01: string;
803
+ base02: string;
804
+ base03: string;
805
+ base04: string;
806
+ base05: string;
807
+ base06: string;
808
+ base07: string;
809
+ base08: string;
810
+ base09: string;
811
+ base0A: string;
812
+ base0B: string;
813
+ base0C: string;
814
+ base0D: string;
815
+ base0E: string;
816
+ base0F: string;
817
+ }
818
+ //#endregion
819
+ //#region packages/theme/src/import/base16.d.ts
820
+ /**
821
+ * Import a Base16 YAML (or JSON) scheme into a ColorScheme.
822
+ *
823
+ * Mapping:
824
+ * base00 → background, base01 → brightBlack, base02 → selectionBackground,
825
+ * base03 → white (muted fg), base05 → foreground/brightWhite,
826
+ * base08 → red, base09 → brightRed, base0A → yellow,
827
+ * base0B → green, base0C → cyan, base0D → blue, base0E → magenta,
828
+ * base0F → brightMagenta.
829
+ *
830
+ * Bright color variants are derived by brightening normals.
831
+ * `dark` is inferred from base00 luminance.
832
+ */
833
+ declare function importBase16(yamlOrJson: string): ColorScheme;
834
+ //#endregion
835
+ //#region packages/theme/src/export/base16.d.ts
836
+ /**
837
+ * Export a ColorScheme to Base16 YAML format.
838
+ *
839
+ * Mapping:
840
+ * background → base00, brightBlack → base01, selectionBackground → base02,
841
+ * white → base03, (interpolated) → base04, foreground → base05,
842
+ * (interpolated) → base06, (interpolated) → base07,
843
+ * red → base08, brightRed → base09, yellow → base0A, green → base0B,
844
+ * cyan → base0C, blue → base0D, magenta → base0E, brightMagenta → base0F.
845
+ */
846
+ declare function exportBase16(palette: ColorScheme): string;
847
+ //#endregion
848
+ //#region packages/theme/src/schemes/catppuccin.d.ts
849
+ /** Catppuccin Mocha — the classic dark variant. */
850
+ declare const catppuccinMocha: ColorScheme;
851
+ /** Catppuccin Frappe — muted dark variant. */
852
+ declare const catppuccinFrappe: ColorScheme;
853
+ /** Catppuccin Macchiato — warm dark variant. */
854
+ declare const catppuccinMacchiato: ColorScheme;
855
+ /** Catppuccin Latte — the light variant. */
856
+ declare const catppuccinLatte: ColorScheme;
857
+ //#endregion
858
+ //#region packages/theme/src/schemes/nord.d.ts
859
+ /** Nord — the classic dark arctic theme. */
860
+ declare const nord: ColorScheme;
861
+ //#endregion
862
+ //#region packages/theme/src/schemes/dracula.d.ts
863
+ /** Dracula — vibrant dark theme. */
864
+ declare const dracula: ColorScheme;
865
+ //#endregion
866
+ //#region packages/theme/src/schemes/solarized.d.ts
867
+ /** Solarized Dark — Ethan Schoonover's classic dark variant. */
868
+ declare const solarizedDark: ColorScheme;
869
+ /** Solarized Light — Ethan Schoonover's classic light variant. */
870
+ declare const solarizedLight: ColorScheme;
871
+ //#endregion
872
+ //#region packages/theme/src/schemes/tokyo-night.d.ts
873
+ /** Tokyo Night — the default dark variant. */
874
+ declare const tokyoNight: ColorScheme;
875
+ /** Tokyo Night Storm — slightly lighter background. */
876
+ declare const tokyoNightStorm: ColorScheme;
877
+ /** Tokyo Night Day — the light variant. */
878
+ declare const tokyoNightDay: ColorScheme;
879
+ //#endregion
880
+ //#region packages/theme/src/schemes/one-dark.d.ts
881
+ /** One Dark — the classic Atom editor theme. */
882
+ declare const oneDark: ColorScheme;
883
+ //#endregion
884
+ //#region packages/theme/src/schemes/gruvbox.d.ts
885
+ /** Gruvbox Dark — warm retro dark theme. */
886
+ declare const gruvboxDark: ColorScheme;
887
+ /** Gruvbox Light — warm retro light theme. */
888
+ declare const gruvboxLight: ColorScheme;
889
+ //#endregion
890
+ //#region packages/theme/src/schemes/rose-pine.d.ts
891
+ /** Rosé Pine — the main dark variant. */
892
+ declare const rosePine: ColorScheme;
893
+ /** Rosé Pine Moon — slightly lighter dark variant. */
894
+ declare const rosePineMoon: ColorScheme;
895
+ /** Rosé Pine Dawn — the light variant. */
896
+ declare const rosePineDawn: ColorScheme;
897
+ //#endregion
898
+ //#region packages/theme/src/schemes/kanagawa.d.ts
899
+ /** Kanagawa Wave — the default dark variant, inspired by "The Great Wave off Kanagawa". */
900
+ declare const kanagawaWave: ColorScheme;
901
+ /** Kanagawa Dragon — a muted, earthy dark variant. */
902
+ declare const kanagawaDragon: ColorScheme;
903
+ /** Kanagawa Lotus — the light variant, inspired by lotus flowers. */
904
+ declare const kanagawaLotus: ColorScheme;
905
+ //#endregion
906
+ //#region packages/theme/src/schemes/everforest.d.ts
907
+ /** Everforest Dark — warm green-based dark theme (medium background). */
908
+ declare const everforestDark: ColorScheme;
909
+ /** Everforest Light — warm green-based light theme (medium background). */
910
+ declare const everforestLight: ColorScheme;
911
+ //#endregion
912
+ //#region packages/theme/src/schemes/monokai.d.ts
913
+ /** Monokai Classic — the original Sublime Text Monokai colors. */
914
+ declare const monokai: ColorScheme;
915
+ /** Monokai Pro — the modern, refined Monokai with balanced colors. */
916
+ declare const monokaiPro: ColorScheme;
917
+ //#endregion
918
+ //#region packages/theme/src/schemes/snazzy.d.ts
919
+ /** Snazzy — clean dark theme by Sindre Sorhus. */
920
+ declare const snazzy: ColorScheme;
921
+ //#endregion
922
+ //#region packages/theme/src/schemes/material.d.ts
923
+ /** Material Darker — the deep dark Material variant. */
924
+ declare const materialDark: ColorScheme;
925
+ /** Material Lighter — the light Material variant. */
926
+ declare const materialLight: ColorScheme;
927
+ //#endregion
928
+ //#region packages/theme/src/schemes/palenight.d.ts
929
+ /** Palenight — the soft, purple-tinted Material dark variant. */
930
+ declare const palenight: ColorScheme;
931
+ //#endregion
932
+ //#region packages/theme/src/schemes/ayu.d.ts
933
+ /** Ayu Dark — deep dark variant with warm accents. */
934
+ declare const ayuDark: ColorScheme;
935
+ /** Ayu Mirage — balanced dark variant with softer contrast. */
936
+ declare const ayuMirage: ColorScheme;
937
+ /** Ayu Light — clean light variant. */
938
+ declare const ayuLight: ColorScheme;
939
+ //#endregion
940
+ //#region packages/theme/src/schemes/nightfox.d.ts
941
+ /** Nightfox — dark blue-toned variant. */
942
+ declare const nightfox: ColorScheme;
943
+ /** Dawnfox — warm light variant inspired by Rose Pine Dawn. */
944
+ declare const dawnfox: ColorScheme;
945
+ //#endregion
946
+ //#region packages/theme/src/schemes/horizon.d.ts
947
+ /** Horizon — warm dark variant with vivid accents. */
948
+ declare const horizon: ColorScheme;
949
+ //#endregion
950
+ //#region packages/theme/src/schemes/moonfly.d.ts
951
+ /** Moonfly — dark charcoal theme. */
952
+ declare const moonfly: ColorScheme;
953
+ //#endregion
954
+ //#region packages/theme/src/schemes/nightfly.d.ts
955
+ /** Nightfly — midnight-blue dark theme. */
956
+ declare const nightfly: ColorScheme;
957
+ //#endregion
958
+ //#region packages/theme/src/schemes/oxocarbon.d.ts
959
+ /** Oxocarbon Dark — IBM Carbon-inspired dark variant. */
960
+ declare const oxocarbonDark: ColorScheme;
961
+ /** Oxocarbon Light — IBM Carbon-inspired light variant. */
962
+ declare const oxocarbonLight: ColorScheme;
963
+ //#endregion
964
+ //#region packages/theme/src/schemes/sonokai.d.ts
965
+ /** Sonokai — vivid dark theme with Monokai-inspired accents. */
966
+ declare const sonokai: ColorScheme;
967
+ //#endregion
968
+ //#region packages/theme/src/schemes/edge.d.ts
969
+ /** Edge Dark — clean dark variant with balanced accents. */
970
+ declare const edgeDark: ColorScheme;
971
+ /** Edge Light — clean, readable light variant. */
972
+ declare const edgeLight: ColorScheme;
973
+ //#endregion
974
+ //#region packages/theme/src/schemes/modus.d.ts
975
+ /** Modus Vivendi — elegant dark theme with maximum legibility. */
976
+ declare const modusVivendi: ColorScheme;
977
+ /** Modus Operandi — elegant light theme with maximum legibility. */
978
+ declare const modusOperandi: ColorScheme;
979
+ //#endregion
980
+ //#region packages/theme/src/schemes/index.d.ts
981
+ /**
982
+ * Dark ANSI 16 theme — hex-valued, derived from the default dark scheme.
983
+ * All token values are hex strings (no ANSI slot names).
984
+ * Terminal rendering quantizes hex to 4-bit ANSI codes when colorLevel === "basic".
985
+ *
986
+ * Sterling flat tokens (`bg-surface-subtle`, `fg-on-accent`, `border-focus`, …)
987
+ * are baked in at construction — consumers can read either legacy fields or
988
+ * Sterling flat keys off the same Theme object.
989
+ */
990
+ declare const ansi16DarkTheme: Theme$1;
991
+ /**
992
+ * Light ANSI 16 theme — hex-valued, derived from the default light scheme.
993
+ * All token values are hex strings (no ANSI slot names).
994
+ * Terminal rendering quantizes hex to 4-bit ANSI codes when colorLevel === "basic".
995
+ *
996
+ * Sterling flat tokens baked in at construction.
997
+ */
998
+ declare const ansi16LightTheme: Theme$1;
999
+ /** Dark truecolor theme — derived from Nord. Sterling flat tokens baked in. */
1000
+ declare const defaultDarkTheme: Theme$1;
1001
+ /** Light truecolor theme — derived from Catppuccin Latte. Sterling flat tokens baked in. */
1002
+ declare const defaultLightTheme: Theme$1;
1003
+ /** All built-in ColorScheme definitions (70+ palettes). */
1004
+ declare const builtinPalettes: Record<string, ColorScheme>;
1005
+ /** All built-in themes, indexed by name (includes backward-compat aliases). */
1006
+ declare const builtinThemes: Record<string, Theme$1>;
1007
+ /** Resolve a theme by name. Defaults to dark-ansi16. */
1008
+ declare function getThemeByName(name?: string): Theme$1;
1009
+ /** Resolve a palette by name. Returns undefined if not found. */
1010
+ declare function getSchemeByName(name: string): ColorScheme | undefined;
1011
+ //#endregion
1012
+ //#region packages/theme/src/detect.d.ts
1013
+ /**
1014
+ * Detect the terminal's palette and return a Sterling-aware Theme.
1015
+ *
1016
+ * Identical to `@silvery/ansi`'s `detectTheme` but every returned theme has
1017
+ * Sterling flat tokens baked in via `inlineSterlingTokens`.
1018
+ */
1019
+ declare function detectTheme(opts?: DetectThemeOptions): Promise<Theme$1>;
1020
+ //#endregion
1021
+ //#region packages/theme/src/sterling/types.d.ts
1022
+ /**
1023
+ * Surface-only state pair: only `bg` varies by state. Used by the status
1024
+ * roles (`info`, `success`, `warning`, `error`) where state variants are
1025
+ * meaningful only for surfaces (filled bg), never for text.
1026
+ *
1027
+ * Text tokens on status roles don't hover — `fg-error` is a status color,
1028
+ * not an interactive link. Keeping `fg.hover` / `fg.active` on those roles
1029
+ * invited algorithmic over-generation that produced illegible results
1030
+ * (e.g. catppuccin-frappe `warning.active.fg` collapsing to `#FFFFFF`).
1031
+ */
1032
+ interface BgStatePair {
1033
+ readonly bg: string;
1034
+ }
1035
+ /**
1036
+ * Interactive (link-like) state pair: both `fg` and `bg` vary by state.
1037
+ * Used by `accent` — the canonical interactive-text role.
1038
+ */
1039
+ interface StatePair {
1040
+ readonly fg: string;
1041
+ readonly bg: string;
1042
+ }
1043
+ /**
1044
+ * A status role — fg, bg, and `fgOn` (text color to draw when rendering ON
1045
+ * a filled bg of this role). State variants apply to SURFACE (bg) only;
1046
+ * text-color state variants are reserved for link-like roles (`accent`).
1047
+ */
1048
+ interface InteractiveRole {
1049
+ /** Foreground hex — use for text/icon in this role. */
1050
+ readonly fg: string;
1051
+ /** Background hex — use as fill for emphasis. */
1052
+ readonly bg: string;
1053
+ /** Foreground to use when drawing ON `bg` (contrast-picked). */
1054
+ readonly fgOn: string;
1055
+ /** Hover state — surface only (adaptive ±L shift on bg). */
1056
+ readonly hover: BgStatePair;
1057
+ /** Active (pressed) state — surface only (adaptive ±L shift on bg). */
1058
+ readonly active: BgStatePair;
1059
+ }
1060
+ /**
1061
+ * Accent — the canonical link-like interactive-text role. Has everything
1062
+ * `InteractiveRole` does PLUS a focus-ring border AND `fg.hover` /
1063
+ * `fg.active` text-color state variants (link hover treatments).
1064
+ */
1065
+ interface AccentRole {
1066
+ /** Foreground hex — use for text/icon in accent. */
1067
+ readonly fg: string;
1068
+ /** Background hex — use as fill for emphasis. */
1069
+ readonly bg: string;
1070
+ /** Foreground to use when drawing ON `bg` (contrast-picked). */
1071
+ readonly fgOn: string;
1072
+ /** Border color for focus rings using this accent. */
1073
+ readonly border: string;
1074
+ /** Hover state — both fg (link hover) and bg (surface hover). */
1075
+ readonly hover: StatePair;
1076
+ /** Active (pressed) state — both fg and bg. */
1077
+ readonly active: StatePair;
1078
+ }
1079
+ /** Surface hierarchy — `default` is the canvas, subtle/raised/overlay stack upward. */
1080
+ interface SurfaceRole {
1081
+ readonly default: string;
1082
+ readonly subtle: string;
1083
+ readonly raised: string;
1084
+ readonly overlay: string;
1085
+ readonly hover: string;
1086
+ }
1087
+ /** Border roles — `focus` is the focus-ring color; `default` is normal rule line. */
1088
+ interface BorderRole {
1089
+ readonly default: string;
1090
+ readonly focus: string;
1091
+ readonly muted: string;
1092
+ }
1093
+ /** Cursor colors. */
1094
+ interface CursorRole {
1095
+ readonly fg: string;
1096
+ readonly bg: string;
1097
+ }
1098
+ /** Muted role — lower-emphasis text/bg for deemphasized content. */
1099
+ interface MutedRole {
1100
+ readonly fg: string;
1101
+ readonly bg: string;
1102
+ }
1103
+ /**
1104
+ * The nested, programmatic form of a Theme. All leaf values are hex strings.
1105
+ * Reached via `theme.accent.bg`, `theme.surface.raised`, etc.
1106
+ */
1107
+ interface Roles {
1108
+ readonly accent: AccentRole;
1109
+ readonly info: InteractiveRole;
1110
+ readonly success: InteractiveRole;
1111
+ readonly warning: InteractiveRole;
1112
+ readonly error: InteractiveRole;
1113
+ readonly muted: MutedRole;
1114
+ readonly surface: SurfaceRole;
1115
+ readonly border: BorderRole;
1116
+ readonly cursor: CursorRole;
1117
+ }
1118
+ /**
1119
+ * Every flat hyphen-key that Sterling emits. String-literal union so that
1120
+ * `theme["bg-accent"]` is type-checked and typos fail the compile.
1121
+ *
1122
+ * Grammar: `prefix-role[-state]` or `prefix-on-role` or `prefix-role-kind[-state]`.
1123
+ * (See design-system.md §"Flattening rule".)
1124
+ */
1125
+ type FlatToken = "bg-surface-default" | "bg-surface-subtle" | "bg-surface-raised" | "bg-surface-overlay" | "bg-surface-hover" | "border-default" | "border-focus" | "border-muted" | "fg-cursor" | "bg-cursor" | "fg-muted" | "bg-muted" | "fg-accent" | "bg-accent" | "fg-on-accent" | "fg-accent-hover" | "bg-accent-hover" | "fg-accent-active" | "bg-accent-active" | "border-accent" | "fg-info" | "bg-info" | "fg-on-info" | "bg-info-hover" | "bg-info-active" | "fg-success" | "bg-success" | "fg-on-success" | "bg-success-hover" | "bg-success-active" | "fg-warning" | "bg-warning" | "fg-on-warning" | "bg-warning-hover" | "bg-warning-active" | "fg-error" | "bg-error" | "fg-on-error" | "bg-error-hover" | "bg-error-active";
1126
+ /** The flat projection — every FlatToken maps to a hex string. */
1127
+ type FlatTokens = { readonly [K in FlatToken]: string };
1128
+ /**
1129
+ * Per-token record of HOW a token was derived. Populated only when the
1130
+ * derivation is called with `{ trace: true }`. Used by the Sterling
1131
+ * storybook to visualize derivation rules.
1132
+ */
1133
+ interface DerivationStep {
1134
+ /** Token path (e.g. `"accent.hover.bg"` or flat `"bg-accent-hover"`). */
1135
+ readonly token: string;
1136
+ /** Human-readable rule name (e.g. `"OKLCH +0.04L on accent.bg"`). */
1137
+ readonly rule: string;
1138
+ /** Input hex(es) the rule operated on. */
1139
+ readonly inputs: readonly string[];
1140
+ /** Output hex. */
1141
+ readonly output: string;
1142
+ /** If auto-lift adjusted this token, the original value before adjustment. */
1143
+ readonly liftedFrom?: string;
1144
+ /** If pinned by scheme author, true. */
1145
+ readonly pinned?: boolean;
1146
+ }
1147
+ type DerivationTrace = readonly DerivationStep[];
1148
+ /**
1149
+ * Categorical color ring — 8 harmonious hues for tagging, chart series,
1150
+ * calendar categories, priority levels — any CATEGORICAL color that isn't
1151
+ * stateful. ensureContrast-adjusted against bg at derivation time. Consumers
1152
+ * access these via `$red`, `$orange`, …, `$pink` or direct field access.
1153
+ *
1154
+ * Distinguish from:
1155
+ * - `$color0..$color15` — raw terminal ANSI (user's theme verbatim)
1156
+ * - `$error/$warning/$success` — semantic state (communicates meaning)
1157
+ * - `$brand` — app identity anchor (one color)
1158
+ */
1159
+ interface CategoricalHues {
1160
+ readonly red: string;
1161
+ readonly orange: string;
1162
+ readonly yellow: string;
1163
+ readonly green: string;
1164
+ readonly teal: string;
1165
+ readonly blue: string;
1166
+ readonly purple: string;
1167
+ readonly pink: string;
1168
+ }
1169
+ /**
1170
+ * The canonical Sterling Theme — Sterling flat tokens + nested roles on the
1171
+ * same object, plus a small surface of non-token metadata and runtime
1172
+ * convenience fields the framework depends on:
1173
+ *
1174
+ * Two access paths for every hex leaf:
1175
+ * - Nested: `theme.accent.hover.bg`
1176
+ * - Flat: `theme["bg-accent-hover"]`
1177
+ * Both paths reference the same string (not copies). The object is frozen
1178
+ * after derivation (see `flatten.ts`).
1179
+ *
1180
+ * Non-token metadata:
1181
+ * - `name` — scheme display name (if derived from a named scheme)
1182
+ * - `mode` — light/dark
1183
+ * - `derivationTrace` — optional; present only when `{ trace: true }` was passed
1184
+ * - `variants` — typography preset bundles (h1, body, code, …) resolved by
1185
+ * `<Text variant="…">`
1186
+ * - `palette` — 16-slot ANSI catalog used by `$color0` … `$color15`
1187
+ * - categorical hues (`red`, `orange`, `yellow`, `green`, `teal`, `blue`,
1188
+ * `purple`, `pink`) — hex strings for categorical UI
1189
+ *
1190
+ * The nested roles (`accent`, `muted`, `surface`, `border`, `cursor`, plus
1191
+ * the status roles `info`/`success`/`warning`/`error`) are authoritative for
1192
+ * stateful tokens. Legacy flat hex aliases for these roles (`theme.primary`,
1193
+ * `theme.muted`, `theme.accent` as strings) are emitted as runtime
1194
+ * conveniences via the scheme-builder but are not part of this type — they
1195
+ * were deleted in silvery 0.19.0.
1196
+ */
1197
+ type Theme = FlatTokens & Roles & {
1198
+ readonly name?: string;
1199
+ readonly mode: "light" | "dark";
1200
+ readonly derivationTrace?: DerivationTrace;
1201
+ readonly variants: Record<string, Variant>;
1202
+ readonly palette: readonly string[];
1203
+ } & CategoricalHues;
1204
+ /**
1205
+ * A typography variant — a named bundle of visual properties applied to a
1206
+ * Text component via `variant="h1"`. The variant acts as a *default*: caller
1207
+ * props always win over variant values.
1208
+ *
1209
+ * Color values follow the same syntax as `TextColor` — `$token` strings, hex
1210
+ * values, ANSI names, or any string accepted by the color system.
1211
+ */
1212
+ interface Variant {
1213
+ readonly color?: string;
1214
+ readonly backgroundColor?: string;
1215
+ readonly bold?: boolean;
1216
+ readonly italic?: boolean;
1217
+ readonly dim?: boolean;
1218
+ readonly underlineStyle?: "single" | "double" | "curly" | "dotted" | "dashed";
1219
+ }
1220
+ /**
1221
+ * Metadata describing a DesignSystem's Theme shape — for tooling (docs,
1222
+ * storybook, CSS export). Plain data, no functions.
1223
+ */
1224
+ interface ThemeShape {
1225
+ /** The list of FlatTokens this system emits. */
1226
+ readonly flatTokens: readonly string[];
1227
+ /** The list of role-object keys this system emits (e.g. `["accent", "info", ...]`). */
1228
+ readonly roles: readonly string[];
1229
+ /** The list of state variants used on interactive roles (e.g. `["hover", "active"]`). */
1230
+ readonly states: readonly string[];
1231
+ }
1232
+ /** Contrast enforcement mode for derivation. See D3 in sterling-preflight.md. */
1233
+ type ContrastMode = /** Throw on WCAG AA failure on core role pairs. Used by catalog tests. */"strict" /** Auto-lift failing tokens via OKLCH L shifts. Used for user schemes. */ | "auto-lift";
1234
+ /** Options accepted by all derivation entry points. */
1235
+ interface DeriveOptions {
1236
+ /** Default: `"auto-lift"`. */
1237
+ readonly contrast?: ContrastMode;
1238
+ /** If true, attach `derivationTrace` to the returned Theme. Default: false. */
1239
+ readonly trace?: boolean;
1240
+ /**
1241
+ * Per-role token pins. A scheme author can pin specific tokens (e.g.
1242
+ * `{ "error.fg": "#bf616a" }`) to skip auto-adjustment. The path syntax is
1243
+ * nested-style: `"accent.hover.bg"`, `"error.fg"`. Flat-form pins are
1244
+ * also accepted: `{ "bg-accent": "#...", "fg-on-error": "#..." }`.
1245
+ */
1246
+ readonly pins?: Readonly<Record<string, string>>;
1247
+ /**
1248
+ * Force light/dark inference. By default inferred from
1249
+ * `scheme.dark` or WCAG luminance of `scheme.background`.
1250
+ */
1251
+ readonly mode?: "light" | "dark";
1252
+ }
1253
+ /**
1254
+ * The `DesignSystem` contract. Sterling is the default implementation; other
1255
+ * packages (e.g. `@silvery/design-material`) publish alternatives matching
1256
+ * this shape.
1257
+ */
1258
+ interface DesignSystem {
1259
+ /** Display name for tooling (e.g. `"sterling"`). */
1260
+ readonly name: string;
1261
+ /** Metadata about this system's Theme shape. */
1262
+ readonly shape: ThemeShape;
1263
+ /**
1264
+ * Whether the framework should auto-apply `bakeFlat` to each derivation's
1265
+ * output — projecting hex leaves onto flat hyphen-keys on the same object.
1266
+ *
1267
+ * - `true` — use {@link defaultFlattenRule} (channel-role-state, Sterling style)
1268
+ * - `FlattenRule` — system-specific rule (e.g. Material `onPrimary`)
1269
+ * - `false` or omitted — no auto-flatten (system is responsible, or
1270
+ * consumer only uses nested form)
1271
+ *
1272
+ * Sterling and anything modelled on it should set `flatten: true` —
1273
+ * flat-projection-on-same-object is a universal feature of nested
1274
+ * hex-leaf POJOs and Sterling users expect `theme["bg-accent"]` access.
1275
+ */
1276
+ readonly flatten?: boolean | FlattenRule;
1277
+ /** Return a raw default Theme, no input required. */
1278
+ defaults(mode?: "light" | "dark"): Theme;
1279
+ /**
1280
+ * Fill partial theme values with defaults. Useful for hand-curated themes
1281
+ * that override a few roles.
1282
+ */
1283
+ theme(partial?: DeepPartial<Theme>, opts?: DeriveOptions): Theme;
1284
+ /** Derive from a 22-color terminal scheme — Sterling's primary path. */
1285
+ deriveFromScheme(scheme: ColorScheme, opts?: DeriveOptions): Theme;
1286
+ /** Derive from a single seed color — Material-style. */
1287
+ deriveFromColor(color: string, opts?: DeriveOptions & {
1288
+ mode?: "light" | "dark";
1289
+ }): Theme;
1290
+ /** Derive from a light/dark scheme pair. */
1291
+ deriveFromPair(light: ColorScheme, dark: ColorScheme, opts?: DeriveOptions): {
1292
+ light: Theme;
1293
+ dark: Theme;
1294
+ };
1295
+ /** Derive from a scheme plus a brand-color overlay (F — brand discipline). */
1296
+ deriveFromSchemeWithBrand(scheme: ColorScheme, brand: string, opts?: DeriveOptions): Theme;
1297
+ }
1298
+ /** Utility: recursive `Partial` for nested Theme overrides. */
1299
+ type DeepPartial<T> = T extends object ? T extends readonly unknown[] ? T : { [K in keyof T]?: DeepPartial<T[K]> } : T;
1300
+ //#endregion
1301
+ //#region packages/theme/src/sterling/sterling.d.ts
1302
+ /**
1303
+ * Sterling — the user-facing DesignSystem. `defineDesignSystem` wraps
1304
+ * `rawSterling` with auto-`bakeFlat` (per `flatten: true`), so every
1305
+ * returned Theme has both nested roles AND flat hyphen keys populated.
1306
+ */
1307
+ declare const sterling: DesignSystem;
1308
+ //#endregion
1309
+ //#region packages/theme/src/sterling/define.d.ts
1310
+ /**
1311
+ * Wrap a DesignSystem so every derivation method auto-applies `bakeFlat`
1312
+ * per the `flatten` flag. Pass your raw system (one that returns nested
1313
+ * themes) and this returns a user-facing system whose outputs have flat
1314
+ * keys populated.
1315
+ */
1316
+ declare function defineDesignSystem(def: DesignSystem): DesignSystem;
1317
+ //#endregion
1318
+ //#region packages/theme/src/sterling/contrast.d.ts
1319
+ /**
1320
+ * Sterling contrast guardrails — D3 from sterling-preflight.md.
1321
+ *
1322
+ * Two modes:
1323
+ * - `strict` — throw when a core role pair fails WCAG AA 4.5:1.
1324
+ * Used by the catalog test (all 84 shipped schemes must pass).
1325
+ * - `auto-lift` — adjust OKLCH lightness until AA passes (±0.04L increments
1326
+ * up to ~0.20L). Logs at debug; silent by default. Used for user schemes
1327
+ * at runtime.
1328
+ *
1329
+ * Pinned tokens (per-role overrides supplied by scheme authors) are excluded
1330
+ * from auto-lift and from strict-mode enforcement — the author accepts the
1331
+ * contrast consequence of pinning.
1332
+ */
1333
+ /** WCAG AA threshold for normal text. */
1334
+ declare const WCAG_AA = 4.5;
1335
+ interface ContrastViolation {
1336
+ readonly token: string;
1337
+ readonly fg: string;
1338
+ readonly bg: string;
1339
+ readonly ratio: number;
1340
+ readonly target: number;
1341
+ }
1342
+ declare class ContrastError extends Error {
1343
+ readonly violations: readonly ContrastViolation[];
1344
+ constructor(violations: readonly ContrastViolation[]);
1345
+ }
1346
+ /**
1347
+ * Verify `fg` on `bg` meets `target` ratio. Returns `null` when already
1348
+ * passing; otherwise returns a ContrastViolation.
1349
+ */
1350
+ declare function checkAA(token: string, fg: string, bg: string, target?: number): ContrastViolation | null;
1351
+ /**
1352
+ * Auto-lift `fg` against `bg` until the `target` contrast ratio is met,
1353
+ * via OKLCH L shifts (hue + chroma preserved). Light bg → darken;
1354
+ * dark bg → lighten.
1355
+ *
1356
+ * Implementation note: binary-searches the minimum L shift achieving the
1357
+ * target. Falls back to a best-effort value if the target is unreachable
1358
+ * (e.g., yellow against white can never hit 4.5:1 at any lightness while
1359
+ * preserving yellow hue; the result is the darkest in-gamut yellow).
1360
+ */
1361
+ declare function autoLift(fg: string, bg: string, target?: number): {
1362
+ value: string;
1363
+ lifted: boolean;
1364
+ };
1365
+ //#endregion
1366
+ //#region packages/theme/src/sterling/derive.d.ts
1367
+ /**
1368
+ * Derive a Theme's nested roles from a ColorScheme. Guardrails applied.
1369
+ */
1370
+ declare function deriveRoles(scheme: ColorScheme, opts: DeriveOptions): {
1371
+ roles: Roles;
1372
+ mode: "light" | "dark";
1373
+ trace: DerivationStep[];
1374
+ violations: ContrastViolation[];
1375
+ };
1376
+ /**
1377
+ * Derive a full Theme (pre-flatten) from a ColorScheme. Throws `ContrastError`
1378
+ * in strict mode if any role pair fails WCAG AA. Callers typically wrap this
1379
+ * with `flatten()` (from `flatten.ts`) to get the user-facing Theme.
1380
+ *
1381
+ * Returned Theme is NOT frozen and DOES NOT contain flat keys yet.
1382
+ */
1383
+ declare function deriveTheme(scheme: ColorScheme, opts?: DeriveOptions): Omit<Theme, keyof FlatTokens>;
1384
+ //#endregion
1385
+ //#region packages/theme/src/sterling/flat-tokens.d.ts
1386
+ declare const STERLING_FLAT_TOKENS: readonly FlatToken[];
1387
+ //#endregion
1388
+ //#region packages/theme/src/sterling/defaults.d.ts
1389
+ declare function defaultScheme(mode?: "light" | "dark"): ColorScheme;
1390
+ //#endregion
1391
+ export { ayuMirage as $, resetBackgroundColor as $t, detectTheme as A, pickColorLevel as An, Base16Scheme as At, modusVivendi as B, createTheme as Bt, InteractiveRole as C, disableMouse as Cn, nord as Ct, SurfaceRole as D, bakeFlat as Dn, catppuccinMocha as Dt, StatePair as E, FlattenRule as En, catppuccinMacchiato as Et, defaultDarkTheme as F, detectTerminalCaps as Fn, ThemeValidationResult as Ft, oxocarbonLight as G, fromColors as Gt, edgeLight as H, quickTheme as Ht, defaultLightTheme as I, validateTheme as It, horizon as J, generateTheme$1 as Jt, nightfly as K, fromPreset as Kt, getSchemeByName as L, ValidationResult as Lt, ansi16LightTheme as M, ColorLevel as Mn, resolveAliases as Mt, builtinPalettes as N, TerminalCaps as Nn, resolveTokenAlias as Nt, Theme as O, defaultFlattenRule as On, exportBase16 as Ot, builtinThemes as P, defaultCaps as Pn, THEME_TOKEN_KEYS as Pt, ayuLight as Q, queryForegroundColor as Qt, getThemeByName as R, validateColorScheme as Rt, FlatTokens as S, disableKittyKeyboard as Sn, dracula as St, Roles as T, enableMouse as Tn, catppuccinLatte as Tt, sonokai as U, assignPrimaryToSlot as Ut, edgeDark as V, presetTheme as Vt, oxocarbonDark as W, fromBase16 as Wt, nightfox as X, queryBackgroundColor as Xt, dawnfox as Y, detectColorScheme as Yt, ayuDark as Z, queryCursorColor as Zt, DerivationStep as _, AnsiPrimary as _n, tokyoNight as _t, ContrastError as a, parsePaletteResponse as an, monokaiPro as at, DesignSystem as b, Theme$1 as bn, solarizedDark as bt, autoLift as c, setPaletteColor as cn, kanagawaDragon as ct, sterling as d, detectTerminalScheme as dn, rosePine as dt, resetCursorColor as en, palenight as et, AccentRole as f, KnownVariant as fn, rosePineDawn as ft, DeepPartial as g, ActiveScheme as gn, oneDark as gt, CursorRole as h, deriveTheme$1 as hn, gruvboxLight as ht, deriveTheme as i, setForegroundColor as in, monokai as it, ansi16DarkTheme as j, quantizeHex as jn, themeToCSSVars as jt, ThemeShape as k, ColorTier as kn, importBase16 as kt, checkAA as l, DetectThemeOptions as ln, kanagawaLotus as lt, ContrastMode as m, DetectSchemeResult as mn, gruvboxDark as mt, STERLING_FLAT_TOKENS as n, setBackgroundColor as nn, materialLight as nt, ContrastViolation as o, queryMultiplePaletteColors as on, everforestDark as ot, BorderRole as p, DetectSchemeOptions as pn, rosePineMoon as pt, moonfly as q, generateTheme as qt, deriveRoles as r, setCursorColor as rn, snazzy as rt, WCAG_AA as s, queryPaletteColor as sn, everforestLight as st, defaultScheme as t, resetForegroundColor as tn, materialDark as tt, defineDesignSystem as u, DetectedScheme as un, kanagawaWave as ut, DerivationTrace as v, COLOR_SCHEME_FIELDS as vn, tokyoNightDay as vt, MutedRole as w, enableKittyKeyboard as wn, catppuccinFrappe as wt, FlatToken as x, resolveThemeColor as xn, solarizedLight as xt, DeriveOptions as y, ColorScheme as yn, tokyoNightStorm as yt, modusOperandi as z, autoGenerateTheme as zt };
1392
+ //# sourceMappingURL=index-D3saHouR.d.mts.map