@hypercli/ui 0.1.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/LICENSE +21 -0
- package/README.md +11 -0
- package/dist/capabilities/index.d.ts +62 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +182 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/colors.d.ts +32 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +40 -0
- package/dist/colors.js.map +1 -0
- package/dist/components/columns.d.ts +28 -0
- package/dist/components/columns.d.ts.map +1 -0
- package/dist/components/columns.js +70 -0
- package/dist/components/columns.js.map +1 -0
- package/dist/components/confirmPrompt.d.ts +38 -0
- package/dist/components/confirmPrompt.d.ts.map +1 -0
- package/dist/components/confirmPrompt.js +109 -0
- package/dist/components/confirmPrompt.js.map +1 -0
- package/dist/components/diff.d.ts +37 -0
- package/dist/components/diff.d.ts.map +1 -0
- package/dist/components/diff.js +36 -0
- package/dist/components/diff.js.map +1 -0
- package/dist/components/helpLayout.d.ts +59 -0
- package/dist/components/helpLayout.d.ts.map +1 -0
- package/dist/components/helpLayout.js +103 -0
- package/dist/components/helpLayout.js.map +1 -0
- package/dist/components/index.d.ts +38 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +23 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/keyValue.d.ts +31 -0
- package/dist/components/keyValue.d.ts.map +1 -0
- package/dist/components/keyValue.js +36 -0
- package/dist/components/keyValue.js.map +1 -0
- package/dist/components/list.d.ts +30 -0
- package/dist/components/list.d.ts.map +1 -0
- package/dist/components/list.js +80 -0
- package/dist/components/list.js.map +1 -0
- package/dist/components/message.d.ts +33 -0
- package/dist/components/message.d.ts.map +1 -0
- package/dist/components/message.js +86 -0
- package/dist/components/message.js.map +1 -0
- package/dist/components/panel.d.ts +28 -0
- package/dist/components/panel.d.ts.map +1 -0
- package/dist/components/panel.js +30 -0
- package/dist/components/panel.js.map +1 -0
- package/dist/components/progressBar.d.ts +44 -0
- package/dist/components/progressBar.d.ts.map +1 -0
- package/dist/components/progressBar.js +154 -0
- package/dist/components/progressBar.js.map +1 -0
- package/dist/components/section.d.ts +22 -0
- package/dist/components/section.d.ts.map +1 -0
- package/dist/components/section.js +48 -0
- package/dist/components/section.js.map +1 -0
- package/dist/components/selectPrompt.d.ts +58 -0
- package/dist/components/selectPrompt.d.ts.map +1 -0
- package/dist/components/selectPrompt.js +206 -0
- package/dist/components/selectPrompt.js.map +1 -0
- package/dist/components/spinner.d.ts +38 -0
- package/dist/components/spinner.d.ts.map +1 -0
- package/dist/components/spinner.js +125 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/statusList.d.ts +22 -0
- package/dist/components/statusList.d.ts.map +1 -0
- package/dist/components/statusList.js +43 -0
- package/dist/components/statusList.js.map +1 -0
- package/dist/components/table.d.ts +39 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/table.js +132 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/textPrompt.d.ts +43 -0
- package/dist/components/textPrompt.d.ts.map +1 -0
- package/dist/components/textPrompt.js +123 -0
- package/dist/components/textPrompt.js.map +1 -0
- package/dist/components/tree.d.ts +30 -0
- package/dist/components/tree.d.ts.map +1 -0
- package/dist/components/tree.js +49 -0
- package/dist/components/tree.js.map +1 -0
- package/dist/ds-index.d.ts +113 -0
- package/dist/ds-index.d.ts.map +1 -0
- package/dist/ds-index.js +112 -0
- package/dist/ds-index.js.map +1 -0
- package/dist/help.d.ts +32 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +34 -0
- package/dist/help.js.map +1 -0
- package/dist/hyper-theme.d.ts +8 -0
- package/dist/hyper-theme.d.ts.map +1 -0
- package/dist/hyper-theme.js +30 -0
- package/dist/hyper-theme.js.map +1 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/md.d.ts +12 -0
- package/dist/md.d.ts.map +1 -0
- package/dist/md.js +19 -0
- package/dist/md.js.map +1 -0
- package/dist/messages.d.ts +20 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +65 -0
- package/dist/messages.js.map +1 -0
- package/dist/palette.d.ts +20 -0
- package/dist/palette.d.ts.map +1 -0
- package/dist/palette.js +22 -0
- package/dist/palette.js.map +1 -0
- package/dist/primitives/align.d.ts +23 -0
- package/dist/primitives/align.d.ts.map +1 -0
- package/dist/primitives/align.js +40 -0
- package/dist/primitives/align.js.map +1 -0
- package/dist/primitives/badge.d.ts +24 -0
- package/dist/primitives/badge.d.ts.map +1 -0
- package/dist/primitives/badge.js +40 -0
- package/dist/primitives/badge.js.map +1 -0
- package/dist/primitives/border.d.ts +29 -0
- package/dist/primitives/border.d.ts.map +1 -0
- package/dist/primitives/border.js +100 -0
- package/dist/primitives/border.js.map +1 -0
- package/dist/primitives/context.d.ts +48 -0
- package/dist/primitives/context.d.ts.map +1 -0
- package/dist/primitives/context.js +64 -0
- package/dist/primitives/context.js.map +1 -0
- package/dist/primitives/divider.d.ts +25 -0
- package/dist/primitives/divider.d.ts.map +1 -0
- package/dist/primitives/divider.js +56 -0
- package/dist/primitives/divider.js.map +1 -0
- package/dist/primitives/indent.d.ts +16 -0
- package/dist/primitives/indent.d.ts.map +1 -0
- package/dist/primitives/indent.js +25 -0
- package/dist/primitives/indent.js.map +1 -0
- package/dist/primitives/index.d.ts +32 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +22 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/line.d.ts +21 -0
- package/dist/primitives/line.d.ts.map +1 -0
- package/dist/primitives/line.js +29 -0
- package/dist/primitives/line.js.map +1 -0
- package/dist/primitives/markdown.d.ts +91 -0
- package/dist/primitives/markdown.d.ts.map +1 -0
- package/dist/primitives/markdown.js +62 -0
- package/dist/primitives/markdown.js.map +1 -0
- package/dist/primitives/pad.d.ts +24 -0
- package/dist/primitives/pad.d.ts.map +1 -0
- package/dist/primitives/pad.js +20 -0
- package/dist/primitives/pad.js.map +1 -0
- package/dist/primitives/stack.d.ts +22 -0
- package/dist/primitives/stack.d.ts.map +1 -0
- package/dist/primitives/stack.js +21 -0
- package/dist/primitives/stack.js.map +1 -0
- package/dist/primitives/styledText.d.ts +36 -0
- package/dist/primitives/styledText.d.ts.map +1 -0
- package/dist/primitives/styledText.js +42 -0
- package/dist/primitives/styledText.js.map +1 -0
- package/dist/primitives/symbol.d.ts +15 -0
- package/dist/primitives/symbol.d.ts.map +1 -0
- package/dist/primitives/symbol.js +18 -0
- package/dist/primitives/symbol.js.map +1 -0
- package/dist/primitives/truncate.d.ts +23 -0
- package/dist/primitives/truncate.d.ts.map +1 -0
- package/dist/primitives/truncate.js +99 -0
- package/dist/primitives/truncate.js.map +1 -0
- package/dist/primitives/wrap.d.ts +23 -0
- package/dist/primitives/wrap.d.ts.map +1 -0
- package/dist/primitives/wrap.js +30 -0
- package/dist/primitives/wrap.js.map +1 -0
- package/dist/render/ansi-utils.d.ts +49 -0
- package/dist/render/ansi-utils.d.ts.map +1 -0
- package/dist/render/ansi-utils.js +405 -0
- package/dist/render/ansi-utils.js.map +1 -0
- package/dist/render/index.d.ts +11 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +11 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/sgr.d.ts +60 -0
- package/dist/render/sgr.d.ts.map +1 -0
- package/dist/render/sgr.js +191 -0
- package/dist/render/sgr.js.map +1 -0
- package/dist/render/strip.d.ts +24 -0
- package/dist/render/strip.d.ts.map +1 -0
- package/dist/render/strip.js +81 -0
- package/dist/render/strip.js.map +1 -0
- package/dist/render/width.d.ts +30 -0
- package/dist/render/width.d.ts.map +1 -0
- package/dist/render/width.js +149 -0
- package/dist/render/width.js.map +1 -0
- package/dist/shortcuts.d.ts +76 -0
- package/dist/shortcuts.d.ts.map +1 -0
- package/dist/shortcuts.js +117 -0
- package/dist/shortcuts.js.map +1 -0
- package/dist/styles.d.ts +43 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +44 -0
- package/dist/styles.js.map +1 -0
- package/dist/symbols.d.ts +19 -0
- package/dist/symbols.d.ts.map +1 -0
- package/dist/symbols.js +21 -0
- package/dist/symbols.js.map +1 -0
- package/dist/test/compare.d.ts +28 -0
- package/dist/test/compare.d.ts.map +1 -0
- package/dist/test/compare.js +37 -0
- package/dist/test/compare.js.map +1 -0
- package/dist/test/index.d.ts +16 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +14 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/mock.d.ts +50 -0
- package/dist/test/mock.d.ts.map +1 -0
- package/dist/test/mock.js +135 -0
- package/dist/test/mock.js.map +1 -0
- package/dist/test/render.d.ts +29 -0
- package/dist/test/render.d.ts.map +1 -0
- package/dist/test/render.js +87 -0
- package/dist/test/render.js.map +1 -0
- package/dist/test/snapshot.d.ts +16 -0
- package/dist/test/snapshot.d.ts.map +1 -0
- package/dist/test/snapshot.js +216 -0
- package/dist/test/snapshot.js.map +1 -0
- package/dist/theme/builtins.d.ts +10 -0
- package/dist/theme/builtins.d.ts.map +1 -0
- package/dist/theme/builtins.js +102 -0
- package/dist/theme/builtins.js.map +1 -0
- package/dist/theme/engine.d.ts +51 -0
- package/dist/theme/engine.d.ts.map +1 -0
- package/dist/theme/engine.js +123 -0
- package/dist/theme/engine.js.map +1 -0
- package/dist/theme/index.d.ts +10 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +12 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/merge.d.ts +24 -0
- package/dist/theme/merge.d.ts.map +1 -0
- package/dist/theme/merge.js +66 -0
- package/dist/theme/merge.js.map +1 -0
- package/dist/theme/types.d.ts +44 -0
- package/dist/theme/types.d.ts.map +1 -0
- package/dist/theme/types.js +8 -0
- package/dist/theme/types.js.map +1 -0
- package/dist/theme.d.ts +9 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +53 -0
- package/dist/theme.js.map +1 -0
- package/dist/tokens/defaults.d.ts +13 -0
- package/dist/tokens/defaults.d.ts.map +1 -0
- package/dist/tokens/defaults.js +248 -0
- package/dist/tokens/defaults.js.map +1 -0
- package/dist/tokens/index.d.ts +10 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +10 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/tokens/resolver.d.ts +100 -0
- package/dist/tokens/resolver.d.ts.map +1 -0
- package/dist/tokens/resolver.js +138 -0
- package/dist/tokens/resolver.js.map +1 -0
- package/dist/tokens/types.d.ts +265 -0
- package/dist/tokens/types.d.ts.map +1 -0
- package/dist/tokens/types.js +10 -0
- package/dist/tokens/types.js.map +1 -0
- package/dist/tokens.d.ts +26 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +30 -0
- package/dist/tokens.js.map +1 -0
- package/dist/types.d.ts +38 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test Rendering Utilities
|
|
3
|
+
*
|
|
4
|
+
* Captures rendered output and provides assertions for ANSI-styled strings.
|
|
5
|
+
*/
|
|
6
|
+
import { stripAnsi } from "../render/index.js";
|
|
7
|
+
import { stringWidth } from "../render/index.js";
|
|
8
|
+
/**
|
|
9
|
+
* Regex matching SGR sequences that contain color codes.
|
|
10
|
+
* Color codes: 30-37, 38, 39, 40-47, 48, 49, 90-97, 100-107
|
|
11
|
+
*/
|
|
12
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape detection requires control characters
|
|
13
|
+
const COLOR_SGR_REGEX = /\x1b\[([0-9;]*)m/g;
|
|
14
|
+
/** SGR code numbers for style attributes */
|
|
15
|
+
const STYLE_CODES = {
|
|
16
|
+
bold: 1,
|
|
17
|
+
dim: 2,
|
|
18
|
+
italic: 3,
|
|
19
|
+
underline: 4,
|
|
20
|
+
inverse: 7,
|
|
21
|
+
strikethrough: 9,
|
|
22
|
+
};
|
|
23
|
+
function isColorCode(code) {
|
|
24
|
+
return (code >= 30 && code <= 49) || (code >= 90 && code <= 97) || (code >= 100 && code <= 107);
|
|
25
|
+
}
|
|
26
|
+
function detectColor(raw) {
|
|
27
|
+
const regex = new RegExp(COLOR_SGR_REGEX.source, "g");
|
|
28
|
+
for (const match of raw.matchAll(regex)) {
|
|
29
|
+
const params = match[1];
|
|
30
|
+
if (params === "" || params === "0")
|
|
31
|
+
continue;
|
|
32
|
+
const parts = params.split(";");
|
|
33
|
+
for (const part of parts) {
|
|
34
|
+
const code = Number.parseInt(part, 10);
|
|
35
|
+
if (!Number.isNaN(code) && isColorCode(code)) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
function detectStyle(raw, attr) {
|
|
43
|
+
const targetCode = STYLE_CODES[attr];
|
|
44
|
+
if (targetCode === undefined)
|
|
45
|
+
return false;
|
|
46
|
+
const regex = new RegExp(COLOR_SGR_REGEX.source, "g");
|
|
47
|
+
for (const match of raw.matchAll(regex)) {
|
|
48
|
+
const params = match[1];
|
|
49
|
+
if (params === "" || params === "0")
|
|
50
|
+
continue;
|
|
51
|
+
const parts = params.split(";");
|
|
52
|
+
for (const part of parts) {
|
|
53
|
+
const code = Number.parseInt(part, 10);
|
|
54
|
+
if (code === targetCode)
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Wraps a rendered string in a {@link RenderedOutput} object for inspection and assertions.
|
|
62
|
+
*
|
|
63
|
+
* @param output - The raw styled string to analyze.
|
|
64
|
+
* @returns A {@link RenderedOutput} object with plain text, color detection, and style queries.
|
|
65
|
+
*/
|
|
66
|
+
export function render(output) {
|
|
67
|
+
const plain = stripAnsi(output);
|
|
68
|
+
const lines = plain.split("\n");
|
|
69
|
+
return {
|
|
70
|
+
styled: output,
|
|
71
|
+
plain,
|
|
72
|
+
get hasColor() {
|
|
73
|
+
return detectColor(output);
|
|
74
|
+
},
|
|
75
|
+
hasStyle(attr) {
|
|
76
|
+
return detectStyle(output, attr);
|
|
77
|
+
},
|
|
78
|
+
get width() {
|
|
79
|
+
return stringWidth(lines[0] ?? "");
|
|
80
|
+
},
|
|
81
|
+
lines,
|
|
82
|
+
get lineCount() {
|
|
83
|
+
return lines.length;
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/test/render.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAmBjD;;;GAGG;AACH,6GAA6G;AAC7G,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAE5C,4CAA4C;AAC5C,MAAM,WAAW,GAA2B;IAC3C,IAAI,EAAE,CAAC;IACP,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,CAAC;IACT,SAAS,EAAE,CAAC;IACZ,OAAO,EAAE,CAAC;IACV,aAAa,EAAE,CAAC;CAChB,CAAC;AAEF,SAAS,WAAW,CAAC,IAAY;IAChC,OAAO,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC;AACjG,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC/B,MAAM,KAAK,GAAG,IAA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AQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACvC,IAAI,IAAI,KAAK,UAAU;gBAAE,OAAO,IAAI,CAAC;QACtC,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,MAAc;IACpC,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEhC,OAAO;QACN,MAAM,EAAE,MAAM;QACd,KAAK;QACL,IAAI,QAAQ;YACX,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QACD,QAAQ,CAAC,IAAI;YACZ,OAAO,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,KAAK;YACR,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACpC,CAAC;QACD,KAAK;QACL,IAAI,SAAS;YACZ,OAAO,KAAK,CAAC,MAAM,CAAC;QACrB,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapshot Utilities
|
|
3
|
+
*
|
|
4
|
+
* Converts ANSI-styled output to a human-readable snapshot format
|
|
5
|
+
* with readable tokens like [bold], [red], [/bold], [/red].
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Converts styled output to a human-readable snapshot format.
|
|
9
|
+
* Replaces ANSI SGR codes with readable tokens like `[bold]`, `[red]`, `[/bold]`, `[/red]`.
|
|
10
|
+
* Strips volatile content (timestamps, durations) for deterministic snapshots.
|
|
11
|
+
*
|
|
12
|
+
* @param output - The raw ANSI-styled string to convert.
|
|
13
|
+
* @returns A snapshot string with readable style tokens.
|
|
14
|
+
*/
|
|
15
|
+
export declare function snapshot(output: string): string;
|
|
16
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/test/snapshot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiMH;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CA4B/C"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapshot Utilities
|
|
3
|
+
*
|
|
4
|
+
* Converts ANSI-styled output to a human-readable snapshot format
|
|
5
|
+
* with readable tokens like [bold], [red], [/bold], [/red].
|
|
6
|
+
*/
|
|
7
|
+
/** Maps SGR enable codes to readable names */
|
|
8
|
+
const ATTR_NAMES = {
|
|
9
|
+
1: "bold",
|
|
10
|
+
2: "dim",
|
|
11
|
+
3: "italic",
|
|
12
|
+
4: "underline",
|
|
13
|
+
7: "inverse",
|
|
14
|
+
9: "strikethrough",
|
|
15
|
+
};
|
|
16
|
+
/** Maps SGR reset codes to what they close */
|
|
17
|
+
const ATTR_RESET_CODES = {
|
|
18
|
+
22: ["bold", "dim"],
|
|
19
|
+
23: ["italic"],
|
|
20
|
+
24: ["underline"],
|
|
21
|
+
27: ["inverse"],
|
|
22
|
+
29: ["strikethrough"],
|
|
23
|
+
39: ["fg"],
|
|
24
|
+
49: ["bg"],
|
|
25
|
+
};
|
|
26
|
+
/** ANSI 16 foreground color code → name */
|
|
27
|
+
const FG_COLOR_NAMES = {
|
|
28
|
+
30: "black",
|
|
29
|
+
31: "red",
|
|
30
|
+
32: "green",
|
|
31
|
+
33: "yellow",
|
|
32
|
+
34: "blue",
|
|
33
|
+
35: "magenta",
|
|
34
|
+
36: "cyan",
|
|
35
|
+
37: "white",
|
|
36
|
+
90: "brightBlack",
|
|
37
|
+
91: "brightRed",
|
|
38
|
+
92: "brightGreen",
|
|
39
|
+
93: "brightYellow",
|
|
40
|
+
94: "brightBlue",
|
|
41
|
+
95: "brightMagenta",
|
|
42
|
+
96: "brightCyan",
|
|
43
|
+
97: "brightWhite",
|
|
44
|
+
};
|
|
45
|
+
/** ANSI 16 background color code → name */
|
|
46
|
+
const BG_COLOR_NAMES = {
|
|
47
|
+
40: "black",
|
|
48
|
+
41: "red",
|
|
49
|
+
42: "green",
|
|
50
|
+
43: "yellow",
|
|
51
|
+
44: "blue",
|
|
52
|
+
45: "magenta",
|
|
53
|
+
46: "cyan",
|
|
54
|
+
47: "white",
|
|
55
|
+
100: "brightBlack",
|
|
56
|
+
101: "brightRed",
|
|
57
|
+
102: "brightGreen",
|
|
58
|
+
103: "brightYellow",
|
|
59
|
+
104: "brightBlue",
|
|
60
|
+
105: "brightMagenta",
|
|
61
|
+
106: "brightCyan",
|
|
62
|
+
107: "brightWhite",
|
|
63
|
+
};
|
|
64
|
+
function toHex(n) {
|
|
65
|
+
return n.toString(16).padStart(2, "0");
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Process a list of SGR parameter codes and produce readable tokens.
|
|
69
|
+
* Tracks open attributes for context-dependent resets (e.g. code 22 closes bold or dim).
|
|
70
|
+
*/
|
|
71
|
+
function processCodes(codes, openAttrs) {
|
|
72
|
+
const tokens = [];
|
|
73
|
+
let i = 0;
|
|
74
|
+
while (i < codes.length) {
|
|
75
|
+
const code = codes[i];
|
|
76
|
+
// Full reset
|
|
77
|
+
if (code === 0) {
|
|
78
|
+
tokens.push("[reset]");
|
|
79
|
+
openAttrs.clear();
|
|
80
|
+
i++;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
// Style attributes (enable)
|
|
84
|
+
if (ATTR_NAMES[code]) {
|
|
85
|
+
const name = ATTR_NAMES[code];
|
|
86
|
+
tokens.push(`[${name}]`);
|
|
87
|
+
openAttrs.add(name);
|
|
88
|
+
i++;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
// Style attribute resets
|
|
92
|
+
if (ATTR_RESET_CODES[code]) {
|
|
93
|
+
const candidates = ATTR_RESET_CODES[code];
|
|
94
|
+
if (candidates.length === 1) {
|
|
95
|
+
// Unambiguous reset
|
|
96
|
+
const name = candidates[0];
|
|
97
|
+
tokens.push(`[/${name}]`);
|
|
98
|
+
openAttrs.delete(name);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// Ambiguous reset (e.g. 22 resets both bold and dim)
|
|
102
|
+
// Close whichever is currently open; if both, close both
|
|
103
|
+
const closed = [];
|
|
104
|
+
for (const candidate of candidates) {
|
|
105
|
+
if (openAttrs.has(candidate)) {
|
|
106
|
+
closed.push(candidate);
|
|
107
|
+
openAttrs.delete(candidate);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (closed.length === 0) {
|
|
111
|
+
// Nothing open — emit the first candidate
|
|
112
|
+
tokens.push(`[/${candidates[0]}]`);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
for (const name of closed) {
|
|
116
|
+
tokens.push(`[/${name}]`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
i++;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
// Foreground 16-color
|
|
124
|
+
if (FG_COLOR_NAMES[code]) {
|
|
125
|
+
tokens.push(`[${FG_COLOR_NAMES[code]}]`);
|
|
126
|
+
openAttrs.add("fg");
|
|
127
|
+
i++;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
// Background 16-color
|
|
131
|
+
if (BG_COLOR_NAMES[code]) {
|
|
132
|
+
tokens.push(`[bg:${BG_COLOR_NAMES[code]}]`);
|
|
133
|
+
openAttrs.add("bg");
|
|
134
|
+
i++;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
// Extended foreground: 38;5;N or 38;2;R;G;B
|
|
138
|
+
if (code === 38) {
|
|
139
|
+
const sub = codes[i + 1];
|
|
140
|
+
if (sub === 5 && i + 2 < codes.length) {
|
|
141
|
+
tokens.push(`[fg:${codes[i + 2]}]`);
|
|
142
|
+
openAttrs.add("fg");
|
|
143
|
+
i += 3;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (sub === 2 && i + 4 < codes.length) {
|
|
147
|
+
const r = codes[i + 2];
|
|
148
|
+
const g = codes[i + 3];
|
|
149
|
+
const b = codes[i + 4];
|
|
150
|
+
tokens.push(`[fg:#${toHex(r)}${toHex(g)}${toHex(b)}]`);
|
|
151
|
+
openAttrs.add("fg");
|
|
152
|
+
i += 5;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
i++;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
// Extended background: 48;5;N or 48;2;R;G;B
|
|
159
|
+
if (code === 48) {
|
|
160
|
+
const sub = codes[i + 1];
|
|
161
|
+
if (sub === 5 && i + 2 < codes.length) {
|
|
162
|
+
tokens.push(`[bg:${codes[i + 2]}]`);
|
|
163
|
+
openAttrs.add("bg");
|
|
164
|
+
i += 3;
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (sub === 2 && i + 4 < codes.length) {
|
|
168
|
+
const r = codes[i + 2];
|
|
169
|
+
const g = codes[i + 3];
|
|
170
|
+
const b = codes[i + 4];
|
|
171
|
+
tokens.push(`[bg:#${toHex(r)}${toHex(g)}${toHex(b)}]`);
|
|
172
|
+
openAttrs.add("bg");
|
|
173
|
+
i += 5;
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
i++;
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
// Unknown code — skip
|
|
180
|
+
i++;
|
|
181
|
+
}
|
|
182
|
+
return tokens;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Converts styled output to a human-readable snapshot format.
|
|
186
|
+
* Replaces ANSI SGR codes with readable tokens like `[bold]`, `[red]`, `[/bold]`, `[/red]`.
|
|
187
|
+
* Strips volatile content (timestamps, durations) for deterministic snapshots.
|
|
188
|
+
*
|
|
189
|
+
* @param output - The raw ANSI-styled string to convert.
|
|
190
|
+
* @returns A snapshot string with readable style tokens.
|
|
191
|
+
*/
|
|
192
|
+
export function snapshot(output) {
|
|
193
|
+
const openAttrs = new Set();
|
|
194
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape detection requires control characters
|
|
195
|
+
const SGR_REGEX = /\x1b\[([0-9;]*)m/g;
|
|
196
|
+
let result = output.replace(SGR_REGEX, (_match, params) => {
|
|
197
|
+
if (params === "") {
|
|
198
|
+
// Empty params = reset
|
|
199
|
+
const tokens = processCodes([0], openAttrs);
|
|
200
|
+
return tokens.join("");
|
|
201
|
+
}
|
|
202
|
+
const codes = params.split(";").map((s) => Number.parseInt(s, 10));
|
|
203
|
+
const tokens = processCodes(codes, openAttrs);
|
|
204
|
+
return tokens.join("");
|
|
205
|
+
});
|
|
206
|
+
// Strip non-SGR ANSI sequences (cursor movement, etc.)
|
|
207
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape detection requires control characters
|
|
208
|
+
result = result.replace(/\x1b\[[0-9;]*[A-Za-ln-z]/g, "");
|
|
209
|
+
// Strip volatile content for stable snapshots
|
|
210
|
+
// Duration patterns: (1.2s), (123ms), (0.5s)
|
|
211
|
+
result = result.replace(/\(\d+(?:\.\d+)?(?:ms|s)\)/g, "(TIME)");
|
|
212
|
+
// ISO date patterns: 2024-01-15, 2025-12-31
|
|
213
|
+
result = result.replace(/\d{4}-\d{2}-\d{2}/g, "(DATE)");
|
|
214
|
+
return result;
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/test/snapshot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,8CAA8C;AAC9C,MAAM,UAAU,GAA2B;IAC1C,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,WAAW;IAC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KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAC3E,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,uDAAuD;IACvD,6GAA6G;IAC7G,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;IAEzD,8CAA8C;IAC9C,6CAA6C;IAC7C,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,4BAA4B,EAAE,QAAQ,CAAC,CAAC;IAChE,4CAA4C;IAC5C,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;IAExD,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in Themes
|
|
3
|
+
*
|
|
4
|
+
* Four built-in themes shipped with the design system. Each is a partial
|
|
5
|
+
* token override — only values that differ from defaultTokens are specified.
|
|
6
|
+
*/
|
|
7
|
+
import type { BuiltinThemeName, Theme } from "./types.ts";
|
|
8
|
+
/** All built-in themes indexed by name. */
|
|
9
|
+
export declare const builtinThemes: Record<BuiltinThemeName, Theme>;
|
|
10
|
+
//# sourceMappingURL=builtins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../../src/theme/builtins.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AA8F1D,2CAA2C;AAC3C,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAKzD,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in Themes
|
|
3
|
+
*
|
|
4
|
+
* Four built-in themes shipped with the design system. Each is a partial
|
|
5
|
+
* token override — only values that differ from defaultTokens are specified.
|
|
6
|
+
*/
|
|
7
|
+
/** Minimal theme: ASCII-only symbols, no decorative borders, muted colors. */
|
|
8
|
+
const minimal = {
|
|
9
|
+
name: "minimal",
|
|
10
|
+
meta: {
|
|
11
|
+
description: "Clean, ASCII-friendly theme with minimal decoration",
|
|
12
|
+
},
|
|
13
|
+
border: {
|
|
14
|
+
style: "ascii",
|
|
15
|
+
},
|
|
16
|
+
symbol: {
|
|
17
|
+
success: { unicode: "+", ascii: "+" },
|
|
18
|
+
error: { unicode: "x", ascii: "x" },
|
|
19
|
+
warning: { unicode: "!", ascii: "!" },
|
|
20
|
+
info: { unicode: "-", ascii: "-" },
|
|
21
|
+
},
|
|
22
|
+
color: {
|
|
23
|
+
info: "dim",
|
|
24
|
+
heading: "bold",
|
|
25
|
+
},
|
|
26
|
+
components: {
|
|
27
|
+
table: { variant: "borderless" },
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
/** High contrast theme: no dim text, verbose status labels, maximum readability. */
|
|
31
|
+
const highContrast = {
|
|
32
|
+
name: "highContrast",
|
|
33
|
+
meta: {
|
|
34
|
+
description: "High contrast theme with no dim text and verbose status labels",
|
|
35
|
+
},
|
|
36
|
+
type: {
|
|
37
|
+
deEmphasis: { bold: false, dim: false },
|
|
38
|
+
heading3: { bold: true, dim: false },
|
|
39
|
+
caption: { italic: true, dim: false },
|
|
40
|
+
},
|
|
41
|
+
symbol: {
|
|
42
|
+
success: { unicode: "[OK]", ascii: "[OK]" },
|
|
43
|
+
error: { unicode: "[FAIL]", ascii: "[FAIL]" },
|
|
44
|
+
warning: { unicode: "[WARN]", ascii: "[WARN]" },
|
|
45
|
+
info: { unicode: "[INFO]", ascii: "[INFO]" },
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
/** Monochrome theme: no color at all, relies on bold/dim/underline for hierarchy. */
|
|
49
|
+
const monochrome = {
|
|
50
|
+
name: "monochrome",
|
|
51
|
+
meta: {
|
|
52
|
+
description: "Colorless theme using only text attributes for visual hierarchy",
|
|
53
|
+
},
|
|
54
|
+
color: {
|
|
55
|
+
fg: "default",
|
|
56
|
+
fgMuted: "default",
|
|
57
|
+
error: "default",
|
|
58
|
+
warning: "default",
|
|
59
|
+
success: "default",
|
|
60
|
+
info: "default",
|
|
61
|
+
accent: "default",
|
|
62
|
+
emphasis: "default",
|
|
63
|
+
code: "default",
|
|
64
|
+
heading: "default",
|
|
65
|
+
bgError: "default",
|
|
66
|
+
bgWarning: "default",
|
|
67
|
+
bgSuccess: "default",
|
|
68
|
+
bgInfo: "default",
|
|
69
|
+
bgHighlight: "default",
|
|
70
|
+
diffAdded: "default",
|
|
71
|
+
diffRemoved: "default",
|
|
72
|
+
diffContext: "default",
|
|
73
|
+
diffHunk: "default",
|
|
74
|
+
},
|
|
75
|
+
type: {
|
|
76
|
+
emphasis: { bold: true },
|
|
77
|
+
deEmphasis: { dim: true },
|
|
78
|
+
heading1: { bold: true, underline: true },
|
|
79
|
+
link: { underline: true },
|
|
80
|
+
},
|
|
81
|
+
symbol: {
|
|
82
|
+
success: { unicode: "[OK]", ascii: "[OK]" },
|
|
83
|
+
error: { unicode: "[FAIL]", ascii: "[FAIL]" },
|
|
84
|
+
warning: { unicode: "[WARN]", ascii: "[WARN]" },
|
|
85
|
+
info: { unicode: "[INFO]", ascii: "[INFO]" },
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
/** The default theme is empty — it adds nothing on top of defaultTokens. */
|
|
89
|
+
const defaultTheme = {
|
|
90
|
+
name: "default",
|
|
91
|
+
meta: {
|
|
92
|
+
description: "The default theme with no overrides",
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
/** All built-in themes indexed by name. */
|
|
96
|
+
export const builtinThemes = {
|
|
97
|
+
default: defaultTheme,
|
|
98
|
+
minimal,
|
|
99
|
+
highContrast,
|
|
100
|
+
monochrome,
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=builtins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins.js","sourceRoot":"","sources":["../../src/theme/builtins.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,8EAA8E;AAC9E,MAAM,OAAO,GAAU;IACtB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE;QACL,WAAW,EAAE,qDAAqD;KAClE;IACD,MAAM,EAAE;QACP,KAAK,EAAE,OAAO;KACd;IACD,MAAM,EAAE;QACP,OAAO,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE;QACrC,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE;QACnC,OAAO,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE;QACrC,IAAI,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE;KAClC;IACD,KAAK,EAAE;QACN,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,MAAM;KACf;IACD,UAAU,EAAE;QACX,KAAK,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE;KAChC;CACD,CAAC;AAEF,oFAAoF;AACpF,MAAM,YAAY,GAAU;IAC3B,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE;QACL,WAAW,EAAE,gEAAgE;KAC7E;IACD,IAAI,EAAE;QACL,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE;QACvC,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE;QACpC,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE;KACrC;IACD,MAAM,EAAE;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AE;QAC3C,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;QAC7C,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;QAC/C,IAAI,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;KAC5C;CACD,CAAC;AAEF,4EAA4E;AAC5E,MAAM,YAAY,GAAU;IAC3B,IAAI,EAAE,SAAS;IACf,IAAI,EAAE;QACL,WAAW,EAAE,qCAAqC;KAClD;CACD,CAAC;AAEF,2CAA2C;AAC3C,MAAM,CAAC,MAAM,aAAa,GAAoC;IAC7D,OAAO,EAAE,YAAY;IACrB,OAAO;IACP,YAAY;IACZ,UAAU;CACV,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme Engine
|
|
3
|
+
*
|
|
4
|
+
* Composes themes, merges them with default tokens, resolves the result
|
|
5
|
+
* against terminal capabilities, and caches the resolved output.
|
|
6
|
+
*/
|
|
7
|
+
import type { TerminalCapabilities } from "../capabilities/index.ts";
|
|
8
|
+
import type { ResolvedTokens, TokenSet } from "../tokens/index.ts";
|
|
9
|
+
import type { Theme, ThemeInput } from "./types.ts";
|
|
10
|
+
/**
|
|
11
|
+
* Manages theme composition, token resolution, and caching.
|
|
12
|
+
*
|
|
13
|
+
* The engine composes one or more theme inputs, merges them onto the default
|
|
14
|
+
* token set, and lazily resolves the result against terminal capabilities.
|
|
15
|
+
* Resolved tokens are cached and invalidated whenever the theme changes.
|
|
16
|
+
*/
|
|
17
|
+
export declare class ThemeEngine {
|
|
18
|
+
private tokens;
|
|
19
|
+
private capabilities;
|
|
20
|
+
private resolved;
|
|
21
|
+
private currentTheme;
|
|
22
|
+
/**
|
|
23
|
+
* @param capabilities - The terminal capabilities to resolve tokens against.
|
|
24
|
+
* @param themeInput - Optional theme configuration to apply over defaults.
|
|
25
|
+
*/
|
|
26
|
+
constructor(capabilities: TerminalCapabilities, themeInput?: ThemeInput);
|
|
27
|
+
/** Get the current resolved tokens. Lazily resolved and cached. */
|
|
28
|
+
get resolvedTokens(): ResolvedTokens;
|
|
29
|
+
/** Get the raw merged token set (pre-resolution). */
|
|
30
|
+
get rawTokens(): TokenSet;
|
|
31
|
+
/**
|
|
32
|
+
* Replace the current theme entirely. Invalidates the resolved token cache.
|
|
33
|
+
*
|
|
34
|
+
* @param themeInput - The new theme to apply.
|
|
35
|
+
*/
|
|
36
|
+
setTheme(themeInput: ThemeInput): void;
|
|
37
|
+
/**
|
|
38
|
+
* Merge a partial theme on top of the current theme. Invalidates the resolved token cache.
|
|
39
|
+
*
|
|
40
|
+
* @param partial - Partial theme overrides to merge.
|
|
41
|
+
*/
|
|
42
|
+
mergeTheme(partial: Theme): void;
|
|
43
|
+
/**
|
|
44
|
+
* Get component-level defaults from the theme.
|
|
45
|
+
*
|
|
46
|
+
* @param componentName - The component name to look up.
|
|
47
|
+
* @returns The component defaults record, or `undefined` if none configured.
|
|
48
|
+
*/
|
|
49
|
+
getComponentDefaults(componentName: string): Record<string, unknown> | undefined;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/theme/engine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAInE,OAAO,KAAK,EAAoB,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAoDtE;;;;;;GAMG;AACH,qBAAa,WAAW;IACvB,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,YAAY,CAAQ;IAE5B;;;OAGG;gBACS,YAAY,EAAE,oBAAoB,EAAE,UAAU,CAAC,EAAE,UAAU;IAMvE,mEAAmE;IACnE,IAAI,cAAc,IAAI,cAAc,CAKnC;IAED,qDAAqD;IACrD,IAAI,SAAS,IAAI,QAAQ,CAExB;IAED;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAMtC;;;;OAIG;IACH,UAAU,CAAC,OAAO,EAAE,KAAK,GAAG,IAAI;IAMhC;;;;;OAKG;IACH,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;CAGhF"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme Engine
|
|
3
|
+
*
|
|
4
|
+
* Composes themes, merges them with default tokens, resolves the result
|
|
5
|
+
* against terminal capabilities, and caches the resolved output.
|
|
6
|
+
*/
|
|
7
|
+
import { defaultTokens, resolveTokens } from "../tokens/index.js";
|
|
8
|
+
import { builtinThemes } from "./builtins.js";
|
|
9
|
+
import { deepMerge } from "./merge.js";
|
|
10
|
+
/**
|
|
11
|
+
* Normalizes a single ThemeInput entry (string or object) into a Theme object.
|
|
12
|
+
* If the theme has `extends`, the base theme is resolved first and the
|
|
13
|
+
* extending theme is merged on top.
|
|
14
|
+
*/
|
|
15
|
+
function resolveTheme(input) {
|
|
16
|
+
if (typeof input === "string") {
|
|
17
|
+
return builtinThemes[input];
|
|
18
|
+
}
|
|
19
|
+
if (input.extends) {
|
|
20
|
+
const base = builtinThemes[input.extends];
|
|
21
|
+
return deepMerge(base, input);
|
|
22
|
+
}
|
|
23
|
+
return input;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Composes a ThemeInput (name, object, or array) into a single merged Theme.
|
|
27
|
+
*/
|
|
28
|
+
function composeThemes(input) {
|
|
29
|
+
if (Array.isArray(input)) {
|
|
30
|
+
const resolved = input.map(resolveTheme);
|
|
31
|
+
if (resolved.length === 0)
|
|
32
|
+
return {};
|
|
33
|
+
return resolved.reduce((acc, theme) => deepMerge(acc, theme));
|
|
34
|
+
}
|
|
35
|
+
return resolveTheme(input);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Applies a Theme's partial overrides onto the complete default token set,
|
|
39
|
+
* producing a full TokenSet.
|
|
40
|
+
*/
|
|
41
|
+
function applyThemeToTokens(theme) {
|
|
42
|
+
const overrides = {};
|
|
43
|
+
if (theme.color)
|
|
44
|
+
overrides.color = theme.color;
|
|
45
|
+
if (theme.type)
|
|
46
|
+
overrides.type = theme.type;
|
|
47
|
+
if (theme.space)
|
|
48
|
+
overrides.space = theme.space;
|
|
49
|
+
if (theme.layout)
|
|
50
|
+
overrides.layout = theme.layout;
|
|
51
|
+
if (theme.symbol)
|
|
52
|
+
overrides.symbol = theme.symbol;
|
|
53
|
+
if (theme.border)
|
|
54
|
+
overrides.border = theme.border;
|
|
55
|
+
if (theme.tree)
|
|
56
|
+
overrides.tree = theme.tree;
|
|
57
|
+
if (theme.motion)
|
|
58
|
+
overrides.motion = theme.motion;
|
|
59
|
+
return deepMerge(defaultTokens, overrides);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Manages theme composition, token resolution, and caching.
|
|
63
|
+
*
|
|
64
|
+
* The engine composes one or more theme inputs, merges them onto the default
|
|
65
|
+
* token set, and lazily resolves the result against terminal capabilities.
|
|
66
|
+
* Resolved tokens are cached and invalidated whenever the theme changes.
|
|
67
|
+
*/
|
|
68
|
+
export class ThemeEngine {
|
|
69
|
+
tokens;
|
|
70
|
+
capabilities;
|
|
71
|
+
resolved = null;
|
|
72
|
+
currentTheme;
|
|
73
|
+
/**
|
|
74
|
+
* @param capabilities - The terminal capabilities to resolve tokens against.
|
|
75
|
+
* @param themeInput - Optional theme configuration to apply over defaults.
|
|
76
|
+
*/
|
|
77
|
+
constructor(capabilities, themeInput) {
|
|
78
|
+
this.capabilities = capabilities;
|
|
79
|
+
this.currentTheme = themeInput ? composeThemes(themeInput) : {};
|
|
80
|
+
this.tokens = applyThemeToTokens(this.currentTheme);
|
|
81
|
+
}
|
|
82
|
+
/** Get the current resolved tokens. Lazily resolved and cached. */
|
|
83
|
+
get resolvedTokens() {
|
|
84
|
+
if (this.resolved === null) {
|
|
85
|
+
this.resolved = resolveTokens(this.tokens, this.capabilities);
|
|
86
|
+
}
|
|
87
|
+
return this.resolved;
|
|
88
|
+
}
|
|
89
|
+
/** Get the raw merged token set (pre-resolution). */
|
|
90
|
+
get rawTokens() {
|
|
91
|
+
return this.tokens;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Replace the current theme entirely. Invalidates the resolved token cache.
|
|
95
|
+
*
|
|
96
|
+
* @param themeInput - The new theme to apply.
|
|
97
|
+
*/
|
|
98
|
+
setTheme(themeInput) {
|
|
99
|
+
this.currentTheme = composeThemes(themeInput);
|
|
100
|
+
this.tokens = applyThemeToTokens(this.currentTheme);
|
|
101
|
+
this.resolved = null;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Merge a partial theme on top of the current theme. Invalidates the resolved token cache.
|
|
105
|
+
*
|
|
106
|
+
* @param partial - Partial theme overrides to merge.
|
|
107
|
+
*/
|
|
108
|
+
mergeTheme(partial) {
|
|
109
|
+
this.currentTheme = deepMerge(this.currentTheme, partial);
|
|
110
|
+
this.tokens = applyThemeToTokens(this.currentTheme);
|
|
111
|
+
this.resolved = null;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get component-level defaults from the theme.
|
|
115
|
+
*
|
|
116
|
+
* @param componentName - The component name to look up.
|
|
117
|
+
* @returns The component defaults record, or `undefined` if none configured.
|
|
118
|
+
*/
|
|
119
|
+
getComponentDefaults(componentName) {
|
|
120
|
+
return this.currentTheme.components?.[componentName];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 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AY,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED,qDAAqD;IACrD,IAAI,SAAS;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,UAAsB;QAC9B,IAAI,CAAC,YAAY,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,OAAc;QACxB,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAC1D,IAAI,CAAC,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACH,oBAAoB,CAAC,aAAqB;QACzC,OAAO,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,aAAa,CAAC,CAAC;IACtD,CAAC;CACD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme Engine — Barrel Export
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all theme types, built-in themes, the engine, and utilities.
|
|
5
|
+
*/
|
|
6
|
+
export type { DeepPartial, BuiltinThemeName, Theme, ThemeInput } from "./types.ts";
|
|
7
|
+
export { builtinThemes } from "./builtins.ts";
|
|
8
|
+
export { ThemeEngine } from "./engine.ts";
|
|
9
|
+
export { deepMerge } from "./merge.ts";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGnF,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
|