silvery 0.21.0 → 0.23.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/README.md +1 -1
- package/dist/{Text-Lq0dmj8-.mjs → Text-Ci6UCSTL.mjs} +46 -48
- package/dist/Text-Ci6UCSTL.mjs.map +1 -0
- package/dist/{render-string-DkQacASz.mjs → ag-q9lRlKlt.mjs} +5322 -4259
- package/dist/ag-q9lRlKlt.mjs.map +1 -0
- package/dist/{animation-ZMN2_XKv.mjs → animation-CZ4x2R7C.mjs} +1 -1
- package/dist/{animation-ZMN2_XKv.mjs.map → animation-CZ4x2R7C.mjs.map} +1 -1
- package/dist/{ansi-D1KQMAbf.mjs → ansi-CLmIMnop.mjs} +1 -1
- package/dist/{ansi-D1KQMAbf.mjs.map → ansi-CLmIMnop.mjs.map} +1 -1
- package/dist/{ansi-2Xn0yatP.d.mts → ansi-zmNzgkPB.d.mts} +1 -1
- package/dist/{ansi-2Xn0yatP.d.mts.map → ansi-zmNzgkPB.d.mts.map} +1 -1
- package/dist/{backend-B-WYLUib.mjs → backend-DSiSIc-h.mjs} +2 -2
- package/dist/{backend-B-WYLUib.mjs.map → backend-DSiSIc-h.mjs.map} +1 -1
- package/dist/chain-bridge-CkYcMxlq.mjs +4149 -0
- package/dist/chain-bridge-CkYcMxlq.mjs.map +1 -0
- package/dist/{chunk-BSw8zbkd.mjs → chunk-BEJ448es.mjs} +1 -3
- package/dist/cli-VNqUKlXw.mjs +4 -0
- package/dist/{context-BU5LkkIy.mjs → context-CEhuD1R_.mjs} +1 -1
- package/dist/{context-BU5LkkIy.mjs.map → context-CEhuD1R_.mjs.map} +1 -1
- package/dist/devtools-BF4IMumr.mjs +2 -0
- package/dist/{devtools-DcQjgyjL.mjs → devtools-td2AjFwc.mjs} +5 -5
- package/dist/{devtools-DcQjgyjL.mjs.map → devtools-td2AjFwc.mjs.map} +1 -1
- package/dist/{easing-BI-ASGMO.d.mts → easing-C5MrdO7V.d.mts} +1 -1
- package/dist/{easing-BI-ASGMO.d.mts.map → easing-C5MrdO7V.d.mts.map} +1 -1
- package/dist/{eta-CJlGH06n.mjs → eta-BwYWEjfS.mjs} +1 -1
- package/dist/{eta-CJlGH06n.mjs.map → eta-BwYWEjfS.mjs.map} +1 -1
- package/dist/{flexily-zero-adapter-C4lW_Ov5.mjs → flexily-zero-adapter-DktX3HsX.mjs} +1 -1
- package/dist/{flexily-zero-adapter-C3Vj0fPt.mjs → flexily-zero-adapter-VoBGHG14.mjs} +1 -1
- package/dist/{flexily-zero-adapter-C3Vj0fPt.mjs.map → flexily-zero-adapter-VoBGHG14.mjs.map} +1 -1
- package/dist/hit-registry-D_nxOivS.d.mts +71 -0
- package/dist/hit-registry-D_nxOivS.d.mts.map +1 -0
- package/dist/{UPNG-DosRPdF4.mjs → image-CIF75xMr.mjs} +891 -6
- package/dist/image-CIF75xMr.mjs.map +1 -0
- package/dist/{index-CSQf13CI.d.mts → index-377zdPLP.d.mts} +35 -12
- package/dist/index-377zdPLP.d.mts.map +1 -0
- package/dist/{index-Cl9KKjQ_.d.mts → index-BcSr0RAQ.d.mts} +8670 -10659
- package/dist/index-BcSr0RAQ.d.mts.map +1 -0
- package/dist/{index-XbNrPhWl.d.mts → index-DLnpxDAm.d.mts} +2 -2
- package/dist/{index-XbNrPhWl.d.mts.map → index-DLnpxDAm.d.mts.map} +1 -1
- package/dist/{index-BUMxS65f.d.mts → index-DlNmckTq.d.mts} +2 -2
- package/dist/{index-BUMxS65f.d.mts.map → index-DlNmckTq.d.mts.map} +1 -1
- package/dist/index.d.mts +12 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +18 -15
- package/dist/index.mjs.map +1 -1
- package/dist/{layout-engine-C2px0RJE.mjs → layout-engine-BgR58vL0.mjs} +3 -3
- package/dist/{layout-engine-C2px0RJE.mjs.map → layout-engine-BgR58vL0.mjs.map} +1 -1
- package/dist/{layout-engine-C07LEXWT.mjs → layout-engine-DNjTha8f.mjs} +1 -1
- package/dist/{layout-signals-Cnw6xk8Q.mjs → layout-signals-CGYbHmxy.mjs} +146 -23
- package/dist/layout-signals-CGYbHmxy.mjs.map +1 -0
- package/dist/{bound-term-0sPrrzH1.d.mts → mouse-events-B2z5tbsL.d.mts} +780 -379
- package/dist/mouse-events-B2z5tbsL.d.mts.map +1 -0
- package/dist/{mouse-events-Dki3ISIp.mjs → mouse-events-WQ2h-uqG.mjs} +45 -10
- package/dist/mouse-events-WQ2h-uqG.mjs.map +1 -0
- package/dist/{multi-progress-DHZ2xUT2.d.mts → multi-progress-BaEFfHKP.d.mts} +2 -2
- package/dist/{multi-progress-DHZ2xUT2.d.mts.map → multi-progress-BaEFfHKP.d.mts.map} +1 -1
- package/dist/{multi-progress-CIRjrzma.mjs → multi-progress-zCWHEm9P.mjs} +3 -3
- package/dist/{multi-progress-CIRjrzma.mjs.map → multi-progress-zCWHEm9P.mjs.map} +1 -1
- package/dist/{node-CjM5Rt-M.mjs → node-CJ3J_rW-.mjs} +1 -1
- package/dist/{node-CjM5Rt-M.mjs.map → node-CJ3J_rW-.mjs.map} +1 -1
- package/dist/{progress-DB_Xo071.mjs → progress-6vJ7nxUg.mjs} +4 -4
- package/dist/{progress-DB_Xo071.mjs.map → progress-6vJ7nxUg.mjs.map} +1 -1
- package/dist/{progress-bar-oJwq22CR.mjs → progress-bar-BlFNsZL8.mjs} +4 -4
- package/dist/{progress-bar-oJwq22CR.mjs.map → progress-bar-BlFNsZL8.mjs.map} +1 -1
- package/dist/{reconciler-DldIJB93.mjs → reconciler--_-biN23.mjs} +190 -134
- package/dist/reconciler--_-biN23.mjs.map +1 -0
- package/dist/{render-string-BcoCpjCB.mjs → render-string-DaghHpLN.mjs} +1 -1
- package/dist/render-string-DtHZP0cU.mjs +215 -0
- package/dist/render-string-DtHZP0cU.mjs.map +1 -0
- package/dist/runtime.d.mts +4 -3
- package/dist/runtime.mjs +4 -3
- package/dist/schemes-DWQPxXAi.mjs +2516 -0
- package/dist/{schemes-JjNp4aSl.mjs.map → schemes-DWQPxXAi.mjs.map} +1 -1
- package/dist/{spinner-D9lrHr8s.mjs → spinner-B50hILqx.mjs} +19 -4
- package/dist/{spinner-D9lrHr8s.mjs.map → spinner-B50hILqx.mjs.map} +1 -1
- package/dist/{spinner-CZINHpkV.d.mts → spinner-DN10UfF0.d.mts} +2 -2
- package/dist/{spinner-CZINHpkV.d.mts.map → spinner-DN10UfF0.d.mts.map} +1 -1
- package/dist/{src-BNTToU7l.mjs → src-B8lf1kiR.mjs} +1507 -1166
- package/dist/src-B8lf1kiR.mjs.map +1 -0
- package/dist/{src-5w9QR6_8.mjs → src-BOLdi3WG.mjs} +105 -237
- package/dist/src-BOLdi3WG.mjs.map +1 -0
- package/dist/{src-BR4xNwdG.mjs → src-BXeTHHlL.mjs} +20240 -25437
- package/dist/src-BXeTHHlL.mjs.map +1 -0
- package/dist/{src-DKp-_OFG.mjs → src-BqeBFB3X.mjs} +90 -47
- package/dist/src-BqeBFB3X.mjs.map +1 -0
- package/dist/src-DbqcSrhy.mjs +3901 -0
- package/dist/src-DbqcSrhy.mjs.map +1 -0
- package/dist/{steps-Bp2uNqnn.d.mts → steps-B2kBmFpb.d.mts} +1 -1
- package/dist/{steps-Bp2uNqnn.d.mts.map → steps-B2kBmFpb.d.mts.map} +1 -1
- package/dist/{svg-Cz0UXcDj.mjs → svg-NmV9dgB9.mjs} +1 -1
- package/dist/{svg-Cz0UXcDj.mjs.map → svg-NmV9dgB9.mjs.map} +1 -1
- package/dist/{svg-g1D6ErwR.d.mts → svg-VUr78l5d.d.mts} +1 -1
- package/dist/{svg-g1D6ErwR.d.mts.map → svg-VUr78l5d.d.mts.map} +1 -1
- package/dist/term.d.mts +2 -2
- package/dist/term.mjs +3 -8
- package/dist/test.d.mts +673 -0
- package/dist/test.d.mts.map +1 -0
- package/dist/test.mjs +2829 -0
- package/dist/test.mjs.map +1 -0
- package/dist/theme.d.mts +2 -2
- package/dist/theme.d.mts.map +1 -1
- package/dist/theme.mjs +3 -8
- package/dist/{types-kt_fKR37.d.mts → types-D_E0FbqA.d.mts} +1 -1
- package/dist/{types-kt_fKR37.d.mts.map → types-D_E0FbqA.d.mts.map} +1 -1
- package/dist/ui/animation.d.mts +2 -2
- package/dist/ui/animation.mjs +1 -1
- package/dist/ui/ansi.d.mts +1 -1
- package/dist/ui/ansi.mjs +1 -1
- package/dist/ui/cli.d.mts +3 -3
- package/dist/ui/cli.mjs +5 -5
- package/dist/ui/image.d.mts +1 -1
- package/dist/ui/image.mjs +1 -1
- package/dist/ui/progress.d.mts +4 -4
- package/dist/ui/progress.mjs +4 -4
- package/dist/ui/react.d.mts +1 -1
- package/dist/ui/react.mjs +2 -2
- package/dist/ui/recording-chrome-react.d.mts +1 -1
- package/dist/ui/recording-chrome-react.mjs +2 -2
- package/dist/ui/recording-chrome.d.mts +1 -1
- package/dist/ui/recording-chrome.mjs +1 -1
- package/dist/ui/utils.mjs +1 -1
- package/dist/ui/wrappers.d.mts +2 -2
- package/dist/ui/wrappers.mjs +1 -1
- package/dist/ui.d.mts +6 -6
- package/dist/ui.mjs +7 -7
- package/dist/unicode-CxyxVGmB.mjs +11077 -0
- package/dist/unicode-CxyxVGmB.mjs.map +1 -0
- package/dist/{useLatest-DRDDVwjh.d.mts → useLatest-UOvWy0ZW.d.mts} +2 -2
- package/dist/{useLatest-DRDDVwjh.d.mts.map → useLatest-UOvWy0ZW.d.mts.map} +1 -1
- package/dist/useLayout-D5cE8OCI.mjs +424 -0
- package/dist/useLayout-D5cE8OCI.mjs.map +1 -0
- package/dist/{with-text-input-YeohVLeo.d.mts → with-text-input-DLoSCBrm.d.mts} +3 -3
- package/dist/{with-text-input-YeohVLeo.d.mts.map → with-text-input-DLoSCBrm.d.mts.map} +1 -1
- package/dist/wrap-measurer-registration-IV2HtcCd.d.mts +3106 -0
- package/dist/wrap-measurer-registration-IV2HtcCd.d.mts.map +1 -0
- package/dist/{wrapper-C70ATkVv.mjs → wrapper-CD29afOs.mjs} +59 -17
- package/dist/wrapper-CD29afOs.mjs.map +1 -0
- package/dist/{wrappers-BCUYITrY.mjs → wrappers-CInBJm44.mjs} +18 -8
- package/dist/wrappers-CInBJm44.mjs.map +1 -0
- package/dist/{yoga-adapter-BnZX1PAY.mjs → yoga-adapter-9uab5Qn-.mjs} +2 -2
- package/dist/{yoga-adapter-BnZX1PAY.mjs.map → yoga-adapter-9uab5Qn-.mjs.map} +1 -1
- package/dist/yoga-adapter-yqTl1aXK.mjs +2 -0
- package/package.json +59 -14
- package/dist/Text-Lq0dmj8-.mjs.map +0 -1
- package/dist/UPNG-Bo33r8rA.mjs +0 -3
- package/dist/UPNG-DosRPdF4.mjs.map +0 -1
- package/dist/__vite-browser-external-2447137e-D_JM6skp.mjs +0 -6
- package/dist/__vite-browser-external-2447137e-D_JM6skp.mjs.map +0 -1
- package/dist/ansi-yC4RyBNY.mjs +0 -22441
- package/dist/ansi-yC4RyBNY.mjs.map +0 -1
- package/dist/apng-CR08rIaH.mjs +0 -58
- package/dist/apng-CR08rIaH.mjs.map +0 -1
- package/dist/apng-DaHfVaVI.mjs +0 -3
- package/dist/assets/resvgjs.darwin-arm64-BtufyGW1.node +0 -0
- package/dist/assets/skia.darwin-arm64-DQs5sT6N.node +0 -0
- package/dist/backends-CUtan80W.mjs +0 -3
- package/dist/backends-DIVYzKqd.mjs +0 -1083
- package/dist/backends-DIVYzKqd.mjs.map +0 -1
- package/dist/bound-term-0sPrrzH1.d.mts.map +0 -1
- package/dist/canvas-1v7dPT-_.mjs +0 -3
- package/dist/canvas-CSuPOMNt.mjs +0 -1442
- package/dist/canvas-CSuPOMNt.mjs.map +0 -1
- package/dist/cli-dvo0r2fs.mjs +0 -4
- package/dist/compare-CQodSH4G.mjs +0 -376
- package/dist/compare-CQodSH4G.mjs.map +0 -1
- package/dist/compare-DHlcxEYA.mjs +0 -3
- package/dist/devtools-CJdt5H0X.mjs +0 -2
- package/dist/fonts-BFmhXDv7.mjs +0 -88
- package/dist/fonts-BFmhXDv7.mjs.map +0 -1
- package/dist/gif-C_AjaT9d.mjs +0 -188
- package/dist/gif-C_AjaT9d.mjs.map +0 -1
- package/dist/gif-DaC4XrxA.mjs +0 -3
- package/dist/gifenc-BOUT-KFB.mjs +0 -730
- package/dist/gifenc-BOUT-KFB.mjs.map +0 -1
- package/dist/image-C2Birh2x.mjs +0 -1252
- package/dist/image-C2Birh2x.mjs.map +0 -1
- package/dist/index-CSQf13CI.d.mts.map +0 -1
- package/dist/index-Cl9KKjQ_.d.mts.map +0 -1
- package/dist/key-mapping-CS-YD_cD.mjs +0 -132
- package/dist/key-mapping-CS-YD_cD.mjs.map +0 -1
- package/dist/key-mapping-Yn-Jgrij.mjs +0 -3
- package/dist/layout-signals-Cnw6xk8Q.mjs.map +0 -1
- package/dist/mouse-events-Dki3ISIp.mjs.map +0 -1
- package/dist/playwright-D5YiZcNS.mjs +0 -76397
- package/dist/playwright-D5YiZcNS.mjs.map +0 -1
- package/dist/png-codec-Dp84742B.mjs +0 -36
- package/dist/png-codec-Dp84742B.mjs.map +0 -1
- package/dist/png-codec-QwOtJ8Zs.mjs +0 -3
- package/dist/rasterizer-BRXrDdWx.mjs +0 -3
- package/dist/rasterizer-CpEhJvdR.mjs +0 -296
- package/dist/rasterizer-CpEhJvdR.mjs.map +0 -1
- package/dist/reconciler-DldIJB93.mjs.map +0 -1
- package/dist/render-string-DkQacASz.mjs.map +0 -1
- package/dist/resvg-js-DkOndZI3.mjs +0 -203
- package/dist/resvg-js-DkOndZI3.mjs.map +0 -1
- package/dist/schemes-JjNp4aSl.mjs +0 -2611
- package/dist/src-5w9QR6_8.mjs.map +0 -1
- package/dist/src-BNTToU7l.mjs.map +0 -1
- package/dist/src-BR4xNwdG.mjs.map +0 -1
- package/dist/src-DKp-_OFG.mjs.map +0 -1
- package/dist/src-bt8wSrfJ.mjs +0 -258
- package/dist/src-bt8wSrfJ.mjs.map +0 -1
- package/dist/src-e33Y6kNJ.mjs +0 -3
- package/dist/src-iDwu25UD.mjs +0 -1814
- package/dist/src-iDwu25UD.mjs.map +0 -1
- package/dist/svg-15lZZzxq.mjs +0 -486
- package/dist/svg-15lZZzxq.mjs.map +0 -1
- package/dist/svg-DY72a4HK.mjs +0 -3
- package/dist/term.mjs.map +0 -1
- package/dist/theme.mjs.map +0 -1
- package/dist/ui/display.d.mts +0 -35
- package/dist/ui/display.d.mts.map +0 -1
- package/dist/ui/display.mjs +0 -123
- package/dist/ui/display.mjs.map +0 -1
- package/dist/ui/input.d.mts +0 -184
- package/dist/ui/input.d.mts.map +0 -1
- package/dist/ui/input.mjs +0 -285
- package/dist/ui/input.mjs.map +0 -1
- package/dist/wrapper-C70ATkVv.mjs.map +0 -1
- package/dist/wrappers-BCUYITrY.mjs.map +0 -1
- package/dist/yoga-adapter-DxgsQ_gg.mjs +0 -2
- package/dist/zipBundle-3nqeDRtm.mjs +0 -3
- package/dist/zipBundle-VNAYFmqJ.mjs +0 -2003
- package/dist/zipBundle-VNAYFmqJ.mjs.map +0 -1
|
@@ -1,29 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { blend, brighten, checkContrast, colorDistance, complement, contrastFg, darken, deltaE, ensureContrast, hexToOklch, hexToRgb as hexToRgb$1, oklchToHex, relativeLuminance } from "@silvery/color";
|
|
1
|
+
import { blend, brighten, checkContrast, colorDistance, complement, contrastFg, darken, deltaE, ensureContrast, hexToOklch, hexToRgb as hexToRgb$1, mixSrgb, oklchToHex, relativeLuminance } from "@silvery/color";
|
|
3
2
|
import "string-width";
|
|
4
3
|
//#region packages/ansi/src/constants.ts
|
|
5
4
|
/**
|
|
5
|
+
* ANSI escape code constants for extended terminal features.
|
|
6
|
+
*
|
|
7
|
+
* @see https://sw.kovidgoyal.net/kitty/underlines/
|
|
8
|
+
* @see https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Extended underline style codes.
|
|
12
|
+
* Uses colon-separated parameters (ISO 8613-6): \x1b[4:Nm
|
|
13
|
+
*/
|
|
14
|
+
const UNDERLINE_CODES = {
|
|
15
|
+
none: "\x1B[4:0m",
|
|
16
|
+
single: "\x1B[4:1m",
|
|
17
|
+
double: "\x1B[4:2m",
|
|
18
|
+
curly: "\x1B[4:3m",
|
|
19
|
+
dotted: "\x1B[4:4m",
|
|
20
|
+
dashed: "\x1B[4:5m",
|
|
21
|
+
reset: "\x1B[4:0m"
|
|
22
|
+
};
|
|
23
|
+
/** Standard underline on (SGR 4) - works on all terminals */
|
|
24
|
+
const UNDERLINE_STANDARD = "\x1B[4m";
|
|
25
|
+
/** Standard underline off (SGR 24) */
|
|
26
|
+
const UNDERLINE_RESET_STANDARD = "\x1B[24m";
|
|
27
|
+
/**
|
|
28
|
+
* Reset underline color to default (SGR 59)
|
|
29
|
+
*/
|
|
30
|
+
const UNDERLINE_COLOR_RESET = "\x1B[59m";
|
|
31
|
+
/**
|
|
6
32
|
* Build underline color escape code for RGB values.
|
|
7
33
|
* Format: \x1b[58:2::r:g:bm (SGR 58 with RGB color space)
|
|
8
34
|
*/
|
|
9
35
|
function buildUnderlineColorCode(r, g, b) {
|
|
10
36
|
return `\x1b[58:2::${r}:${g}:${b}m`;
|
|
11
37
|
}
|
|
12
|
-
var UNDERLINE_CODES, UNDERLINE_STANDARD, UNDERLINE_RESET_STANDARD, UNDERLINE_COLOR_RESET;
|
|
13
|
-
var init_constants = __esmMin((() => {
|
|
14
|
-
UNDERLINE_CODES = {
|
|
15
|
-
none: "\x1B[4:0m",
|
|
16
|
-
single: "\x1B[4:1m",
|
|
17
|
-
double: "\x1B[4:2m",
|
|
18
|
-
curly: "\x1B[4:3m",
|
|
19
|
-
dotted: "\x1B[4:4m",
|
|
20
|
-
dashed: "\x1B[4:5m",
|
|
21
|
-
reset: "\x1B[4:0m"
|
|
22
|
-
};
|
|
23
|
-
UNDERLINE_STANDARD = "\x1B[4m";
|
|
24
|
-
UNDERLINE_RESET_STANDARD = "\x1B[24m";
|
|
25
|
-
UNDERLINE_COLOR_RESET = "\x1B[59m";
|
|
26
|
-
}));
|
|
27
38
|
//#endregion
|
|
28
39
|
//#region packages/ansi/src/caps.ts
|
|
29
40
|
/**
|
|
@@ -63,7 +74,6 @@ function defaultCaps() {
|
|
|
63
74
|
maybeWideEmojis: true
|
|
64
75
|
};
|
|
65
76
|
}
|
|
66
|
-
var init_caps = __esmMin((() => {}));
|
|
67
77
|
//#endregion
|
|
68
78
|
//#region packages/ansi/src/emulator.ts
|
|
69
79
|
/**
|
|
@@ -77,7 +87,6 @@ function defaultEmulator() {
|
|
|
77
87
|
TERM: ""
|
|
78
88
|
};
|
|
79
89
|
}
|
|
80
|
-
var init_emulator = __esmMin((() => {}));
|
|
81
90
|
//#endregion
|
|
82
91
|
//#region packages/ansi/src/theme/invariants.ts
|
|
83
92
|
/**
|
|
@@ -105,6 +114,187 @@ var init_emulator = __esmMin((() => {}));
|
|
|
105
114
|
* bakeFlat pipeline. No concat-kebab legacy names (`primaryfg`, `mutedbg`, …)
|
|
106
115
|
* — those were removed in silvery 0.19.0 (Sterling interior migration).
|
|
107
116
|
*/
|
|
117
|
+
const AA_RATIO = 4.5;
|
|
118
|
+
const FAINT_RATIO = 1.5;
|
|
119
|
+
const SELECTION_DELTA_L$1 = .08;
|
|
120
|
+
const CURSOR_DELTA_E$1 = .15;
|
|
121
|
+
/**
|
|
122
|
+
* Contrast invariant pairs — all Sterling flat-token keys.
|
|
123
|
+
*
|
|
124
|
+
* These keys are populated on every Theme at derivation time via `bakeFlat`;
|
|
125
|
+
* bracket access (`theme["bg-accent"]`) is the canonical lookup form and is
|
|
126
|
+
* what `validateThemeInvariants` uses below.
|
|
127
|
+
*/
|
|
128
|
+
const CONTRAST_PAIRS = [
|
|
129
|
+
{
|
|
130
|
+
rule: "contrast:fg/bg",
|
|
131
|
+
fg: "fg",
|
|
132
|
+
bg: "bg",
|
|
133
|
+
min: AA_RATIO
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
rule: "contrast:fg/bg-surface-default",
|
|
137
|
+
fg: "fg",
|
|
138
|
+
bg: "bg-surface-default",
|
|
139
|
+
min: AA_RATIO
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
rule: "contrast:fg/bg-surface-subtle",
|
|
143
|
+
fg: "fg",
|
|
144
|
+
bg: "bg-surface-subtle",
|
|
145
|
+
min: AA_RATIO
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
rule: "contrast:fg/bg-surface-raised",
|
|
149
|
+
fg: "fg",
|
|
150
|
+
bg: "bg-surface-raised",
|
|
151
|
+
min: AA_RATIO
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
rule: "contrast:fg/bg-surface-hover",
|
|
155
|
+
fg: "fg",
|
|
156
|
+
bg: "bg-surface-hover",
|
|
157
|
+
min: AA_RATIO
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
rule: "contrast:fg/bg-surface-overlay",
|
|
161
|
+
fg: "fg",
|
|
162
|
+
bg: "bg-surface-overlay",
|
|
163
|
+
min: AA_RATIO
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
rule: "contrast:fg/bg-muted",
|
|
167
|
+
fg: "fg",
|
|
168
|
+
bg: "bg-muted",
|
|
169
|
+
min: AA_RATIO
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
rule: "contrast:fg-muted/bg",
|
|
173
|
+
fg: "fg-muted",
|
|
174
|
+
bg: "bg",
|
|
175
|
+
min: 3
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
rule: "contrast:fg-muted/bg-muted",
|
|
179
|
+
fg: "fg-muted",
|
|
180
|
+
bg: "bg-muted",
|
|
181
|
+
min: 3
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
rule: "contrast:fg-accent/bg",
|
|
185
|
+
fg: "fg-accent",
|
|
186
|
+
bg: "bg",
|
|
187
|
+
min: AA_RATIO
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
rule: "contrast:fg-error/bg",
|
|
191
|
+
fg: "fg-error",
|
|
192
|
+
bg: "bg",
|
|
193
|
+
min: AA_RATIO
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
rule: "contrast:fg-warning/bg",
|
|
197
|
+
fg: "fg-warning",
|
|
198
|
+
bg: "bg",
|
|
199
|
+
min: AA_RATIO
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
rule: "contrast:fg-success/bg",
|
|
203
|
+
fg: "fg-success",
|
|
204
|
+
bg: "bg",
|
|
205
|
+
min: AA_RATIO
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
rule: "contrast:fg-info/bg",
|
|
209
|
+
fg: "fg-info",
|
|
210
|
+
bg: "bg",
|
|
211
|
+
min: AA_RATIO
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
rule: "contrast:fg-on-accent/bg-accent",
|
|
215
|
+
fg: "fg-on-accent",
|
|
216
|
+
bg: "bg-accent",
|
|
217
|
+
min: AA_RATIO
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
rule: "contrast:fg-on-error/bg-error",
|
|
221
|
+
fg: "fg-on-error",
|
|
222
|
+
bg: "bg-error",
|
|
223
|
+
min: AA_RATIO
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
rule: "contrast:fg-on-warning/bg-warning",
|
|
227
|
+
fg: "fg-on-warning",
|
|
228
|
+
bg: "bg-warning",
|
|
229
|
+
min: AA_RATIO
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
rule: "contrast:fg-on-success/bg-success",
|
|
233
|
+
fg: "fg-on-success",
|
|
234
|
+
bg: "bg-success",
|
|
235
|
+
min: AA_RATIO
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
rule: "contrast:fg-on-info/bg-info",
|
|
239
|
+
fg: "fg-on-info",
|
|
240
|
+
bg: "bg-info",
|
|
241
|
+
min: AA_RATIO
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
rule: "contrast:fg-on-selected/bg-selected",
|
|
245
|
+
fg: "fg-on-selected",
|
|
246
|
+
bg: "bg-selected",
|
|
247
|
+
min: AA_RATIO
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
rule: "contrast:fg-on-inverse/bg-inverse",
|
|
251
|
+
fg: "fg-on-inverse",
|
|
252
|
+
bg: "bg-inverse",
|
|
253
|
+
min: AA_RATIO
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
rule: "contrast:fg-on-inverse/bg-inverse-hover",
|
|
257
|
+
fg: "fg-on-inverse",
|
|
258
|
+
bg: "bg-inverse-hover",
|
|
259
|
+
min: AA_RATIO
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
rule: "contrast:fg-on-inverse-muted/bg-inverse",
|
|
263
|
+
fg: "fg-on-inverse-muted",
|
|
264
|
+
bg: "bg-inverse",
|
|
265
|
+
min: 3
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
rule: "contrast:fg-on-inverse-muted/bg-inverse-hover",
|
|
269
|
+
fg: "fg-on-inverse-muted",
|
|
270
|
+
bg: "bg-inverse-hover",
|
|
271
|
+
min: 3
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
rule: "contrast:fg-cursor/bg-cursor",
|
|
275
|
+
fg: "fg-cursor",
|
|
276
|
+
bg: "bg-cursor",
|
|
277
|
+
min: AA_RATIO
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
rule: "contrast:border-default/bg",
|
|
281
|
+
fg: "border-default",
|
|
282
|
+
bg: "bg",
|
|
283
|
+
min: 3
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
rule: "contrast:border-focus/bg",
|
|
287
|
+
fg: "border-focus",
|
|
288
|
+
bg: "bg",
|
|
289
|
+
min: 3
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
rule: "contrast:border-muted/bg",
|
|
293
|
+
fg: "border-muted",
|
|
294
|
+
bg: "bg",
|
|
295
|
+
min: FAINT_RATIO
|
|
296
|
+
}
|
|
297
|
+
];
|
|
108
298
|
function lightness(hex) {
|
|
109
299
|
const o = hexToOklch(hex);
|
|
110
300
|
return o ? o.L : null;
|
|
@@ -196,167 +386,18 @@ function formatViolations(violations) {
|
|
|
196
386
|
if (violations.length === 0) return "";
|
|
197
387
|
return violations.map((v) => ` - [${v.rule}] ${v.message}`).join("\n");
|
|
198
388
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
{
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
rule: "contrast:fg/bg-surface-default",
|
|
214
|
-
fg: "fg",
|
|
215
|
-
bg: "bg-surface-default",
|
|
216
|
-
min: AA_RATIO
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
rule: "contrast:fg/bg-surface-subtle",
|
|
220
|
-
fg: "fg",
|
|
221
|
-
bg: "bg-surface-subtle",
|
|
222
|
-
min: AA_RATIO
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
rule: "contrast:fg/bg-surface-raised",
|
|
226
|
-
fg: "fg",
|
|
227
|
-
bg: "bg-surface-raised",
|
|
228
|
-
min: AA_RATIO
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
rule: "contrast:fg/bg-surface-hover",
|
|
232
|
-
fg: "fg",
|
|
233
|
-
bg: "bg-surface-hover",
|
|
234
|
-
min: AA_RATIO
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
rule: "contrast:fg/bg-surface-overlay",
|
|
238
|
-
fg: "fg",
|
|
239
|
-
bg: "bg-surface-overlay",
|
|
240
|
-
min: AA_RATIO
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
rule: "contrast:fg/bg-muted",
|
|
244
|
-
fg: "fg",
|
|
245
|
-
bg: "bg-muted",
|
|
246
|
-
min: AA_RATIO
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
rule: "contrast:fg-muted/bg",
|
|
250
|
-
fg: "fg-muted",
|
|
251
|
-
bg: "bg",
|
|
252
|
-
min: 3
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
rule: "contrast:fg-muted/bg-muted",
|
|
256
|
-
fg: "fg-muted",
|
|
257
|
-
bg: "bg-muted",
|
|
258
|
-
min: 3
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
rule: "contrast:fg-accent/bg",
|
|
262
|
-
fg: "fg-accent",
|
|
263
|
-
bg: "bg",
|
|
264
|
-
min: AA_RATIO
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
rule: "contrast:fg-error/bg",
|
|
268
|
-
fg: "fg-error",
|
|
269
|
-
bg: "bg",
|
|
270
|
-
min: AA_RATIO
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
rule: "contrast:fg-warning/bg",
|
|
274
|
-
fg: "fg-warning",
|
|
275
|
-
bg: "bg",
|
|
276
|
-
min: AA_RATIO
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
rule: "contrast:fg-success/bg",
|
|
280
|
-
fg: "fg-success",
|
|
281
|
-
bg: "bg",
|
|
282
|
-
min: AA_RATIO
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
rule: "contrast:fg-info/bg",
|
|
286
|
-
fg: "fg-info",
|
|
287
|
-
bg: "bg",
|
|
288
|
-
min: AA_RATIO
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
rule: "contrast:fg-on-accent/bg-accent",
|
|
292
|
-
fg: "fg-on-accent",
|
|
293
|
-
bg: "bg-accent",
|
|
294
|
-
min: AA_RATIO
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
rule: "contrast:fg-on-error/bg-error",
|
|
298
|
-
fg: "fg-on-error",
|
|
299
|
-
bg: "bg-error",
|
|
300
|
-
min: AA_RATIO
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
rule: "contrast:fg-on-warning/bg-warning",
|
|
304
|
-
fg: "fg-on-warning",
|
|
305
|
-
bg: "bg-warning",
|
|
306
|
-
min: AA_RATIO
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
rule: "contrast:fg-on-success/bg-success",
|
|
310
|
-
fg: "fg-on-success",
|
|
311
|
-
bg: "bg-success",
|
|
312
|
-
min: AA_RATIO
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
rule: "contrast:fg-on-info/bg-info",
|
|
316
|
-
fg: "fg-on-info",
|
|
317
|
-
bg: "bg-info",
|
|
318
|
-
min: AA_RATIO
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
rule: "contrast:fg-on-selected/bg-selected",
|
|
322
|
-
fg: "fg-on-selected",
|
|
323
|
-
bg: "bg-selected",
|
|
324
|
-
min: AA_RATIO
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
rule: "contrast:fg-cursor/bg-cursor",
|
|
328
|
-
fg: "fg-cursor",
|
|
329
|
-
bg: "bg-cursor",
|
|
330
|
-
min: AA_RATIO
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
rule: "contrast:border-default/bg",
|
|
334
|
-
fg: "border-default",
|
|
335
|
-
bg: "bg",
|
|
336
|
-
min: 3
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
rule: "contrast:border-focus/bg",
|
|
340
|
-
fg: "border-focus",
|
|
341
|
-
bg: "bg",
|
|
342
|
-
min: 3
|
|
343
|
-
},
|
|
344
|
-
{
|
|
345
|
-
rule: "contrast:border-muted/bg",
|
|
346
|
-
fg: "border-muted",
|
|
347
|
-
bg: "bg",
|
|
348
|
-
min: FAINT_RATIO
|
|
349
|
-
}
|
|
350
|
-
];
|
|
351
|
-
ThemeInvariantError = class extends Error {
|
|
352
|
-
violations;
|
|
353
|
-
constructor(violations) {
|
|
354
|
-
super(`Theme invariants failed (${violations.length} violation${violations.length === 1 ? "" : "s"}):\n${formatViolations(violations)}`);
|
|
355
|
-
this.name = "ThemeInvariantError";
|
|
356
|
-
this.violations = violations;
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
}));
|
|
389
|
+
/**
|
|
390
|
+
* Thrown by `loadTheme({ mode: "strict" })` when invariants fail.
|
|
391
|
+
* Carries the violations array for programmatic inspection.
|
|
392
|
+
*/
|
|
393
|
+
var ThemeInvariantError = class extends Error {
|
|
394
|
+
violations;
|
|
395
|
+
constructor(violations) {
|
|
396
|
+
super(`Theme invariants failed (${violations.length} violation${violations.length === 1 ? "" : "s"}):\n${formatViolations(violations)}`);
|
|
397
|
+
this.name = "ThemeInvariantError";
|
|
398
|
+
this.violations = violations;
|
|
399
|
+
}
|
|
400
|
+
};
|
|
360
401
|
//#endregion
|
|
361
402
|
//#region packages/ansi/src/theme/derived.ts
|
|
362
403
|
/**
|
|
@@ -372,6 +413,40 @@ var init_invariants = __esmMin((() => {
|
|
|
372
413
|
* Canonical authority: derive.ts truecolor path. ANSI16 paths are aligned to
|
|
373
414
|
* deriveAnsi16Theme output (which is itself the canonical ANSI16 reference).
|
|
374
415
|
*/
|
|
416
|
+
/** Default typography variants — token-based, works across any theme. */
|
|
417
|
+
const DEFAULT_VARIANTS$1 = {
|
|
418
|
+
h1: {
|
|
419
|
+
color: "$primary",
|
|
420
|
+
bold: true
|
|
421
|
+
},
|
|
422
|
+
h2: {
|
|
423
|
+
color: "$accent",
|
|
424
|
+
bold: true
|
|
425
|
+
},
|
|
426
|
+
h3: { bold: true },
|
|
427
|
+
body: {},
|
|
428
|
+
"body-muted": { color: "$muted" },
|
|
429
|
+
"fine-print": {
|
|
430
|
+
color: "$muted",
|
|
431
|
+
dim: true
|
|
432
|
+
},
|
|
433
|
+
strong: { bold: true },
|
|
434
|
+
em: { italic: true },
|
|
435
|
+
link: {
|
|
436
|
+
color: "$fg-link",
|
|
437
|
+
underlineStyle: "single"
|
|
438
|
+
},
|
|
439
|
+
key: {
|
|
440
|
+
color: "$accent",
|
|
441
|
+
bold: true
|
|
442
|
+
},
|
|
443
|
+
code: { backgroundColor: "$mutedbg" },
|
|
444
|
+
kbd: {
|
|
445
|
+
backgroundColor: "$mutedbg",
|
|
446
|
+
color: "$accent",
|
|
447
|
+
bold: true
|
|
448
|
+
}
|
|
449
|
+
};
|
|
375
450
|
/**
|
|
376
451
|
* Derive the shared "delta" fields common to every theme object:
|
|
377
452
|
* brand tokens, categorical ring, state variants, and typography variants.
|
|
@@ -408,42 +483,6 @@ function deriveFields(input) {
|
|
|
408
483
|
variants: DEFAULT_VARIANTS$1
|
|
409
484
|
};
|
|
410
485
|
}
|
|
411
|
-
var DEFAULT_VARIANTS$1;
|
|
412
|
-
var init_derived = __esmMin((() => {
|
|
413
|
-
DEFAULT_VARIANTS$1 = {
|
|
414
|
-
h1: {
|
|
415
|
-
color: "$primary",
|
|
416
|
-
bold: true
|
|
417
|
-
},
|
|
418
|
-
h2: {
|
|
419
|
-
color: "$accent",
|
|
420
|
-
bold: true
|
|
421
|
-
},
|
|
422
|
-
h3: { bold: true },
|
|
423
|
-
body: {},
|
|
424
|
-
"body-muted": { color: "$muted" },
|
|
425
|
-
"fine-print": {
|
|
426
|
-
color: "$muted",
|
|
427
|
-
dim: true
|
|
428
|
-
},
|
|
429
|
-
strong: { bold: true },
|
|
430
|
-
em: { italic: true },
|
|
431
|
-
link: {
|
|
432
|
-
color: "$fg-link",
|
|
433
|
-
underlineStyle: "single"
|
|
434
|
-
},
|
|
435
|
-
key: {
|
|
436
|
-
color: "$accent",
|
|
437
|
-
bold: true
|
|
438
|
-
},
|
|
439
|
-
code: { backgroundColor: "$mutedbg" },
|
|
440
|
-
kbd: {
|
|
441
|
-
backgroundColor: "$mutedbg",
|
|
442
|
-
color: "$accent",
|
|
443
|
-
bold: true
|
|
444
|
-
}
|
|
445
|
-
};
|
|
446
|
-
}));
|
|
447
486
|
//#endregion
|
|
448
487
|
//#region packages/ansi/src/sterling/contrast.ts
|
|
449
488
|
/**
|
|
@@ -460,6 +499,18 @@ var init_derived = __esmMin((() => {
|
|
|
460
499
|
* from auto-lift and from strict-mode enforcement — the author accepts the
|
|
461
500
|
* contrast consequence of pinning.
|
|
462
501
|
*/
|
|
502
|
+
/** WCAG AA threshold for normal text. */
|
|
503
|
+
const WCAG_AA = 4.5;
|
|
504
|
+
var ContrastError = class extends Error {
|
|
505
|
+
violations;
|
|
506
|
+
constructor(violations) {
|
|
507
|
+
const summary = violations.slice(0, 5).map((v) => `${v.token}: ${v.ratio.toFixed(2)} < ${v.target} (fg=${v.fg}, bg=${v.bg})`).join("; ");
|
|
508
|
+
const extra = violations.length > 5 ? ` (+${violations.length - 5} more)` : "";
|
|
509
|
+
super(`Sterling contrast: ${violations.length} violation(s): ${summary}${extra}`);
|
|
510
|
+
this.name = "ContrastError";
|
|
511
|
+
this.violations = violations;
|
|
512
|
+
}
|
|
513
|
+
};
|
|
463
514
|
/**
|
|
464
515
|
* Verify `fg` on `bg` meets `target` ratio. Returns `null` when already
|
|
465
516
|
* passing; otherwise returns a ContrastViolation.
|
|
@@ -502,20 +553,6 @@ function autoLift(fg, bg, target = WCAG_AA) {
|
|
|
502
553
|
lifted: adjusted !== fg
|
|
503
554
|
};
|
|
504
555
|
}
|
|
505
|
-
var WCAG_AA, ContrastError;
|
|
506
|
-
var init_contrast = __esmMin((() => {
|
|
507
|
-
WCAG_AA = 4.5;
|
|
508
|
-
ContrastError = class extends Error {
|
|
509
|
-
violations;
|
|
510
|
-
constructor(violations) {
|
|
511
|
-
const summary = violations.slice(0, 5).map((v) => `${v.token}: ${v.ratio.toFixed(2)} < ${v.target} (fg=${v.fg}, bg=${v.bg})`).join("; ");
|
|
512
|
-
const extra = violations.length > 5 ? ` (+${violations.length - 5} more)` : "";
|
|
513
|
-
super(`Sterling contrast: ${violations.length} violation(s): ${summary}${extra}`);
|
|
514
|
-
this.name = "ContrastError";
|
|
515
|
-
this.violations = violations;
|
|
516
|
-
}
|
|
517
|
-
};
|
|
518
|
-
}));
|
|
519
556
|
//#endregion
|
|
520
557
|
//#region packages/ansi/src/sterling/derive.ts
|
|
521
558
|
/**
|
|
@@ -545,6 +582,59 @@ var init_contrast = __esmMin((() => {
|
|
|
545
582
|
* auto-lift; they're written verbatim onto the Theme.
|
|
546
583
|
*/
|
|
547
584
|
/**
|
|
585
|
+
* Default typography variants — token-based, works across any Sterling theme.
|
|
586
|
+
* Consumed by `<Text variant="h1">` via the theme's `variants` record.
|
|
587
|
+
*
|
|
588
|
+
* Keys use Sterling flat-token names in their color slots (`$fg-accent`,
|
|
589
|
+
* `$fg-muted`, `$bg-muted`) so the defaults resolve against every Sterling-
|
|
590
|
+
* derived Theme without further wiring.
|
|
591
|
+
*/
|
|
592
|
+
const DEFAULT_VARIANTS = {
|
|
593
|
+
h1: {
|
|
594
|
+
color: "$fg-accent",
|
|
595
|
+
bold: true
|
|
596
|
+
},
|
|
597
|
+
h2: {
|
|
598
|
+
color: "$fg-accent",
|
|
599
|
+
bold: true
|
|
600
|
+
},
|
|
601
|
+
h3: { bold: true },
|
|
602
|
+
h4: {
|
|
603
|
+
color: "$fg-muted",
|
|
604
|
+
bold: true
|
|
605
|
+
},
|
|
606
|
+
h5: {
|
|
607
|
+
color: "$fg-muted",
|
|
608
|
+
italic: true
|
|
609
|
+
},
|
|
610
|
+
h6: {
|
|
611
|
+
color: "$fg-muted",
|
|
612
|
+
dim: true
|
|
613
|
+
},
|
|
614
|
+
body: {},
|
|
615
|
+
"body-muted": { color: "$fg-muted" },
|
|
616
|
+
"fine-print": {
|
|
617
|
+
color: "$fg-muted",
|
|
618
|
+
dim: true
|
|
619
|
+
},
|
|
620
|
+
strong: { bold: true },
|
|
621
|
+
em: { italic: true },
|
|
622
|
+
link: {
|
|
623
|
+
color: "$fg-accent",
|
|
624
|
+
underlineStyle: "single"
|
|
625
|
+
},
|
|
626
|
+
key: {
|
|
627
|
+
color: "$fg-accent",
|
|
628
|
+
bold: true
|
|
629
|
+
},
|
|
630
|
+
code: { backgroundColor: "$bg-muted" },
|
|
631
|
+
kbd: {
|
|
632
|
+
backgroundColor: "$bg-muted",
|
|
633
|
+
color: "$fg-accent",
|
|
634
|
+
bold: true
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
/**
|
|
548
638
|
* Build the 16-slot ANSI palette from a ColorScheme. Indexed `$color0` …
|
|
549
639
|
* `$color15` by the framework's token resolver.
|
|
550
640
|
*/
|
|
@@ -734,6 +824,35 @@ function guardTarget(nestedPath, flatPath, rule, inputs, value, against, target,
|
|
|
734
824
|
});
|
|
735
825
|
return finalValue;
|
|
736
826
|
}
|
|
827
|
+
/** Whether a foreground clears `target` against every supplied surface. */
|
|
828
|
+
function clearsEverySurface(value, surfaces, target) {
|
|
829
|
+
return surfaces.every((surface) => checkAA("contrast-bounded mix", value, surface, target) === null);
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Preserve an alpha-like sRGB mix as far as its readability budget allows.
|
|
833
|
+
*
|
|
834
|
+
* `maxMix` is the desired amount of `toward` color. When that exact mix falls
|
|
835
|
+
* below the contrast floor on either surface, binary-search back toward the
|
|
836
|
+
* readable foreground and return the most-deemphasized passing hex. This keeps
|
|
837
|
+
* muted text on the same color line instead of allowing a generic contrast
|
|
838
|
+
* repair to flip it to the opposite light/dark pole.
|
|
839
|
+
*/
|
|
840
|
+
function mixSrgbWithContrastFloor(foreground, toward, maxMix, surfaces, target) {
|
|
841
|
+
const desired = mixSrgb(foreground, toward, maxMix);
|
|
842
|
+
if (clearsEverySurface(desired, surfaces, target)) return desired;
|
|
843
|
+
let passingMix = 0;
|
|
844
|
+
let failingMix = maxMix;
|
|
845
|
+
let best = foreground;
|
|
846
|
+
for (let step = 0; step < 16; step++) {
|
|
847
|
+
const candidateMix = (passingMix + failingMix) / 2;
|
|
848
|
+
const candidate = mixSrgb(foreground, toward, candidateMix);
|
|
849
|
+
if (clearsEverySurface(candidate, surfaces, target)) {
|
|
850
|
+
passingMix = candidateMix;
|
|
851
|
+
best = candidate;
|
|
852
|
+
} else failingMix = candidateMix;
|
|
853
|
+
}
|
|
854
|
+
return best;
|
|
855
|
+
}
|
|
737
856
|
/**
|
|
738
857
|
* Derive a Theme's nested roles from a ColorScheme. Guardrails applied.
|
|
739
858
|
*/
|
|
@@ -783,6 +902,7 @@ function deriveRoles(scheme, opts) {
|
|
|
783
902
|
fg: guard("muted.fg", "fg-muted", "blend(fg, bg, 0.4)", [fg, bg], blend(fg, bg, .4), mutedBg, 3),
|
|
784
903
|
bg: mutedBg
|
|
785
904
|
};
|
|
905
|
+
const faint = { fg: guard("faint.fg", "fg-faint", "blend(fg, bg, 0.55)", [fg, bg], blend(fg, bg, .55), mutedBg, 1.5) };
|
|
786
906
|
const fgForSurfaceLift = ensureContrast(fg, blend(bg, fg, .08), WCAG_AA);
|
|
787
907
|
const surfaceDefault = guard("surface.default", "bg-surface-default", "scheme.background", [bg], bg);
|
|
788
908
|
const surface = {
|
|
@@ -812,9 +932,19 @@ function deriveRoles(scheme, opts) {
|
|
|
812
932
|
hover: { bg: guard("selected.hover.bg", "bg-selected-hover", `OKLCH ${shiftLabel(selectedBg)} ${selectedDeltaH.hover}L on selected.bg`, [selectedBg], shiftL(selectedBg, selectedDeltaH.hover)) }
|
|
813
933
|
};
|
|
814
934
|
const inverseBg = guard("inverse.bg", "bg-inverse", "blend(fg, bg, 0.1)", [fg, bg], blend(fg, bg, .1));
|
|
935
|
+
const inverseFgOn = guard("inverse.fgOn", "fg-on-inverse", "contrast-pick(scheme.fg/bg/BW)", [inverseBg], pickFgOn(inverseBg, scheme), inverseBg);
|
|
936
|
+
const inverseHoverBg = guard("inverse.hover.bg", "bg-inverse-hover", "mixSrgb(inverse.bg, inverse.fgOn, 0.1)", [inverseBg, inverseFgOn], mixSrgb(inverseBg, inverseFgOn, .1), inverseFgOn);
|
|
937
|
+
const inverseMutedCandidate = mixSrgbWithContrastFloor(inverseFgOn, inverseBg, .35, [inverseBg, inverseHoverBg], 3);
|
|
938
|
+
const inverseMutedFgOn = guard("inverse.muted.fgOn", "fg-on-inverse-muted", "mixSrgb(inverse.fgOn, inverse.bg, ≤0.35), bounded to ≥3:1 on inverse surfaces", [
|
|
939
|
+
inverseFgOn,
|
|
940
|
+
inverseBg,
|
|
941
|
+
inverseHoverBg
|
|
942
|
+
], inverseMutedCandidate, inverseBg, 3);
|
|
815
943
|
const inverse = {
|
|
816
944
|
bg: inverseBg,
|
|
817
|
-
fgOn:
|
|
945
|
+
fgOn: inverseFgOn,
|
|
946
|
+
hover: { bg: inverseHoverBg },
|
|
947
|
+
muted: { fgOn: inverseMutedFgOn }
|
|
818
948
|
};
|
|
819
949
|
const link = { fg: guard("link.fg", "fg-link", mode === "dark" ? "scheme.brightBlue" : "scheme.blue", [mode === "dark" ? scheme.brightBlue : scheme.blue], mode === "dark" ? scheme.brightBlue : scheme.blue, bg) };
|
|
820
950
|
const fgDisabledRaw = blend(surfaceDefault, fg, .38);
|
|
@@ -828,6 +958,7 @@ function deriveRoles(scheme, opts) {
|
|
|
828
958
|
warning,
|
|
829
959
|
error,
|
|
830
960
|
muted,
|
|
961
|
+
faint,
|
|
831
962
|
surface,
|
|
832
963
|
border,
|
|
833
964
|
cursor,
|
|
@@ -845,6 +976,7 @@ function deriveRoles(scheme, opts) {
|
|
|
845
976
|
violations
|
|
846
977
|
};
|
|
847
978
|
}
|
|
979
|
+
const SELECTION_DELTA_L = .08;
|
|
848
980
|
/**
|
|
849
981
|
* Nudge selectionBg's OKLCH L until it differs from bg by ≥ SELECTION_DELTA_L.
|
|
850
982
|
* Mirrors the legacy theme's repairSelectionBg behavior — preserves hue +
|
|
@@ -865,6 +997,7 @@ function repairSelectionBg$1(selectionBg, bg) {
|
|
|
865
997
|
H: oSel.H
|
|
866
998
|
});
|
|
867
999
|
}
|
|
1000
|
+
const CURSOR_DELTA_E = .15;
|
|
868
1001
|
/**
|
|
869
1002
|
* Nudge cursorBg's OKLCH L until it differs from bg by ≥ CURSOR_DELTA_E
|
|
870
1003
|
* (perceptual distance, not just lightness). Preserves hue + chroma but
|
|
@@ -979,57 +1112,6 @@ function mergePartial(base, patch) {
|
|
|
979
1112
|
}
|
|
980
1113
|
return out;
|
|
981
1114
|
}
|
|
982
|
-
var DEFAULT_VARIANTS, SELECTION_DELTA_L, CURSOR_DELTA_E;
|
|
983
|
-
var init_derive$1 = __esmMin((() => {
|
|
984
|
-
init_contrast();
|
|
985
|
-
DEFAULT_VARIANTS = {
|
|
986
|
-
h1: {
|
|
987
|
-
color: "$fg-accent",
|
|
988
|
-
bold: true
|
|
989
|
-
},
|
|
990
|
-
h2: {
|
|
991
|
-
color: "$fg-accent",
|
|
992
|
-
bold: true
|
|
993
|
-
},
|
|
994
|
-
h3: { bold: true },
|
|
995
|
-
h4: {
|
|
996
|
-
color: "$fg-muted",
|
|
997
|
-
bold: true
|
|
998
|
-
},
|
|
999
|
-
h5: {
|
|
1000
|
-
color: "$fg-muted",
|
|
1001
|
-
italic: true
|
|
1002
|
-
},
|
|
1003
|
-
h6: {
|
|
1004
|
-
color: "$fg-muted",
|
|
1005
|
-
dim: true
|
|
1006
|
-
},
|
|
1007
|
-
body: {},
|
|
1008
|
-
"body-muted": { color: "$fg-muted" },
|
|
1009
|
-
"fine-print": {
|
|
1010
|
-
color: "$fg-muted",
|
|
1011
|
-
dim: true
|
|
1012
|
-
},
|
|
1013
|
-
strong: { bold: true },
|
|
1014
|
-
em: { italic: true },
|
|
1015
|
-
link: {
|
|
1016
|
-
color: "$fg-accent",
|
|
1017
|
-
underlineStyle: "single"
|
|
1018
|
-
},
|
|
1019
|
-
key: {
|
|
1020
|
-
color: "$fg-accent",
|
|
1021
|
-
bold: true
|
|
1022
|
-
},
|
|
1023
|
-
code: { backgroundColor: "$bg-muted" },
|
|
1024
|
-
kbd: {
|
|
1025
|
-
backgroundColor: "$bg-muted",
|
|
1026
|
-
color: "$fg-accent",
|
|
1027
|
-
bold: true
|
|
1028
|
-
}
|
|
1029
|
-
};
|
|
1030
|
-
SELECTION_DELTA_L = .08;
|
|
1031
|
-
CURSOR_DELTA_E = .15;
|
|
1032
|
-
}));
|
|
1033
1115
|
//#endregion
|
|
1034
1116
|
//#region packages/ansi/src/sterling/inline.ts
|
|
1035
1117
|
/**
|
|
@@ -1191,6 +1273,8 @@ function inlineSterlingTokens(theme, scheme) {
|
|
|
1191
1273
|
setIfAbsent("fg-muted", m.fg);
|
|
1192
1274
|
setIfAbsent("bg-muted", m.bg);
|
|
1193
1275
|
}
|
|
1276
|
+
const ft = roles.faint;
|
|
1277
|
+
if (ft) setIfAbsent("fg-faint", ft.fg);
|
|
1194
1278
|
const sel = roles.selected;
|
|
1195
1279
|
if (sel) {
|
|
1196
1280
|
setIfAbsent("bg-selected", sel.bg);
|
|
@@ -1201,6 +1285,8 @@ function inlineSterlingTokens(theme, scheme) {
|
|
|
1201
1285
|
if (inv) {
|
|
1202
1286
|
setIfAbsent("bg-inverse", inv.bg);
|
|
1203
1287
|
setIfAbsent("fg-on-inverse", inv.fgOn);
|
|
1288
|
+
setIfAbsent("bg-inverse-hover", inv.hover.bg);
|
|
1289
|
+
setIfAbsent("fg-on-inverse-muted", inv.muted.fgOn);
|
|
1204
1290
|
}
|
|
1205
1291
|
const lnk = roles.link;
|
|
1206
1292
|
if (lnk) setIfAbsent("fg-link", lnk.fg);
|
|
@@ -1217,9 +1303,6 @@ function inlineSterlingTokens(theme, scheme) {
|
|
|
1217
1303
|
setIfAbsent("bg-backdrop", blend(src.background, "#000000", .4));
|
|
1218
1304
|
return out;
|
|
1219
1305
|
}
|
|
1220
|
-
var init_inline = __esmMin((() => {
|
|
1221
|
-
init_derive$1();
|
|
1222
|
-
}));
|
|
1223
1306
|
//#endregion
|
|
1224
1307
|
//#region packages/ansi/src/theme/derive.ts
|
|
1225
1308
|
/**
|
|
@@ -1268,6 +1351,10 @@ function loadTheme(palette, opts = {}) {
|
|
|
1268
1351
|
}
|
|
1269
1352
|
return theme;
|
|
1270
1353
|
}
|
|
1354
|
+
const AA$1 = 4.5;
|
|
1355
|
+
const DIM = 3;
|
|
1356
|
+
const FAINT$1 = 1.5;
|
|
1357
|
+
const CONTROL = 3;
|
|
1271
1358
|
/**
|
|
1272
1359
|
* Build a "raw" Theme with legacy single-hex role fields. The output is NOT a
|
|
1273
1360
|
* complete Sterling Theme — Sterling roles + flat tokens are layered on by
|
|
@@ -1518,78 +1605,81 @@ function repairCursorBg(cursorBg, bg) {
|
|
|
1518
1605
|
if (d2 !== null && d2 >= .15) return candidate;
|
|
1519
1606
|
return oBg.L > .5 ? "#000000" : "#FFFFFF";
|
|
1520
1607
|
}
|
|
1521
|
-
var AA$1, DIM, FAINT$1, CONTROL;
|
|
1522
|
-
var init_derive = __esmMin((() => {
|
|
1523
|
-
init_invariants();
|
|
1524
|
-
init_derived();
|
|
1525
|
-
init_inline();
|
|
1526
|
-
AA$1 = 4.5;
|
|
1527
|
-
DIM = 3;
|
|
1528
|
-
FAINT$1 = 1.5;
|
|
1529
|
-
CONTROL = 3;
|
|
1530
|
-
}));
|
|
1531
1608
|
//#endregion
|
|
1532
1609
|
//#region packages/ansi/src/theme/default-schemes.ts
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1610
|
+
const defaultDarkScheme = {
|
|
1611
|
+
name: "default-dark",
|
|
1612
|
+
dark: true,
|
|
1613
|
+
black: "#2e3440",
|
|
1614
|
+
red: "#bf616a",
|
|
1615
|
+
green: "#a3be8c",
|
|
1616
|
+
yellow: "#ebcb8b",
|
|
1617
|
+
blue: "#81a1c1",
|
|
1618
|
+
magenta: "#b48ead",
|
|
1619
|
+
cyan: "#88c0d0",
|
|
1620
|
+
white: "#d8dee9",
|
|
1621
|
+
brightBlack: "#4c566a",
|
|
1622
|
+
brightRed: "#bf616a",
|
|
1623
|
+
brightGreen: "#a3be8c",
|
|
1624
|
+
brightYellow: "#ebcb8b",
|
|
1625
|
+
brightBlue: "#81a1c1",
|
|
1626
|
+
brightMagenta: "#b48ead",
|
|
1627
|
+
brightCyan: "#8fbcbb",
|
|
1628
|
+
brightWhite: "#eceff4",
|
|
1629
|
+
foreground: "#d8dee9",
|
|
1630
|
+
background: "#2e3440",
|
|
1631
|
+
cursorColor: "#d8dee9",
|
|
1632
|
+
cursorText: "#2e3440",
|
|
1633
|
+
selectionBackground: "#434c5e",
|
|
1634
|
+
selectionForeground: "#d8dee9"
|
|
1635
|
+
};
|
|
1636
|
+
const defaultLightScheme = {
|
|
1637
|
+
name: "default-light",
|
|
1638
|
+
dark: false,
|
|
1639
|
+
black: "#5c6370",
|
|
1640
|
+
red: "#d20f39",
|
|
1641
|
+
green: "#40a02b",
|
|
1642
|
+
yellow: "#df8e1d",
|
|
1643
|
+
blue: "#1e66f5",
|
|
1644
|
+
magenta: "#8839ef",
|
|
1645
|
+
cyan: "#179299",
|
|
1646
|
+
white: "#dce0e8",
|
|
1647
|
+
brightBlack: "#6c7086",
|
|
1648
|
+
brightRed: "#d20f39",
|
|
1649
|
+
brightGreen: "#40a02b",
|
|
1650
|
+
brightYellow: "#df8e1d",
|
|
1651
|
+
brightBlue: "#1e66f5",
|
|
1652
|
+
brightMagenta: "#8839ef",
|
|
1653
|
+
brightCyan: "#179299",
|
|
1654
|
+
brightWhite: "#eff1f5",
|
|
1655
|
+
foreground: "#4c4f69",
|
|
1656
|
+
background: "#eff1f5",
|
|
1657
|
+
cursorColor: "#dc8a78",
|
|
1658
|
+
cursorText: "#eff1f5",
|
|
1659
|
+
selectionBackground: "#ccd0da",
|
|
1660
|
+
selectionForeground: "#4c4f69"
|
|
1661
|
+
};
|
|
1662
|
+
/**
|
|
1663
|
+
* Dark ANSI 16 theme — hex-valued, derived from the default dark scheme.
|
|
1664
|
+
*
|
|
1665
|
+
* All token values are hex strings. Terminal rendering quantizes hex to
|
|
1666
|
+
* 4-bit ANSI codes at paint time when colorLevel === "ansi16".
|
|
1667
|
+
*/
|
|
1668
|
+
const ansi16DarkTheme = deriveAnsi16Theme(defaultDarkScheme);
|
|
1669
|
+
/**
|
|
1670
|
+
* Light ANSI 16 theme — hex-valued, derived from the default light scheme.
|
|
1671
|
+
*
|
|
1672
|
+
* All token values are hex strings. Terminal rendering quantizes hex to
|
|
1673
|
+
* 4-bit ANSI codes at paint time when colorLevel === "ansi16".
|
|
1674
|
+
*/
|
|
1675
|
+
const ansi16LightTheme = deriveAnsi16Theme(defaultLightScheme);
|
|
1591
1676
|
//#endregion
|
|
1592
1677
|
//#region packages/ansi/src/osc-palette.ts
|
|
1678
|
+
/**
|
|
1679
|
+
* OSC 4 Terminal Color Palette Query/Set — pure ANSI protocol.
|
|
1680
|
+
*/
|
|
1681
|
+
const ESC$4 = "\x1B";
|
|
1682
|
+
const BEL$2 = "\x07";
|
|
1593
1683
|
function queryPaletteColor(index, write) {
|
|
1594
1684
|
if (index < 0 || index > 255) throw new RangeError(`Palette index must be 0-255, got ${index}`);
|
|
1595
1685
|
write(`${ESC$4}]4;${index};?${BEL$2}`);
|
|
@@ -1601,6 +1691,8 @@ function setPaletteColor(index, color, write) {
|
|
|
1601
1691
|
if (index < 0 || index > 255) throw new RangeError(`Palette index must be 0-255, got ${index}`);
|
|
1602
1692
|
write(`${ESC$4}]4;${index};${color}${BEL$2}`);
|
|
1603
1693
|
}
|
|
1694
|
+
const OSC4_PREFIX = `${ESC$4}]4;`;
|
|
1695
|
+
const OSC4_BODY_RE = /^(\d+);rgb:([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})$/;
|
|
1604
1696
|
function parsePaletteResponse(input) {
|
|
1605
1697
|
const prefixIdx = input.indexOf(OSC4_PREFIX);
|
|
1606
1698
|
if (prefixIdx === -1) return null;
|
|
@@ -1625,41 +1717,79 @@ function normalizeHexChannel$1(hex) {
|
|
|
1625
1717
|
default: return hex.slice(0, 2);
|
|
1626
1718
|
}
|
|
1627
1719
|
}
|
|
1628
|
-
var ESC$4, BEL$2, OSC4_PREFIX, OSC4_BODY_RE;
|
|
1629
|
-
var init_osc_palette = __esmMin((() => {
|
|
1630
|
-
ESC$4 = "\x1B";
|
|
1631
|
-
BEL$2 = "\x07";
|
|
1632
|
-
OSC4_PREFIX = `${ESC$4}]4;`;
|
|
1633
|
-
OSC4_BODY_RE = /^(\d+);rgb:([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})$/;
|
|
1634
|
-
}));
|
|
1635
1720
|
//#endregion
|
|
1636
1721
|
//#region packages/ansi/src/protocol-error.ts
|
|
1722
|
+
/**
|
|
1723
|
+
* ProtocolError — structured error for terminal protocol parse failures.
|
|
1724
|
+
*
|
|
1725
|
+
* Used by parsers to signal that input WAS identified as belonging to this
|
|
1726
|
+
* protocol (prefix/marker matched) but is malformed in a way the parser
|
|
1727
|
+
* cannot recover from (missing terminator, invalid base64, missing required
|
|
1728
|
+
* field, etc.).
|
|
1729
|
+
*
|
|
1730
|
+
* Distinct from a `null` return:
|
|
1731
|
+
*
|
|
1732
|
+
* - `null` = "no input matched, but input was valid" — the parser does not
|
|
1733
|
+
* recognize this input as belonging to its protocol family at all (no
|
|
1734
|
+
* prefix, no marker). Used by discriminator chains to mean "next parser
|
|
1735
|
+
* please."
|
|
1736
|
+
*
|
|
1737
|
+
* - `throw ProtocolError` = "this WAS for us but is broken" — the parser
|
|
1738
|
+
* committed to the protocol (prefix matched), then the body failed
|
|
1739
|
+
* validation. Callers should log and continue, NOT crash.
|
|
1740
|
+
*
|
|
1741
|
+
* Carries structured context so callers can route, dedupe, and log
|
|
1742
|
+
* without re-parsing the raw bytes:
|
|
1743
|
+
*
|
|
1744
|
+
* - `parser` — name of the parser that threw (e.g. "parseClipboardResponse")
|
|
1745
|
+
* - `input` — raw input bytes (truncated for safety; full length retained
|
|
1746
|
+
* in `inputLength`)
|
|
1747
|
+
* - `reason` — short human-readable description of why-invalid
|
|
1748
|
+
*
|
|
1749
|
+
* Acceptance for bead `@km/silvery/15127-custom-protocol-implementation/
|
|
1750
|
+
* protocol-loud-errors`: parsers must fail loudly on protocol violation
|
|
1751
|
+
* instead of silently dropping malformed input.
|
|
1752
|
+
*
|
|
1753
|
+
* @module
|
|
1754
|
+
*/
|
|
1755
|
+
/** Maximum chars of raw input retained on the error (rest is truncated). */
|
|
1756
|
+
const INPUT_TRUNCATE_LENGTH = 256;
|
|
1757
|
+
/**
|
|
1758
|
+
* Thrown by protocol parsers when input is identified as belonging to the
|
|
1759
|
+
* protocol but is malformed.
|
|
1760
|
+
*
|
|
1761
|
+
* Callers (dispatch boundaries in `runtime/input-owner.ts`, `renderer.ts`,
|
|
1762
|
+
* and similar) should catch ProtocolError, log via the appropriate logger,
|
|
1763
|
+
* and continue — never let a protocol parse error crash the app.
|
|
1764
|
+
*/
|
|
1765
|
+
var ProtocolError = class extends Error {
|
|
1766
|
+
name = "ProtocolError";
|
|
1767
|
+
parser;
|
|
1768
|
+
input;
|
|
1769
|
+
inputLength;
|
|
1770
|
+
reason;
|
|
1771
|
+
constructor(opts) {
|
|
1772
|
+
const inputLength = opts.input.length;
|
|
1773
|
+
const truncated = inputLength > INPUT_TRUNCATE_LENGTH ? `${opts.input.slice(0, INPUT_TRUNCATE_LENGTH)}…<${inputLength - INPUT_TRUNCATE_LENGTH} more chars>` : opts.input;
|
|
1774
|
+
super(`${opts.parser}: ${opts.reason} (input=${JSON.stringify(truncated)})`);
|
|
1775
|
+
this.parser = opts.parser;
|
|
1776
|
+
this.input = truncated;
|
|
1777
|
+
this.inputLength = inputLength;
|
|
1778
|
+
this.reason = opts.reason;
|
|
1779
|
+
}
|
|
1780
|
+
};
|
|
1637
1781
|
/** Narrowing helper — true if `err` is a ProtocolError. */
|
|
1638
1782
|
function isProtocolError(err) {
|
|
1639
1783
|
return err instanceof ProtocolError;
|
|
1640
1784
|
}
|
|
1641
|
-
var INPUT_TRUNCATE_LENGTH, ProtocolError;
|
|
1642
|
-
var init_protocol_error = __esmMin((() => {
|
|
1643
|
-
INPUT_TRUNCATE_LENGTH = 256;
|
|
1644
|
-
ProtocolError = class extends Error {
|
|
1645
|
-
name = "ProtocolError";
|
|
1646
|
-
parser;
|
|
1647
|
-
input;
|
|
1648
|
-
inputLength;
|
|
1649
|
-
reason;
|
|
1650
|
-
constructor(opts) {
|
|
1651
|
-
const inputLength = opts.input.length;
|
|
1652
|
-
const truncated = inputLength > INPUT_TRUNCATE_LENGTH ? `${opts.input.slice(0, INPUT_TRUNCATE_LENGTH)}…<${inputLength - INPUT_TRUNCATE_LENGTH} more chars>` : opts.input;
|
|
1653
|
-
super(`${opts.parser}: ${opts.reason} (input=${JSON.stringify(truncated)})`);
|
|
1654
|
-
this.parser = opts.parser;
|
|
1655
|
-
this.input = truncated;
|
|
1656
|
-
this.inputLength = inputLength;
|
|
1657
|
-
this.reason = opts.reason;
|
|
1658
|
-
}
|
|
1659
|
-
};
|
|
1660
|
-
}));
|
|
1661
1785
|
//#endregion
|
|
1662
1786
|
//#region packages/ansi/src/osc-colors.ts
|
|
1787
|
+
/**
|
|
1788
|
+
* OSC 10/11/12 Terminal Color Queries — pure ANSI protocol.
|
|
1789
|
+
*/
|
|
1790
|
+
const ESC$3 = "\x1B";
|
|
1791
|
+
const BEL$1 = "\x07";
|
|
1792
|
+
const RGB_BODY_RE$1 = /rgb:([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})/;
|
|
1663
1793
|
function normalizeHexChannel(hex) {
|
|
1664
1794
|
switch (hex.length) {
|
|
1665
1795
|
case 1: return hex + hex;
|
|
@@ -1743,13 +1873,6 @@ async function detectColorScheme(write, read, timeoutMs = 200) {
|
|
|
1743
1873
|
const b = parseInt(bg.slice(5, 7), 16) / 255;
|
|
1744
1874
|
return .2126 * r + .7152 * g + .0722 * b > .5 ? "light" : "dark";
|
|
1745
1875
|
}
|
|
1746
|
-
var ESC$3, BEL$1, RGB_BODY_RE$1;
|
|
1747
|
-
var init_osc_colors = __esmMin((() => {
|
|
1748
|
-
init_protocol_error();
|
|
1749
|
-
ESC$3 = "\x1B";
|
|
1750
|
-
BEL$1 = "\x07";
|
|
1751
|
-
RGB_BODY_RE$1 = /rgb:([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})/;
|
|
1752
|
-
}));
|
|
1753
1876
|
//#endregion
|
|
1754
1877
|
//#region packages/ansi/src/theme/detect.ts
|
|
1755
1878
|
/**
|
|
@@ -1872,6 +1995,9 @@ async function probeColors(timeoutOrOpts) {
|
|
|
1872
1995
|
if (didSetRaw) stdin.setRawMode(false);
|
|
1873
1996
|
}
|
|
1874
1997
|
}
|
|
1998
|
+
const ESC$2 = "\x1B";
|
|
1999
|
+
const BEL = "\x07";
|
|
2000
|
+
const RGB_BODY_RE = /rgb:([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})/;
|
|
1875
2001
|
/** OSC response parser for a specific OSC code (10 or 11). Returns the
|
|
1876
2002
|
* first matching response in the buffer and the byte count to consume
|
|
1877
2003
|
* (the end of that response, so leading garbage is cleared as well).
|
|
@@ -1988,6 +2114,13 @@ async function probeColorsViaOwner(input, timeoutMs) {
|
|
|
1988
2114
|
palette
|
|
1989
2115
|
};
|
|
1990
2116
|
}
|
|
2117
|
+
/**
|
|
2118
|
+
* Legacy alias for {@link probeColors}. Prefer `probeColors` in new code —
|
|
2119
|
+
* the name says what it does (probes terminal color slots), and "detect" is
|
|
2120
|
+
* reserved for the full cascade (`detectScheme`, `detectTheme`). Retained
|
|
2121
|
+
* as a stable alias — no deprecation schedule.
|
|
2122
|
+
*/
|
|
2123
|
+
const detectTerminalScheme = probeColors;
|
|
1991
2124
|
async function detectTheme(opts = {}) {
|
|
1992
2125
|
const colorLevel = opts.caps?.colorLevel;
|
|
1993
2126
|
if (colorLevel === "mono" || colorLevel === "ansi16") return opts.caps?.darkBackground ?? true ? ansi16DarkTheme : ansi16LightTheme;
|
|
@@ -2014,19 +2147,229 @@ function isDarkColor(hex) {
|
|
|
2014
2147
|
const b = parseInt(hex.slice(5, 7), 16) / 255;
|
|
2015
2148
|
return .2126 * r + .7152 * g + .0722 * b <= .5;
|
|
2016
2149
|
}
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2150
|
+
//#endregion
|
|
2151
|
+
//#region packages/ansi/src/kitty-graphics-probe.ts
|
|
2152
|
+
const APC = "\x1B_G";
|
|
2153
|
+
const ST = "\x1B\\";
|
|
2154
|
+
/**
|
|
2155
|
+
* The image id used for the support query. Chosen well above the runtime image
|
|
2156
|
+
* id range (1..255) so a probe ack can never be confused with a real image's
|
|
2157
|
+
* response.
|
|
2158
|
+
*/
|
|
2159
|
+
const KITTY_PROBE_ID = 7777;
|
|
2160
|
+
/**
|
|
2161
|
+
* Parse a Kitty graphics query response for {@link KITTY_PROBE_ID}.
|
|
2162
|
+
*
|
|
2163
|
+
* - `{ result: true }` — `\x1b_Gi=<id>;OK\x1b\` → graphics supported.
|
|
2164
|
+
* - `{ result: false }` — a well-formed response for our id that is NOT `OK`
|
|
2165
|
+
* (the terminal parsed the APC but rejected the query).
|
|
2166
|
+
* - `null` — no complete response for our id yet (the probe keeps
|
|
2167
|
+
* waiting; on timeout the caller treats this as
|
|
2168
|
+
* unsupported).
|
|
2169
|
+
*/
|
|
2170
|
+
function parseKittyGraphicsResponse(acc, id) {
|
|
2171
|
+
const prefix = `${APC}i=${id};`;
|
|
2172
|
+
const start = acc.indexOf(prefix);
|
|
2173
|
+
if (start === -1) return null;
|
|
2174
|
+
const bodyStart = start + prefix.length;
|
|
2175
|
+
const end = acc.indexOf(ST, bodyStart);
|
|
2176
|
+
if (end === -1) return null;
|
|
2177
|
+
return {
|
|
2178
|
+
result: acc.slice(bodyStart, end).trim() === "OK",
|
|
2179
|
+
consumed: end + 2
|
|
2180
|
+
};
|
|
2181
|
+
}
|
|
2182
|
+
/**
|
|
2183
|
+
* Probe the terminal at runtime for Kitty graphics support. Resolves:
|
|
2184
|
+
* - `true` — the terminal acknowledged it can paint Kitty graphics.
|
|
2185
|
+
* - `false` — a non-`OK` response (the protocol is understood but refused).
|
|
2186
|
+
* - `undefined` — no response within `timeoutMs` (the terminal does not speak
|
|
2187
|
+
* the protocol, or a proxy/capture that cannot paint it).
|
|
2188
|
+
*
|
|
2189
|
+
* The query is a 1×1 RGB query-only command, harmless to a terminal that ignores
|
|
2190
|
+
* unknown APC sequences. Routed through the session's {@link ProbeInputOwner}
|
|
2191
|
+
* (never `process.stdin` directly) so it is safe inside a running TUI.
|
|
2192
|
+
*/
|
|
2193
|
+
async function probeKittyGraphics(input, timeoutMs = 150) {
|
|
2194
|
+
const query = `${APC}i=${KITTY_PROBE_ID},s=1,v=1,a=q,t=d,f=24;AAAA${ST}`;
|
|
2195
|
+
return await input.probe({
|
|
2196
|
+
query,
|
|
2197
|
+
timeoutMs,
|
|
2198
|
+
parse: (acc) => parseKittyGraphicsResponse(acc, 7777)
|
|
2199
|
+
}) ?? void 0;
|
|
2200
|
+
}
|
|
2028
2201
|
//#endregion
|
|
2029
2202
|
//#region packages/ansi/src/color-maps.ts
|
|
2203
|
+
/** Modifier SGR codes: open -> close */
|
|
2204
|
+
const MODIFIERS = {
|
|
2205
|
+
reset: [0, 0],
|
|
2206
|
+
bold: [1, 22],
|
|
2207
|
+
dim: [2, 22],
|
|
2208
|
+
italic: [3, 23],
|
|
2209
|
+
underline: [4, 24],
|
|
2210
|
+
inverse: [7, 27],
|
|
2211
|
+
hidden: [8, 28],
|
|
2212
|
+
strikethrough: [9, 29],
|
|
2213
|
+
overline: [53, 55]
|
|
2214
|
+
};
|
|
2215
|
+
/** Foreground color name -> ANSI SGR code */
|
|
2216
|
+
const FG_COLORS = {
|
|
2217
|
+
black: 30,
|
|
2218
|
+
red: 31,
|
|
2219
|
+
green: 32,
|
|
2220
|
+
yellow: 33,
|
|
2221
|
+
blue: 34,
|
|
2222
|
+
magenta: 35,
|
|
2223
|
+
cyan: 36,
|
|
2224
|
+
white: 37,
|
|
2225
|
+
blackBright: 90,
|
|
2226
|
+
gray: 90,
|
|
2227
|
+
grey: 90,
|
|
2228
|
+
redBright: 91,
|
|
2229
|
+
greenBright: 92,
|
|
2230
|
+
yellowBright: 93,
|
|
2231
|
+
blueBright: 94,
|
|
2232
|
+
magentaBright: 95,
|
|
2233
|
+
cyanBright: 96,
|
|
2234
|
+
whiteBright: 97
|
|
2235
|
+
};
|
|
2236
|
+
/** Background color name -> ANSI SGR code */
|
|
2237
|
+
const BG_COLORS = {
|
|
2238
|
+
bgBlack: 40,
|
|
2239
|
+
bgRed: 41,
|
|
2240
|
+
bgGreen: 42,
|
|
2241
|
+
bgYellow: 43,
|
|
2242
|
+
bgBlue: 44,
|
|
2243
|
+
bgMagenta: 45,
|
|
2244
|
+
bgCyan: 46,
|
|
2245
|
+
bgWhite: 47,
|
|
2246
|
+
bgBlackBright: 100,
|
|
2247
|
+
bgGray: 100,
|
|
2248
|
+
bgGrey: 100,
|
|
2249
|
+
bgRedBright: 101,
|
|
2250
|
+
bgGreenBright: 102,
|
|
2251
|
+
bgYellowBright: 103,
|
|
2252
|
+
bgBlueBright: 104,
|
|
2253
|
+
bgMagentaBright: 105,
|
|
2254
|
+
bgCyanBright: 106,
|
|
2255
|
+
bgWhiteBright: 107
|
|
2256
|
+
};
|
|
2257
|
+
/** Standard ANSI 16 color RGB values for nearest-color matching.
|
|
2258
|
+
* Uses xterm-256 standard values for consistent mapping (matches chalk/ansi-styles). */
|
|
2259
|
+
const ANSI_16_COLORS = [
|
|
2260
|
+
[
|
|
2261
|
+
0,
|
|
2262
|
+
0,
|
|
2263
|
+
0
|
|
2264
|
+
],
|
|
2265
|
+
[
|
|
2266
|
+
128,
|
|
2267
|
+
0,
|
|
2268
|
+
0
|
|
2269
|
+
],
|
|
2270
|
+
[
|
|
2271
|
+
0,
|
|
2272
|
+
128,
|
|
2273
|
+
0
|
|
2274
|
+
],
|
|
2275
|
+
[
|
|
2276
|
+
128,
|
|
2277
|
+
128,
|
|
2278
|
+
0
|
|
2279
|
+
],
|
|
2280
|
+
[
|
|
2281
|
+
0,
|
|
2282
|
+
0,
|
|
2283
|
+
128
|
|
2284
|
+
],
|
|
2285
|
+
[
|
|
2286
|
+
128,
|
|
2287
|
+
0,
|
|
2288
|
+
128
|
|
2289
|
+
],
|
|
2290
|
+
[
|
|
2291
|
+
0,
|
|
2292
|
+
128,
|
|
2293
|
+
128
|
|
2294
|
+
],
|
|
2295
|
+
[
|
|
2296
|
+
192,
|
|
2297
|
+
192,
|
|
2298
|
+
192
|
|
2299
|
+
],
|
|
2300
|
+
[
|
|
2301
|
+
128,
|
|
2302
|
+
128,
|
|
2303
|
+
128
|
|
2304
|
+
],
|
|
2305
|
+
[
|
|
2306
|
+
255,
|
|
2307
|
+
0,
|
|
2308
|
+
0
|
|
2309
|
+
],
|
|
2310
|
+
[
|
|
2311
|
+
0,
|
|
2312
|
+
255,
|
|
2313
|
+
0
|
|
2314
|
+
],
|
|
2315
|
+
[
|
|
2316
|
+
255,
|
|
2317
|
+
255,
|
|
2318
|
+
0
|
|
2319
|
+
],
|
|
2320
|
+
[
|
|
2321
|
+
0,
|
|
2322
|
+
0,
|
|
2323
|
+
255
|
|
2324
|
+
],
|
|
2325
|
+
[
|
|
2326
|
+
255,
|
|
2327
|
+
0,
|
|
2328
|
+
255
|
|
2329
|
+
],
|
|
2330
|
+
[
|
|
2331
|
+
0,
|
|
2332
|
+
255,
|
|
2333
|
+
255
|
|
2334
|
+
],
|
|
2335
|
+
[
|
|
2336
|
+
255,
|
|
2337
|
+
255,
|
|
2338
|
+
255
|
|
2339
|
+
]
|
|
2340
|
+
];
|
|
2341
|
+
/**
|
|
2342
|
+
* Canonical hex values for the 16 standard ANSI color slots.
|
|
2343
|
+
*
|
|
2344
|
+
* These are the xterm-256 reference values — the same RGB values used by
|
|
2345
|
+
* `nearestAnsi16` for quantization. Used to convert ANSI16 slot-name themes
|
|
2346
|
+
* (e.g., "yellow") into hex-valued themes (e.g., "#808000") so Theme objects
|
|
2347
|
+
* are pure hex across all tiers.
|
|
2348
|
+
*
|
|
2349
|
+
* Terminal-rendering behavior is unchanged: the output phase reads `colorLevel`
|
|
2350
|
+
* and emits 4-bit ANSI codes when `colorLevel === "basic"` — the hex value is
|
|
2351
|
+
* only carried in the Theme object itself, not emitted verbatim.
|
|
2352
|
+
*/
|
|
2353
|
+
const ANSI16_SLOT_HEX = {
|
|
2354
|
+
black: "#000000",
|
|
2355
|
+
red: "#800000",
|
|
2356
|
+
green: "#008000",
|
|
2357
|
+
yellow: "#808000",
|
|
2358
|
+
blue: "#000080",
|
|
2359
|
+
magenta: "#800080",
|
|
2360
|
+
cyan: "#008080",
|
|
2361
|
+
white: "#c0c0c0",
|
|
2362
|
+
blackBright: "#808080",
|
|
2363
|
+
gray: "#808080",
|
|
2364
|
+
grey: "#808080",
|
|
2365
|
+
redBright: "#ff0000",
|
|
2366
|
+
greenBright: "#00ff00",
|
|
2367
|
+
yellowBright: "#ffff00",
|
|
2368
|
+
blueBright: "#0000ff",
|
|
2369
|
+
magentaBright: "#ff00ff",
|
|
2370
|
+
cyanBright: "#00ffff",
|
|
2371
|
+
whiteBright: "#ffffff"
|
|
2372
|
+
};
|
|
2030
2373
|
/** Find nearest ANSI 16 color index for an RGB value. */
|
|
2031
2374
|
function nearestAnsi16(r, g, b) {
|
|
2032
2375
|
let bestIdx = 0;
|
|
@@ -2161,6 +2504,11 @@ function quantizeHex(hex, tier) {
|
|
|
2161
2504
|
}
|
|
2162
2505
|
return (.2126 * r + .7152 * g + .0722 * b) / 255 >= .5 ? "#ffffff" : "#000000";
|
|
2163
2506
|
}
|
|
2507
|
+
/**
|
|
2508
|
+
* Hex-regex used to detect hex leaves during tier quantization walks.
|
|
2509
|
+
* Matches `#rgb` and `#rrggbb` (case-insensitive).
|
|
2510
|
+
*/
|
|
2511
|
+
const HEX_LEAF_RE$1 = /^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/;
|
|
2164
2512
|
function isHexLeaf$1(value) {
|
|
2165
2513
|
return typeof value === "string" && HEX_LEAF_RE$1.test(value);
|
|
2166
2514
|
}
|
|
@@ -2220,171 +2568,34 @@ function pickColorLevelWalk(obj, tier) {
|
|
|
2220
2568
|
}
|
|
2221
2569
|
return obj;
|
|
2222
2570
|
}
|
|
2223
|
-
var MODIFIERS, FG_COLORS, BG_COLORS, ANSI_16_COLORS, ANSI16_SLOT_HEX, HEX_LEAF_RE$1;
|
|
2224
|
-
var init_color_maps = __esmMin((() => {
|
|
2225
|
-
MODIFIERS = {
|
|
2226
|
-
reset: [0, 0],
|
|
2227
|
-
bold: [1, 22],
|
|
2228
|
-
dim: [2, 22],
|
|
2229
|
-
italic: [3, 23],
|
|
2230
|
-
underline: [4, 24],
|
|
2231
|
-
inverse: [7, 27],
|
|
2232
|
-
hidden: [8, 28],
|
|
2233
|
-
strikethrough: [9, 29],
|
|
2234
|
-
overline: [53, 55]
|
|
2235
|
-
};
|
|
2236
|
-
FG_COLORS = {
|
|
2237
|
-
black: 30,
|
|
2238
|
-
red: 31,
|
|
2239
|
-
green: 32,
|
|
2240
|
-
yellow: 33,
|
|
2241
|
-
blue: 34,
|
|
2242
|
-
magenta: 35,
|
|
2243
|
-
cyan: 36,
|
|
2244
|
-
white: 37,
|
|
2245
|
-
blackBright: 90,
|
|
2246
|
-
gray: 90,
|
|
2247
|
-
grey: 90,
|
|
2248
|
-
redBright: 91,
|
|
2249
|
-
greenBright: 92,
|
|
2250
|
-
yellowBright: 93,
|
|
2251
|
-
blueBright: 94,
|
|
2252
|
-
magentaBright: 95,
|
|
2253
|
-
cyanBright: 96,
|
|
2254
|
-
whiteBright: 97
|
|
2255
|
-
};
|
|
2256
|
-
BG_COLORS = {
|
|
2257
|
-
bgBlack: 40,
|
|
2258
|
-
bgRed: 41,
|
|
2259
|
-
bgGreen: 42,
|
|
2260
|
-
bgYellow: 43,
|
|
2261
|
-
bgBlue: 44,
|
|
2262
|
-
bgMagenta: 45,
|
|
2263
|
-
bgCyan: 46,
|
|
2264
|
-
bgWhite: 47,
|
|
2265
|
-
bgBlackBright: 100,
|
|
2266
|
-
bgGray: 100,
|
|
2267
|
-
bgGrey: 100,
|
|
2268
|
-
bgRedBright: 101,
|
|
2269
|
-
bgGreenBright: 102,
|
|
2270
|
-
bgYellowBright: 103,
|
|
2271
|
-
bgBlueBright: 104,
|
|
2272
|
-
bgMagentaBright: 105,
|
|
2273
|
-
bgCyanBright: 106,
|
|
2274
|
-
bgWhiteBright: 107
|
|
2275
|
-
};
|
|
2276
|
-
ANSI_16_COLORS = [
|
|
2277
|
-
[
|
|
2278
|
-
0,
|
|
2279
|
-
0,
|
|
2280
|
-
0
|
|
2281
|
-
],
|
|
2282
|
-
[
|
|
2283
|
-
128,
|
|
2284
|
-
0,
|
|
2285
|
-
0
|
|
2286
|
-
],
|
|
2287
|
-
[
|
|
2288
|
-
0,
|
|
2289
|
-
128,
|
|
2290
|
-
0
|
|
2291
|
-
],
|
|
2292
|
-
[
|
|
2293
|
-
128,
|
|
2294
|
-
128,
|
|
2295
|
-
0
|
|
2296
|
-
],
|
|
2297
|
-
[
|
|
2298
|
-
0,
|
|
2299
|
-
0,
|
|
2300
|
-
128
|
|
2301
|
-
],
|
|
2302
|
-
[
|
|
2303
|
-
128,
|
|
2304
|
-
0,
|
|
2305
|
-
128
|
|
2306
|
-
],
|
|
2307
|
-
[
|
|
2308
|
-
0,
|
|
2309
|
-
128,
|
|
2310
|
-
128
|
|
2311
|
-
],
|
|
2312
|
-
[
|
|
2313
|
-
192,
|
|
2314
|
-
192,
|
|
2315
|
-
192
|
|
2316
|
-
],
|
|
2317
|
-
[
|
|
2318
|
-
128,
|
|
2319
|
-
128,
|
|
2320
|
-
128
|
|
2321
|
-
],
|
|
2322
|
-
[
|
|
2323
|
-
255,
|
|
2324
|
-
0,
|
|
2325
|
-
0
|
|
2326
|
-
],
|
|
2327
|
-
[
|
|
2328
|
-
0,
|
|
2329
|
-
255,
|
|
2330
|
-
0
|
|
2331
|
-
],
|
|
2332
|
-
[
|
|
2333
|
-
255,
|
|
2334
|
-
255,
|
|
2335
|
-
0
|
|
2336
|
-
],
|
|
2337
|
-
[
|
|
2338
|
-
0,
|
|
2339
|
-
0,
|
|
2340
|
-
255
|
|
2341
|
-
],
|
|
2342
|
-
[
|
|
2343
|
-
255,
|
|
2344
|
-
0,
|
|
2345
|
-
255
|
|
2346
|
-
],
|
|
2347
|
-
[
|
|
2348
|
-
0,
|
|
2349
|
-
255,
|
|
2350
|
-
255
|
|
2351
|
-
],
|
|
2352
|
-
[
|
|
2353
|
-
255,
|
|
2354
|
-
255,
|
|
2355
|
-
255
|
|
2356
|
-
]
|
|
2357
|
-
];
|
|
2358
|
-
ANSI16_SLOT_HEX = {
|
|
2359
|
-
black: "#000000",
|
|
2360
|
-
red: "#800000",
|
|
2361
|
-
green: "#008000",
|
|
2362
|
-
yellow: "#808000",
|
|
2363
|
-
blue: "#000080",
|
|
2364
|
-
magenta: "#800080",
|
|
2365
|
-
cyan: "#008080",
|
|
2366
|
-
white: "#c0c0c0",
|
|
2367
|
-
blackBright: "#808080",
|
|
2368
|
-
gray: "#808080",
|
|
2369
|
-
grey: "#808080",
|
|
2370
|
-
redBright: "#ff0000",
|
|
2371
|
-
greenBright: "#00ff00",
|
|
2372
|
-
yellowBright: "#ffff00",
|
|
2373
|
-
blueBright: "#0000ff",
|
|
2374
|
-
magentaBright: "#ff00ff",
|
|
2375
|
-
cyanBright: "#00ffff",
|
|
2376
|
-
whiteBright: "#ffffff"
|
|
2377
|
-
};
|
|
2378
|
-
HEX_LEAF_RE$1 = /^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/;
|
|
2379
|
-
}));
|
|
2380
2571
|
//#endregion
|
|
2381
2572
|
//#region packages/ansi/src/profile.ts
|
|
2382
2573
|
/**
|
|
2574
|
+
* Terminal profile — single source of truth for terminal detection.
|
|
2575
|
+
*
|
|
2576
|
+
* One function, one profile. Collapses the previously redundant trio of
|
|
2577
|
+
* `detectColor()`, `detectTerminalCaps()`, and `resolveColorTier()` into a
|
|
2578
|
+
* single entry point: {@link createTerminalProfile}.
|
|
2579
|
+
*
|
|
2580
|
+
* Phase 3 of `km-silvery.terminal-profile-plateau`. Phase 4 (unify entry
|
|
2581
|
+
* points) will thread the profile through `run()`, `createApp().run()`, and
|
|
2582
|
+
* `render()` so every Term instance is populated from one detection pass.
|
|
2583
|
+
*
|
|
2584
|
+
* Post km-silvery.plateau-naming-polish (2026-04-23): 2-layer shape —
|
|
2585
|
+
* `profile.caps` (protocol flags + `maybe*` heuristics) and `profile.emulator`
|
|
2586
|
+
* (program/version/TERM). The former `profile.heuristics` namespace was
|
|
2587
|
+
* absorbed into caps with a `maybe` prefix per-field.
|
|
2588
|
+
*
|
|
2589
|
+
* Phase 7 of `km-silvery.caps-restructure` (Pro verdict 2026-04-23) originally
|
|
2590
|
+
* split the flat `TerminalCaps` into three layers; the heuristics layer proved
|
|
2591
|
+
* too small to earn its own namespace and was collapsed in the naming polish.
|
|
2592
|
+
*/
|
|
2593
|
+
/**
|
|
2383
2594
|
* Build a {@link TerminalProfile} from the current environment.
|
|
2384
2595
|
*
|
|
2385
2596
|
* Priority for the final `colorLevel` (highest wins):
|
|
2386
|
-
* 1. `
|
|
2387
|
-
* 2. `
|
|
2597
|
+
* 1. `FORCE_COLOR` env var → `0/false → mono, 1 → ansi16, 2 → 256, 3 → truecolor`
|
|
2598
|
+
* 2. `NO_COLOR` env var → `"mono"`
|
|
2388
2599
|
* 3. `options.colorLevel` (caller-supplied explicit tier)
|
|
2389
2600
|
* 4. `options.caps.colorLevel` (base caps' pre-detected tier)
|
|
2390
2601
|
* 5. Auto-detected tier from env (TERM, COLORTERM, TERM_PROGRAM, …)
|
|
@@ -2407,7 +2618,7 @@ var init_color_maps = __esmMin((() => {
|
|
|
2407
2618
|
* const profile = createTerminalProfile()
|
|
2408
2619
|
* console.log(profile.colorLevel) // "truecolor" on Ghostty
|
|
2409
2620
|
*
|
|
2410
|
-
* // Force a tier (still honors
|
|
2621
|
+
* // Force a tier (still honors FORCE_COLOR / NO_COLOR env precedence)
|
|
2411
2622
|
* const forced = createTerminalProfile({ colorLevel: "256" })
|
|
2412
2623
|
*
|
|
2413
2624
|
* // Term path — base caps already detected, just resolve color tier.
|
|
@@ -2530,6 +2741,8 @@ function freezeProfileInDev(profile) {
|
|
|
2530
2741
|
async function probeTerminalProfile(options = {}) {
|
|
2531
2742
|
const profile = createTerminalProfile(options);
|
|
2532
2743
|
if (options.probeTheme === false) return profile;
|
|
2744
|
+
let kittyGraphics = profile.caps.kittyGraphics;
|
|
2745
|
+
if (kittyGraphics && options.input) kittyGraphics = await probeKittyGraphics(options.input, options.timeoutMs ?? 150) === true;
|
|
2533
2746
|
const theme = await detectTheme({
|
|
2534
2747
|
caps: profile.caps,
|
|
2535
2748
|
fallbackDark: options.fallbackDark,
|
|
@@ -2538,8 +2751,13 @@ async function probeTerminalProfile(options = {}) {
|
|
|
2538
2751
|
input: options.input
|
|
2539
2752
|
});
|
|
2540
2753
|
const resolvedTheme = profile.caps.colorForced ? pickColorLevel(theme, profile.colorLevel) : theme;
|
|
2754
|
+
const caps = kittyGraphics === profile.caps.kittyGraphics ? profile.caps : {
|
|
2755
|
+
...profile.caps,
|
|
2756
|
+
kittyGraphics
|
|
2757
|
+
};
|
|
2541
2758
|
return freezeProfileInDev({
|
|
2542
2759
|
...profile,
|
|
2760
|
+
caps,
|
|
2543
2761
|
theme: resolvedTheme
|
|
2544
2762
|
});
|
|
2545
2763
|
}
|
|
@@ -2549,15 +2767,8 @@ async function probeTerminalProfile(options = {}) {
|
|
|
2549
2767
|
* `process.env` twice.
|
|
2550
2768
|
*/
|
|
2551
2769
|
function detectColorFromEnv(env, stdout) {
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
if (forceColor !== void 0) {
|
|
2555
|
-
if (forceColor === "0" || forceColor === "false") return "mono";
|
|
2556
|
-
if (forceColor === "1") return "ansi16";
|
|
2557
|
-
if (forceColor === "2") return "256";
|
|
2558
|
-
if (forceColor === "3") return "truecolor";
|
|
2559
|
-
return "ansi16";
|
|
2560
|
-
}
|
|
2770
|
+
const envTier = envColorTier(env);
|
|
2771
|
+
if (envTier !== void 0) return envTier;
|
|
2561
2772
|
if (!stdout.isTTY) return "mono";
|
|
2562
2773
|
if (env.TERM === "dumb") return "mono";
|
|
2563
2774
|
const colorTerm = env.COLORTERM;
|
|
@@ -2580,7 +2791,6 @@ function detectColorFromEnv(env, stdout) {
|
|
|
2580
2791
|
* env always beats caller-supplied overrides.
|
|
2581
2792
|
*/
|
|
2582
2793
|
function envColorTier(env) {
|
|
2583
|
-
if (env.NO_COLOR !== void 0) return "mono";
|
|
2584
2794
|
const force = env.FORCE_COLOR;
|
|
2585
2795
|
if (force !== void 0) {
|
|
2586
2796
|
if (force === "0" || force === "false") return "mono";
|
|
@@ -2589,6 +2799,7 @@ function envColorTier(env) {
|
|
|
2589
2799
|
if (force === "3") return "truecolor";
|
|
2590
2800
|
return "ansi16";
|
|
2591
2801
|
}
|
|
2802
|
+
if (env.NO_COLOR !== void 0) return "mono";
|
|
2592
2803
|
}
|
|
2593
2804
|
/**
|
|
2594
2805
|
* Deterministic env-based detection of the full two-layer profile
|
|
@@ -2604,7 +2815,7 @@ function detectTerminalProfileFromEnv(env, stdout) {
|
|
|
2604
2815
|
const TERM = env.TERM ?? "";
|
|
2605
2816
|
const noColor = env.NO_COLOR !== void 0;
|
|
2606
2817
|
const isAppleTerminal = programLower === "apple_terminal";
|
|
2607
|
-
const colorLevel =
|
|
2818
|
+
const colorLevel = detectColorFromEnv(env, stdout);
|
|
2608
2819
|
const isKitty = TERM === "xterm-kitty";
|
|
2609
2820
|
const isITerm = programLower === "iterm.app";
|
|
2610
2821
|
const isGhostty = programLower === "ghostty";
|
|
@@ -2664,7 +2875,7 @@ function detectTerminalProfileFromEnv(env, stdout) {
|
|
|
2664
2875
|
sixel: !isDumb && (isFoot || isWezTerm),
|
|
2665
2876
|
osc52: isModern || !isDumb && isAlacritty,
|
|
2666
2877
|
hyperlinks: isModern || !isDumb && isAlacritty,
|
|
2667
|
-
notifications: isITerm ||
|
|
2878
|
+
notifications: isDumb ? false : isKitty ? "osc99" : isITerm ? "osc9" : isGhostty || isWezTerm || isFoot ? "osc777" : false,
|
|
2668
2879
|
syncOutput: isModern || !isDumb && isAlacritty,
|
|
2669
2880
|
maybeDarkBackground,
|
|
2670
2881
|
maybeNerdFont,
|
|
@@ -2688,10 +2899,20 @@ function utf8Locale(env) {
|
|
|
2688
2899
|
function termImpliesUnicode(term) {
|
|
2689
2900
|
return term.includes("xterm") || term.includes("rxvt") || term.includes("screen") || term.includes("tmux");
|
|
2690
2901
|
}
|
|
2902
|
+
const CI_ENVS = [
|
|
2903
|
+
"CI",
|
|
2904
|
+
"GITHUB_ACTIONS",
|
|
2905
|
+
"GITLAB_CI",
|
|
2906
|
+
"JENKINS_URL",
|
|
2907
|
+
"BUILDKITE",
|
|
2908
|
+
"CIRCLECI",
|
|
2909
|
+
"TRAVIS"
|
|
2910
|
+
];
|
|
2911
|
+
let cachedMacOSDarkMode;
|
|
2691
2912
|
function detectMacOSDarkMode() {
|
|
2692
2913
|
if (cachedMacOSDarkMode !== void 0) return cachedMacOSDarkMode;
|
|
2693
2914
|
try {
|
|
2694
|
-
const { spawnSync } =
|
|
2915
|
+
const { spawnSync } = process.getBuiltinModule("node:child_process");
|
|
2695
2916
|
cachedMacOSDarkMode = spawnSync("defaults", [
|
|
2696
2917
|
"read",
|
|
2697
2918
|
"-g",
|
|
@@ -2705,60 +2926,76 @@ function detectMacOSDarkMode() {
|
|
|
2705
2926
|
}
|
|
2706
2927
|
return cachedMacOSDarkMode;
|
|
2707
2928
|
}
|
|
2708
|
-
var CI_ENVS, cachedMacOSDarkMode;
|
|
2709
|
-
var init_profile = __esmMin((() => {
|
|
2710
|
-
init_caps();
|
|
2711
|
-
init_emulator();
|
|
2712
|
-
init_detect();
|
|
2713
|
-
init_color_maps();
|
|
2714
|
-
CI_ENVS = [
|
|
2715
|
-
"CI",
|
|
2716
|
-
"GITHUB_ACTIONS",
|
|
2717
|
-
"GITLAB_CI",
|
|
2718
|
-
"JENKINS_URL",
|
|
2719
|
-
"BUILDKITE",
|
|
2720
|
-
"CIRCLECI",
|
|
2721
|
-
"TRAVIS"
|
|
2722
|
-
];
|
|
2723
|
-
}));
|
|
2724
2929
|
//#endregion
|
|
2725
2930
|
//#region packages/ansi/src/sgr-codes.ts
|
|
2726
2931
|
/**
|
|
2727
|
-
*
|
|
2728
|
-
*
|
|
2729
|
-
*
|
|
2730
|
-
*
|
|
2932
|
+
* Marker bit for the PACKED numeric truecolor form: `0x1000000 | r<<16 | g<<8 | b`.
|
|
2933
|
+
* ag-term's ANSI parser (unicode.ts) tracks inline truecolor SGR in this compact
|
|
2934
|
+
* form, and those numbers reach fg/bgColorCode via styleToAnsiCodes when wrapped
|
|
2935
|
+
* text re-emits carried styles (fixSgrAcrossWrappedLines).
|
|
2731
2936
|
*/
|
|
2937
|
+
const PACKED_TRUECOLOR = 16777216;
|
|
2938
|
+
/** The palette slot for a color, or `undefined` for a genuine truecolor. */
|
|
2939
|
+
function paletteSlot(color) {
|
|
2940
|
+
const idx = typeof color === "number" ? color : color.index;
|
|
2941
|
+
return typeof idx === "number" && idx >= 0 && idx <= 255 ? idx : void 0;
|
|
2942
|
+
}
|
|
2943
|
+
/** Resolve a non-palette color to truecolor components, unpacking the packed numeric form. */
|
|
2944
|
+
function truecolorRgb(color) {
|
|
2945
|
+
if (typeof color === "number") {
|
|
2946
|
+
if (color >= PACKED_TRUECOLOR && color <= 33554431) return {
|
|
2947
|
+
r: color >> 16 & 255,
|
|
2948
|
+
g: color >> 8 & 255,
|
|
2949
|
+
b: color & 255
|
|
2950
|
+
};
|
|
2951
|
+
throw new Error(`sgr-codes: number ${color} is neither a palette slot (0-255) nor a packed truecolor (0x1000000|rgb)`);
|
|
2952
|
+
}
|
|
2953
|
+
return color;
|
|
2954
|
+
}
|
|
2732
2955
|
/**
|
|
2733
2956
|
* Emit the shortest SGR code string for a foreground color.
|
|
2734
2957
|
* - Basic 0-7: 4-bit code (30+N)
|
|
2735
2958
|
* - Extended 8-255: 256-color (38;5;N)
|
|
2736
|
-
* - RGB: true color (38;2;R;G;B)
|
|
2959
|
+
* - RGB (no palette index): true color (38;2;R;G;B)
|
|
2737
2960
|
*/
|
|
2738
2961
|
function fgColorCode(color) {
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
return
|
|
2962
|
+
const slot = paletteSlot(color);
|
|
2963
|
+
if (slot !== void 0) {
|
|
2964
|
+
if (slot <= 7) return `${30 + slot}`;
|
|
2965
|
+
return `38;5;${slot}`;
|
|
2742
2966
|
}
|
|
2743
|
-
|
|
2967
|
+
const { r, g, b } = truecolorRgb(color);
|
|
2968
|
+
return `38;2;${r};${g};${b}`;
|
|
2744
2969
|
}
|
|
2745
2970
|
/**
|
|
2746
2971
|
* Emit the shortest SGR code string for a background color.
|
|
2747
2972
|
* - Basic 0-7: 4-bit code (40+N)
|
|
2748
2973
|
* - Extended 8-255: 256-color (48;5;N)
|
|
2749
|
-
* - RGB: true color (48;2;R;G;B)
|
|
2974
|
+
* - RGB (no palette index): true color (48;2;R;G;B)
|
|
2750
2975
|
*/
|
|
2751
2976
|
function bgColorCode(color) {
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
return
|
|
2977
|
+
const slot = paletteSlot(color);
|
|
2978
|
+
if (slot !== void 0) {
|
|
2979
|
+
if (slot <= 7) return `${40 + slot}`;
|
|
2980
|
+
return `48;5;${slot}`;
|
|
2755
2981
|
}
|
|
2756
|
-
|
|
2982
|
+
const { r, g, b } = truecolorRgb(color);
|
|
2983
|
+
return `48;2;${r};${g};${b}`;
|
|
2757
2984
|
}
|
|
2758
|
-
var init_sgr_codes = __esmMin((() => {}));
|
|
2759
2985
|
//#endregion
|
|
2760
2986
|
//#region packages/ansi/src/utils.ts
|
|
2761
2987
|
/**
|
|
2988
|
+
* Process-lifetime set of warning IDs that have already fired. Used by
|
|
2989
|
+
* {@link warnOnce} to avoid console spam on every re-render / every paste /
|
|
2990
|
+
* every parse. Shared across packages — one latch per warning ID, regardless
|
|
2991
|
+
* of which module emits it.
|
|
2992
|
+
*
|
|
2993
|
+
* Intentionally process-global (not scoped per {@link Term}) because the
|
|
2994
|
+
* warnings gated here describe developer-mistake conditions that are
|
|
2995
|
+
* semantically "once per process": spam is worse than missed repeats.
|
|
2996
|
+
*/
|
|
2997
|
+
const _firedWarnings = /* @__PURE__ */ new Set();
|
|
2998
|
+
/**
|
|
2762
2999
|
* Emit a warning exactly once per process, keyed by `id`.
|
|
2763
3000
|
*
|
|
2764
3001
|
* The first call with a given `id` invokes `emit(message)`; subsequent calls
|
|
@@ -2795,12 +3032,56 @@ function warnOnce(id, emit) {
|
|
|
2795
3032
|
_firedWarnings.add(id);
|
|
2796
3033
|
emit();
|
|
2797
3034
|
}
|
|
2798
|
-
var _firedWarnings;
|
|
2799
|
-
var init_utils = __esmMin((() => {
|
|
2800
|
-
_firedWarnings = /* @__PURE__ */ new Set();
|
|
2801
|
-
}));
|
|
2802
3035
|
//#endregion
|
|
2803
3036
|
//#region packages/ansi/src/flatten.ts
|
|
3037
|
+
/**
|
|
3038
|
+
* Channel-role-state default rule. Matches Sterling / Primer / CSS-var
|
|
3039
|
+
* conventions: `{kind}-{role}[-{state}]`, with `fg-on-{role}` for `fgOn`,
|
|
3040
|
+
* and implicit-kind collapse for the `surface` / `border` roles.
|
|
3041
|
+
*
|
|
3042
|
+
* Mapping examples:
|
|
3043
|
+
* | Path | Flat key |
|
|
3044
|
+
* | ---------------------------- | --------------------------- |
|
|
3045
|
+
* | `accent.fg` | `fg-accent` |
|
|
3046
|
+
* | `accent.bg` | `bg-accent` |
|
|
3047
|
+
* | `accent.fgOn` | `fg-on-accent` |
|
|
3048
|
+
* | `inverse.muted.fgOn` | `fg-on-inverse-muted` |
|
|
3049
|
+
* | `accent.border` | `border-accent` |
|
|
3050
|
+
* | `accent.hover.bg` | `bg-accent-hover` |
|
|
3051
|
+
* | `accent.active.fg` | `fg-accent-active` |
|
|
3052
|
+
* | `info.hover.bg` | `bg-info-hover` |
|
|
3053
|
+
* | `cursor.fg` | `fg-cursor` |
|
|
3054
|
+
* | `muted.bg` | `bg-muted` |
|
|
3055
|
+
* | `surface.default` | `bg-surface-default` |
|
|
3056
|
+
* | `surface.subtle` | `bg-surface-subtle` |
|
|
3057
|
+
* | `surface.hover` | `bg-surface-hover` |
|
|
3058
|
+
* | `border.default` | `border-default` |
|
|
3059
|
+
* | `border.focus` | `border-focus` |
|
|
3060
|
+
* | `border.muted` | `border-muted` |
|
|
3061
|
+
*
|
|
3062
|
+
* Returns `null` for depth-1 leaves (e.g. `mode`, `name` — not role-scoped)
|
|
3063
|
+
* so metadata doesn't get flattened. The caller (`bakeFlat`) already filters
|
|
3064
|
+
* non-hex leaves, but the rule also guards paths shorter than 2 segments.
|
|
3065
|
+
*/
|
|
3066
|
+
const defaultFlattenRule = (path) => {
|
|
3067
|
+
if (path.length < 2) return null;
|
|
3068
|
+
const role = path[0];
|
|
3069
|
+
const last = path[path.length - 1];
|
|
3070
|
+
const mid = path.slice(1, -1);
|
|
3071
|
+
if (last === "fgOn") {
|
|
3072
|
+
const state = mid.length > 0 ? mid.join("-") : void 0;
|
|
3073
|
+
return state ? `fg-on-${role}-${state}` : `fg-on-${role}`;
|
|
3074
|
+
}
|
|
3075
|
+
if (last === "fg" || last === "bg" || last === "border") {
|
|
3076
|
+
const state = mid.length > 0 ? mid.join("-") : void 0;
|
|
3077
|
+
return state ? `${last}-${role}-${state}` : `${last}-${role}`;
|
|
3078
|
+
}
|
|
3079
|
+
if (role === "surface") return `bg-surface-${last}`;
|
|
3080
|
+
if (role === "border") return `border-${last}`;
|
|
3081
|
+
return null;
|
|
3082
|
+
};
|
|
3083
|
+
/** Matches `#rgb`, `#rrggbb`, and `#rrggbbaa` (case-insensitive). */
|
|
3084
|
+
const HEX_LEAF_RE = /^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?([0-9a-fA-F]{2})?$/;
|
|
2804
3085
|
function isHexLeaf(value) {
|
|
2805
3086
|
return typeof value === "string" && HEX_LEAF_RE.test(value);
|
|
2806
3087
|
}
|
|
@@ -2849,26 +3130,25 @@ function freezeDeep(o) {
|
|
|
2849
3130
|
Object.freeze(o);
|
|
2850
3131
|
for (const k of Object.keys(o)) freezeDeep(o[k]);
|
|
2851
3132
|
}
|
|
2852
|
-
var defaultFlattenRule, HEX_LEAF_RE;
|
|
2853
|
-
var init_flatten = __esmMin((() => {
|
|
2854
|
-
defaultFlattenRule = (path) => {
|
|
2855
|
-
if (path.length < 2) return null;
|
|
2856
|
-
const role = path[0];
|
|
2857
|
-
const last = path[path.length - 1];
|
|
2858
|
-
const mid = path.slice(1, -1);
|
|
2859
|
-
if (last === "fgOn") return `fg-on-${role}`;
|
|
2860
|
-
if (last === "fg" || last === "bg" || last === "border") {
|
|
2861
|
-
const state = mid.length > 0 ? mid.join("-") : void 0;
|
|
2862
|
-
return state ? `${last}-${role}-${state}` : `${last}-${role}`;
|
|
2863
|
-
}
|
|
2864
|
-
if (role === "surface") return `bg-surface-${last}`;
|
|
2865
|
-
if (role === "border") return `border-${last}`;
|
|
2866
|
-
return null;
|
|
2867
|
-
};
|
|
2868
|
-
HEX_LEAF_RE = /^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?([0-9a-fA-F]{2})?$/;
|
|
2869
|
-
}));
|
|
2870
3133
|
//#endregion
|
|
2871
3134
|
//#region packages/ansi/src/terminal-control.ts
|
|
3135
|
+
/**
|
|
3136
|
+
* ANSI terminal control helpers.
|
|
3137
|
+
*
|
|
3138
|
+
* Pure string-returning functions for terminal control sequences.
|
|
3139
|
+
* No side effects, no stdout writes -- consumers compose and write.
|
|
3140
|
+
*
|
|
3141
|
+
* Covers: screen management, cursor control, scroll regions,
|
|
3142
|
+
* mouse tracking, keyboard protocols, and bracketed paste.
|
|
3143
|
+
*
|
|
3144
|
+
* @see https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
|
|
3145
|
+
* @see https://sw.kovidgoyal.net/kitty/keyboard-protocol/
|
|
3146
|
+
*/
|
|
3147
|
+
/** Escape character (0x1B) */
|
|
3148
|
+
const ESC$1 = "\x1B";
|
|
3149
|
+
/** Control Sequence Introducer: ESC [ */
|
|
3150
|
+
const CSI$1 = `${ESC$1}[`;
|
|
3151
|
+
`${ESC$1}`;
|
|
2872
3152
|
function enableMouse(options = {}) {
|
|
2873
3153
|
return `${CSI$1}?1003h${CSI$1}?1006h${options.pixels ? `${CSI$1}?1016h` : ""}`;
|
|
2874
3154
|
}
|
|
@@ -2920,15 +3200,58 @@ function enableKittyKeyboard(flags = 1) {
|
|
|
2920
3200
|
function disableKittyKeyboard() {
|
|
2921
3201
|
return `${CSI$1}<u`;
|
|
2922
3202
|
}
|
|
2923
|
-
var ESC$1, CSI$1;
|
|
2924
|
-
var init_terminal_control = __esmMin((() => {
|
|
2925
|
-
ESC$1 = "\x1B";
|
|
2926
|
-
CSI$1 = `${ESC$1}[`;
|
|
2927
|
-
`${ESC$1}`;
|
|
2928
|
-
}));
|
|
2929
3203
|
//#endregion
|
|
2930
3204
|
//#region packages/ansi/src/kitty-graphics.ts
|
|
2931
3205
|
/**
|
|
3206
|
+
* Kitty graphics protocol — minimal encoder for cell-sized overlay placements.
|
|
3207
|
+
*
|
|
3208
|
+
* Used by the backdrop-fade pass to fade emoji/wide-char glyphs (SGR 2 "dim"
|
|
3209
|
+
* is a no-op on bitmap emoji in most terminals). We upload a single tiny
|
|
3210
|
+
* translucent RGBA image once, then emit `a=p` placements over specific cells
|
|
3211
|
+
* with `z=1` so the overlay sits on top of the already-rendered emoji glyph.
|
|
3212
|
+
*
|
|
3213
|
+
* ## Protocol summary
|
|
3214
|
+
*
|
|
3215
|
+
* The Kitty graphics protocol uses APC escapes: `\x1b_G<control>;<payload>\x1b\\`.
|
|
3216
|
+
* Control parameters are key=value pairs separated by commas. Payload is
|
|
3217
|
+
* base64-encoded image data (only on upload).
|
|
3218
|
+
*
|
|
3219
|
+
* Key commands we use:
|
|
3220
|
+
*
|
|
3221
|
+
* | Command | Meaning |
|
|
3222
|
+
* | ----------- | ------------------------------------------------------------- |
|
|
3223
|
+
* | `a=t` | Transmit (upload) image data |
|
|
3224
|
+
* | `a=p` | Place a previously-uploaded image |
|
|
3225
|
+
* | `a=d` | Delete (remove placements and/or free images) |
|
|
3226
|
+
* | `f=32` | RGBA pixel format (4 bytes per pixel) |
|
|
3227
|
+
* | `s=W,v=H` | Source image dimensions in pixels |
|
|
3228
|
+
* | `i=<id>` | Image ID (stable across frames) |
|
|
3229
|
+
* | `p=<id>` | Placement ID (stable per cell) |
|
|
3230
|
+
* | `C=1` | Disable cursor movement after placement (crucial for overlay) |
|
|
3231
|
+
* | `c=<cols>` | Cell column extent |
|
|
3232
|
+
* | `r=<rows>` | Cell row extent |
|
|
3233
|
+
* | `z=<zidx>` | Z-index (0 = below text, 1 = above text) |
|
|
3234
|
+
* | `q=2` | Quiet mode (suppress OK/error responses from terminal) |
|
|
3235
|
+
*
|
|
3236
|
+
* Because the image is tiled into a single cell, `c=1,r=1,C=1` keeps the
|
|
3237
|
+
* placement local — it doesn't shift the rendered text layout.
|
|
3238
|
+
*
|
|
3239
|
+
* @see https://sw.kovidgoyal.net/kitty/graphics-protocol/
|
|
3240
|
+
*/
|
|
3241
|
+
/**
|
|
3242
|
+
* Stable image ID for the backdrop scrim overlay. Uploaded once per terminal
|
|
3243
|
+
* session; placements reuse this ID. Value is arbitrary — just needs to be
|
|
3244
|
+
* unique within the process. 0xBEEF picked for grep-ability.
|
|
3245
|
+
*/
|
|
3246
|
+
const BACKDROP_SCRIM_IMAGE_ID = 48879;
|
|
3247
|
+
/**
|
|
3248
|
+
* Placement ID base for backdrop scrim placements. Each cell gets a unique
|
|
3249
|
+
* placement ID derived from `x * OFFSET + y`. This lets us target individual
|
|
3250
|
+
* placements for deletion while leaving others alive. `i=<id>,p=<pid>` refers
|
|
3251
|
+
* to a single placement.
|
|
3252
|
+
*/
|
|
3253
|
+
const BACKDROP_PLACEMENT_X_STRIDE = 1e4;
|
|
3254
|
+
/**
|
|
2932
3255
|
* Derive a stable placement ID for a given (x, y) cell. Max column = 9999,
|
|
2933
3256
|
* which comfortably exceeds any realistic terminal width.
|
|
2934
3257
|
*/
|
|
@@ -3035,33 +3358,41 @@ function kittyDeleteAllScrimPlacements(imageId = BACKDROP_SCRIM_IMAGE_ID) {
|
|
|
3035
3358
|
function cupTo(col, row) {
|
|
3036
3359
|
return `\x1b[${row + 1};${col + 1}H`;
|
|
3037
3360
|
}
|
|
3038
|
-
var BACKDROP_SCRIM_IMAGE_ID, BACKDROP_PLACEMENT_X_STRIDE;
|
|
3039
|
-
var init_kitty_graphics = __esmMin((() => {
|
|
3040
|
-
BACKDROP_SCRIM_IMAGE_ID = 48879;
|
|
3041
|
-
BACKDROP_PLACEMENT_X_STRIDE = 1e4;
|
|
3042
|
-
}));
|
|
3043
3361
|
//#endregion
|
|
3044
3362
|
//#region packages/ansi/src/style/colors.ts
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
surface: 37
|
|
3060
|
-
};
|
|
3061
|
-
}));
|
|
3363
|
+
/** Default ANSI codes for theme tokens when no theme object is given. */
|
|
3364
|
+
const THEME_TOKEN_DEFAULTS = {
|
|
3365
|
+
primary: 33,
|
|
3366
|
+
secondary: 36,
|
|
3367
|
+
accent: 35,
|
|
3368
|
+
error: 31,
|
|
3369
|
+
warning: 33,
|
|
3370
|
+
success: 32,
|
|
3371
|
+
info: 36,
|
|
3372
|
+
muted: 2,
|
|
3373
|
+
link: 34,
|
|
3374
|
+
border: 90,
|
|
3375
|
+
surface: 37
|
|
3376
|
+
};
|
|
3062
3377
|
//#endregion
|
|
3063
3378
|
//#region packages/ansi/src/style/style.ts
|
|
3064
3379
|
/**
|
|
3380
|
+
* createStyle() — theme-aware chalk replacement.
|
|
3381
|
+
*
|
|
3382
|
+
* Returns a chainable Proxy-based style object. Access properties to
|
|
3383
|
+
* accumulate styles, call with a string to apply them.
|
|
3384
|
+
*
|
|
3385
|
+
* @example
|
|
3386
|
+
* ```ts
|
|
3387
|
+
* const s = createStyle()
|
|
3388
|
+
* s.bold.red("error") // "\x1b[1;31merror\x1b[22;39m"
|
|
3389
|
+
* s.hex("#ff0000")("text") // truecolor foreground
|
|
3390
|
+
*
|
|
3391
|
+
* const s = createStyle({ theme })
|
|
3392
|
+
* s.primary("deploy") // resolves $primary from theme
|
|
3393
|
+
* ```
|
|
3394
|
+
*/
|
|
3395
|
+
/**
|
|
3065
3396
|
* Resolve a color value against a theme — the canonical token resolver.
|
|
3066
3397
|
*
|
|
3067
3398
|
* If the color starts with `$`, looks up the token in the theme.
|
|
@@ -3112,6 +3443,35 @@ function resolveToken(name, theme) {
|
|
|
3112
3443
|
if (typeof stripped === "string") return stripped;
|
|
3113
3444
|
}
|
|
3114
3445
|
}
|
|
3446
|
+
const ESC = "\x1B[";
|
|
3447
|
+
const KNOWN_METHODS = new Set([
|
|
3448
|
+
"hex",
|
|
3449
|
+
"rgb",
|
|
3450
|
+
"bgHex",
|
|
3451
|
+
"bgRgb",
|
|
3452
|
+
"ansi256",
|
|
3453
|
+
"bgAnsi256",
|
|
3454
|
+
"resolve",
|
|
3455
|
+
"curlyUnderline",
|
|
3456
|
+
"dottedUnderline",
|
|
3457
|
+
"dashedUnderline",
|
|
3458
|
+
"doubleUnderline",
|
|
3459
|
+
"underlineColor",
|
|
3460
|
+
"styledUnderline"
|
|
3461
|
+
]);
|
|
3462
|
+
const THEME_TOKENS = new Set([
|
|
3463
|
+
"primary",
|
|
3464
|
+
"secondary",
|
|
3465
|
+
"accent",
|
|
3466
|
+
"error",
|
|
3467
|
+
"warning",
|
|
3468
|
+
"success",
|
|
3469
|
+
"info",
|
|
3470
|
+
"muted",
|
|
3471
|
+
"link",
|
|
3472
|
+
"border",
|
|
3473
|
+
"surface"
|
|
3474
|
+
]);
|
|
3115
3475
|
/** Convert chalk numeric level (0-3) to {@link ColorLevel}. */
|
|
3116
3476
|
function fromChalkLevel(n) {
|
|
3117
3477
|
if (n <= 0) return "mono";
|
|
@@ -3177,6 +3537,7 @@ function createStyle(options) {
|
|
|
3177
3537
|
closes: []
|
|
3178
3538
|
}, ref);
|
|
3179
3539
|
}
|
|
3540
|
+
createStyle();
|
|
3180
3541
|
/**
|
|
3181
3542
|
* Create a chain that reads level from a mutable ref.
|
|
3182
3543
|
* This allows `style.level = 3` to affect all subsequent calls.
|
|
@@ -3344,6 +3705,8 @@ function createChainWithRef(state, ref) {
|
|
|
3344
3705
|
proxyRef.proxy = proxy;
|
|
3345
3706
|
return proxy;
|
|
3346
3707
|
}
|
|
3708
|
+
const UNDERLINE_OPEN = "\x1B[4m";
|
|
3709
|
+
const UNDERLINE_CLOSE = "\x1B[24m";
|
|
3347
3710
|
/** `style.curlyUnderline(text)` / `.dotted` / `.dashed` / `.double`. */
|
|
3348
3711
|
function applyExtendedUnderline(text, name, ref) {
|
|
3349
3712
|
if (ref.level === "mono") return text;
|
|
@@ -3365,46 +3728,17 @@ function applyStyledUnderline(text, name, rgb, ref) {
|
|
|
3365
3728
|
if (!ref.caps.underlineColor) return `${styleCode}${text}${UNDERLINE_CODES.reset}`;
|
|
3366
3729
|
return `${styleCode}${buildUnderlineColorCode(r, g, b)}${text}${UNDERLINE_CODES.reset}${UNDERLINE_COLOR_RESET}`;
|
|
3367
3730
|
}
|
|
3368
|
-
var ESC, KNOWN_METHODS, THEME_TOKENS, UNDERLINE_OPEN, UNDERLINE_CLOSE;
|
|
3369
|
-
var init_style = __esmMin((() => {
|
|
3370
|
-
init_profile();
|
|
3371
|
-
init_constants();
|
|
3372
|
-
init_colors();
|
|
3373
|
-
ESC = "\x1B[";
|
|
3374
|
-
KNOWN_METHODS = new Set([
|
|
3375
|
-
"hex",
|
|
3376
|
-
"rgb",
|
|
3377
|
-
"bgHex",
|
|
3378
|
-
"bgRgb",
|
|
3379
|
-
"ansi256",
|
|
3380
|
-
"bgAnsi256",
|
|
3381
|
-
"resolve",
|
|
3382
|
-
"curlyUnderline",
|
|
3383
|
-
"dottedUnderline",
|
|
3384
|
-
"dashedUnderline",
|
|
3385
|
-
"doubleUnderline",
|
|
3386
|
-
"underlineColor",
|
|
3387
|
-
"styledUnderline"
|
|
3388
|
-
]);
|
|
3389
|
-
THEME_TOKENS = new Set([
|
|
3390
|
-
"primary",
|
|
3391
|
-
"secondary",
|
|
3392
|
-
"accent",
|
|
3393
|
-
"error",
|
|
3394
|
-
"warning",
|
|
3395
|
-
"success",
|
|
3396
|
-
"info",
|
|
3397
|
-
"muted",
|
|
3398
|
-
"link",
|
|
3399
|
-
"border",
|
|
3400
|
-
"surface"
|
|
3401
|
-
]);
|
|
3402
|
-
createStyle();
|
|
3403
|
-
UNDERLINE_OPEN = "\x1B[4m";
|
|
3404
|
-
UNDERLINE_CLOSE = "\x1B[24m";
|
|
3405
|
-
}));
|
|
3406
3731
|
//#endregion
|
|
3407
3732
|
//#region packages/ansi/src/style/mixed-proxy.ts
|
|
3733
|
+
/** Methods on Style that take arguments and return a new Style chain. */
|
|
3734
|
+
const STYLE_METHODS = new Set([
|
|
3735
|
+
"hex",
|
|
3736
|
+
"bgHex",
|
|
3737
|
+
"rgb",
|
|
3738
|
+
"bgRgb",
|
|
3739
|
+
"ansi256",
|
|
3740
|
+
"bgAnsi256"
|
|
3741
|
+
]);
|
|
3408
3742
|
/**
|
|
3409
3743
|
* Create a proxy that wraps a style instance with additional properties.
|
|
3410
3744
|
*
|
|
@@ -3462,20 +3796,99 @@ function createChainProxy(currentStyle, extra) {
|
|
|
3462
3796
|
const proxyTarget = function() {};
|
|
3463
3797
|
return new Proxy(proxyTarget, handler);
|
|
3464
3798
|
}
|
|
3465
|
-
var STYLE_METHODS;
|
|
3466
|
-
var init_mixed_proxy = __esmMin((() => {
|
|
3467
|
-
STYLE_METHODS = new Set([
|
|
3468
|
-
"hex",
|
|
3469
|
-
"bgHex",
|
|
3470
|
-
"rgb",
|
|
3471
|
-
"bgRgb",
|
|
3472
|
-
"ansi256",
|
|
3473
|
-
"bgAnsi256"
|
|
3474
|
-
]);
|
|
3475
|
-
}));
|
|
3476
3799
|
//#endregion
|
|
3477
3800
|
//#region packages/ansi/src/theme/monochrome.ts
|
|
3478
3801
|
/**
|
|
3802
|
+
* Default monochrome attrs — Polaris-aligned mapping from the design spec.
|
|
3803
|
+
*
|
|
3804
|
+
* The philosophy: every *semantic* token that would normally carry color gets an
|
|
3805
|
+
* attrs set that preserves its hierarchy rank and state semantics. Example:
|
|
3806
|
+
* error (danger) is bold+inverse so it *grabs* attention even without red;
|
|
3807
|
+
* warning is bold to stand out but not as aggressively; info is italic to
|
|
3808
|
+
* indicate auxiliary information.
|
|
3809
|
+
*
|
|
3810
|
+
* Structural surfaces (bg/mutedbg/surfacebg/popoverbg) have no attrs — they
|
|
3811
|
+
* represent background planes that monochrome terminals can't vary anyway.
|
|
3812
|
+
*/
|
|
3813
|
+
const DEFAULT_MONO_ATTRS = {
|
|
3814
|
+
bg: [],
|
|
3815
|
+
mutedbg: [],
|
|
3816
|
+
surfacebg: [],
|
|
3817
|
+
popoverbg: [],
|
|
3818
|
+
border: [],
|
|
3819
|
+
cursorbg: [],
|
|
3820
|
+
fg: [],
|
|
3821
|
+
muted: ["dim"],
|
|
3822
|
+
disabledfg: ["dim"],
|
|
3823
|
+
surface: [],
|
|
3824
|
+
popover: [],
|
|
3825
|
+
primary: ["bold"],
|
|
3826
|
+
secondary: ["bold"],
|
|
3827
|
+
accent: ["italic", "bold"],
|
|
3828
|
+
error: ["bold", "inverse"],
|
|
3829
|
+
warning: ["bold"],
|
|
3830
|
+
success: ["bold"],
|
|
3831
|
+
info: ["italic"],
|
|
3832
|
+
primaryfg: [],
|
|
3833
|
+
secondaryfg: [],
|
|
3834
|
+
accentfg: [],
|
|
3835
|
+
errorfg: ["inverse"],
|
|
3836
|
+
warningfg: [],
|
|
3837
|
+
successfg: [],
|
|
3838
|
+
infofg: [],
|
|
3839
|
+
focusborder: ["bold"],
|
|
3840
|
+
inputborder: [],
|
|
3841
|
+
cursor: [],
|
|
3842
|
+
"fg-muted": ["dim"],
|
|
3843
|
+
"bg-muted": [],
|
|
3844
|
+
"fg-accent": ["italic", "bold"],
|
|
3845
|
+
"bg-accent": [],
|
|
3846
|
+
"fg-on-accent": [],
|
|
3847
|
+
"border-accent": [],
|
|
3848
|
+
"fg-accent-hover": ["italic", "bold"],
|
|
3849
|
+
"bg-accent-hover": [],
|
|
3850
|
+
"fg-accent-active": ["italic", "bold"],
|
|
3851
|
+
"bg-accent-active": [],
|
|
3852
|
+
"fg-info": ["italic"],
|
|
3853
|
+
"bg-info": [],
|
|
3854
|
+
"fg-on-info": [],
|
|
3855
|
+
"bg-info-hover": [],
|
|
3856
|
+
"bg-info-active": [],
|
|
3857
|
+
"fg-success": ["bold"],
|
|
3858
|
+
"bg-success": [],
|
|
3859
|
+
"fg-on-success": [],
|
|
3860
|
+
"bg-success-hover": [],
|
|
3861
|
+
"bg-success-active": [],
|
|
3862
|
+
"fg-warning": ["bold"],
|
|
3863
|
+
"bg-warning": [],
|
|
3864
|
+
"fg-on-warning": [],
|
|
3865
|
+
"bg-warning-hover": [],
|
|
3866
|
+
"bg-warning-active": [],
|
|
3867
|
+
"fg-error": ["bold", "inverse"],
|
|
3868
|
+
"bg-error": [],
|
|
3869
|
+
"fg-on-error": ["inverse"],
|
|
3870
|
+
"bg-error-hover": [],
|
|
3871
|
+
"bg-error-active": [],
|
|
3872
|
+
"bg-surface-default": [],
|
|
3873
|
+
"bg-surface-subtle": [],
|
|
3874
|
+
"bg-surface-raised": [],
|
|
3875
|
+
"bg-surface-overlay": [],
|
|
3876
|
+
"bg-surface-hover": [],
|
|
3877
|
+
"border-default": [],
|
|
3878
|
+
"border-focus": ["bold"],
|
|
3879
|
+
"border-muted": [],
|
|
3880
|
+
"fg-cursor": [],
|
|
3881
|
+
"bg-cursor": [],
|
|
3882
|
+
"bg-selected": ["inverse"],
|
|
3883
|
+
"fg-on-selected": [],
|
|
3884
|
+
"bg-selected-hover": ["inverse"],
|
|
3885
|
+
"bg-inverse": ["inverse"],
|
|
3886
|
+
"fg-on-inverse": [],
|
|
3887
|
+
"bg-inverse-hover": ["inverse"],
|
|
3888
|
+
"fg-on-inverse-muted": ["dim"],
|
|
3889
|
+
"fg-link": ["underline"]
|
|
3890
|
+
};
|
|
3891
|
+
/**
|
|
3479
3892
|
* Produce per-token monochrome attrs from a base Theme.
|
|
3480
3893
|
*
|
|
3481
3894
|
* Currently returns `DEFAULT_MONO_ATTRS` — a canonical mapping. Passed the
|
|
@@ -3517,87 +3930,29 @@ function monoAttrsForColorString(color, theme) {
|
|
|
3517
3930
|
if (stripped !== void 0) return stripped;
|
|
3518
3931
|
}
|
|
3519
3932
|
}
|
|
3520
|
-
var DEFAULT_MONO_ATTRS;
|
|
3521
|
-
var init_monochrome = __esmMin((() => {
|
|
3522
|
-
DEFAULT_MONO_ATTRS = {
|
|
3523
|
-
bg: [],
|
|
3524
|
-
mutedbg: [],
|
|
3525
|
-
surfacebg: [],
|
|
3526
|
-
popoverbg: [],
|
|
3527
|
-
border: [],
|
|
3528
|
-
cursorbg: [],
|
|
3529
|
-
fg: [],
|
|
3530
|
-
muted: ["dim"],
|
|
3531
|
-
disabledfg: ["dim"],
|
|
3532
|
-
surface: [],
|
|
3533
|
-
popover: [],
|
|
3534
|
-
primary: ["bold"],
|
|
3535
|
-
secondary: ["bold"],
|
|
3536
|
-
accent: ["italic", "bold"],
|
|
3537
|
-
error: ["bold", "inverse"],
|
|
3538
|
-
warning: ["bold"],
|
|
3539
|
-
success: ["bold"],
|
|
3540
|
-
info: ["italic"],
|
|
3541
|
-
primaryfg: [],
|
|
3542
|
-
secondaryfg: [],
|
|
3543
|
-
accentfg: [],
|
|
3544
|
-
errorfg: ["inverse"],
|
|
3545
|
-
warningfg: [],
|
|
3546
|
-
successfg: [],
|
|
3547
|
-
infofg: [],
|
|
3548
|
-
focusborder: ["bold"],
|
|
3549
|
-
inputborder: [],
|
|
3550
|
-
cursor: [],
|
|
3551
|
-
"fg-muted": ["dim"],
|
|
3552
|
-
"bg-muted": [],
|
|
3553
|
-
"fg-accent": ["italic", "bold"],
|
|
3554
|
-
"bg-accent": [],
|
|
3555
|
-
"fg-on-accent": [],
|
|
3556
|
-
"border-accent": [],
|
|
3557
|
-
"fg-accent-hover": ["italic", "bold"],
|
|
3558
|
-
"bg-accent-hover": [],
|
|
3559
|
-
"fg-accent-active": ["italic", "bold"],
|
|
3560
|
-
"bg-accent-active": [],
|
|
3561
|
-
"fg-info": ["italic"],
|
|
3562
|
-
"bg-info": [],
|
|
3563
|
-
"fg-on-info": [],
|
|
3564
|
-
"bg-info-hover": [],
|
|
3565
|
-
"bg-info-active": [],
|
|
3566
|
-
"fg-success": ["bold"],
|
|
3567
|
-
"bg-success": [],
|
|
3568
|
-
"fg-on-success": [],
|
|
3569
|
-
"bg-success-hover": [],
|
|
3570
|
-
"bg-success-active": [],
|
|
3571
|
-
"fg-warning": ["bold"],
|
|
3572
|
-
"bg-warning": [],
|
|
3573
|
-
"fg-on-warning": [],
|
|
3574
|
-
"bg-warning-hover": [],
|
|
3575
|
-
"bg-warning-active": [],
|
|
3576
|
-
"fg-error": ["bold", "inverse"],
|
|
3577
|
-
"bg-error": [],
|
|
3578
|
-
"fg-on-error": ["inverse"],
|
|
3579
|
-
"bg-error-hover": [],
|
|
3580
|
-
"bg-error-active": [],
|
|
3581
|
-
"bg-surface-default": [],
|
|
3582
|
-
"bg-surface-subtle": [],
|
|
3583
|
-
"bg-surface-raised": [],
|
|
3584
|
-
"bg-surface-overlay": [],
|
|
3585
|
-
"bg-surface-hover": [],
|
|
3586
|
-
"border-default": [],
|
|
3587
|
-
"border-focus": ["bold"],
|
|
3588
|
-
"border-muted": [],
|
|
3589
|
-
"fg-cursor": [],
|
|
3590
|
-
"bg-cursor": [],
|
|
3591
|
-
"bg-selected": ["inverse"],
|
|
3592
|
-
"fg-on-selected": [],
|
|
3593
|
-
"bg-selected-hover": ["inverse"],
|
|
3594
|
-
"bg-inverse": ["inverse"],
|
|
3595
|
-
"fg-on-inverse": [],
|
|
3596
|
-
"fg-link": ["underline"]
|
|
3597
|
-
};
|
|
3598
|
-
}));
|
|
3599
3933
|
//#endregion
|
|
3600
3934
|
//#region packages/ansi/src/theme/fingerprint.ts
|
|
3935
|
+
/** Fields that are always probed and used for fingerprinting. */
|
|
3936
|
+
const FINGERPRINT_FIELDS = [
|
|
3937
|
+
"foreground",
|
|
3938
|
+
"background",
|
|
3939
|
+
"black",
|
|
3940
|
+
"red",
|
|
3941
|
+
"green",
|
|
3942
|
+
"yellow",
|
|
3943
|
+
"blue",
|
|
3944
|
+
"magenta",
|
|
3945
|
+
"cyan",
|
|
3946
|
+
"white",
|
|
3947
|
+
"brightBlack",
|
|
3948
|
+
"brightRed",
|
|
3949
|
+
"brightGreen",
|
|
3950
|
+
"brightYellow",
|
|
3951
|
+
"brightBlue",
|
|
3952
|
+
"brightMagenta",
|
|
3953
|
+
"brightCyan",
|
|
3954
|
+
"brightWhite"
|
|
3955
|
+
];
|
|
3601
3956
|
/**
|
|
3602
3957
|
* Map ΔE thresholds into a 0–1 confidence.
|
|
3603
3958
|
*
|
|
@@ -3650,58 +4005,32 @@ function fingerprintMatch(probed, catalog, opts = {}) {
|
|
|
3650
4005
|
}
|
|
3651
4006
|
return best;
|
|
3652
4007
|
}
|
|
3653
|
-
var FINGERPRINT_FIELDS;
|
|
3654
|
-
var init_fingerprint = __esmMin((() => {
|
|
3655
|
-
FINGERPRINT_FIELDS = [
|
|
3656
|
-
"foreground",
|
|
3657
|
-
"background",
|
|
3658
|
-
"black",
|
|
3659
|
-
"red",
|
|
3660
|
-
"green",
|
|
3661
|
-
"yellow",
|
|
3662
|
-
"blue",
|
|
3663
|
-
"magenta",
|
|
3664
|
-
"cyan",
|
|
3665
|
-
"white",
|
|
3666
|
-
"brightBlack",
|
|
3667
|
-
"brightRed",
|
|
3668
|
-
"brightGreen",
|
|
3669
|
-
"brightYellow",
|
|
3670
|
-
"brightBlue",
|
|
3671
|
-
"brightMagenta",
|
|
3672
|
-
"brightCyan",
|
|
3673
|
-
"brightWhite"
|
|
3674
|
-
];
|
|
3675
|
-
}));
|
|
3676
4008
|
//#endregion
|
|
3677
4009
|
//#region packages/ansi/src/theme/types.ts
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
"selectionForeground"
|
|
3703
|
-
];
|
|
3704
|
-
}));
|
|
4010
|
+
const COLOR_SCHEME_FIELDS = [
|
|
4011
|
+
"black",
|
|
4012
|
+
"red",
|
|
4013
|
+
"green",
|
|
4014
|
+
"yellow",
|
|
4015
|
+
"blue",
|
|
4016
|
+
"magenta",
|
|
4017
|
+
"cyan",
|
|
4018
|
+
"white",
|
|
4019
|
+
"brightBlack",
|
|
4020
|
+
"brightRed",
|
|
4021
|
+
"brightGreen",
|
|
4022
|
+
"brightYellow",
|
|
4023
|
+
"brightBlue",
|
|
4024
|
+
"brightMagenta",
|
|
4025
|
+
"brightCyan",
|
|
4026
|
+
"brightWhite",
|
|
4027
|
+
"foreground",
|
|
4028
|
+
"background",
|
|
4029
|
+
"cursorColor",
|
|
4030
|
+
"cursorText",
|
|
4031
|
+
"selectionBackground",
|
|
4032
|
+
"selectionForeground"
|
|
4033
|
+
];
|
|
3705
4034
|
//#endregion
|
|
3706
4035
|
//#region packages/ansi/src/theme/orchestrator.ts
|
|
3707
4036
|
function envOverride() {
|
|
@@ -3855,46 +4184,138 @@ async function detectSchemeTheme(opts = {}) {
|
|
|
3855
4184
|
const { theme } = await detectScheme(opts);
|
|
3856
4185
|
return theme;
|
|
3857
4186
|
}
|
|
3858
|
-
var init_orchestrator = __esmMin((() => {
|
|
3859
|
-
init_types();
|
|
3860
|
-
init_derive();
|
|
3861
|
-
init_detect();
|
|
3862
|
-
init_fingerprint();
|
|
3863
|
-
init_default_schemes();
|
|
3864
|
-
}));
|
|
3865
4187
|
//#endregion
|
|
3866
|
-
//#region packages/ansi/src/
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
4188
|
+
//#region packages/ansi/src/sterling/flat-tokens.ts
|
|
4189
|
+
const STERLING_FLAT_TOKENS = [
|
|
4190
|
+
"bg-surface-default",
|
|
4191
|
+
"bg-surface-subtle",
|
|
4192
|
+
"bg-surface-raised",
|
|
4193
|
+
"bg-surface-overlay",
|
|
4194
|
+
"bg-surface-hover",
|
|
4195
|
+
"border-default",
|
|
4196
|
+
"border-focus",
|
|
4197
|
+
"border-muted",
|
|
4198
|
+
"fg-cursor",
|
|
4199
|
+
"bg-cursor",
|
|
4200
|
+
"fg-muted",
|
|
4201
|
+
"bg-muted",
|
|
4202
|
+
"fg-faint",
|
|
4203
|
+
"fg-accent",
|
|
4204
|
+
"bg-accent",
|
|
4205
|
+
"fg-on-accent",
|
|
4206
|
+
"fg-accent-hover",
|
|
4207
|
+
"bg-accent-hover",
|
|
4208
|
+
"fg-accent-active",
|
|
4209
|
+
"bg-accent-active",
|
|
4210
|
+
"border-accent",
|
|
4211
|
+
"fg-info",
|
|
4212
|
+
"bg-info",
|
|
4213
|
+
"fg-on-info",
|
|
4214
|
+
"bg-info-hover",
|
|
4215
|
+
"bg-info-active",
|
|
4216
|
+
"fg-success",
|
|
4217
|
+
"bg-success",
|
|
4218
|
+
"fg-on-success",
|
|
4219
|
+
"bg-success-hover",
|
|
4220
|
+
"bg-success-active",
|
|
4221
|
+
"fg-warning",
|
|
4222
|
+
"bg-warning",
|
|
4223
|
+
"fg-on-warning",
|
|
4224
|
+
"bg-warning-hover",
|
|
4225
|
+
"bg-warning-active",
|
|
4226
|
+
"fg-error",
|
|
4227
|
+
"bg-error",
|
|
4228
|
+
"fg-on-error",
|
|
4229
|
+
"bg-error-hover",
|
|
4230
|
+
"bg-error-active",
|
|
4231
|
+
"bg-selected",
|
|
4232
|
+
"fg-on-selected",
|
|
4233
|
+
"bg-selected-hover",
|
|
4234
|
+
"bg-inverse",
|
|
4235
|
+
"fg-on-inverse",
|
|
4236
|
+
"bg-inverse-hover",
|
|
4237
|
+
"fg-on-inverse-muted",
|
|
4238
|
+
"fg-link",
|
|
4239
|
+
"fg-disabled",
|
|
4240
|
+
"bg-disabled",
|
|
4241
|
+
"border-disabled",
|
|
4242
|
+
"bg-backdrop",
|
|
4243
|
+
"fg-default",
|
|
4244
|
+
"bg-default"
|
|
4245
|
+
];
|
|
4246
|
+
new Set([
|
|
4247
|
+
"bg",
|
|
4248
|
+
"fg",
|
|
4249
|
+
"muted",
|
|
4250
|
+
"mutedbg",
|
|
4251
|
+
"surface",
|
|
4252
|
+
"surfacebg",
|
|
4253
|
+
"popover",
|
|
4254
|
+
"popoverbg",
|
|
4255
|
+
"cursor",
|
|
4256
|
+
"cursorbg",
|
|
4257
|
+
"primary",
|
|
4258
|
+
"primaryfg",
|
|
4259
|
+
"secondary",
|
|
4260
|
+
"secondaryfg",
|
|
4261
|
+
"accent",
|
|
4262
|
+
"accentfg",
|
|
4263
|
+
"error",
|
|
4264
|
+
"errorfg",
|
|
4265
|
+
"warning",
|
|
4266
|
+
"warningfg",
|
|
4267
|
+
"success",
|
|
4268
|
+
"successfg",
|
|
4269
|
+
"info",
|
|
4270
|
+
"infofg",
|
|
4271
|
+
"border",
|
|
4272
|
+
"inputborder",
|
|
4273
|
+
"focusborder",
|
|
4274
|
+
"disabledfg",
|
|
4275
|
+
"palette",
|
|
4276
|
+
"name",
|
|
4277
|
+
"brand",
|
|
4278
|
+
"brand-hover",
|
|
4279
|
+
"brand-active",
|
|
4280
|
+
"primary-hover",
|
|
4281
|
+
"primary-active",
|
|
4282
|
+
"accent-hover",
|
|
4283
|
+
"accent-active",
|
|
4284
|
+
"fg-hover",
|
|
4285
|
+
"fg-active",
|
|
4286
|
+
...STERLING_FLAT_TOKENS
|
|
4287
|
+
]);
|
|
3889
4288
|
//#endregion
|
|
3890
|
-
//#region packages/ansi/src/theme/
|
|
3891
|
-
|
|
4289
|
+
//#region packages/ansi/src/theme/tokens.ts
|
|
4290
|
+
/**
|
|
4291
|
+
* Runtime constant — the 12 built-in variant names shipped by silvery.
|
|
4292
|
+
*
|
|
4293
|
+
* Used in dev warnings when an unknown variant is looked up in Text.tsx:
|
|
4294
|
+
* ```
|
|
4295
|
+
* Warning: Unknown variant "h11". Known variants: h1, h2, h3, …
|
|
4296
|
+
* ```
|
|
4297
|
+
*
|
|
4298
|
+
* Mirrors `VariantName` exactly — update both when variants change.
|
|
4299
|
+
*/
|
|
4300
|
+
const KNOWN_VARIANTS = [
|
|
4301
|
+
"h1",
|
|
4302
|
+
"h2",
|
|
4303
|
+
"h3",
|
|
4304
|
+
"body",
|
|
4305
|
+
"body-muted",
|
|
4306
|
+
"fine-print",
|
|
4307
|
+
"strong",
|
|
4308
|
+
"em",
|
|
4309
|
+
"link",
|
|
4310
|
+
"key",
|
|
4311
|
+
"code",
|
|
4312
|
+
"kbd"
|
|
4313
|
+
];
|
|
3892
4314
|
//#endregion
|
|
3893
|
-
//#region packages/ansi/src/
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
}));
|
|
4315
|
+
//#region packages/ansi/src/color-scheme.ts
|
|
4316
|
+
const CSI = `[`;
|
|
4317
|
+
`${CSI}`;
|
|
4318
|
+
`${CSI}`;
|
|
3898
4319
|
//#endregion
|
|
3899
4320
|
//#region packages/ansi/src/theme/generate.ts
|
|
3900
4321
|
/**
|
|
@@ -3980,132 +4401,104 @@ function generateTheme(primary, dark) {
|
|
|
3980
4401
|
...derived
|
|
3981
4402
|
};
|
|
3982
4403
|
}
|
|
3983
|
-
var init_generate = __esmMin((() => {
|
|
3984
|
-
init_derived();
|
|
3985
|
-
}));
|
|
3986
|
-
//#endregion
|
|
3987
|
-
//#region packages/ansi/src/sterling/flat-tokens.ts
|
|
3988
|
-
var STERLING_FLAT_TOKENS;
|
|
3989
|
-
var init_flat_tokens = __esmMin((() => {
|
|
3990
|
-
STERLING_FLAT_TOKENS = [
|
|
3991
|
-
"bg-surface-default",
|
|
3992
|
-
"bg-surface-subtle",
|
|
3993
|
-
"bg-surface-raised",
|
|
3994
|
-
"bg-surface-overlay",
|
|
3995
|
-
"bg-surface-hover",
|
|
3996
|
-
"border-default",
|
|
3997
|
-
"border-focus",
|
|
3998
|
-
"border-muted",
|
|
3999
|
-
"fg-cursor",
|
|
4000
|
-
"bg-cursor",
|
|
4001
|
-
"fg-muted",
|
|
4002
|
-
"bg-muted",
|
|
4003
|
-
"fg-accent",
|
|
4004
|
-
"bg-accent",
|
|
4005
|
-
"fg-on-accent",
|
|
4006
|
-
"fg-accent-hover",
|
|
4007
|
-
"bg-accent-hover",
|
|
4008
|
-
"fg-accent-active",
|
|
4009
|
-
"bg-accent-active",
|
|
4010
|
-
"border-accent",
|
|
4011
|
-
"fg-info",
|
|
4012
|
-
"bg-info",
|
|
4013
|
-
"fg-on-info",
|
|
4014
|
-
"bg-info-hover",
|
|
4015
|
-
"bg-info-active",
|
|
4016
|
-
"fg-success",
|
|
4017
|
-
"bg-success",
|
|
4018
|
-
"fg-on-success",
|
|
4019
|
-
"bg-success-hover",
|
|
4020
|
-
"bg-success-active",
|
|
4021
|
-
"fg-warning",
|
|
4022
|
-
"bg-warning",
|
|
4023
|
-
"fg-on-warning",
|
|
4024
|
-
"bg-warning-hover",
|
|
4025
|
-
"bg-warning-active",
|
|
4026
|
-
"fg-error",
|
|
4027
|
-
"bg-error",
|
|
4028
|
-
"fg-on-error",
|
|
4029
|
-
"bg-error-hover",
|
|
4030
|
-
"bg-error-active",
|
|
4031
|
-
"bg-selected",
|
|
4032
|
-
"fg-on-selected",
|
|
4033
|
-
"bg-selected-hover",
|
|
4034
|
-
"bg-inverse",
|
|
4035
|
-
"fg-on-inverse",
|
|
4036
|
-
"fg-link",
|
|
4037
|
-
"fg-disabled",
|
|
4038
|
-
"bg-disabled",
|
|
4039
|
-
"border-disabled",
|
|
4040
|
-
"bg-backdrop",
|
|
4041
|
-
"fg-default",
|
|
4042
|
-
"bg-default"
|
|
4043
|
-
];
|
|
4044
|
-
}));
|
|
4045
4404
|
//#endregion
|
|
4046
4405
|
//#region packages/ansi/src/sterling/defaults.ts
|
|
4406
|
+
/**
|
|
4407
|
+
* A hand-tuned neutral dark scheme — not a copy of any catalog palette, but
|
|
4408
|
+
* close to Nord/Dracula territory. Used only when the caller asks for a
|
|
4409
|
+
* "raw default" (no scheme at all).
|
|
4410
|
+
*/
|
|
4411
|
+
const darkBaseline = {
|
|
4412
|
+
name: "sterling-dark",
|
|
4413
|
+
dark: true,
|
|
4414
|
+
primary: "#7FB4CA",
|
|
4415
|
+
black: "#1E1E2E",
|
|
4416
|
+
red: "#E06C75",
|
|
4417
|
+
green: "#98C379",
|
|
4418
|
+
yellow: "#E5C07B",
|
|
4419
|
+
blue: "#61AFEF",
|
|
4420
|
+
magenta: "#C678DD",
|
|
4421
|
+
cyan: "#56B6C2",
|
|
4422
|
+
white: "#ABB2BF",
|
|
4423
|
+
brightBlack: "#5C6370",
|
|
4424
|
+
brightRed: "#E06C75",
|
|
4425
|
+
brightGreen: "#98C379",
|
|
4426
|
+
brightYellow: "#E5C07B",
|
|
4427
|
+
brightBlue: "#61AFEF",
|
|
4428
|
+
brightMagenta: "#C678DD",
|
|
4429
|
+
brightCyan: "#56B6C2",
|
|
4430
|
+
brightWhite: "#FFFFFF",
|
|
4431
|
+
foreground: "#E4E4E7",
|
|
4432
|
+
background: "#16181D",
|
|
4433
|
+
cursorColor: "#E4E4E7",
|
|
4434
|
+
cursorText: "#16181D",
|
|
4435
|
+
selectionBackground: "#3E4452",
|
|
4436
|
+
selectionForeground: "#E4E4E7"
|
|
4437
|
+
};
|
|
4438
|
+
const lightBaseline = {
|
|
4439
|
+
name: "sterling-light",
|
|
4440
|
+
dark: false,
|
|
4441
|
+
primary: "#1F6FEB",
|
|
4442
|
+
black: "#24292F",
|
|
4443
|
+
red: "#CF222E",
|
|
4444
|
+
green: "#1A7F37",
|
|
4445
|
+
yellow: "#9A6700",
|
|
4446
|
+
blue: "#0969DA",
|
|
4447
|
+
magenta: "#8250DF",
|
|
4448
|
+
cyan: "#1B7C83",
|
|
4449
|
+
white: "#6E7781",
|
|
4450
|
+
brightBlack: "#57606A",
|
|
4451
|
+
brightRed: "#A40E26",
|
|
4452
|
+
brightGreen: "#2DA44E",
|
|
4453
|
+
brightYellow: "#BF8700",
|
|
4454
|
+
brightBlue: "#218BFF",
|
|
4455
|
+
brightMagenta: "#A475F9",
|
|
4456
|
+
brightCyan: "#3192AA",
|
|
4457
|
+
brightWhite: "#8C959F",
|
|
4458
|
+
foreground: "#1F2328",
|
|
4459
|
+
background: "#FFFFFF",
|
|
4460
|
+
cursorColor: "#1F2328",
|
|
4461
|
+
cursorText: "#FFFFFF",
|
|
4462
|
+
selectionBackground: "#DDF4FF",
|
|
4463
|
+
selectionForeground: "#1F2328"
|
|
4464
|
+
};
|
|
4047
4465
|
function defaultScheme(mode = "dark") {
|
|
4048
4466
|
return mode === "dark" ? darkBaseline : lightBaseline;
|
|
4049
4467
|
}
|
|
4050
|
-
var darkBaseline, lightBaseline;
|
|
4051
|
-
var init_defaults = __esmMin((() => {
|
|
4052
|
-
darkBaseline = {
|
|
4053
|
-
name: "sterling-dark",
|
|
4054
|
-
dark: true,
|
|
4055
|
-
primary: "#7FB4CA",
|
|
4056
|
-
black: "#1E1E2E",
|
|
4057
|
-
red: "#E06C75",
|
|
4058
|
-
green: "#98C379",
|
|
4059
|
-
yellow: "#E5C07B",
|
|
4060
|
-
blue: "#61AFEF",
|
|
4061
|
-
magenta: "#C678DD",
|
|
4062
|
-
cyan: "#56B6C2",
|
|
4063
|
-
white: "#ABB2BF",
|
|
4064
|
-
brightBlack: "#5C6370",
|
|
4065
|
-
brightRed: "#E06C75",
|
|
4066
|
-
brightGreen: "#98C379",
|
|
4067
|
-
brightYellow: "#E5C07B",
|
|
4068
|
-
brightBlue: "#61AFEF",
|
|
4069
|
-
brightMagenta: "#C678DD",
|
|
4070
|
-
brightCyan: "#56B6C2",
|
|
4071
|
-
brightWhite: "#FFFFFF",
|
|
4072
|
-
foreground: "#E4E4E7",
|
|
4073
|
-
background: "#16181D",
|
|
4074
|
-
cursorColor: "#E4E4E7",
|
|
4075
|
-
cursorText: "#16181D",
|
|
4076
|
-
selectionBackground: "#3E4452",
|
|
4077
|
-
selectionForeground: "#E4E4E7"
|
|
4078
|
-
};
|
|
4079
|
-
lightBaseline = {
|
|
4080
|
-
name: "sterling-light",
|
|
4081
|
-
dark: false,
|
|
4082
|
-
primary: "#1F6FEB",
|
|
4083
|
-
black: "#24292F",
|
|
4084
|
-
red: "#CF222E",
|
|
4085
|
-
green: "#1A7F37",
|
|
4086
|
-
yellow: "#9A6700",
|
|
4087
|
-
blue: "#0969DA",
|
|
4088
|
-
magenta: "#8250DF",
|
|
4089
|
-
cyan: "#1B7C83",
|
|
4090
|
-
white: "#6E7781",
|
|
4091
|
-
brightBlack: "#57606A",
|
|
4092
|
-
brightRed: "#A40E26",
|
|
4093
|
-
brightGreen: "#2DA44E",
|
|
4094
|
-
brightYellow: "#BF8700",
|
|
4095
|
-
brightBlue: "#218BFF",
|
|
4096
|
-
brightMagenta: "#A475F9",
|
|
4097
|
-
brightCyan: "#3192AA",
|
|
4098
|
-
brightWhite: "#8C959F",
|
|
4099
|
-
foreground: "#1F2328",
|
|
4100
|
-
background: "#FFFFFF",
|
|
4101
|
-
cursorColor: "#1F2328",
|
|
4102
|
-
cursorText: "#FFFFFF",
|
|
4103
|
-
selectionBackground: "#DDF4FF",
|
|
4104
|
-
selectionForeground: "#1F2328"
|
|
4105
|
-
};
|
|
4106
|
-
}));
|
|
4107
4468
|
//#endregion
|
|
4108
4469
|
//#region packages/ansi/src/sterling/define.ts
|
|
4470
|
+
/**
|
|
4471
|
+
* `defineDesignSystem` — wrap a DesignSystem so its derivations auto-apply
|
|
4472
|
+
* `bakeFlat` per the `flatten` flag.
|
|
4473
|
+
*
|
|
4474
|
+
* This makes flat-projection-on-same-object a FRAMEWORK feature, not a
|
|
4475
|
+
* Sterling-specific one. Any `DesignSystem` whose Theme is a nested POJO of
|
|
4476
|
+
* hex-string leaves gets `theme.accent.bg` AND `theme["bg-accent"]` access
|
|
4477
|
+
* without reimplementing the walk.
|
|
4478
|
+
*
|
|
4479
|
+
* ```ts
|
|
4480
|
+
* export const sterling = defineDesignSystem({
|
|
4481
|
+
* name: "sterling",
|
|
4482
|
+
* shape: STERLING_SHAPE,
|
|
4483
|
+
* flatten: true, // ← opt in to default channel-role-state rule
|
|
4484
|
+
* defaults(mode) { return derive(...) },
|
|
4485
|
+
* theme(partial) { return derive(...) },
|
|
4486
|
+
* deriveFromScheme(scheme) { return derive(...) },
|
|
4487
|
+
* // … etc. Return VALUES without flat keys; defineDesignSystem bakes them.
|
|
4488
|
+
* })
|
|
4489
|
+
* ```
|
|
4490
|
+
*
|
|
4491
|
+
* Contract:
|
|
4492
|
+
* - `flatten: true` → apply `bakeFlat(theme)` with `defaultFlattenRule`
|
|
4493
|
+
* - `flatten: <fn>` → apply `bakeFlat(theme, <fn>)`
|
|
4494
|
+
* - `flatten: false` / omitted → pass-through (identity)
|
|
4495
|
+
*
|
|
4496
|
+
* All derivation methods (`defaults`, `theme`, `deriveFromScheme`,
|
|
4497
|
+
* `deriveFromColor`, `deriveFromPair`, `deriveFromSchemeWithBrand`) are
|
|
4498
|
+
* wrapped; their return values go through the flatten filter before
|
|
4499
|
+
* reaching the caller. `deriveFromPair` returns `{ light, dark }` —
|
|
4500
|
+
* both are flattened.
|
|
4501
|
+
*/
|
|
4109
4502
|
function resolveFlatten(flatten) {
|
|
4110
4503
|
if (flatten === false || flatten === void 0) return (t) => t;
|
|
4111
4504
|
if (typeof flatten === "function") {
|
|
@@ -4140,9 +4533,6 @@ function defineDesignSystem(def) {
|
|
|
4140
4533
|
deriveFromSchemeWithBrand: (scheme, brand, opts) => flatten(def.deriveFromSchemeWithBrand(scheme, brand, opts))
|
|
4141
4534
|
};
|
|
4142
4535
|
}
|
|
4143
|
-
var init_define = __esmMin((() => {
|
|
4144
|
-
init_flatten();
|
|
4145
|
-
}));
|
|
4146
4536
|
//#endregion
|
|
4147
4537
|
//#region packages/ansi/src/sterling/sterling.ts
|
|
4148
4538
|
/**
|
|
@@ -4164,6 +4554,26 @@ var init_define = __esmMin((() => {
|
|
|
4164
4554
|
* AND flat hyphen keys populated — the user-facing `$fg-accent` syntax
|
|
4165
4555
|
* resolves against the flat keys, while programmatic access uses nested.
|
|
4166
4556
|
*/
|
|
4557
|
+
const STERLING_SHAPE = {
|
|
4558
|
+
flatTokens: STERLING_FLAT_TOKENS,
|
|
4559
|
+
roles: [
|
|
4560
|
+
"accent",
|
|
4561
|
+
"info",
|
|
4562
|
+
"success",
|
|
4563
|
+
"warning",
|
|
4564
|
+
"error",
|
|
4565
|
+
"muted",
|
|
4566
|
+
"faint",
|
|
4567
|
+
"surface",
|
|
4568
|
+
"border",
|
|
4569
|
+
"cursor",
|
|
4570
|
+
"selected",
|
|
4571
|
+
"inverse",
|
|
4572
|
+
"link",
|
|
4573
|
+
"disabled"
|
|
4574
|
+
],
|
|
4575
|
+
states: ["hover", "active"]
|
|
4576
|
+
};
|
|
4167
4577
|
/**
|
|
4168
4578
|
* Internal: build a nested Theme (no flat keys). `defineDesignSystem` applies
|
|
4169
4579
|
* `bakeFlat` afterwards — the inner derivation stays flat-agnostic.
|
|
@@ -4192,78 +4602,115 @@ function applyBrand(scheme, brand) {
|
|
|
4192
4602
|
primary: brand
|
|
4193
4603
|
};
|
|
4194
4604
|
}
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
"
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4605
|
+
/**
|
|
4606
|
+
* Sterling — the user-facing DesignSystem. `defineDesignSystem` wraps
|
|
4607
|
+
* `rawSterling` with auto-`bakeFlat` (per `flatten: true`), so every
|
|
4608
|
+
* returned Theme has both nested roles AND flat hyphen keys populated.
|
|
4609
|
+
*/
|
|
4610
|
+
const sterling = defineDesignSystem({
|
|
4611
|
+
name: "sterling",
|
|
4612
|
+
shape: STERLING_SHAPE,
|
|
4613
|
+
flatten: true,
|
|
4614
|
+
defaults(mode = "dark") {
|
|
4615
|
+
return buildRawTheme(defaultScheme(mode), { contrast: "auto-lift" });
|
|
4616
|
+
},
|
|
4617
|
+
theme(partial, opts = {}) {
|
|
4618
|
+
const base = buildRawTheme(defaultScheme(opts.mode ?? "dark"), {
|
|
4619
|
+
...opts,
|
|
4620
|
+
contrast: opts.contrast ?? "auto-lift"
|
|
4621
|
+
});
|
|
4622
|
+
if (!partial) return base;
|
|
4623
|
+
return mergePartial(base, partial);
|
|
4624
|
+
},
|
|
4625
|
+
deriveFromScheme(scheme, opts = {}) {
|
|
4626
|
+
return buildRawTheme(scheme, opts);
|
|
4627
|
+
},
|
|
4628
|
+
deriveFromColor(color, opts = {}) {
|
|
4629
|
+
return buildRawTheme({
|
|
4630
|
+
...defaultScheme(opts.mode ?? "dark"),
|
|
4631
|
+
name: `seed:${color}`,
|
|
4632
|
+
primary: color,
|
|
4633
|
+
blue: color,
|
|
4634
|
+
brightBlue: blend(color, "#ffffff", .15)
|
|
4635
|
+
}, opts);
|
|
4636
|
+
},
|
|
4637
|
+
deriveFromPair(light, dark, opts = {}) {
|
|
4638
|
+
return {
|
|
4639
|
+
light: buildRawTheme(light, {
|
|
4229
4640
|
...opts,
|
|
4230
|
-
|
|
4231
|
-
})
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
primary: color,
|
|
4243
|
-
blue: color,
|
|
4244
|
-
brightBlue: blend(color, "#ffffff", .15)
|
|
4245
|
-
}, opts);
|
|
4246
|
-
},
|
|
4247
|
-
deriveFromPair(light, dark, opts = {}) {
|
|
4248
|
-
return {
|
|
4249
|
-
light: buildRawTheme(light, {
|
|
4250
|
-
...opts,
|
|
4251
|
-
mode: "light"
|
|
4252
|
-
}),
|
|
4253
|
-
dark: buildRawTheme(dark, {
|
|
4254
|
-
...opts,
|
|
4255
|
-
mode: "dark"
|
|
4256
|
-
})
|
|
4257
|
-
};
|
|
4258
|
-
},
|
|
4259
|
-
deriveFromSchemeWithBrand(scheme, brand, opts = {}) {
|
|
4260
|
-
return buildRawTheme(applyBrand(scheme, brand), opts);
|
|
4261
|
-
}
|
|
4262
|
-
};
|
|
4263
|
-
sterling = defineDesignSystem(rawSterling);
|
|
4264
|
-
}));
|
|
4641
|
+
mode: "light"
|
|
4642
|
+
}),
|
|
4643
|
+
dark: buildRawTheme(dark, {
|
|
4644
|
+
...opts,
|
|
4645
|
+
mode: "dark"
|
|
4646
|
+
})
|
|
4647
|
+
};
|
|
4648
|
+
},
|
|
4649
|
+
deriveFromSchemeWithBrand(scheme, brand, opts = {}) {
|
|
4650
|
+
return buildRawTheme(applyBrand(scheme, brand), opts);
|
|
4651
|
+
}
|
|
4652
|
+
});
|
|
4265
4653
|
//#endregion
|
|
4266
4654
|
//#region packages/ansi/src/sterling/token-manifest.ts
|
|
4655
|
+
const AA = "AA 4.5:1";
|
|
4656
|
+
const NA = "—";
|
|
4657
|
+
[...[
|
|
4658
|
+
"info",
|
|
4659
|
+
"success",
|
|
4660
|
+
"warning",
|
|
4661
|
+
"error"
|
|
4662
|
+
].flatMap((role) => [
|
|
4663
|
+
{
|
|
4664
|
+
flat: `fg-${role}`,
|
|
4665
|
+
path: `${role}.fg`,
|
|
4666
|
+
family: role,
|
|
4667
|
+
axis: "fg",
|
|
4668
|
+
purpose: `${capitalize(role)} status text.`,
|
|
4669
|
+
derivation: seedRule(role),
|
|
4670
|
+
contrast: AA,
|
|
4671
|
+
tierNotes: "Seeds from the matching ANSI palette slot."
|
|
4672
|
+
},
|
|
4673
|
+
{
|
|
4674
|
+
flat: `bg-${role}`,
|
|
4675
|
+
path: `${role}.bg`,
|
|
4676
|
+
family: role,
|
|
4677
|
+
axis: "bg",
|
|
4678
|
+
purpose: `${capitalize(role)} fill — alerts, badges.`,
|
|
4679
|
+
derivation: seedRule(role),
|
|
4680
|
+
contrast: NA,
|
|
4681
|
+
tierNotes: "Distinct from siblings in ALL 84 palettes (collision test)."
|
|
4682
|
+
},
|
|
4683
|
+
{
|
|
4684
|
+
flat: `fg-on-${role}`,
|
|
4685
|
+
path: `${role}.fgOn`,
|
|
4686
|
+
family: role,
|
|
4687
|
+
axis: "fg-on",
|
|
4688
|
+
purpose: `Foreground when drawing text ON \`bg-${role}\`.`,
|
|
4689
|
+
derivation: "contrast-pick(scheme.fg / scheme.bg / black / white) for AA on bg.",
|
|
4690
|
+
contrast: AA,
|
|
4691
|
+
tierNotes: "Pre-quantization pick."
|
|
4692
|
+
},
|
|
4693
|
+
{
|
|
4694
|
+
flat: `bg-${role}-hover`,
|
|
4695
|
+
path: `${role}.hover.bg`,
|
|
4696
|
+
family: role,
|
|
4697
|
+
axis: "bg-hover",
|
|
4698
|
+
purpose: `Hover fill for ${role} surfaces.`,
|
|
4699
|
+
derivation: `OKLCH ±0.04L on bg-${role}.`,
|
|
4700
|
+
contrast: NA,
|
|
4701
|
+
tierNotes: "Often collapses with bg in ansi16."
|
|
4702
|
+
},
|
|
4703
|
+
{
|
|
4704
|
+
flat: `bg-${role}-active`,
|
|
4705
|
+
path: `${role}.active.bg`,
|
|
4706
|
+
family: role,
|
|
4707
|
+
axis: "bg-active",
|
|
4708
|
+
purpose: `Pressed/active fill for ${role} surfaces.`,
|
|
4709
|
+
derivation: `OKLCH ±0.08L on bg-${role}.`,
|
|
4710
|
+
contrast: NA,
|
|
4711
|
+
tierNotes: "Collapses to bg in low tiers."
|
|
4712
|
+
}
|
|
4713
|
+
])];
|
|
4267
4714
|
function capitalize(s) {
|
|
4268
4715
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
4269
4716
|
}
|
|
@@ -4275,113 +4722,7 @@ function seedRule(role) {
|
|
|
4275
4722
|
case "error": return "scheme.red.";
|
|
4276
4723
|
}
|
|
4277
4724
|
}
|
|
4278
|
-
var AA, NA;
|
|
4279
|
-
var init_token_manifest = __esmMin((() => {
|
|
4280
|
-
AA = "AA 4.5:1";
|
|
4281
|
-
NA = "—";
|
|
4282
|
-
[...[
|
|
4283
|
-
"info",
|
|
4284
|
-
"success",
|
|
4285
|
-
"warning",
|
|
4286
|
-
"error"
|
|
4287
|
-
].flatMap((role) => [
|
|
4288
|
-
{
|
|
4289
|
-
flat: `fg-${role}`,
|
|
4290
|
-
path: `${role}.fg`,
|
|
4291
|
-
family: role,
|
|
4292
|
-
axis: "fg",
|
|
4293
|
-
purpose: `${capitalize(role)} status text.`,
|
|
4294
|
-
derivation: seedRule(role),
|
|
4295
|
-
contrast: AA,
|
|
4296
|
-
tierNotes: "Seeds from the matching ANSI palette slot."
|
|
4297
|
-
},
|
|
4298
|
-
{
|
|
4299
|
-
flat: `bg-${role}`,
|
|
4300
|
-
path: `${role}.bg`,
|
|
4301
|
-
family: role,
|
|
4302
|
-
axis: "bg",
|
|
4303
|
-
purpose: `${capitalize(role)} fill — alerts, badges.`,
|
|
4304
|
-
derivation: seedRule(role),
|
|
4305
|
-
contrast: NA,
|
|
4306
|
-
tierNotes: "Distinct from siblings in ALL 84 palettes (collision test)."
|
|
4307
|
-
},
|
|
4308
|
-
{
|
|
4309
|
-
flat: `fg-on-${role}`,
|
|
4310
|
-
path: `${role}.fgOn`,
|
|
4311
|
-
family: role,
|
|
4312
|
-
axis: "fg-on",
|
|
4313
|
-
purpose: `Foreground when drawing text ON \`bg-${role}\`.`,
|
|
4314
|
-
derivation: "contrast-pick(scheme.fg / scheme.bg / black / white) for AA on bg.",
|
|
4315
|
-
contrast: AA,
|
|
4316
|
-
tierNotes: "Pre-quantization pick."
|
|
4317
|
-
},
|
|
4318
|
-
{
|
|
4319
|
-
flat: `bg-${role}-hover`,
|
|
4320
|
-
path: `${role}.hover.bg`,
|
|
4321
|
-
family: role,
|
|
4322
|
-
axis: "bg-hover",
|
|
4323
|
-
purpose: `Hover fill for ${role} surfaces.`,
|
|
4324
|
-
derivation: `OKLCH ±0.04L on bg-${role}.`,
|
|
4325
|
-
contrast: NA,
|
|
4326
|
-
tierNotes: "Often collapses with bg in ansi16."
|
|
4327
|
-
},
|
|
4328
|
-
{
|
|
4329
|
-
flat: `bg-${role}-active`,
|
|
4330
|
-
path: `${role}.active.bg`,
|
|
4331
|
-
family: role,
|
|
4332
|
-
axis: "bg-active",
|
|
4333
|
-
purpose: `Pressed/active fill for ${role} surfaces.`,
|
|
4334
|
-
derivation: `OKLCH ±0.08L on bg-${role}.`,
|
|
4335
|
-
contrast: NA,
|
|
4336
|
-
tierNotes: "Collapses to bg in low tiers."
|
|
4337
|
-
}
|
|
4338
|
-
])];
|
|
4339
|
-
}));
|
|
4340
|
-
//#endregion
|
|
4341
|
-
//#region packages/ansi/src/sterling/index.ts
|
|
4342
|
-
var init_sterling = __esmMin((() => {
|
|
4343
|
-
init_sterling$1();
|
|
4344
|
-
init_define();
|
|
4345
|
-
init_derive$1();
|
|
4346
|
-
init_inline();
|
|
4347
|
-
init_flat_tokens();
|
|
4348
|
-
init_token_manifest();
|
|
4349
|
-
init_defaults();
|
|
4350
|
-
init_contrast();
|
|
4351
|
-
}));
|
|
4352
|
-
//#endregion
|
|
4353
|
-
//#region packages/ansi/src/index.ts
|
|
4354
|
-
var init_src = __esmMin((() => {
|
|
4355
|
-
init_caps();
|
|
4356
|
-
init_profile();
|
|
4357
|
-
init_sgr_codes();
|
|
4358
|
-
init_utils();
|
|
4359
|
-
init_color_maps();
|
|
4360
|
-
init_flatten();
|
|
4361
|
-
init_terminal_control();
|
|
4362
|
-
init_kitty_graphics();
|
|
4363
|
-
init_style();
|
|
4364
|
-
init_mixed_proxy();
|
|
4365
|
-
init_colors();
|
|
4366
|
-
init_derive();
|
|
4367
|
-
init_derived();
|
|
4368
|
-
init_monochrome();
|
|
4369
|
-
init_fingerprint();
|
|
4370
|
-
init_orchestrator();
|
|
4371
|
-
init_invariants();
|
|
4372
|
-
init_default_schemes();
|
|
4373
|
-
init_types();
|
|
4374
|
-
init_tokens();
|
|
4375
|
-
init_detect();
|
|
4376
|
-
init_protocol_error();
|
|
4377
|
-
init_osc_palette();
|
|
4378
|
-
init_color_scheme();
|
|
4379
|
-
init_generators();
|
|
4380
|
-
init_auto_generate();
|
|
4381
|
-
init_generate();
|
|
4382
|
-
init_sterling();
|
|
4383
|
-
}));
|
|
4384
4725
|
//#endregion
|
|
4385
|
-
export {
|
|
4726
|
+
export { setForegroundColor as $, fgColorCode as A, rgbToAnsi256 as B, enableBracketedPaste as C, defaultFlattenRule as D, bakeFlat as E, bgFromRgb as F, queryBackgroundColor as G, detectTheme as H, fgFromRgb as I, resetBackgroundColor as J, queryCursorColor as K, nearestAnsi16 as L, detectColorFromEnv as M, probeTerminalProfile as N, warnOnce as O, ANSI16_SLOT_HEX as P, setCursorColor as Q, pickColorLevel as R, disableMouse as S, enableMouse as T, probeColors as U, detectTerminalScheme as V, detectColorScheme as W, resetForegroundColor as X, resetCursorColor as Y, setBackgroundColor as Z, kittyDeleteAllScrimPlacements as _, KNOWN_VARIANTS as a, setPaletteColor as at, disableBracketedPaste as b, detectSchemeTheme as c, deriveTheme as ct, createMixedStyle as d, ContrastError as dt, ProtocolError as et, createStyle as f, WCAG_AA as ft, cupTo as g, defaultCaps as gt, buildScrimPixels as h, deriveFields as ht, generateTheme as i, queryPaletteColor as it, createTerminalProfile as j, bgColorCode as k, COLOR_SCHEME_FIELDS as l, deriveRoles as lt, backdropPlacementId as m, checkAA as mt, defineDesignSystem as n, parsePaletteResponse as nt, STERLING_FLAT_TOKENS as o, ansi16DarkTheme as ot, resolveThemeColor as p, autoLift as pt, queryForegroundColor as q, defaultScheme as r, queryMultiplePaletteColors as rt, detectScheme as s, ansi16LightTheme as st, sterling as t, isProtocolError as tt, monoAttrsForColorString as u, deriveTheme$1 as ut, kittyPlaceAt as v, enableKittyKeyboard as w, disableKittyKeyboard as x, kittyUploadScrimImage as y, quantizeHex as z };
|
|
4386
4727
|
|
|
4387
|
-
//# sourceMappingURL=src-
|
|
4728
|
+
//# sourceMappingURL=src-B8lf1kiR.mjs.map
|