@promptctl/rich-js 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/anchor.d.ts +45 -0
- package/dist/core/anchor.js +39 -0
- package/dist/core/ansi.d.ts +65 -0
- package/dist/core/ansi.js +231 -0
- package/dist/core/box.d.ts +143 -0
- package/dist/core/box.js +379 -0
- package/dist/core/cells.d.ts +159 -0
- package/dist/core/cells.js +287 -0
- package/dist/core/color.d.ts +246 -0
- package/dist/core/color.js +1038 -0
- package/dist/core/console.d.ts +165 -0
- package/dist/core/console.js +527 -0
- package/dist/core/emoji.d.ts +24 -0
- package/dist/core/emoji.js +391 -0
- package/dist/core/export-html.d.ts +59 -0
- package/dist/core/export-html.js +200 -0
- package/dist/core/export-lines.d.ts +121 -0
- package/dist/core/export-lines.js +141 -0
- package/dist/core/highlighter.d.ts +33 -0
- package/dist/core/highlighter.js +124 -0
- package/dist/core/json.d.ts +27 -0
- package/dist/core/json.js +53 -0
- package/dist/core/markup.d.ts +119 -0
- package/dist/core/markup.js +731 -0
- package/dist/core/measure.d.ts +27 -0
- package/dist/core/measure.js +62 -0
- package/dist/core/oklch.d.ts +161 -0
- package/dist/core/oklch.js +312 -0
- package/dist/core/osc8.d.ts +68 -0
- package/dist/core/osc8.js +90 -0
- package/dist/core/place.d.ts +30 -0
- package/dist/core/place.js +51 -0
- package/dist/core/pretty.d.ts +144 -0
- package/dist/core/pretty.js +476 -0
- package/dist/core/protocol.d.ts +267 -0
- package/dist/core/protocol.js +163 -0
- package/dist/core/render.d.ts +84 -0
- package/dist/core/render.js +145 -0
- package/dist/core/segment.d.ts +161 -0
- package/dist/core/segment.js +492 -0
- package/dist/core/spinnerData.d.ts +12 -0
- package/dist/core/spinnerData.js +117 -0
- package/dist/core/strip.d.ts +141 -0
- package/dist/core/strip.js +305 -0
- package/dist/core/style.d.ts +169 -0
- package/dist/core/style.js +695 -0
- package/dist/core/subscription.d.ts +12 -0
- package/dist/core/subscription.js +12 -0
- package/dist/core/text.d.ts +256 -0
- package/dist/core/text.js +976 -0
- package/dist/core/wrap.d.ts +41 -0
- package/dist/core/wrap.js +127 -0
- package/dist/host/app.d.ts +121 -0
- package/dist/host/app.js +255 -0
- package/dist/host/host-environment.d.ts +26 -0
- package/dist/host/host-environment.js +44 -0
- package/dist/host/index.d.ts +5 -0
- package/dist/host/index.js +3 -0
- package/dist/host/terminal-host.d.ts +179 -0
- package/dist/host/terminal-host.js +186 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +107 -0
- package/dist/node/prompt.d.ts +21 -0
- package/dist/node/prompt.js +30 -0
- package/dist/node/save.d.ts +17 -0
- package/dist/node/save.js +21 -0
- package/dist/node/terminal-host.d.ts +113 -0
- package/dist/node/terminal-host.js +227 -0
- package/dist/node/traceback.d.ts +37 -0
- package/dist/node/traceback.js +134 -0
- package/dist/renderables/align.d.ts +16 -0
- package/dist/renderables/align.js +33 -0
- package/dist/renderables/columns.d.ts +61 -0
- package/dist/renderables/columns.js +152 -0
- package/dist/renderables/constrain.d.ts +15 -0
- package/dist/renderables/constrain.js +37 -0
- package/dist/renderables/embed.d.ts +50 -0
- package/dist/renderables/embed.js +71 -0
- package/dist/renderables/flexStrip.d.ts +41 -0
- package/dist/renderables/flexStrip.js +200 -0
- package/dist/renderables/group.d.ts +11 -0
- package/dist/renderables/group.js +17 -0
- package/dist/renderables/layout.d.ts +92 -0
- package/dist/renderables/layout.js +312 -0
- package/dist/renderables/live.d.ts +50 -0
- package/dist/renderables/live.js +175 -0
- package/dist/renderables/markdown.d.ts +24 -0
- package/dist/renderables/markdown.js +184 -0
- package/dist/renderables/padding.d.ts +38 -0
- package/dist/renderables/padding.js +141 -0
- package/dist/renderables/panel.d.ts +116 -0
- package/dist/renderables/panel.js +307 -0
- package/dist/renderables/progress.d.ts +90 -0
- package/dist/renderables/progress.js +238 -0
- package/dist/renderables/progressBar.d.ts +31 -0
- package/dist/renderables/progressBar.js +53 -0
- package/dist/renderables/prompt.d.ts +49 -0
- package/dist/renderables/prompt.js +125 -0
- package/dist/renderables/rule.d.ts +25 -0
- package/dist/renderables/rule.js +90 -0
- package/dist/renderables/spinner.d.ts +31 -0
- package/dist/renderables/spinner.js +70 -0
- package/dist/renderables/status.d.ts +23 -0
- package/dist/renderables/status.js +60 -0
- package/dist/renderables/syntax.d.ts +35 -0
- package/dist/renderables/syntax.js +115 -0
- package/dist/renderables/table.d.ts +194 -0
- package/dist/renderables/table.js +795 -0
- package/dist/renderables/traceback.d.ts +31 -0
- package/dist/renderables/traceback.js +108 -0
- package/dist/renderables/tree.d.ts +68 -0
- package/dist/renderables/tree.js +150 -0
- package/dist/renderables/viewport.d.ts +114 -0
- package/dist/renderables/viewport.js +198 -0
- package/dist/template-bindings/color-funcs.d.ts +87 -0
- package/dist/template-bindings/color-funcs.js +217 -0
- package/dist/template-bindings/helpers.d.ts +24 -0
- package/dist/template-bindings/helpers.js +48 -0
- package/dist/template-bindings/index.d.ts +107 -0
- package/dist/template-bindings/index.js +146 -0
- package/dist/template-bindings/palette-funcs.d.ts +94 -0
- package/dist/template-bindings/palette-funcs.js +141 -0
- package/dist/template-bindings/style-funcs.d.ts +28 -0
- package/dist/template-bindings/style-funcs.js +155 -0
- package/dist/themes/buildPalette.d.ts +36 -0
- package/dist/themes/buildPalette.js +56 -0
- package/dist/themes/colorMath.d.ts +82 -0
- package/dist/themes/colorMath.js +254 -0
- package/dist/themes/colorRef.d.ts +51 -0
- package/dist/themes/colorRef.js +96 -0
- package/dist/themes/data/ansi-tables.d.ts +14 -0
- package/dist/themes/data/ansi-tables.js +49 -0
- package/dist/themes/data/atom-one-dark.d.ts +3 -0
- package/dist/themes/data/atom-one-dark.js +177 -0
- package/dist/themes/data/atom-one-light.d.ts +3 -0
- package/dist/themes/data/atom-one-light.js +177 -0
- package/dist/themes/data/catppuccin-frappe.d.ts +3 -0
- package/dist/themes/data/catppuccin-frappe.js +177 -0
- package/dist/themes/data/catppuccin-latte.d.ts +3 -0
- package/dist/themes/data/catppuccin-latte.js +177 -0
- package/dist/themes/data/catppuccin-macchiato.d.ts +3 -0
- package/dist/themes/data/catppuccin-macchiato.js +177 -0
- package/dist/themes/data/catppuccin-mocha.d.ts +3 -0
- package/dist/themes/data/catppuccin-mocha.js +177 -0
- package/dist/themes/data/cyberpunk.d.ts +17 -0
- package/dist/themes/data/cyberpunk.js +193 -0
- package/dist/themes/data/default.d.ts +3 -0
- package/dist/themes/data/default.js +160 -0
- package/dist/themes/data/dracula.d.ts +3 -0
- package/dist/themes/data/dracula.js +177 -0
- package/dist/themes/data/flexoki.d.ts +3 -0
- package/dist/themes/data/flexoki.js +177 -0
- package/dist/themes/data/gruvbox.d.ts +3 -0
- package/dist/themes/data/gruvbox.js +177 -0
- package/dist/themes/data/index.d.ts +35 -0
- package/dist/themes/data/index.js +64 -0
- package/dist/themes/data/monokai.d.ts +3 -0
- package/dist/themes/data/monokai.js +177 -0
- package/dist/themes/data/nord.d.ts +3 -0
- package/dist/themes/data/nord.js +177 -0
- package/dist/themes/data/rose-pine-dawn.d.ts +3 -0
- package/dist/themes/data/rose-pine-dawn.js +177 -0
- package/dist/themes/data/rose-pine-moon.d.ts +3 -0
- package/dist/themes/data/rose-pine-moon.js +177 -0
- package/dist/themes/data/rose-pine.d.ts +3 -0
- package/dist/themes/data/rose-pine.js +177 -0
- package/dist/themes/data/solarized-dark.d.ts +3 -0
- package/dist/themes/data/solarized-dark.js +177 -0
- package/dist/themes/data/solarized-light.d.ts +3 -0
- package/dist/themes/data/solarized-light.js +177 -0
- package/dist/themes/data/svg-export.d.ts +3 -0
- package/dist/themes/data/svg-export.js +177 -0
- package/dist/themes/data/textual-ansi.d.ts +3 -0
- package/dist/themes/data/textual-ansi.js +160 -0
- package/dist/themes/data/textual-dark.d.ts +3 -0
- package/dist/themes/data/textual-dark.js +160 -0
- package/dist/themes/data/textual-light.d.ts +3 -0
- package/dist/themes/data/textual-light.js +160 -0
- package/dist/themes/data/tokyo-night.d.ts +3 -0
- package/dist/themes/data/tokyo-night.js +177 -0
- package/dist/themes/data/types.d.ts +31 -0
- package/dist/themes/data/types.js +10 -0
- package/dist/themes/palette.d.ts +21 -0
- package/dist/themes/palette.js +28 -0
- package/dist/themes/ramp.d.ts +83 -0
- package/dist/themes/ramp.js +122 -0
- package/dist/themes/registry.d.ts +44 -0
- package/dist/themes/registry.js +94 -0
- package/dist/themes/terminalThemes.d.ts +49 -0
- package/dist/themes/terminalThemes.js +63 -0
- package/dist/themes/transpose.d.ts +87 -0
- package/dist/themes/transpose.js +138 -0
- package/dist/widgets/button.d.ts +49 -0
- package/dist/widgets/button.js +208 -0
- package/dist/widgets/checkbox.d.ts +41 -0
- package/dist/widgets/checkbox.js +157 -0
- package/dist/widgets/dropdown.d.ts +67 -0
- package/dist/widgets/dropdown.js +450 -0
- package/dist/widgets/event-router.d.ts +71 -0
- package/dist/widgets/event-router.js +629 -0
- package/dist/widgets/focus-manager.d.ts +45 -0
- package/dist/widgets/focus-manager.js +191 -0
- package/dist/widgets/hit.d.ts +64 -0
- package/dist/widgets/hit.js +113 -0
- package/dist/widgets/index.d.ts +20 -0
- package/dist/widgets/index.js +14 -0
- package/dist/widgets/slider.d.ts +57 -0
- package/dist/widgets/slider.js +270 -0
- package/dist/widgets/static-item.d.ts +34 -0
- package/dist/widgets/static-item.js +54 -0
- package/dist/widgets/text-input.d.ts +274 -0
- package/dist/widgets/text-input.js +1165 -0
- package/dist/widgets/toggle.d.ts +44 -0
- package/dist/widgets/toggle.js +180 -0
- package/dist/widgets/types.d.ts +87 -0
- package/dist/widgets/types.js +30 -0
- package/dist/widgets/widget-app.d.ts +63 -0
- package/dist/widgets/widget-app.js +199 -0
- package/dist/widgets/widget-base.d.ts +40 -0
- package/dist/widgets/widget-base.js +165 -0
- package/package.json +6 -2
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
const theme = {
|
|
2
|
+
name: "tokyo-night",
|
|
3
|
+
dark: true,
|
|
4
|
+
// iTerm2-Color-Schemes "TokyoNight Night"
|
|
5
|
+
ansi: {
|
|
6
|
+
black: "#15161E",
|
|
7
|
+
red: "#F7768E",
|
|
8
|
+
green: "#9ECE6A",
|
|
9
|
+
yellow: "#E0AF68",
|
|
10
|
+
blue: "#7AA2F7",
|
|
11
|
+
magenta: "#BB9AF7",
|
|
12
|
+
cyan: "#7DCFFF",
|
|
13
|
+
white: "#A9B1D6",
|
|
14
|
+
brightBlack: "#414868",
|
|
15
|
+
brightRed: "#F7768E",
|
|
16
|
+
brightGreen: "#9ECE6A",
|
|
17
|
+
brightYellow: "#E0AF68",
|
|
18
|
+
brightBlue: "#7AA2F7",
|
|
19
|
+
brightMagenta: "#BB9AF7",
|
|
20
|
+
brightCyan: "#7DCFFF",
|
|
21
|
+
brightWhite: "#C0CAF5",
|
|
22
|
+
},
|
|
23
|
+
vars: {
|
|
24
|
+
"accent": "#FE9E64",
|
|
25
|
+
"accent-darken-1": "#E78A51",
|
|
26
|
+
"accent-darken-2": "#D0763E",
|
|
27
|
+
"accent-darken-3": "#BA632C",
|
|
28
|
+
"accent-lighten-1": "#FFB277",
|
|
29
|
+
"accent-lighten-2": "#FFC78A",
|
|
30
|
+
"accent-lighten-3": "#FFDC9E",
|
|
31
|
+
"accent-muted": "#5E4238",
|
|
32
|
+
"background": "#1A1B26",
|
|
33
|
+
"background-darken-1": "#070817",
|
|
34
|
+
"background-darken-2": "#000000",
|
|
35
|
+
"background-darken-3": "#000000",
|
|
36
|
+
"background-lighten-1": "#292A36",
|
|
37
|
+
"background-lighten-2": "#3A3A47",
|
|
38
|
+
"background-lighten-3": "#4B4B58",
|
|
39
|
+
"block-cursor-background": "#BB9AF7",
|
|
40
|
+
"block-cursor-blurred-background": "#BB9AF74C",
|
|
41
|
+
"block-cursor-blurred-foreground": "#A9B1D6",
|
|
42
|
+
"block-cursor-foreground": "#FFFFFFDD",
|
|
43
|
+
"block-hover-background": "#FFFFFF19",
|
|
44
|
+
"boost": "#FFFFFF0A",
|
|
45
|
+
"boost-darken-1": "#E9E9E90A",
|
|
46
|
+
"boost-darken-2": "#D4D4D40A",
|
|
47
|
+
"boost-darken-3": "#BFBFBF0A",
|
|
48
|
+
"boost-lighten-1": "#FFFFFF0A",
|
|
49
|
+
"boost-lighten-2": "#FFFFFF0A",
|
|
50
|
+
"boost-lighten-3": "#FFFFFF0A",
|
|
51
|
+
"border": "#BB9AF7",
|
|
52
|
+
"border-blurred": "#1E2235",
|
|
53
|
+
"button-color-foreground": "#24283B",
|
|
54
|
+
"button-foreground": "#A9B1D6",
|
|
55
|
+
"error": "#F6768E",
|
|
56
|
+
"error-darken-1": "#E0617A",
|
|
57
|
+
"error-darken-2": "#C94D68",
|
|
58
|
+
"error-darken-3": "#B33856",
|
|
59
|
+
"error-lighten-1": "#FF8AA1",
|
|
60
|
+
"error-lighten-2": "#FF9FB5",
|
|
61
|
+
"error-lighten-3": "#FFB4CA",
|
|
62
|
+
"error-muted": "#5C3645",
|
|
63
|
+
"footer-background": "#414868",
|
|
64
|
+
"footer-description-background": "#00000000",
|
|
65
|
+
"footer-description-foreground": "#A9B1D6",
|
|
66
|
+
"footer-foreground": "#A9B1D6",
|
|
67
|
+
"footer-item-background": "#00000000",
|
|
68
|
+
"footer-key-background": "#00000000",
|
|
69
|
+
"footer-key-foreground": "#FF9E64",
|
|
70
|
+
"foreground": "#A9B1D6",
|
|
71
|
+
"foreground-darken-1": "#949CC1",
|
|
72
|
+
"foreground-darken-2": "#8189AC",
|
|
73
|
+
"foreground-darken-3": "#6D7698",
|
|
74
|
+
"foreground-disabled": "#A9B1D660",
|
|
75
|
+
"foreground-lighten-1": "#BDC5EB",
|
|
76
|
+
"foreground-lighten-2": "#D2DAFF",
|
|
77
|
+
"foreground-lighten-3": "#E7EFFF",
|
|
78
|
+
"foreground-muted": "#A9B1D699",
|
|
79
|
+
"input-cursor-background": "#A9B1D6",
|
|
80
|
+
"input-cursor-foreground": "#1A1B26",
|
|
81
|
+
"input-selection-background": "#D0AEFF66",
|
|
82
|
+
"link-background": "#00000000",
|
|
83
|
+
"link-background-hover": "#BB9AF7",
|
|
84
|
+
"link-color": "#FFFFFFDD",
|
|
85
|
+
"link-color-hover": "#FFFFFFDD",
|
|
86
|
+
"markdown-h1-background": "#00000000",
|
|
87
|
+
"markdown-h1-color": "#BB9AF7",
|
|
88
|
+
"markdown-h2-background": "#00000000",
|
|
89
|
+
"markdown-h2-color": "#BB9AF7",
|
|
90
|
+
"markdown-h3-background": "#00000000",
|
|
91
|
+
"markdown-h3-color": "#BB9AF7",
|
|
92
|
+
"markdown-h4-background": "#00000000",
|
|
93
|
+
"markdown-h4-color": "#A9B1D6",
|
|
94
|
+
"markdown-h5-background": "#00000000",
|
|
95
|
+
"markdown-h5-color": "#A9B1D6",
|
|
96
|
+
"markdown-h6-background": "#00000000",
|
|
97
|
+
"markdown-h6-color": "#A9B1D699",
|
|
98
|
+
"panel": "#414868",
|
|
99
|
+
"panel-darken-1": "#2F3755",
|
|
100
|
+
"panel-darken-2": "#1E2744",
|
|
101
|
+
"panel-darken-3": "#0C1733",
|
|
102
|
+
"panel-lighten-1": "#53597A",
|
|
103
|
+
"panel-lighten-2": "#656B8E",
|
|
104
|
+
"panel-lighten-3": "#787EA1",
|
|
105
|
+
"primary": "#BB9AF7",
|
|
106
|
+
"primary-background": "#504D60",
|
|
107
|
+
"primary-background-darken-1": "#413D52",
|
|
108
|
+
"primary-background-darken-2": "#322E45",
|
|
109
|
+
"primary-background-darken-3": "#322E45",
|
|
110
|
+
"primary-background-lighten-1": "#605D6E",
|
|
111
|
+
"primary-background-lighten-2": "#6F6C7C",
|
|
112
|
+
"primary-background-lighten-3": "#7E7C8A",
|
|
113
|
+
"primary-darken-1": "#A686E1",
|
|
114
|
+
"primary-darken-2": "#9173CC",
|
|
115
|
+
"primary-darken-3": "#7D60B7",
|
|
116
|
+
"primary-lighten-1": "#D0AEFF",
|
|
117
|
+
"primary-lighten-2": "#E5C2FF",
|
|
118
|
+
"primary-lighten-3": "#FBD7FF",
|
|
119
|
+
"primary-muted": "#4A4164",
|
|
120
|
+
"scrollbar": "#4F4270",
|
|
121
|
+
"scrollbar-active": "#BB9AF7",
|
|
122
|
+
"scrollbar-background": "#070817",
|
|
123
|
+
"scrollbar-background-active": "#070817",
|
|
124
|
+
"scrollbar-background-hover": "#070817",
|
|
125
|
+
"scrollbar-corner-color": "#070817",
|
|
126
|
+
"scrollbar-hover": "#615187",
|
|
127
|
+
"secondary": "#7AA2F7",
|
|
128
|
+
"secondary-background": "#484E60",
|
|
129
|
+
"secondary-background-darken-1": "#383E52",
|
|
130
|
+
"secondary-background-darken-2": "#282F45",
|
|
131
|
+
"secondary-background-darken-3": "#282F45",
|
|
132
|
+
"secondary-background-lighten-1": "#585D6E",
|
|
133
|
+
"secondary-background-lighten-2": "#686D7C",
|
|
134
|
+
"secondary-background-lighten-3": "#787D8A",
|
|
135
|
+
"secondary-darken-1": "#648EE1",
|
|
136
|
+
"secondary-darken-2": "#4D7BCC",
|
|
137
|
+
"secondary-darken-3": "#3468B7",
|
|
138
|
+
"secondary-lighten-1": "#8FB6FF",
|
|
139
|
+
"secondary-lighten-2": "#A5CAFF",
|
|
140
|
+
"secondary-lighten-3": "#BBDFFF",
|
|
141
|
+
"secondary-muted": "#364364",
|
|
142
|
+
"success": "#9ECE6A",
|
|
143
|
+
"success-darken-1": "#89B956",
|
|
144
|
+
"success-darken-2": "#75A443",
|
|
145
|
+
"success-darken-3": "#619030",
|
|
146
|
+
"success-lighten-1": "#B2E37D",
|
|
147
|
+
"success-lighten-2": "#C8F891",
|
|
148
|
+
"success-lighten-3": "#DDFFA6",
|
|
149
|
+
"success-muted": "#41503A",
|
|
150
|
+
"surface": "#24283B",
|
|
151
|
+
"surface-active": "#313448",
|
|
152
|
+
"surface-darken-1": "#14182A",
|
|
153
|
+
"surface-darken-2": "#00031B",
|
|
154
|
+
"surface-darken-3": "#000009",
|
|
155
|
+
"surface-lighten-1": "#34384C",
|
|
156
|
+
"surface-lighten-2": "#45495E",
|
|
157
|
+
"surface-lighten-3": "#575A70",
|
|
158
|
+
"text": "#FFFFFFDD",
|
|
159
|
+
"text-accent": "#FFBE98",
|
|
160
|
+
"text-disabled": "#FFFFFF60",
|
|
161
|
+
"text-error": "#F9A4B4",
|
|
162
|
+
"text-muted": "#FFFFFF99",
|
|
163
|
+
"text-primary": "#D2BCF9",
|
|
164
|
+
"text-secondary": "#A7C1F9",
|
|
165
|
+
"text-success": "#BEDE9C",
|
|
166
|
+
"text-warning": "#EACA9B",
|
|
167
|
+
"warning": "#DFAF68",
|
|
168
|
+
"warning-darken-1": "#C99A55",
|
|
169
|
+
"warning-darken-2": "#B48742",
|
|
170
|
+
"warning-darken-3": "#9E7430",
|
|
171
|
+
"warning-lighten-1": "#F6C37B",
|
|
172
|
+
"warning-lighten-2": "#FFD88F",
|
|
173
|
+
"warning-lighten-3": "#FFEDA3",
|
|
174
|
+
"warning-muted": "#554739",
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
export default theme;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static shape of a theme palette as authored. Each `data/<name>.ts` file
|
|
3
|
+
* exports one of these as its default export. The barrel (`./index.ts`)
|
|
4
|
+
* collects them into a single typed map; the registry consumes that map.
|
|
5
|
+
*
|
|
6
|
+
* Distinct from `Palette` — this is the on-disk authoring format (hex
|
|
7
|
+
* strings); `Palette` is the runtime form (parsed ColorRgba values). The
|
|
8
|
+
* registry's `getThemePalette` is the single boundary that hydrates one
|
|
9
|
+
* into the other.
|
|
10
|
+
*/
|
|
11
|
+
export interface ThemePaletteData {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly dark: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The sixteen colours a terminal showing this theme draws `red`, `blue`,
|
|
16
|
+
* `bright_black` and the rest in. A theme without its own table would draw
|
|
17
|
+
* them in the VGA defaults (`blue` as #000080), which belong to no theme.
|
|
18
|
+
*/
|
|
19
|
+
readonly ansi: AnsiColorsData;
|
|
20
|
+
readonly vars: Readonly<Record<string, string>>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* ANSI colour numbers 0–15 in order: the eight normal colours, then their
|
|
24
|
+
* bright forms. Named rather than positional so a data file cannot shift a
|
|
25
|
+
* colour into its neighbour's slot by miscounting.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ANSI_SLOTS: readonly ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "brightBlack", "brightRed", "brightGreen", "brightYellow", "brightBlue", "brightMagenta", "brightCyan", "brightWhite"];
|
|
28
|
+
/** One `#RRGGBB` per ANSI colour number, keyed by `ANSI_SLOTS`. */
|
|
29
|
+
export type AnsiColorsData = {
|
|
30
|
+
readonly [K in (typeof ANSI_SLOTS)[number]]: string;
|
|
31
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ANSI colour numbers 0–15 in order: the eight normal colours, then their
|
|
3
|
+
* bright forms. Named rather than positional so a data file cannot shift a
|
|
4
|
+
* colour into its neighbour's slot by miscounting.
|
|
5
|
+
*/
|
|
6
|
+
export const ANSI_SLOTS = [
|
|
7
|
+
"black", "red", "green", "yellow", "blue", "magenta", "cyan", "white",
|
|
8
|
+
"brightBlack", "brightRed", "brightGreen", "brightYellow",
|
|
9
|
+
"brightBlue", "brightMagenta", "brightCyan", "brightWhite",
|
|
10
|
+
];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ColorRgba } from "../core/color.js";
|
|
2
|
+
/**
|
|
3
|
+
* A semantic palette: a named map from variable name → ColorRgba.
|
|
4
|
+
*
|
|
5
|
+
* Distinct from `ColorTable` (the integer-indexed quantization LUT used by
|
|
6
|
+
* the downgrade pipeline). Palettes carry aesthetic intent — `primary`,
|
|
7
|
+
* `accent`, `error`, etc. — and are the foundation of the theming system.
|
|
8
|
+
*
|
|
9
|
+
* Storage is uniformly ColorRgba; consumers that load from hex JSON
|
|
10
|
+
* parse to ColorRgba at load time. `get` is a bare lookup — turning an
|
|
11
|
+
* author-written *reference* (a name, or a `#RRGGBB` literal) into a colour
|
|
12
|
+
* is `resolveColorRef`'s job in `colorRef.ts`, so a Palette never has to
|
|
13
|
+
* know about the syntax callers write.
|
|
14
|
+
*/
|
|
15
|
+
export declare class Palette {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly dark: boolean;
|
|
18
|
+
readonly vars: ReadonlyMap<string, ColorRgba>;
|
|
19
|
+
constructor(name: string, dark: boolean, vars: ReadonlyMap<string, ColorRgba>);
|
|
20
|
+
get(key: string): ColorRgba | undefined;
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A semantic palette: a named map from variable name → ColorRgba.
|
|
3
|
+
*
|
|
4
|
+
* Distinct from `ColorTable` (the integer-indexed quantization LUT used by
|
|
5
|
+
* the downgrade pipeline). Palettes carry aesthetic intent — `primary`,
|
|
6
|
+
* `accent`, `error`, etc. — and are the foundation of the theming system.
|
|
7
|
+
*
|
|
8
|
+
* Storage is uniformly ColorRgba; consumers that load from hex JSON
|
|
9
|
+
* parse to ColorRgba at load time. `get` is a bare lookup — turning an
|
|
10
|
+
* author-written *reference* (a name, or a `#RRGGBB` literal) into a colour
|
|
11
|
+
* is `resolveColorRef`'s job in `colorRef.ts`, so a Palette never has to
|
|
12
|
+
* know about the syntax callers write.
|
|
13
|
+
*/
|
|
14
|
+
export class Palette {
|
|
15
|
+
name;
|
|
16
|
+
dark;
|
|
17
|
+
vars;
|
|
18
|
+
constructor(name, dark, vars) {
|
|
19
|
+
this.name = name;
|
|
20
|
+
this.dark = dark;
|
|
21
|
+
// Defensive copy: ReadonlyMap is a compile-time aliasing constraint, not a
|
|
22
|
+
// runtime one. Copying at the seam makes Palette genuinely immutable.
|
|
23
|
+
this.vars = new Map(vars);
|
|
24
|
+
}
|
|
25
|
+
get(key) {
|
|
26
|
+
return this.vars.get(key);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A color ramp: a number mapped onto a color through ordered stops.
|
|
3
|
+
*
|
|
4
|
+
* "What does 73 % spent look like" has no answer in a vocabulary of discrete
|
|
5
|
+
* adjustments (`darken`, `mix`, `contrastOn`): each takes colors and returns a
|
|
6
|
+
* color, and none takes a *measurement*. Without a ramp the answer gets
|
|
7
|
+
* computed outside the theme system — a script emits a hex, a template
|
|
8
|
+
* branches `if ge .pct 80 … else if ge .pct 50 …` — and that color decision
|
|
9
|
+
* can no longer transpose with the palette it was meant to belong to. A ramp
|
|
10
|
+
* is the one function whose input is a number, so the decision stays inside.
|
|
11
|
+
*
|
|
12
|
+
* A threshold cascade is a ramp too: the same stops with a `step` easing hold
|
|
13
|
+
* each color until the next position, which is exactly `≥ threshold → hotter`
|
|
14
|
+
* written as data. [LAW:one-type-per-behavior] One primitive; the easing is a
|
|
15
|
+
* value, so a gradient and a cascade differ by one word, not by which function
|
|
16
|
+
* was called.
|
|
17
|
+
*
|
|
18
|
+
* Interpolation is in OKLCH (`Oklch.mix`), so a `linear` ramp between two
|
|
19
|
+
* theme colors passes through perceptually even steps rather than the muddy
|
|
20
|
+
* midpoints of an sRGB blend.
|
|
21
|
+
*
|
|
22
|
+
* [LAW:one-way-deps] Imports `core/color` and `core/oklch` only; nothing here
|
|
23
|
+
* knows what a palette is. Resolving stop *names* is the template binding's
|
|
24
|
+
* job (`paletteFuncs`), which hands this module resolved colors.
|
|
25
|
+
*/
|
|
26
|
+
import type { ColorRgba } from "../core/color.js";
|
|
27
|
+
/** One stop: the color the ramp is exactly `color` at position `at`. */
|
|
28
|
+
export interface ColorStop {
|
|
29
|
+
readonly at: number;
|
|
30
|
+
readonly color: ColorRgba;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* How a value between two stops maps to progress along them. Each easing is
|
|
34
|
+
* a function on segment progress `t ∈ [0, 1)` — `linear` keeps it, `step`
|
|
35
|
+
* holds the left stop for the whole segment.
|
|
36
|
+
*
|
|
37
|
+
* [LAW:dataflow-not-control-flow] The easing is looked up by name and applied
|
|
38
|
+
* unconditionally; `at` runs the same code for a gradient and a cascade.
|
|
39
|
+
*/
|
|
40
|
+
export declare const RAMP_EASINGS: {
|
|
41
|
+
readonly linear: (t: number) => number;
|
|
42
|
+
readonly step: () => number;
|
|
43
|
+
};
|
|
44
|
+
export type RampEasing = keyof typeof RAMP_EASINGS;
|
|
45
|
+
export declare const RAMP_EASING_NAMES: readonly RampEasing[];
|
|
46
|
+
/**
|
|
47
|
+
* The gate a spelled easing crosses. [LAW:parse-dont-validate] — returns the
|
|
48
|
+
* narrowed name, so `ColorRamp` never re-checks. Unknown names throw naming
|
|
49
|
+
* every legal one. [LAW:no-silent-failure]
|
|
50
|
+
*/
|
|
51
|
+
export declare function parseRampEasing(name: string): RampEasing;
|
|
52
|
+
/**
|
|
53
|
+
* An immutable ramp over stops sorted by position.
|
|
54
|
+
*
|
|
55
|
+
* [LAW:single-enforcer] The constructor is the one place a ramp's shape is
|
|
56
|
+
* checked — at least one stop, every position finite, positions
|
|
57
|
+
* non-decreasing — matching the `ColorRgba`/`Oklch` pattern. Positions are
|
|
58
|
+
* required to arrive in order rather than being sorted here: a ramp whose
|
|
59
|
+
* stops are read from configuration (`warning at 80, error at 50`) is an
|
|
60
|
+
* authoring mistake, and sorting would quietly render a different ramp than
|
|
61
|
+
* the one written. [LAW:no-silent-failure]
|
|
62
|
+
*
|
|
63
|
+
* Two stops may share a position: that is a hard edge, the later color
|
|
64
|
+
* taking over at exactly that value (CSS gradients spell a hard stop the
|
|
65
|
+
* same way).
|
|
66
|
+
*/
|
|
67
|
+
export declare class ColorRamp {
|
|
68
|
+
readonly easing: RampEasing;
|
|
69
|
+
readonly stops: readonly ColorStop[];
|
|
70
|
+
constructor(easing: RampEasing, stops: readonly ColorStop[]);
|
|
71
|
+
/**
|
|
72
|
+
* The color at `value`. Below the first stop it is the first color; at or
|
|
73
|
+
* above the last stop it is the last; between two stops it is `easing`
|
|
74
|
+
* of the way from the lower to the upper, so a value exactly on a stop is
|
|
75
|
+
* that stop's color, byte for byte.
|
|
76
|
+
*
|
|
77
|
+
* The two endpoint returns are the exactness contract, not a shortcut:
|
|
78
|
+
* the sRGB → OKLCH → sRGB round-trip can land a channel one unit off, and a
|
|
79
|
+
* ramp that does not hit its own stops exactly would make a `step` ramp
|
|
80
|
+
* paint a color the author never wrote.
|
|
81
|
+
*/
|
|
82
|
+
at(value: number): ColorRgba;
|
|
83
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A color ramp: a number mapped onto a color through ordered stops.
|
|
3
|
+
*
|
|
4
|
+
* "What does 73 % spent look like" has no answer in a vocabulary of discrete
|
|
5
|
+
* adjustments (`darken`, `mix`, `contrastOn`): each takes colors and returns a
|
|
6
|
+
* color, and none takes a *measurement*. Without a ramp the answer gets
|
|
7
|
+
* computed outside the theme system — a script emits a hex, a template
|
|
8
|
+
* branches `if ge .pct 80 … else if ge .pct 50 …` — and that color decision
|
|
9
|
+
* can no longer transpose with the palette it was meant to belong to. A ramp
|
|
10
|
+
* is the one function whose input is a number, so the decision stays inside.
|
|
11
|
+
*
|
|
12
|
+
* A threshold cascade is a ramp too: the same stops with a `step` easing hold
|
|
13
|
+
* each color until the next position, which is exactly `≥ threshold → hotter`
|
|
14
|
+
* written as data. [LAW:one-type-per-behavior] One primitive; the easing is a
|
|
15
|
+
* value, so a gradient and a cascade differ by one word, not by which function
|
|
16
|
+
* was called.
|
|
17
|
+
*
|
|
18
|
+
* Interpolation is in OKLCH (`Oklch.mix`), so a `linear` ramp between two
|
|
19
|
+
* theme colors passes through perceptually even steps rather than the muddy
|
|
20
|
+
* midpoints of an sRGB blend.
|
|
21
|
+
*
|
|
22
|
+
* [LAW:one-way-deps] Imports `core/color` and `core/oklch` only; nothing here
|
|
23
|
+
* knows what a palette is. Resolving stop *names* is the template binding's
|
|
24
|
+
* job (`paletteFuncs`), which hands this module resolved colors.
|
|
25
|
+
*/
|
|
26
|
+
import { Oklch } from "../core/oklch.js";
|
|
27
|
+
/**
|
|
28
|
+
* How a value between two stops maps to progress along them. Each easing is
|
|
29
|
+
* a function on segment progress `t ∈ [0, 1)` — `linear` keeps it, `step`
|
|
30
|
+
* holds the left stop for the whole segment.
|
|
31
|
+
*
|
|
32
|
+
* [LAW:dataflow-not-control-flow] The easing is looked up by name and applied
|
|
33
|
+
* unconditionally; `at` runs the same code for a gradient and a cascade.
|
|
34
|
+
*/
|
|
35
|
+
export const RAMP_EASINGS = {
|
|
36
|
+
linear: (t) => t,
|
|
37
|
+
step: () => 0,
|
|
38
|
+
};
|
|
39
|
+
export const RAMP_EASING_NAMES = Object.keys(RAMP_EASINGS);
|
|
40
|
+
/**
|
|
41
|
+
* The gate a spelled easing crosses. [LAW:parse-dont-validate] — returns the
|
|
42
|
+
* narrowed name, so `ColorRamp` never re-checks. Unknown names throw naming
|
|
43
|
+
* every legal one. [LAW:no-silent-failure]
|
|
44
|
+
*/
|
|
45
|
+
export function parseRampEasing(name) {
|
|
46
|
+
if (!Object.hasOwn(RAMP_EASINGS, name)) {
|
|
47
|
+
throw new RangeError(`unknown ramp easing ${JSON.stringify(name)}; expected one of ` +
|
|
48
|
+
RAMP_EASING_NAMES.map((n) => JSON.stringify(n)).join(", "));
|
|
49
|
+
}
|
|
50
|
+
return name;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* An immutable ramp over stops sorted by position.
|
|
54
|
+
*
|
|
55
|
+
* [LAW:single-enforcer] The constructor is the one place a ramp's shape is
|
|
56
|
+
* checked — at least one stop, every position finite, positions
|
|
57
|
+
* non-decreasing — matching the `ColorRgba`/`Oklch` pattern. Positions are
|
|
58
|
+
* required to arrive in order rather than being sorted here: a ramp whose
|
|
59
|
+
* stops are read from configuration (`warning at 80, error at 50`) is an
|
|
60
|
+
* authoring mistake, and sorting would quietly render a different ramp than
|
|
61
|
+
* the one written. [LAW:no-silent-failure]
|
|
62
|
+
*
|
|
63
|
+
* Two stops may share a position: that is a hard edge, the later color
|
|
64
|
+
* taking over at exactly that value (CSS gradients spell a hard stop the
|
|
65
|
+
* same way).
|
|
66
|
+
*/
|
|
67
|
+
export class ColorRamp {
|
|
68
|
+
easing;
|
|
69
|
+
stops;
|
|
70
|
+
constructor(easing, stops) {
|
|
71
|
+
this.easing = easing;
|
|
72
|
+
this.stops = stops;
|
|
73
|
+
if (stops.length === 0) {
|
|
74
|
+
throw new RangeError("a ColorRamp needs at least one stop");
|
|
75
|
+
}
|
|
76
|
+
for (const [i, stop] of stops.entries()) {
|
|
77
|
+
if (!Number.isFinite(stop.at)) {
|
|
78
|
+
throw new RangeError(`ColorRamp stop ${i} has a non-finite position ${stop.at}`);
|
|
79
|
+
}
|
|
80
|
+
const prev = stops[i - 1];
|
|
81
|
+
if (prev !== undefined && stop.at < prev.at) {
|
|
82
|
+
throw new RangeError(`ColorRamp stops must be in ascending position order; ` +
|
|
83
|
+
`stop ${i} at ${stop.at} follows stop ${i - 1} at ${prev.at}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The color at `value`. Below the first stop it is the first color; at or
|
|
89
|
+
* above the last stop it is the last; between two stops it is `easing`
|
|
90
|
+
* of the way from the lower to the upper, so a value exactly on a stop is
|
|
91
|
+
* that stop's color, byte for byte.
|
|
92
|
+
*
|
|
93
|
+
* The two endpoint returns are the exactness contract, not a shortcut:
|
|
94
|
+
* the sRGB → OKLCH → sRGB round-trip can land a channel one unit off, and a
|
|
95
|
+
* ramp that does not hit its own stops exactly would make a `step` ramp
|
|
96
|
+
* paint a color the author never wrote.
|
|
97
|
+
*/
|
|
98
|
+
at(value) {
|
|
99
|
+
if (!Number.isFinite(value)) {
|
|
100
|
+
throw new RangeError(`ColorRamp.at needs a finite value, got ${value}`);
|
|
101
|
+
}
|
|
102
|
+
const stops = this.stops;
|
|
103
|
+
// The last stop at or below `value`; -1 when `value` is below them all.
|
|
104
|
+
let lower = -1;
|
|
105
|
+
while (lower + 1 < stops.length && stops[lower + 1].at <= value)
|
|
106
|
+
lower++;
|
|
107
|
+
if (lower < 0)
|
|
108
|
+
return stops[0].color;
|
|
109
|
+
const from = stops[lower];
|
|
110
|
+
if (lower === stops.length - 1)
|
|
111
|
+
return from.color;
|
|
112
|
+
// `to.at > value >= from.at` by construction of `lower`, so the segment
|
|
113
|
+
// has positive width and `t ∈ [0, 1)`.
|
|
114
|
+
const to = stops[lower + 1];
|
|
115
|
+
const t = RAMP_EASINGS[this.easing]((value - from.at) / (to.at - from.at));
|
|
116
|
+
if (t <= 0)
|
|
117
|
+
return from.color;
|
|
118
|
+
if (t >= 1)
|
|
119
|
+
return to.color;
|
|
120
|
+
return Oklch.fromRgba(from.color).mix(Oklch.fromRgba(to.color), t).toRgba();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ColorRgba, ColorTable } from "../core/color.js";
|
|
2
|
+
import { Palette } from "./palette.js";
|
|
3
|
+
import { type ThemeName } from "./data/index.js";
|
|
4
|
+
export type { ThemeName };
|
|
5
|
+
/**
|
|
6
|
+
* Returns the static list of available theme names. Pure and synchronous.
|
|
7
|
+
*/
|
|
8
|
+
export declare function listThemePalettes(): readonly ThemeName[];
|
|
9
|
+
/**
|
|
10
|
+
* Returns the Palette for `name`, or `null` if unknown.
|
|
11
|
+
*
|
|
12
|
+
* Synchronous: theme data is bundled at compile time via the data barrel,
|
|
13
|
+
* so no I/O happens here. The Palette itself (which requires hex-parsing
|
|
14
|
+
* ~150 vars into ColorRgba values) is constructed lazily on first request
|
|
15
|
+
* and cached — subsequent calls for the same name return the same instance.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getThemePalette(name: ThemeName): Palette;
|
|
18
|
+
export declare function getThemePalette(name: string): Palette | null;
|
|
19
|
+
/**
|
|
20
|
+
* The eight base colors every theme must declare, and its ANSI table. Returned by
|
|
21
|
+
* `getThemeBaseColors` for callers (notably `terminalThemes.ts`) that only
|
|
22
|
+
* need the substrate and would otherwise pay the cost of hydrating the
|
|
23
|
+
* full ~150-var palette and polluting the registry cache.
|
|
24
|
+
*/
|
|
25
|
+
export interface ThemeBaseColors {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly dark: boolean;
|
|
28
|
+
readonly bg: ColorRgba;
|
|
29
|
+
readonly fg: ColorRgba;
|
|
30
|
+
readonly primary: ColorRgba;
|
|
31
|
+
readonly secondary: ColorRgba;
|
|
32
|
+
readonly accent: ColorRgba;
|
|
33
|
+
readonly success: ColorRgba;
|
|
34
|
+
readonly warning: ColorRgba;
|
|
35
|
+
readonly error: ColorRgba;
|
|
36
|
+
readonly ansi: ColorTable;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Read just the eight base colors from a theme's data file. Cheap — parses
|
|
40
|
+
* 8 hex strings, allocates no Palette, touches no cache. Use this when you
|
|
41
|
+
* want a `TerminalTheme`-shaped substrate without forcing the full ~150-var
|
|
42
|
+
* palette through the registry's hydration path.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getThemeBaseColors(name: ThemeName): ThemeBaseColors;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ColorTable, parseRgbHex, parseRgbaHex } from "../core/color.js";
|
|
2
|
+
import { Palette } from "./palette.js";
|
|
3
|
+
import { THEMES } from "./data/index.js";
|
|
4
|
+
import { ANSI_SLOTS } from "./data/types.js";
|
|
5
|
+
const THEME_NAMES = Object.freeze(Object.keys(THEMES).sort());
|
|
6
|
+
const cache = new Map();
|
|
7
|
+
/**
|
|
8
|
+
* Returns the static list of available theme names. Pure and synchronous.
|
|
9
|
+
*/
|
|
10
|
+
export function listThemePalettes() {
|
|
11
|
+
return THEME_NAMES;
|
|
12
|
+
}
|
|
13
|
+
export function getThemePalette(name) {
|
|
14
|
+
if (!isThemeName(name))
|
|
15
|
+
return null;
|
|
16
|
+
const cached = cache.get(name);
|
|
17
|
+
if (cached !== undefined)
|
|
18
|
+
return cached;
|
|
19
|
+
const palette = hydrate(THEMES[name]);
|
|
20
|
+
cache.set(name, palette);
|
|
21
|
+
return palette;
|
|
22
|
+
}
|
|
23
|
+
function isThemeName(name) {
|
|
24
|
+
return Object.hasOwn(THEMES, name);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Read just the eight base colors from a theme's data file. Cheap — parses
|
|
28
|
+
* 8 hex strings, allocates no Palette, touches no cache. Use this when you
|
|
29
|
+
* want a `TerminalTheme`-shaped substrate without forcing the full ~150-var
|
|
30
|
+
* palette through the registry's hydration path.
|
|
31
|
+
*/
|
|
32
|
+
export function getThemeBaseColors(name) {
|
|
33
|
+
const data = THEMES[name];
|
|
34
|
+
return {
|
|
35
|
+
name: data.name,
|
|
36
|
+
dark: data.dark,
|
|
37
|
+
bg: requireBaseVar(data, "background"),
|
|
38
|
+
fg: requireBaseVar(data, "foreground"),
|
|
39
|
+
primary: requireBaseVar(data, "primary"),
|
|
40
|
+
secondary: requireBaseVar(data, "secondary"),
|
|
41
|
+
accent: requireBaseVar(data, "accent"),
|
|
42
|
+
success: requireBaseVar(data, "success"),
|
|
43
|
+
warning: requireBaseVar(data, "warning"),
|
|
44
|
+
error: requireBaseVar(data, "error"),
|
|
45
|
+
ansi: new ColorTable(ANSI_SLOTS.map((slot) => parseOpaqueHex(data.ansi[slot], data.name, `ansi.${slot}`))),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function requireBaseVar(data, key) {
|
|
49
|
+
const v = data.vars[key];
|
|
50
|
+
if (v === undefined) {
|
|
51
|
+
throw new Error(`Theme ${data.name}: required base var "${key}" missing from data file`);
|
|
52
|
+
}
|
|
53
|
+
return parseHex(v, data.name, key);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Parse a `ThemePaletteData`'s hex strings into a Palette of ColorRgba.
|
|
57
|
+
*
|
|
58
|
+
* [LAW:single-enforcer] Hex → ColorRgba conversion for theme data lives
|
|
59
|
+
* here, not on Palette. Keeping the parser in this module preserves the
|
|
60
|
+
* `core/color → themes/palette` one-way edge (palette.ts must not import
|
|
61
|
+
* ColorRgba as a value, or it cycles with core/color's own use of Palette
|
|
62
|
+
* for INTERNAL_DEFAULT_THEME).
|
|
63
|
+
*/
|
|
64
|
+
function hydrate(data) {
|
|
65
|
+
const map = new Map();
|
|
66
|
+
for (const [k, v] of Object.entries(data.vars)) {
|
|
67
|
+
map.set(k, parseHex(v, data.name, k));
|
|
68
|
+
}
|
|
69
|
+
return new Palette(data.name, data.dark, map);
|
|
70
|
+
}
|
|
71
|
+
// [LAW:single-enforcer] This is the loud-failure boundary for theme hex
|
|
72
|
+
// data. `parseRgbHex`/`parseRgbaHex` in core/color.ts trust their input
|
|
73
|
+
// shape (they assume the caller validated); here we are the caller from
|
|
74
|
+
// the untrusted side (authored data files) and the place that has to
|
|
75
|
+
// reject `"0G"`, `""`, `"#GGGGGG"`, etc.
|
|
76
|
+
const HEX_RE = /^[0-9a-fA-F]+$/;
|
|
77
|
+
/**
|
|
78
|
+
* An ANSI slot is a colour a terminal paints, never a blend, so it takes no
|
|
79
|
+
* alpha: `flattenAlpha` leaves a STANDARD spec alone and would pass one through.
|
|
80
|
+
*/
|
|
81
|
+
function parseOpaqueHex(value, theme, key) {
|
|
82
|
+
if (!/^#[0-9A-Fa-f]{6}$/.test(value)) {
|
|
83
|
+
throw new Error(`Theme ${theme}: ${key} has invalid hex ${JSON.stringify(value)} (expected #RRGGBB)`);
|
|
84
|
+
}
|
|
85
|
+
return parseRgbHex(value.slice(1));
|
|
86
|
+
}
|
|
87
|
+
function parseHex(value, theme, key) {
|
|
88
|
+
const hex = value.startsWith("#") ? value.slice(1) : value;
|
|
89
|
+
if ((hex.length !== 6 && hex.length !== 8) || !HEX_RE.test(hex)) {
|
|
90
|
+
throw new Error(`Theme ${theme}: var ${key} has invalid hex ${JSON.stringify(value)} ` +
|
|
91
|
+
`(expected #RRGGBB or #RRGGBBAA)`);
|
|
92
|
+
}
|
|
93
|
+
return hex.length === 6 ? parseRgbHex(hex) : parseRgbaHex(hex);
|
|
94
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-built `TerminalTheme` constants — every theme in the registry has a
|
|
3
|
+
* matching `<NAME>` export here. There is no inline-only theme; the data
|
|
4
|
+
* file is the single source of truth for every theme's hex values.
|
|
5
|
+
*
|
|
6
|
+
* Editing `data/<name>.ts` updates both the registry's full ~150-var
|
|
7
|
+
* palette (via `getThemePalette(name)`) AND the matching `TerminalTheme`
|
|
8
|
+
* constant exported below (via `getThemeBaseColors(name)`, which pulls
|
|
9
|
+
* just the 8 substrate keys). The two views never drift because both
|
|
10
|
+
* derive from the same authored data.
|
|
11
|
+
*
|
|
12
|
+
* [LAW:one-source-of-truth] Hex values live in `data/<name>.ts`. This
|
|
13
|
+
* module is a derived view that builds a `TerminalTheme` from each
|
|
14
|
+
* theme's eight base colors via `buildPalette` for the substrate palette,
|
|
15
|
+
* and from the theme's own ANSI table for the sixteen named colours.
|
|
16
|
+
*
|
|
17
|
+
* [LAW:one-type-per-behavior] Every theme has the same shape — name,
|
|
18
|
+
* `dark` flag, full Palette in the registry, `TerminalTheme` constant
|
|
19
|
+
* here. Consumers can pick any theme by name without branching on which
|
|
20
|
+
* APIs work for it.
|
|
21
|
+
*
|
|
22
|
+
* [LAW:one-way-deps] `core/color → themes/palette` remains the only edge
|
|
23
|
+
* into themes/. This file imports only sibling theme modules and core
|
|
24
|
+
* color primitives; nothing in `core/` imports back.
|
|
25
|
+
*/
|
|
26
|
+
import { TerminalTheme } from "../core/color.js";
|
|
27
|
+
export declare const DEFAULT_TERMINAL_THEME: TerminalTheme;
|
|
28
|
+
export declare const SVG_EXPORT_THEME: TerminalTheme;
|
|
29
|
+
export declare const MONOKAI: TerminalTheme;
|
|
30
|
+
export declare const NORD: TerminalTheme;
|
|
31
|
+
export declare const GRUVBOX: TerminalTheme;
|
|
32
|
+
export declare const DRACULA: TerminalTheme;
|
|
33
|
+
export declare const TOKYO_NIGHT: TerminalTheme;
|
|
34
|
+
export declare const FLEXOKI: TerminalTheme;
|
|
35
|
+
export declare const CYBERPUNK: TerminalTheme;
|
|
36
|
+
export declare const CATPPUCCIN_MOCHA: TerminalTheme;
|
|
37
|
+
export declare const CATPPUCCIN_LATTE: TerminalTheme;
|
|
38
|
+
export declare const CATPPUCCIN_FRAPPE: TerminalTheme;
|
|
39
|
+
export declare const CATPPUCCIN_MACCHIATO: TerminalTheme;
|
|
40
|
+
export declare const SOLARIZED_DARK: TerminalTheme;
|
|
41
|
+
export declare const SOLARIZED_LIGHT: TerminalTheme;
|
|
42
|
+
export declare const ROSE_PINE: TerminalTheme;
|
|
43
|
+
export declare const ROSE_PINE_MOON: TerminalTheme;
|
|
44
|
+
export declare const ROSE_PINE_DAWN: TerminalTheme;
|
|
45
|
+
export declare const ATOM_ONE_DARK: TerminalTheme;
|
|
46
|
+
export declare const ATOM_ONE_LIGHT: TerminalTheme;
|
|
47
|
+
export declare const TEXTUAL_DARK: TerminalTheme;
|
|
48
|
+
export declare const TEXTUAL_LIGHT: TerminalTheme;
|
|
49
|
+
export declare const TEXTUAL_ANSI: TerminalTheme;
|