@opencode-ai/theme 0.0.0-next-16416 → 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -0
- package/package.json +1 -42
- package/dist/tui/color.d.ts +0 -8
- package/dist/tui/color.js +0 -67
- package/dist/tui/defaults.d.ts +0 -552
- package/dist/tui/defaults.js +0 -437
- package/dist/tui/expand.d.ts +0 -4
- package/dist/tui/expand.js +0 -87
- package/dist/tui/fallback.d.ts +0 -2
- package/dist/tui/fallback.js +0 -54
- package/dist/tui/index.d.ts +0 -7
- package/dist/tui/index.js +0 -6
- package/dist/tui/resolve.d.ts +0 -5
- package/dist/tui/resolve.js +0 -214
- package/dist/tui/schema.d.ts +0 -5552
- package/dist/tui/schema.js +0 -182
- package/dist/tui/select.d.ts +0 -13
- package/dist/tui/select.js +0 -36
- package/dist/tui/syntax.d.ts +0 -3
- package/dist/tui/syntax.js +0 -75
- package/dist/tui/types.d.ts +0 -77
- package/dist/tui/types.js +0 -1
- package/dist/tui/v1-migrate.d.ts +0 -3
- package/dist/tui/v1-migrate.js +0 -429
- package/dist/tui/v1.d.ts +0 -74
- package/dist/tui/v1.js +0 -1
package/dist/tui/v1-migrate.js
DELETED
|
@@ -1,429 +0,0 @@
|
|
|
1
|
-
import { RGBA } from "@opentui/core";
|
|
2
|
-
import { oklchToHex, rgbToOklch } from "./color.js";
|
|
3
|
-
import { DEFAULT_CATEGORICAL, DEFAULT_THEME } from "./defaults.js";
|
|
4
|
-
import { HueStep } from "./schema.js";
|
|
5
|
-
const chromaticHues = ["red", "orange", "yellow", "green", "cyan", "blue", "purple"];
|
|
6
|
-
const categoricalTokens = ["secondary", "accent", "success", "warning", "primary", "error"];
|
|
7
|
-
const minimumChroma = 0.03;
|
|
8
|
-
const lightThreshold = 0.6;
|
|
9
|
-
export function migrateV1(theme) {
|
|
10
|
-
const light = resolveV1(theme, "light");
|
|
11
|
-
const dark = resolveV1(theme, "dark");
|
|
12
|
-
if (light.background.a > 0 && dark.background.a > 0 && light.background.equals(dark.background)) {
|
|
13
|
-
const lightMode = detectMode(light);
|
|
14
|
-
const darkMode = detectMode(dark);
|
|
15
|
-
if (lightMode === darkMode) {
|
|
16
|
-
if (lightMode === "light")
|
|
17
|
-
return { version: 2, standalone: true, light: migrateMode(light, "light") };
|
|
18
|
-
return { version: 2, standalone: true, dark: migrateMode(dark, "dark") };
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
version: 2,
|
|
23
|
-
standalone: true,
|
|
24
|
-
light: migrateMode(light, "light"),
|
|
25
|
-
dark: migrateMode(dark, "dark"),
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function detectMode(theme) {
|
|
29
|
-
return luminance(theme.text) > luminance(theme.background) ? "dark" : "light";
|
|
30
|
-
}
|
|
31
|
-
function luminance(color) {
|
|
32
|
-
return 0.299 * color.r + 0.587 * color.g + 0.114 * color.b;
|
|
33
|
-
}
|
|
34
|
-
function migrateMode(theme, mode) {
|
|
35
|
-
const color = (key) => hex(theme[key]);
|
|
36
|
-
const selected = hex(selectedForeground(theme, theme.primary));
|
|
37
|
-
const destructive = hex(selectedForeground(theme, theme.error));
|
|
38
|
-
const hues = inferHues(theme, mode);
|
|
39
|
-
const categorical = categoricalTokens.flatMap((token) => {
|
|
40
|
-
const hue = hues.byToken[token];
|
|
41
|
-
return hue ? [hue] : [];
|
|
42
|
-
});
|
|
43
|
-
const uniqueCategorical = categorical.filter((hue, index) => categorical.indexOf(hue) === index);
|
|
44
|
-
const text = mode === "light" ? "$hue.neutral.800" : "$hue.neutral.200";
|
|
45
|
-
const textMuted = mode === "light" ? "$hue.neutral.600" : "$hue.neutral.400";
|
|
46
|
-
const primary = mode === "light" ? "$hue.interactive.800" : "$hue.interactive.200";
|
|
47
|
-
const background = mode === "light" ? "$hue.neutral.200" : "$hue.neutral.800";
|
|
48
|
-
const backgroundPanel = mode === "light" ? "$hue.neutral.300" : "$hue.neutral.700";
|
|
49
|
-
const backgroundMenu = mode === "light" ? "$hue.neutral.400" : "$hue.neutral.600";
|
|
50
|
-
return referenceHues({
|
|
51
|
-
hue: {
|
|
52
|
-
gray: neutralScale(theme, mode),
|
|
53
|
-
...Object.fromEntries(chromaticHues.map((name) => {
|
|
54
|
-
const match = hues.byHue[name];
|
|
55
|
-
return [name, match ? hueScale(match.color, mode) : "$hue.gray"];
|
|
56
|
-
})),
|
|
57
|
-
accent: hues.byToken.accent ? `$hue.${hues.byToken.accent}` : "$hue.gray",
|
|
58
|
-
interactive: hues.byToken.primary ? `$hue.${hues.byToken.primary}` : "$hue.gray",
|
|
59
|
-
neutral: "$hue.gray",
|
|
60
|
-
},
|
|
61
|
-
categorical: uniqueCategorical.length ? uniqueCategorical : DEFAULT_CATEGORICAL,
|
|
62
|
-
text: {
|
|
63
|
-
default: text,
|
|
64
|
-
subdued: textMuted,
|
|
65
|
-
action: {
|
|
66
|
-
primary: {
|
|
67
|
-
default: "$text.default",
|
|
68
|
-
$disabled: textMuted,
|
|
69
|
-
$focused: selected,
|
|
70
|
-
$selected: primary,
|
|
71
|
-
},
|
|
72
|
-
destructive: { default: destructive, $disabled: textMuted },
|
|
73
|
-
},
|
|
74
|
-
formfield: {
|
|
75
|
-
default: text,
|
|
76
|
-
$hovered: primary,
|
|
77
|
-
$focused: primary,
|
|
78
|
-
$pressed: primary,
|
|
79
|
-
$disabled: textMuted,
|
|
80
|
-
$selected: primary,
|
|
81
|
-
},
|
|
82
|
-
feedback: {
|
|
83
|
-
error: { default: color("error") },
|
|
84
|
-
warning: { default: color("warning") },
|
|
85
|
-
success: { default: color("success") },
|
|
86
|
-
info: { default: color("info") },
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
background: {
|
|
90
|
-
default: background,
|
|
91
|
-
surface: {
|
|
92
|
-
offset: backgroundPanel,
|
|
93
|
-
overlay: backgroundMenu,
|
|
94
|
-
},
|
|
95
|
-
action: {
|
|
96
|
-
primary: { default: "transparent", $hovered: backgroundPanel, $focused: primary, $selected: "transparent" },
|
|
97
|
-
destructive: { default: color("error") },
|
|
98
|
-
},
|
|
99
|
-
formfield: {
|
|
100
|
-
default: "$background.default",
|
|
101
|
-
},
|
|
102
|
-
feedback: {
|
|
103
|
-
error: { default: "$background.default" },
|
|
104
|
-
warning: { default: "$background.default" },
|
|
105
|
-
success: { default: "$background.default" },
|
|
106
|
-
info: { default: "$background.default" },
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
border: { default: color("border") },
|
|
110
|
-
scrollbar: { default: color("borderActive") },
|
|
111
|
-
diff: {
|
|
112
|
-
text: {
|
|
113
|
-
added: color("diffAdded"),
|
|
114
|
-
removed: color("diffRemoved"),
|
|
115
|
-
context: color("diffContext"),
|
|
116
|
-
hunkHeader: color("diffHunkHeader"),
|
|
117
|
-
},
|
|
118
|
-
background: {
|
|
119
|
-
added: color("diffAddedBg"),
|
|
120
|
-
removed: color("diffRemovedBg"),
|
|
121
|
-
context: color("diffContextBg"),
|
|
122
|
-
},
|
|
123
|
-
highlight: { added: color("diffHighlightAdded"), removed: color("diffHighlightRemoved") },
|
|
124
|
-
lineNumber: {
|
|
125
|
-
text: color("diffLineNumber"),
|
|
126
|
-
background: {
|
|
127
|
-
added: color("diffAddedLineNumberBg"),
|
|
128
|
-
removed: color("diffRemovedLineNumberBg"),
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
syntax: {
|
|
133
|
-
comment: color("syntaxComment"),
|
|
134
|
-
keyword: color("syntaxKeyword"),
|
|
135
|
-
function: color("syntaxFunction"),
|
|
136
|
-
variable: color("syntaxVariable"),
|
|
137
|
-
string: color("syntaxString"),
|
|
138
|
-
number: color("syntaxNumber"),
|
|
139
|
-
type: color("syntaxType"),
|
|
140
|
-
operator: color("syntaxOperator"),
|
|
141
|
-
punctuation: color("syntaxPunctuation"),
|
|
142
|
-
},
|
|
143
|
-
markdown: {
|
|
144
|
-
text: color("markdownText"),
|
|
145
|
-
heading: color("markdownHeading"),
|
|
146
|
-
link: color("markdownLink"),
|
|
147
|
-
linkText: color("markdownLinkText"),
|
|
148
|
-
code: color("markdownCode"),
|
|
149
|
-
blockQuote: color("markdownBlockQuote"),
|
|
150
|
-
emphasis: color("markdownEmph"),
|
|
151
|
-
strong: color("markdownStrong"),
|
|
152
|
-
horizontalRule: color("markdownHorizontalRule"),
|
|
153
|
-
listItem: color("markdownListItem"),
|
|
154
|
-
listEnumeration: color("markdownListEnumeration"),
|
|
155
|
-
image: color("markdownImage"),
|
|
156
|
-
imageText: color("markdownImageText"),
|
|
157
|
-
codeBlock: color("markdownCodeBlock"),
|
|
158
|
-
},
|
|
159
|
-
"@context:elevated": {
|
|
160
|
-
background: {
|
|
161
|
-
default: "$background.surface.offset",
|
|
162
|
-
action: { primary: { $hovered: "$background.surface.overlay" } },
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
"@context:overlay": { background: { default: "$background.surface.overlay" } },
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
function referenceHues(theme) {
|
|
169
|
-
const definitions = theme.hue;
|
|
170
|
-
if (!definitions)
|
|
171
|
-
return theme;
|
|
172
|
-
const scales = new Map();
|
|
173
|
-
function resolve(name, chain = []) {
|
|
174
|
-
const cached = scales.get(name);
|
|
175
|
-
if (cached)
|
|
176
|
-
return cached;
|
|
177
|
-
if (chain.includes(name))
|
|
178
|
-
return;
|
|
179
|
-
const value = definitions?.[name];
|
|
180
|
-
if (!value)
|
|
181
|
-
return;
|
|
182
|
-
if (typeof value !== "string") {
|
|
183
|
-
scales.set(name, value);
|
|
184
|
-
return value;
|
|
185
|
-
}
|
|
186
|
-
const target = /^\$hue\.([^.]+)$/.exec(value)?.[1];
|
|
187
|
-
if (!target)
|
|
188
|
-
return;
|
|
189
|
-
const scale = resolve(target, [...chain, name]);
|
|
190
|
-
if (scale)
|
|
191
|
-
scales.set(name, scale);
|
|
192
|
-
return scale;
|
|
193
|
-
}
|
|
194
|
-
const references = new Map();
|
|
195
|
-
const index = (name, overwrite) => {
|
|
196
|
-
const scale = resolve(name);
|
|
197
|
-
if (!scale)
|
|
198
|
-
return;
|
|
199
|
-
HueStep.literals.forEach((step) => {
|
|
200
|
-
const color = scale[step];
|
|
201
|
-
if (!color || (!overwrite && references.has(color.toLowerCase())))
|
|
202
|
-
return;
|
|
203
|
-
references.set(color.toLowerCase(), `$hue.${name}.${step}`);
|
|
204
|
-
});
|
|
205
|
-
};
|
|
206
|
-
chromaticHues.forEach((name) => index(name, false));
|
|
207
|
-
index("gray", false);
|
|
208
|
-
index("accent", true);
|
|
209
|
-
index("interactive", true);
|
|
210
|
-
index("neutral", true);
|
|
211
|
-
function replace(value) {
|
|
212
|
-
if (typeof value === "string")
|
|
213
|
-
return references.get(value.toLowerCase()) ?? value;
|
|
214
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
215
|
-
return value;
|
|
216
|
-
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, replace(item)]));
|
|
217
|
-
}
|
|
218
|
-
return Object.fromEntries(Object.entries(theme).map(([key, value]) => [key, key === "hue" || key === "categorical" ? value : replace(value)]));
|
|
219
|
-
}
|
|
220
|
-
function inferHues(theme, mode) {
|
|
221
|
-
const colors = [
|
|
222
|
-
["accent", theme.accent],
|
|
223
|
-
["success", theme.success],
|
|
224
|
-
["warning", theme.warning],
|
|
225
|
-
["primary", theme.primary],
|
|
226
|
-
["error", theme.error],
|
|
227
|
-
["info", theme.info],
|
|
228
|
-
["secondary", theme.secondary],
|
|
229
|
-
];
|
|
230
|
-
const inferred = colors.reduce((result, [token, color]) => {
|
|
231
|
-
const nearest = inferHue(color, mode);
|
|
232
|
-
if (!nearest)
|
|
233
|
-
return result;
|
|
234
|
-
const current = result.byHue[nearest.name];
|
|
235
|
-
return {
|
|
236
|
-
byHue: current && current.distance <= nearest.distance
|
|
237
|
-
? result.byHue
|
|
238
|
-
: { ...result.byHue, [nearest.name]: { color, distance: nearest.distance } },
|
|
239
|
-
byToken: { ...result.byToken, [token]: nearest.name },
|
|
240
|
-
};
|
|
241
|
-
}, { byHue: {}, byToken: {} });
|
|
242
|
-
return [
|
|
243
|
-
["accent", theme.accent],
|
|
244
|
-
["primary", theme.primary],
|
|
245
|
-
].reduce((result, [token, color]) => {
|
|
246
|
-
const nearest = inferHue(color, mode);
|
|
247
|
-
if (!nearest)
|
|
248
|
-
return result;
|
|
249
|
-
return {
|
|
250
|
-
byHue: { ...result.byHue, [nearest.name]: { color, distance: nearest.distance } },
|
|
251
|
-
byToken: { ...result.byToken, [token]: nearest.name },
|
|
252
|
-
};
|
|
253
|
-
}, inferred);
|
|
254
|
-
}
|
|
255
|
-
function inferHue(color, mode) {
|
|
256
|
-
const value = toOklch(color);
|
|
257
|
-
if (ambiguous(color, value.c))
|
|
258
|
-
return;
|
|
259
|
-
const anchor = inferenceAnchor(value.l);
|
|
260
|
-
return chromaticHues
|
|
261
|
-
.map((name) => ({
|
|
262
|
-
name,
|
|
263
|
-
distance: hueDistance(value.h, toOklch(RGBA.fromHex(DEFAULT_THEME[mode].hue[name][anchor])).h),
|
|
264
|
-
}))
|
|
265
|
-
.sort((first, second) => first.distance - second.distance)[0];
|
|
266
|
-
}
|
|
267
|
-
function inferenceAnchor(lightness) {
|
|
268
|
-
return lightness >= lightThreshold ? 300 : 700;
|
|
269
|
-
}
|
|
270
|
-
function hueDistance(first, second) {
|
|
271
|
-
const difference = Math.abs(first - second);
|
|
272
|
-
return Math.min(difference, 360 - difference);
|
|
273
|
-
}
|
|
274
|
-
function ambiguous(color, chroma = toOklch(color).c) {
|
|
275
|
-
return color.toInts()[3] === 0 || chroma < minimumChroma;
|
|
276
|
-
}
|
|
277
|
-
function resolveV1(theme, mode) {
|
|
278
|
-
const defs = theme.defs ?? {};
|
|
279
|
-
function resolveColor(value, chain = []) {
|
|
280
|
-
if (value instanceof RGBA)
|
|
281
|
-
return value;
|
|
282
|
-
if (typeof value === "string") {
|
|
283
|
-
if (value === "transparent" || value === "none")
|
|
284
|
-
return RGBA.fromInts(0, 0, 0, 0);
|
|
285
|
-
if (value.startsWith("#"))
|
|
286
|
-
return RGBA.fromHex(value);
|
|
287
|
-
if (chain.includes(value))
|
|
288
|
-
throw new Error(`Circular color reference: ${[...chain, value].join(" -> ")}`);
|
|
289
|
-
const next = defs[value] ?? theme.theme[value];
|
|
290
|
-
if (next === undefined)
|
|
291
|
-
throw new Error(`Color reference "${value}" not found in defs or theme`);
|
|
292
|
-
return resolveColor(next, [...chain, value]);
|
|
293
|
-
}
|
|
294
|
-
if (typeof value === "number")
|
|
295
|
-
return ansi(value);
|
|
296
|
-
if (!value || typeof value !== "object" || !(mode in value))
|
|
297
|
-
throw new Error("Invalid V1 theme color");
|
|
298
|
-
return resolveColor(value[mode], chain);
|
|
299
|
-
}
|
|
300
|
-
const resolved = Object.fromEntries(Object.entries(theme.theme)
|
|
301
|
-
.filter(([key]) => key !== "selectedListItemText" && key !== "backgroundMenu" && key !== "thinkingOpacity")
|
|
302
|
-
.map(([key, value]) => [key, resolveColor(value)]));
|
|
303
|
-
const hasSelectedListItemText = theme.theme.selectedListItemText !== undefined;
|
|
304
|
-
resolved.selectedListItemText = hasSelectedListItemText
|
|
305
|
-
? resolveColor(theme.theme.selectedListItemText)
|
|
306
|
-
: resolved.background;
|
|
307
|
-
resolved.backgroundMenu = theme.theme.backgroundMenu
|
|
308
|
-
? resolveColor(theme.theme.backgroundMenu)
|
|
309
|
-
: resolved.backgroundElement;
|
|
310
|
-
return {
|
|
311
|
-
...resolved,
|
|
312
|
-
_hasSelectedListItemText: hasSelectedListItemText,
|
|
313
|
-
thinkingOpacity: theme.theme.thinkingOpacity ?? 0.6,
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
function selectedForeground(theme, background) {
|
|
317
|
-
if (theme._hasSelectedListItemText)
|
|
318
|
-
return theme.selectedListItemText;
|
|
319
|
-
if (theme.background.a !== 0)
|
|
320
|
-
return theme.background;
|
|
321
|
-
return 0.299 * background.r + 0.587 * background.g + 0.114 * background.b > 0.5
|
|
322
|
-
? RGBA.fromInts(0, 0, 0)
|
|
323
|
-
: RGBA.fromInts(255, 255, 255);
|
|
324
|
-
}
|
|
325
|
-
function hueScale(color, mode) {
|
|
326
|
-
const value = toOklch(color);
|
|
327
|
-
const anchor = mode === "light" ? 800 : 200;
|
|
328
|
-
const endpoint = mode === "light" ? Math.max(0.97, value.l) : Math.min(0.18, value.l);
|
|
329
|
-
const alpha = color.toInts()[3];
|
|
330
|
-
return Object.fromEntries(HueStep.literals.map((step) => {
|
|
331
|
-
if (step === anchor)
|
|
332
|
-
return [step, hex(color)];
|
|
333
|
-
const progress = mode === "light" ? (anchor - step) / (anchor - 100) : (step - anchor) / (900 - anchor);
|
|
334
|
-
const generated = oklchToHex({
|
|
335
|
-
l: value.l + (endpoint - value.l) * progress,
|
|
336
|
-
c: value.c * (1 - progress * 0.5),
|
|
337
|
-
h: value.h,
|
|
338
|
-
});
|
|
339
|
-
return [step, alpha === 255 ? generated : `${generated}${byte(alpha)}`];
|
|
340
|
-
}));
|
|
341
|
-
}
|
|
342
|
-
function neutralScale(theme, mode) {
|
|
343
|
-
const anchors = neutralAnchors(theme, mode);
|
|
344
|
-
return Object.fromEntries(HueStep.literals.map((step) => {
|
|
345
|
-
const exact = anchors.find((anchor) => anchor.step === step);
|
|
346
|
-
if (exact)
|
|
347
|
-
return [step, hex(exact.color)];
|
|
348
|
-
const first = anchors[0];
|
|
349
|
-
const last = anchors.at(-1);
|
|
350
|
-
const [lower, upper] = step < first.step
|
|
351
|
-
? [first, anchors[1]]
|
|
352
|
-
: step > last.step
|
|
353
|
-
? [anchors.at(-2), last]
|
|
354
|
-
: [anchors.filter((anchor) => anchor.step < step).at(-1), anchors.find((anchor) => anchor.step > step)];
|
|
355
|
-
return [step, interpolate(lower.color, upper.color, (step - lower.step) / (upper.step - lower.step))];
|
|
356
|
-
}));
|
|
357
|
-
}
|
|
358
|
-
function neutralAnchors(theme, mode) {
|
|
359
|
-
const light = [
|
|
360
|
-
{ step: 200, color: theme.background },
|
|
361
|
-
{ step: 300, color: theme.backgroundPanel },
|
|
362
|
-
{ step: 400, color: theme.backgroundElement || theme.backgroundMenu },
|
|
363
|
-
{ step: 600, color: theme.textMuted },
|
|
364
|
-
{ step: 800, color: theme.text },
|
|
365
|
-
];
|
|
366
|
-
if (mode === "light")
|
|
367
|
-
return light;
|
|
368
|
-
return light.toReversed().map((source) => ({ ...source, step: (1000 - source.step) }));
|
|
369
|
-
}
|
|
370
|
-
function interpolate(first, second, amount) {
|
|
371
|
-
const start = toOklch(first);
|
|
372
|
-
const end = toOklch(second);
|
|
373
|
-
const startHue = Number.isFinite(start.h) ? start.h : Number.isFinite(end.h) ? end.h : 0;
|
|
374
|
-
const endHue = Number.isFinite(end.h) ? end.h : startHue;
|
|
375
|
-
const hue = ((((endHue - startHue) % 360) + 540) % 360) - 180;
|
|
376
|
-
const generated = oklchToHex({
|
|
377
|
-
l: start.l + (end.l - start.l) * amount,
|
|
378
|
-
c: start.c + (end.c - start.c) * amount,
|
|
379
|
-
h: startHue + hue * amount,
|
|
380
|
-
});
|
|
381
|
-
const alpha = Math.max(0, Math.min(255, Math.round(first.toInts()[3] + (second.toInts()[3] - first.toInts()[3]) * amount)));
|
|
382
|
-
return alpha === 255 ? generated : `${generated}${byte(alpha)}`;
|
|
383
|
-
}
|
|
384
|
-
function toOklch(color) {
|
|
385
|
-
const [red, green, blue] = color.toInts();
|
|
386
|
-
return rgbToOklch(red / 255, green / 255, blue / 255);
|
|
387
|
-
}
|
|
388
|
-
function hex(color) {
|
|
389
|
-
return hexInts(...color.toInts());
|
|
390
|
-
}
|
|
391
|
-
function hexInts(r, g, b, a) {
|
|
392
|
-
return `#${byte(r)}${byte(g)}${byte(b)}${a === 255 ? "" : byte(a)}`;
|
|
393
|
-
}
|
|
394
|
-
function byte(value) {
|
|
395
|
-
return value.toString(16).padStart(2, "0");
|
|
396
|
-
}
|
|
397
|
-
function ansi(code) {
|
|
398
|
-
if (code < 16) {
|
|
399
|
-
const colors = [
|
|
400
|
-
"#000000",
|
|
401
|
-
"#800000",
|
|
402
|
-
"#008000",
|
|
403
|
-
"#808000",
|
|
404
|
-
"#000080",
|
|
405
|
-
"#800080",
|
|
406
|
-
"#008080",
|
|
407
|
-
"#c0c0c0",
|
|
408
|
-
"#808080",
|
|
409
|
-
"#ff0000",
|
|
410
|
-
"#00ff00",
|
|
411
|
-
"#ffff00",
|
|
412
|
-
"#0000ff",
|
|
413
|
-
"#ff00ff",
|
|
414
|
-
"#00ffff",
|
|
415
|
-
"#ffffff",
|
|
416
|
-
];
|
|
417
|
-
return RGBA.fromHex(colors[code] ?? "#000000");
|
|
418
|
-
}
|
|
419
|
-
if (code < 232) {
|
|
420
|
-
const index = code - 16;
|
|
421
|
-
const value = (part) => (part === 0 ? 0 : part * 40 + 55);
|
|
422
|
-
return RGBA.fromInts(value(Math.floor(index / 36)), value(Math.floor(index / 6) % 6), value(index % 6));
|
|
423
|
-
}
|
|
424
|
-
if (code < 256) {
|
|
425
|
-
const gray = (code - 232) * 10 + 8;
|
|
426
|
-
return RGBA.fromInts(gray, gray, gray);
|
|
427
|
-
}
|
|
428
|
-
return RGBA.fromInts(0, 0, 0);
|
|
429
|
-
}
|
package/dist/tui/v1.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { RGBA } from "@opentui/core";
|
|
2
|
-
export type Theme = {
|
|
3
|
-
readonly primary: RGBA;
|
|
4
|
-
readonly secondary: RGBA;
|
|
5
|
-
readonly accent: RGBA;
|
|
6
|
-
readonly error: RGBA;
|
|
7
|
-
readonly warning: RGBA;
|
|
8
|
-
readonly success: RGBA;
|
|
9
|
-
readonly info: RGBA;
|
|
10
|
-
readonly text: RGBA;
|
|
11
|
-
readonly textMuted: RGBA;
|
|
12
|
-
readonly selectedListItemText: RGBA;
|
|
13
|
-
readonly background: RGBA;
|
|
14
|
-
readonly backgroundPanel: RGBA;
|
|
15
|
-
readonly backgroundElement: RGBA;
|
|
16
|
-
readonly backgroundMenu: RGBA;
|
|
17
|
-
readonly border: RGBA;
|
|
18
|
-
readonly borderActive: RGBA;
|
|
19
|
-
readonly borderSubtle: RGBA;
|
|
20
|
-
readonly diffAdded: RGBA;
|
|
21
|
-
readonly diffRemoved: RGBA;
|
|
22
|
-
readonly diffContext: RGBA;
|
|
23
|
-
readonly diffHunkHeader: RGBA;
|
|
24
|
-
readonly diffHighlightAdded: RGBA;
|
|
25
|
-
readonly diffHighlightRemoved: RGBA;
|
|
26
|
-
readonly diffAddedBg: RGBA;
|
|
27
|
-
readonly diffRemovedBg: RGBA;
|
|
28
|
-
readonly diffContextBg: RGBA;
|
|
29
|
-
readonly diffLineNumber: RGBA;
|
|
30
|
-
readonly diffAddedLineNumberBg: RGBA;
|
|
31
|
-
readonly diffRemovedLineNumberBg: RGBA;
|
|
32
|
-
readonly markdownText: RGBA;
|
|
33
|
-
readonly markdownHeading: RGBA;
|
|
34
|
-
readonly markdownLink: RGBA;
|
|
35
|
-
readonly markdownLinkText: RGBA;
|
|
36
|
-
readonly markdownCode: RGBA;
|
|
37
|
-
readonly markdownBlockQuote: RGBA;
|
|
38
|
-
readonly markdownEmph: RGBA;
|
|
39
|
-
readonly markdownStrong: RGBA;
|
|
40
|
-
readonly markdownHorizontalRule: RGBA;
|
|
41
|
-
readonly markdownListItem: RGBA;
|
|
42
|
-
readonly markdownListEnumeration: RGBA;
|
|
43
|
-
readonly markdownImage: RGBA;
|
|
44
|
-
readonly markdownImageText: RGBA;
|
|
45
|
-
readonly markdownCodeBlock: RGBA;
|
|
46
|
-
readonly syntaxComment: RGBA;
|
|
47
|
-
readonly syntaxKeyword: RGBA;
|
|
48
|
-
readonly syntaxFunction: RGBA;
|
|
49
|
-
readonly syntaxVariable: RGBA;
|
|
50
|
-
readonly syntaxString: RGBA;
|
|
51
|
-
readonly syntaxNumber: RGBA;
|
|
52
|
-
readonly syntaxType: RGBA;
|
|
53
|
-
readonly syntaxOperator: RGBA;
|
|
54
|
-
readonly syntaxPunctuation: RGBA;
|
|
55
|
-
readonly thinkingOpacity: number;
|
|
56
|
-
_hasSelectedListItemText: boolean;
|
|
57
|
-
};
|
|
58
|
-
export type ThemeColor = Exclude<keyof Theme, "thinkingOpacity" | "_hasSelectedListItemText">;
|
|
59
|
-
export type HexColor = `#${string}`;
|
|
60
|
-
export type RefName = string;
|
|
61
|
-
export type Variant = {
|
|
62
|
-
dark: HexColor | RefName;
|
|
63
|
-
light: HexColor | RefName;
|
|
64
|
-
};
|
|
65
|
-
export type ColorValue = HexColor | RefName | Variant | RGBA | number;
|
|
66
|
-
export type ThemeV1Json = {
|
|
67
|
-
$schema?: string;
|
|
68
|
-
defs?: Record<string, HexColor | RefName>;
|
|
69
|
-
theme: Omit<Record<ThemeColor, ColorValue>, "selectedListItemText" | "backgroundMenu"> & {
|
|
70
|
-
selectedListItemText?: ColorValue;
|
|
71
|
-
backgroundMenu?: ColorValue;
|
|
72
|
-
thinkingOpacity?: number;
|
|
73
|
-
};
|
|
74
|
-
};
|
package/dist/tui/v1.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|