@zaly/tui 0.0.11 → 0.1.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/assets/schemas/shiki-language.schema.json +352 -0
- package/assets/schemas/shiki-theme.schema.json +71 -0
- package/assets/schemas/theme.schema.json +227 -732
- package/assets/themes/andromeeda.json +97 -0
- package/assets/themes/ayu-dark.json +31 -44
- package/assets/themes/ayu-light.json +106 -0
- package/assets/themes/ayu-mirage.json +106 -0
- package/assets/themes/catppuccin-frappe.json +44 -60
- package/assets/themes/catppuccin-latte.json +44 -60
- package/assets/themes/catppuccin-macchiato.json +44 -60
- package/assets/themes/catppuccin-mocha.json +44 -60
- package/assets/themes/dark-plus.json +99 -0
- package/assets/themes/dracula.json +47 -66
- package/assets/themes/everforest-dark.json +28 -45
- package/assets/themes/everforest-light.json +28 -45
- package/assets/themes/github-dark-default.json +107 -0
- package/assets/themes/github-dark-dimmed.json +107 -0
- package/assets/themes/github-light-default.json +107 -0
- package/assets/themes/gruvbox-dark-hard.json +98 -0
- package/assets/themes/gruvbox-dark-medium.json +34 -48
- package/assets/themes/gruvbox-light-medium.json +98 -0
- package/assets/themes/horizon-bright.json +101 -0
- package/assets/themes/horizon.json +101 -0
- package/assets/themes/iterm2/LICENSE +25 -0
- package/assets/themes/iterm2/README.md +28 -0
- package/assets/themes/iterm2/catppuccin-latte.json +140 -0
- package/assets/themes/iterm2/catppuccin-mocha.json +140 -0
- package/assets/themes/iterm2/github-dark.json +140 -0
- package/assets/themes/iterm2/github.json +140 -0
- package/assets/themes/iterm2/gruvbox-dark.json +140 -0
- package/assets/themes/iterm2/gruvbox-light.json +140 -0
- package/assets/themes/iterm2/nord.json +140 -0
- package/assets/themes/iterm2/tokyonight-day.json +140 -0
- package/assets/themes/iterm2/tokyonight-moon.json +140 -0
- package/assets/themes/kanagawa-dragon.json +55 -68
- package/assets/themes/kanagawa-lotus.json +105 -0
- package/assets/themes/kanagawa-wave.json +55 -68
- package/assets/themes/light-plus.json +99 -0
- package/assets/themes/material-theme-lighter.json +102 -0
- package/assets/themes/material-theme-palenight.json +52 -64
- package/assets/themes/material-theme.json +102 -0
- package/assets/themes/min-dark.json +67 -28
- package/assets/themes/min-light.json +67 -32
- package/assets/themes/monokai.json +55 -67
- package/assets/themes/night-owl-light.json +105 -0
- package/assets/themes/night-owl.json +57 -68
- package/assets/themes/nord.json +53 -55
- package/assets/themes/one-dark-pro.json +46 -57
- package/assets/themes/one-light.json +52 -59
- package/assets/themes/poimandres.json +51 -68
- package/assets/themes/rose-pine-dawn.json +99 -0
- package/assets/themes/rose-pine-moon.json +99 -0
- package/assets/themes/rose-pine.json +51 -50
- package/assets/themes/solarized-dark.json +39 -51
- package/assets/themes/solarized-light.json +40 -52
- package/assets/themes/synthwave-84.json +48 -50
- package/assets/themes/tokyonight-day.json +6 -7
- package/assets/themes/tokyonight-moon.json +6 -6
- package/assets/themes/tokyonight-night.json +6 -6
- package/assets/themes/tokyonight-storm.json +6 -6
- package/assets/themes/vesper.json +51 -58
- package/assets/themes/vitesse-black.json +103 -0
- package/assets/themes/vitesse-dark.json +26 -49
- package/assets/themes/vitesse-light.json +26 -49
- package/dist/{actions-DFboj3g5.d.mts → actions--ODlgCQ5.d.mts} +4 -4
- package/dist/{actions-DFboj3g5.d.mts.map → actions--ODlgCQ5.d.mts.map} +1 -1
- package/dist/{ansi-Clq0ozyA.mjs → ansi-CMv71xVr.mjs} +38 -31
- package/dist/ansi-CMv71xVr.mjs.map +1 -0
- package/dist/ansi.d.mts +3 -1
- package/dist/ansi.d.mts.map +1 -1
- package/dist/ansi.mjs +1 -1
- package/dist/{autocomplete-CxzetPOo.d.mts → autocomplete-CD30kSe_.d.mts} +4 -4
- package/dist/{autocomplete-CxzetPOo.d.mts.map → autocomplete-CD30kSe_.d.mts.map} +1 -1
- package/dist/{box-DLEcEvDH.mjs → box-C_N_7ChP.mjs} +2 -2
- package/dist/box-C_N_7ChP.mjs.map +1 -0
- package/dist/builder-Chwtk0nQ.mjs +196 -0
- package/dist/builder-Chwtk0nQ.mjs.map +1 -0
- package/dist/{callbacks-D132G8dy.mjs → callbacks-DLecWn7G.mjs} +4 -4
- package/dist/{callbacks-D132G8dy.mjs.map → callbacks-DLecWn7G.mjs.map} +1 -1
- package/dist/client-CNGt-dOt.mjs +1 -0
- package/dist/{client-C2GXKfJ1.mjs → client-D7qz4TZt.mjs} +7 -3
- package/dist/client-D7qz4TZt.mjs.map +1 -0
- package/dist/color-DBMQLv4Y.mjs +37 -0
- package/dist/color-DBMQLv4Y.mjs.map +1 -0
- package/dist/{ctx-8Nuf5BrN.mjs → ctx-BaQ2hP5u.mjs} +3 -3
- package/dist/{ctx-8Nuf5BrN.mjs.map → ctx-BaQ2hP5u.mjs.map} +1 -1
- package/dist/ctx-CndlTp1T.mjs +1 -0
- package/dist/{divider-l0-JPEIm.mjs → divider-BlNNN2OS.mjs} +2 -2
- package/dist/divider-BlNNN2OS.mjs.map +1 -0
- package/dist/{files-BUsa-RVl.d.mts → files-B_5HDBPp.d.mts} +3 -3
- package/dist/{files-BUsa-RVl.d.mts.map → files-B_5HDBPp.d.mts.map} +1 -1
- package/dist/github-Cy2hfWJ7.mjs.map +1 -1
- package/dist/{github-D89A3F9U.d.mts → github-CyRwUQ3y.d.mts} +3 -3
- package/dist/{github-D89A3F9U.d.mts.map → github-CyRwUQ3y.d.mts.map} +1 -1
- package/dist/{image-34bU73bW.d.mts → image-BLls2F4t.d.mts} +2 -2
- package/dist/{image-34bU73bW.d.mts.map → image-BLls2F4t.d.mts.map} +1 -1
- package/dist/image-Cqtj3yRA.mjs +178 -0
- package/dist/image-Cqtj3yRA.mjs.map +1 -0
- package/dist/image.d.mts +1 -1
- package/dist/index.d.mts +13 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +8 -7
- package/dist/index.mjs.map +1 -1
- package/dist/{input-D7fQEUdt.mjs → input-ET2YEMcl.mjs} +16 -11
- package/dist/input-ET2YEMcl.mjs.map +1 -0
- package/dist/{input-Dylds_sI.d.mts → input-NuD8TH8N.d.mts} +3 -3
- package/dist/{input-Dylds_sI.d.mts.map → input-NuD8TH8N.d.mts.map} +1 -1
- package/dist/{inspect-DPLRum7L.d.mts → inspect-B1uXxdKC.d.mts} +11 -15
- package/dist/inspect-B1uXxdKC.d.mts.map +1 -0
- package/dist/{inspect-CcgiZ_F9.mjs → inspect-Cxzs-W0g.mjs} +2 -2
- package/dist/{inspect-CcgiZ_F9.mjs.map → inspect-Cxzs-W0g.mjs.map} +1 -1
- package/dist/kitty-DKQYsQfH.mjs +1 -0
- package/dist/{log-Dy_QnPZF.mjs → log-B4djzy2m.mjs} +5 -5
- package/dist/log-B4djzy2m.mjs.map +1 -0
- package/dist/{logger-DvuX9DPS.mjs → logger-CvJCITzP.mjs} +3 -3
- package/dist/{logger-DvuX9DPS.mjs.map → logger-CvJCITzP.mjs.map} +1 -1
- package/dist/{markdown-BGPa7UzD.mjs → markdown-D3ZtRn6C.mjs} +9 -8
- package/dist/markdown-D3ZtRn6C.mjs.map +1 -0
- package/dist/markdown.d.mts +1 -1
- package/dist/markdown.d.mts.map +1 -1
- package/dist/markdown.mjs +1 -1
- package/dist/math-CU0wmC9N.mjs +1 -0
- package/dist/math-Dd7a1irv.mjs +206 -0
- package/dist/math-Dd7a1irv.mjs.map +1 -0
- package/dist/oklch-Bsh5swbC.mjs +99 -0
- package/dist/oklch-Bsh5swbC.mjs.map +1 -0
- package/dist/{overlay-9WXYiGgW.mjs → overlay-LvOjG7kn.mjs} +2 -2
- package/dist/{overlay-9WXYiGgW.mjs.map → overlay-LvOjG7kn.mjs.map} +1 -1
- package/dist/{picker-JL8lZfRH.d.mts → picker-B-OxKKnD.d.mts} +5 -5
- package/dist/{picker-JL8lZfRH.d.mts.map → picker-B-OxKKnD.d.mts.map} +1 -1
- package/dist/{picker-BqHINl_a.mjs → picker-f6xjgACX.mjs} +2 -2
- package/dist/{picker-BqHINl_a.mjs.map → picker-f6xjgACX.mjs.map} +1 -1
- package/dist/{queries-B_lOwEiE.mjs → queries-BUkBxkuM.mjs} +66 -3
- package/dist/queries-BUkBxkuM.mjs.map +1 -0
- package/dist/{queries-Cvalgu6P.d.mts → queries-C75-wG1B.d.mts} +42 -11
- package/dist/queries-C75-wG1B.d.mts.map +1 -0
- package/dist/{registry-3hLzS4ks.mjs → registry-DUWpSPoo.mjs} +208 -68
- package/dist/registry-DUWpSPoo.mjs.map +1 -0
- package/dist/{render-f7M2856V.mjs → render-B7LfNM5K.mjs} +2 -2
- package/dist/{render-f7M2856V.mjs.map → render-B7LfNM5K.mjs.map} +1 -1
- package/dist/{renderer-V6AGjbyf.mjs → renderer-BLsd-wrG.mjs} +167 -20
- package/dist/renderer-BLsd-wrG.mjs.map +1 -0
- package/dist/renderer-YHbR7JZ4.mjs +1 -0
- package/dist/{renderer-DesbRwjQ.mjs → renderer-aAtkFgll.mjs} +8 -7
- package/dist/renderer-aAtkFgll.mjs.map +1 -0
- package/dist/{select-zGd5pbiB.d.mts → select-BKE5LzdN.d.mts} +3 -3
- package/dist/{select-zGd5pbiB.d.mts.map → select-BKE5LzdN.d.mts.map} +1 -1
- package/dist/services/logger.d.mts +1 -1
- package/dist/services/logger.mjs +1 -1
- package/dist/services/notifier.d.mts +1 -1
- package/dist/services/notifier.mjs +2 -2
- package/dist/services/picker.d.mts +5 -5
- package/dist/services/picker.mjs +6 -6
- package/dist/services/prompt.d.mts +4 -4
- package/dist/services/prompt.mjs +5 -5
- package/dist/shiki/server.mjs +37 -14
- package/dist/shiki/server.mjs.map +1 -1
- package/dist/shiki-B4U0s8jT.mjs +635 -0
- package/dist/shiki-B4U0s8jT.mjs.map +1 -0
- package/dist/shiki-CJauRusM.mjs +20 -0
- package/dist/shiki-CJauRusM.mjs.map +1 -0
- package/dist/style-DslRHzI4.mjs +109 -0
- package/dist/style-DslRHzI4.mjs.map +1 -0
- package/dist/style.d.mts +4 -3
- package/dist/style.d.mts.map +1 -1
- package/dist/style.mjs +4 -4
- package/dist/{text-CRZD9KTN.mjs → text-BoJdKXLU.mjs} +2 -2
- package/dist/{text-CRZD9KTN.mjs.map → text-BoJdKXLU.mjs.map} +1 -1
- package/dist/{text-BefiXAFW.d.mts → text-CmxbA8lk.d.mts} +3 -3
- package/dist/{text-BefiXAFW.d.mts.map → text-CmxbA8lk.d.mts.map} +1 -1
- package/dist/{text-BLz1tRoC.mjs → text-DPrhma4x.mjs} +2 -2
- package/dist/text-DPrhma4x.mjs.map +1 -0
- package/dist/text.d.mts +1 -1
- package/dist/text.mjs +1 -1
- package/dist/theme-C8LkcoaK.mjs +61 -0
- package/dist/theme-C8LkcoaK.mjs.map +1 -0
- package/dist/theme-DVX8dvGG.mjs +1794 -0
- package/dist/theme-DVX8dvGG.mjs.map +1 -0
- package/dist/themes.d.mts +213 -73
- package/dist/themes.d.mts.map +1 -1
- package/dist/themes.mjs +1 -1
- package/dist/{tree-CArtDRec.d.mts → tree-CTvSpF9b.d.mts} +3 -3
- package/dist/{tree-CArtDRec.d.mts.map → tree-CTvSpF9b.d.mts.map} +1 -1
- package/dist/{types-C0EOLZDc.d.mts → types-C9ceMsbJ.d.mts} +137 -137
- package/dist/types-C9ceMsbJ.d.mts.map +1 -0
- package/dist/{widget-DtJU2-BJ.d.mts → widget-DlF32PRp.d.mts} +2 -2
- package/dist/{widget-DtJU2-BJ.d.mts.map → widget-DlF32PRp.d.mts.map} +1 -1
- package/dist/widgets/autocomplete.d.mts +1 -1
- package/dist/widgets/autocomplete.mjs +2 -2
- package/dist/widgets/box.d.mts +1 -1
- package/dist/widgets/box.mjs +1 -1
- package/dist/widgets/code.d.mts +4 -2
- package/dist/widgets/code.d.mts.map +1 -1
- package/dist/widgets/code.mjs +8 -7
- package/dist/widgets/code.mjs.map +1 -1
- package/dist/widgets/completions/actions.d.mts +1 -1
- package/dist/widgets/completions/files.d.mts +1 -1
- package/dist/widgets/completions/github.d.mts +1 -1
- package/dist/widgets/completions/index.d.mts +3 -3
- package/dist/widgets/diff.d.mts +2 -2
- package/dist/widgets/diff.d.mts.map +1 -1
- package/dist/widgets/diff.mjs +35 -12
- package/dist/widgets/diff.mjs.map +1 -1
- package/dist/widgets/divider.d.mts +3 -3
- package/dist/widgets/divider.mjs +1 -1
- package/dist/widgets/image.d.mts +1 -1
- package/dist/widgets/image.mjs +4 -4
- package/dist/widgets/image.mjs.map +1 -1
- package/dist/widgets/input.d.mts +1 -1
- package/dist/widgets/input.mjs +1 -1
- package/dist/widgets/log.d.mts +1 -1
- package/dist/widgets/log.mjs +1 -1
- package/dist/widgets/markdown.d.mts +4 -4
- package/dist/widgets/markdown.d.mts.map +1 -1
- package/dist/widgets/markdown.mjs +1 -1
- package/dist/widgets/overlay.d.mts +1 -1
- package/dist/widgets/overlay.mjs +1 -1
- package/dist/widgets/picker.d.mts +1 -1
- package/dist/widgets/picker.mjs +1 -1
- package/dist/widgets/progress.d.mts +4 -4
- package/dist/widgets/progress.mjs.map +1 -1
- package/dist/widgets/select.d.mts +1 -1
- package/dist/widgets/show.d.mts +1 -1
- package/dist/widgets/spinner.d.mts +2 -2
- package/dist/widgets/text.d.mts +1 -1
- package/dist/widgets/text.mjs +1 -1
- package/dist/widgets/tree.d.mts +1 -1
- package/dist/widgets/widget.d.mts +1 -1
- package/package.json +5 -7
- package/assets/themes/dracula-soft.json +0 -119
- package/assets/themes/github-dark.json +0 -123
- package/assets/themes/github-light.json +0 -123
- package/dist/ansi-Clq0ozyA.mjs.map +0 -1
- package/dist/box-DLEcEvDH.mjs.map +0 -1
- package/dist/builder-DC9byAmK.mjs +0 -386
- package/dist/builder-DC9byAmK.mjs.map +0 -1
- package/dist/client-C2GXKfJ1.mjs.map +0 -1
- package/dist/client-bzdHIDL2.mjs +0 -1
- package/dist/ctx-k0wTqeql.mjs +0 -1
- package/dist/divider-l0-JPEIm.mjs.map +0 -1
- package/dist/image-Cm5T-uw-.mjs +0 -108
- package/dist/image-Cm5T-uw-.mjs.map +0 -1
- package/dist/input-D7fQEUdt.mjs.map +0 -1
- package/dist/inspect-DPLRum7L.d.mts.map +0 -1
- package/dist/log-Dy_QnPZF.mjs.map +0 -1
- package/dist/markdown-BGPa7UzD.mjs.map +0 -1
- package/dist/queries-B_lOwEiE.mjs.map +0 -1
- package/dist/queries-Cvalgu6P.d.mts.map +0 -1
- package/dist/registry-3hLzS4ks.mjs.map +0 -1
- package/dist/renderer-BSMOuiLM.mjs +0 -1
- package/dist/renderer-DesbRwjQ.mjs.map +0 -1
- package/dist/renderer-V6AGjbyf.mjs.map +0 -1
- package/dist/shiki--ASSYv4_.mjs +0 -12
- package/dist/shiki--ASSYv4_.mjs.map +0 -1
- package/dist/shiki-D7l5--zz.mjs +0 -432
- package/dist/shiki-D7l5--zz.mjs.map +0 -1
- package/dist/text-BLz1tRoC.mjs.map +0 -1
- package/dist/theme.config-BKXX_noZ.mjs +0 -863
- package/dist/theme.config-BKXX_noZ.mjs.map +0 -1
- package/dist/types-C0EOLZDc.d.mts.map +0 -1
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "file:./../schemas/theme.schema.json",
|
|
3
|
-
"id": "github-light",
|
|
4
|
-
"name": "GitHub Light",
|
|
5
|
-
"shiki": "github-light",
|
|
6
|
-
"text": "#24292e",
|
|
7
|
-
"subtle": "#959da5",
|
|
8
|
-
"ui": {
|
|
9
|
-
"bg": "#fff",
|
|
10
|
-
"fg": "#24292e"
|
|
11
|
-
},
|
|
12
|
-
"primary": "#0366d6",
|
|
13
|
-
"accent": "#005cc5",
|
|
14
|
-
"success": "#28a745",
|
|
15
|
-
"info": "#1b7c83",
|
|
16
|
-
"warn": "#f9c513",
|
|
17
|
-
"error": "#cb2431",
|
|
18
|
-
"muted": "#959da5",
|
|
19
|
-
"border": "#e1e4e8",
|
|
20
|
-
"code": {
|
|
21
|
-
"bg": "#f6f8fa"
|
|
22
|
-
},
|
|
23
|
-
"mdCodeBlock": {
|
|
24
|
-
"bg": "#f6f8fa"
|
|
25
|
-
},
|
|
26
|
-
"overlay": {
|
|
27
|
-
"bg": "#f6f8fa"
|
|
28
|
-
},
|
|
29
|
-
"highlight": {
|
|
30
|
-
"bg": "#dae9f9"
|
|
31
|
-
},
|
|
32
|
-
"selection": {
|
|
33
|
-
"bg": "#dae9f9"
|
|
34
|
-
},
|
|
35
|
-
"diffAdd": {
|
|
36
|
-
"bg": "#e4f9e9",
|
|
37
|
-
"fg": "#22863a"
|
|
38
|
-
},
|
|
39
|
-
"diffDel": {
|
|
40
|
-
"bg": "#fae5e7",
|
|
41
|
-
"fg": "#b31d28"
|
|
42
|
-
},
|
|
43
|
-
"diffTitle": {
|
|
44
|
-
"fg": "#b31d28",
|
|
45
|
-
"bg": "#ffeef0"
|
|
46
|
-
},
|
|
47
|
-
"comment": {
|
|
48
|
-
"fg": "#6a737d"
|
|
49
|
-
},
|
|
50
|
-
"syntaxNumber": {
|
|
51
|
-
"fg": "#005cc5"
|
|
52
|
-
},
|
|
53
|
-
"syntaxString": {
|
|
54
|
-
"fg": "#032f62"
|
|
55
|
-
},
|
|
56
|
-
"syntaxBoolean": {
|
|
57
|
-
"fg": "#005cc5"
|
|
58
|
-
},
|
|
59
|
-
"syntaxFunction": {
|
|
60
|
-
"fg": "#6f42c1"
|
|
61
|
-
},
|
|
62
|
-
"syntaxField": {
|
|
63
|
-
"fg": "#24292e"
|
|
64
|
-
},
|
|
65
|
-
"syntaxConstant": {
|
|
66
|
-
"fg": "#005cc5"
|
|
67
|
-
},
|
|
68
|
-
"syntaxSpecial": {
|
|
69
|
-
"fg": "#d73a49"
|
|
70
|
-
},
|
|
71
|
-
"mdHeading": {
|
|
72
|
-
"bold": true,
|
|
73
|
-
"fg": "#005cc5"
|
|
74
|
-
},
|
|
75
|
-
"mdHeading1": {
|
|
76
|
-
"bold": true,
|
|
77
|
-
"fg": "#005cc5"
|
|
78
|
-
},
|
|
79
|
-
"mdHeading2": {
|
|
80
|
-
"bold": true,
|
|
81
|
-
"fg": "#005cc5"
|
|
82
|
-
},
|
|
83
|
-
"mdHeading3": {
|
|
84
|
-
"bold": true,
|
|
85
|
-
"fg": "#005cc5"
|
|
86
|
-
},
|
|
87
|
-
"mdHeading4": {
|
|
88
|
-
"bold": true,
|
|
89
|
-
"fg": "#005cc5"
|
|
90
|
-
},
|
|
91
|
-
"mdHeading5": {
|
|
92
|
-
"bold": true,
|
|
93
|
-
"fg": "#005cc5"
|
|
94
|
-
},
|
|
95
|
-
"mdHeading6": {
|
|
96
|
-
"bold": true,
|
|
97
|
-
"fg": "#005cc5"
|
|
98
|
-
},
|
|
99
|
-
"mdBold": {
|
|
100
|
-
"bold": true,
|
|
101
|
-
"fg": "#24292e"
|
|
102
|
-
},
|
|
103
|
-
"mdItalic": {
|
|
104
|
-
"italic": true,
|
|
105
|
-
"fg": "#24292e"
|
|
106
|
-
},
|
|
107
|
-
"mdStrikethrough": {
|
|
108
|
-
"strikethrough": true
|
|
109
|
-
},
|
|
110
|
-
"mdLink": {
|
|
111
|
-
"underline": true
|
|
112
|
-
},
|
|
113
|
-
"mdQuote": {
|
|
114
|
-
"fg": "#22863a"
|
|
115
|
-
},
|
|
116
|
-
"mdCode": {
|
|
117
|
-
"fg": "#005cc5"
|
|
118
|
-
},
|
|
119
|
-
"mdHr": {
|
|
120
|
-
"bold": true,
|
|
121
|
-
"fg": "#005cc5"
|
|
122
|
-
}
|
|
123
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ansi-Clq0ozyA.mjs","names":[],"sources":["../src/style/color.ts","../src/style/ansi.ts"],"sourcesContent":["import type { HexColor, RGB } from \"./types.ts\"\n\nimport { clamp } from \"@zaly/shared\"\n\nconst hexByte = (n: number): string => clamp(Math.round(n), 0, 255).toString(16).padStart(2, \"0\")\n\nexport function toHex(c: RGB): HexColor\nexport function toHex(r: number, g: number, b: number): HexColor\nexport function toHex(x: number | RGB, y?: number, z?: number): HexColor {\n const [r, g, b] = Array.isArray(x) ? x : [x, y!, z!]\n return `#${hexByte(r)}${hexByte(g)}${hexByte(b)}`\n}\n\nexport function parseHex(hex: string): RGB {\n let s = hex.charCodeAt(0) === 0x23 ? hex.slice(1) : hex // strip leading #\n if (s.length === 4) s = s.slice(0, 3) // strip alpha\n if (s.length === 8) s = s.slice(0, 6) // strip alpha\n if (s.length === 3) {\n // Expand \"abc\" → \"aabbcc\" without allocating an array.\n s = s[0] + s[0] + s[1] + s[1] + s[2] + s[2]\n }\n if (s.length !== 6) throw new Error(`invalid hex color: ${hex}`)\n const n = Number.parseInt(s, 16)\n if (Number.isNaN(n)) throw new Error(`invalid hex color: ${hex}`)\n return [(n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff]\n}\n\nexport function isHexColor(s: string): s is HexColor {\n return /^#[0-9a-fA-F]{3,8}$/.test(s)\n}\n","import type { AnsiColor, AnsiStyle } from \"./types.ts\"\n\nimport { sliceAnsi } from \"@zaly/shared/ansi\"\nimport { hasColors } from \"@zaly/shared/env\"\nimport { isHexColor, parseHex, toHex } from \"./color.ts\"\n\n/** Optional wrap mode: `\"word\"` (default) breaks at word boundaries;\n * `\"char\"` hard-wraps mid-word. */\nexport interface WrapOpts {\n mode?: \"word\" | \"char\"\n}\n\n// ---- ANSI escape categories -------------------------------------------\n// OSC 8 hyperlink sequence. ESC + backslash is the \"string terminator\" (ST)\n// that closes the OSC. Format: `ESC]8;;URL ST TEXT ESC]8;; ST`.\nconst OSC8 = \"\\x1b]8;;\"\nconst ST = \"\\x1b\\\\\"\nexport const RESET = \"\\x1b[0m\"\n\n// Attribute → SGR code. Order matters for stable output.\nconst ATTRS = [\n [\"bold\", 1],\n [\"dim\", 2],\n [\"italic\", 3],\n [\"underline\", 4],\n [\"inverse\", 7],\n [\"strikethrough\", 9],\n] as const satisfies readonly (readonly [keyof AnsiStyle, number])[]\n\n// Standard 8-color ANSI palette. Offsets from SGR 30 (fg) and 40 (bg).\nconst ANSI_OFFSET: Record<string, number> = {\n black: 0,\n blue: 4,\n cyan: 6,\n green: 2,\n magenta: 5,\n red: 1,\n white: 7,\n yellow: 3,\n}\n\nconst ANSI_BG: Record<number, AnsiColor> = {\n 100: \"gray\", // or \"brightBlack\" if that exists\n 101: \"brightRed\",\n 102: \"brightGreen\",\n 103: \"brightYellow\",\n 104: \"brightBlue\",\n 105: \"brightMagenta\",\n 106: \"brightCyan\",\n 107: \"brightWhite\",\n 40: \"black\",\n 41: \"red\",\n 42: \"green\",\n 43: \"yellow\",\n 44: \"blue\",\n 45: \"magenta\",\n 46: \"cyan\",\n 47: \"white\",\n}\n\nconst notFound = Symbol(\"not found\")\nconst colorCache = new Map<string, string | typeof notFound>()\n\n/**\n * Wrap `text` in an OSC 8 hyperlink pointing at `url`. Modern terminals\n * (iTerm2, kitty, WezTerm, VS Code, Ghostty, …) render the text as\n * clickable while falling back gracefully to plain text elsewhere.\n *\n * Safe to nest ANSI SGR styling inside the `text` argument — OSC 8 is a\n * separate escape category and doesn't conflict.\n *\n * An empty `url` short-circuits and returns `text` unchanged, so callers\n * can unconditionally pipe link text through this helper.\n *\n * @internal\n */\nexport function hyperlink(url: string, text: string): string {\n if (url === \"\") return text\n return `${OSC8}${url}${ST}${text}${OSC8}${ST}`\n}\n\nexport function ansiColor(color: AnsiColor, kind: \"fg\" | \"bg\"): string | undefined {\n if (!hasColors) return\n const key = `${color}-${kind}`\n let cached = colorCache.get(key)\n if (cached === undefined) colorCache.set(key, (cached = _ansiColor(color, kind)) ?? notFound)\n return cached === notFound ? undefined : cached\n}\n\nfunction _ansiColor(color: AnsiColor, kind: \"fg\" | \"bg\"): string | undefined {\n if (color === \"inherit\") return\n // Gray aliases to brightBlack.\n if (color === \"gray\" || color === \"grey\") return String(kind === \"fg\" ? 90 : 100)\n\n const base = color in ANSI_OFFSET ? color : undefined\n if (base !== undefined) return String((kind === \"fg\" ? 30 : 40) + ANSI_OFFSET[base])\n\n if (color.startsWith(\"bright\")) {\n const rest = color.slice(\"bright\".length).toLowerCase()\n if (rest in ANSI_OFFSET) return String((kind === \"fg\" ? 90 : 100) + ANSI_OFFSET[rest])\n }\n\n const rgb = isHexColor(color) ? parseHex(color) : undefined\n if (rgb) {\n const indicator = kind === \"fg\" ? 38 : 48\n return `${indicator};2;${rgb[0]};${rgb[1]};${rgb[2]}`\n }\n}\n\nexport function openAnsi(style: AnsiStyle) {\n if (!hasColors) return \"\"\n const params: (number | string | undefined)[] = []\n for (const [key, code] of ATTRS) if (style[key]) params.push(code)\n if (style.fg !== undefined) params.push(ansiColor(style.fg, \"fg\"))\n if (style.bg !== undefined) params.push(ansiColor(style.bg, \"bg\"))\n const attrs = params.filter((p) => p !== undefined)\n if (attrs.length === 0) return \"\"\n return `\\x1b[${attrs.join(\";\")}m`\n}\n\nexport function styleAnsi(text: string, style?: AnsiStyle): string {\n if (!style) return text\n const open = openAnsi(style)\n if (open === \"\") return text\n return `${open}${text}${RESET}`\n}\n\n/**\n * Post-process a styled string so an outer style is re-applied after any\n * inner full-reset (`\\x1b[0m`). Without this, a child's reset clobbers\n * the parent's bg/fg/attrs for the remainder of the line.\n *\n * `escape` is the already-built SGR run to re-emit after each reset\n * (typically the return value of `openStyle(parentStyle, theme)`). If\n * empty, the input is returned unchanged.\n *\n * Inlined indexOf loop rather than `String.prototype.replaceAll` — the\n * manual version avoids the regex/object allocation overhead of\n * `replaceAll` and runs meaningfully faster on short strings (hot in\n * the builder's `apply`, called once per styled span). Pattern taken\n * from ansis's nested-style resolver.\n *\n * @internal\n */\nexport function reapplyStyle(s: string, escape: string): string {\n if (escape === \"\" || !s.includes(RESET)) return s\n const replacement = RESET + escape\n const searchLength = RESET.length\n let result = \"\"\n let lastPos = 0\n let pos = s.indexOf(RESET)\n while (pos !== -1) {\n result += s.slice(lastPos, pos) + replacement\n lastPos = pos + searchLength\n pos = s.indexOf(RESET, lastPos)\n }\n return result + s.slice(lastPos)\n}\n\nexport function stripAnsiBg(s: string): string {\n return s.replaceAll(/\\x1b\\[([0-9;]*)m/g, (match, raw: string) => {\n const next = stripBgParams(raw)\n if (next === raw) return match\n return next === \"\" ? \"\" : `\\x1b[${next}m`\n })\n}\n\nfunction stripBgParams(raw: string): string {\n if (raw === \"\") return raw\n const params = raw.split(\";\").map(Number)\n const ret: number[] = []\n for (let i = 0; i < params.length; i++) {\n const p = params[i]\n if ((p >= 40 && p <= 47) || (p >= 100 && p <= 107) || p === 49) continue\n if (p === 48) {\n const mode = params[i + 1]\n if (mode === 2) {\n i += 4\n continue\n }\n if (mode === 5) {\n i += 2\n continue\n }\n continue\n }\n ret.push(p)\n }\n return ret.join(\";\")\n}\n\nexport function ansiBg(str: string, idx: number): AnsiColor | undefined {\n const cell = sliceAnsi(str, idx, idx + 1)\n\n let bg: AnsiColor | undefined\n\n for (const match of cell.matchAll(/\\x1b\\[([0-9;]*)m/g)) {\n const params = match[1].split(\";\").map(Number)\n\n for (let i = 0; i < params.length; i++) {\n const p = params[i]\n\n if ((p >= 40 && p <= 47) || (p >= 100 && p <= 107)) {\n bg = ANSI_BG[p]\n } else if (p === 48 && params[i + 1] === 2) {\n bg = toHex(params[i + 2], params[i + 3], params[i + 4])\n i += 4\n }\n }\n }\n\n return bg\n}\n"],"mappings":";;;;AAIA,MAAM,WAAW,MAAsB,MAAM,KAAK,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;AAIhG,SAAgB,MAAM,GAAiB,GAAY,GAAsB;CACvE,MAAM,CAAC,GAAG,GAAG,KAAK,MAAM,QAAQ,CAAC,IAAI,IAAI;EAAC;EAAG;EAAI;CAAE;CACnD,OAAO,IAAI,QAAQ,CAAC,IAAI,QAAQ,CAAC,IAAI,QAAQ,CAAC;AAChD;AAEA,SAAgB,SAAS,KAAkB;CACzC,IAAI,IAAI,IAAI,WAAW,CAAC,MAAM,KAAO,IAAI,MAAM,CAAC,IAAI;CACpD,IAAI,EAAE,WAAW,GAAG,IAAI,EAAE,MAAM,GAAG,CAAC;CACpC,IAAI,EAAE,WAAW,GAAG,IAAI,EAAE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F;GACA;EACF;EACA,IAAI,KAAK,CAAC;CACZ;CACA,OAAO,IAAI,KAAK,GAAG;AACrB;AAEA,SAAgB,OAAO,KAAa,KAAoC;CACtE,MAAM,OAAO,UAAU,KAAK,KAAK,MAAM,CAAC;CAExC,IAAI;CAEJ,KAAK,MAAM,SAAS,KAAK,SAAS,mBAAmB,GAAG;EACtD,MAAM,SAAS,MAAM,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;EAE7C,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;GACtC,MAAM,IAAI,OAAO;GAEjB,IAAK,KAAK,MAAM,KAAK,MAAQ,KAAK,OAAO,KAAK,KAC5C,KAAK,QAAQ;QACR,IAAI,MAAM,MAAM,OAAO,IAAI,OAAO,GAAG;IAC1C,KAAK,MAAM,OAAO,IAAI,IAAI,OAAO,IAAI,IAAI,OAAO,IAAI,EAAE;IACtD,KAAK;GACP;EACF;CACF;CAEA,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"box-DLEcEvDH.mjs","names":[],"sources":["../src/layout/border.ts","../src/widgets/box.ts"],"sourcesContent":["import type { StyleBuilder } from \"../style/builder.ts\"\n\nimport { sliceAnsi, stringWidth } from \"@zaly/shared/ansi\"\n\n/**\n * Border-character glyphs for drawing a box outline. Any single-cell string\n * is allowed (including multi-byte glyphs like rounded corners).\n */\nexport interface BorderChars {\n h: string\n v: string\n tl: string\n tr: string\n bl: string\n br: string\n}\n\nexport type BorderSpec = boolean | \"single\" | \"double\" | \"rounded\" | BorderChars\n\n/** @internal */\nexport const borders = {\n double: { bl: \"╚\", br: \"╝\", h: \"═\", tl: \"╔\", tr: \"╗\", v: \"║\" },\n rounded: { bl: \"╰\", br: \"╯\", h: \"─\", tl: \"╭\", tr: \"╮\", v: \"│\" },\n single: { bl: \"└\", br: \"┘\", h: \"─\", tl: \"┌\", tr: \"┐\", v: \"│\" },\n} as const satisfies Record<string, BorderChars>\n\n/** Resolve the `border` style value to a concrete BorderChars, or undefined.\n *\n * @internal*/\nexport function resolveBorder(spec: BorderSpec | undefined): BorderChars | undefined {\n if (spec === undefined || spec === false) return undefined\n if (spec === true) return borders.single\n if (typeof spec === \"string\") return borders[spec]\n return spec\n}\n\nexport type TitleAlign = \"left\" | \"center\" | \"right\"\n\nexport interface DrawBorderOpts {\n /**\n * Optional title embedded in the top border, with a single-cell space on\n * each side. Ellipsis-truncated when it overflows the budget.\n */\n title?: string\n /** Placement of `title` along the top border. Defaults to `\"left\"`. */\n titleAlign?: TitleAlign\n /**\n * Styled wrapper applied to the border glyphs (corners, horizontal,\n * vertical). Use `ctx.style.add(slotOrStyle)` at the call site so the\n * theme is resolved once per render.\n */\n borderStyle?: StyleBuilder\n /** Styled wrapper applied to the title text (including the padding spaces). */\n titleStyle?: StyleBuilder\n}\n\n/** Pass-through wrapper used when no style is supplied. */\nconst identity = (s: string): string => s\n\n/**\n * Wrap pre-rendered inner rows with a border, adding top/bottom border rows\n * and left/right border chars to each inner row. Inner rows must be padded\n * to a uniform width; the output rows are `innerWidth + 2` wide.\n *\n * Border glyphs and the optional title can be styled independently via\n * `borderStyle` / `titleStyle` — each is a pre-bound `StyleBuilder`, so\n * this helper stays purely about geometry and never touches SGR itself.\n *\n * @internal\n */\nexport function drawBorder(\n rows: readonly string[],\n chars: BorderChars,\n opts: DrawBorderOpts = {}\n): string[] {\n const { title, titleAlign } = opts\n const inner = rows.length > 0 ? stringWidth(rows[0]) : 0\n const wrapB = opts.borderStyle ?? identity\n const wrapT = opts.titleStyle ?? identity\n\n const out: string[] = []\n out.push(topRow({ align: titleAlign ?? \"left\", chars, inner, title, wrapB, wrapT }))\n const v = wrapB(chars.v)\n for (const row of rows) out.push(v + row + v)\n out.push(wrapB(chars.bl + chars.h.repeat(inner) + chars.br))\n return out\n}\n\ninterface TopRowArgs {\n align: TitleAlign\n chars: BorderChars\n inner: number\n title: string | undefined\n wrapB: (s: string) => string\n wrapT: (s: string) => string\n}\n\nfunction topRow({ align, chars, inner, title, wrapB, wrapT }: TopRowArgs): string {\n if (title === undefined || title === \"\") {\n return wrapB(chars.tl + chars.h.repeat(inner) + chars.tr)\n }\n // Chrome: h + space + title + space + h (4 cells of chrome around the title)\n const budget = inner - 4\n if (budget <= 0) return wrapB(chars.tl + chars.h.repeat(inner) + chars.tr)\n const shown = truncate(title, budget)\n const totalH = inner - 2 - stringWidth(shown)\n const { leading, trailing } = distributeH(totalH, align)\n const prefix = wrapB(`${chars.tl}${chars.h.repeat(leading)}`)\n const titleSeg = wrapT(` ${shown} `)\n const suffix = wrapB(`${chars.h.repeat(trailing)}${chars.tr}`)\n return prefix + titleSeg + suffix\n}\n\nfunction distributeH(totalH: number, align: TitleAlign): { leading: number; trailing: number } {\n if (align === \"left\") return { leading: 1, trailing: totalH - 1 }\n if (align === \"right\") return { leading: totalH - 1, trailing: 1 }\n // center: leading rounds down so odd slack biases the title slightly left.\n const leading = Math.floor(totalH / 2)\n return { leading, trailing: totalH - leading }\n}\n\nfunction truncate(s: string, width: number): string {\n if (stringWidth(s) <= width) return s\n if (width <= 1) return \"…\".repeat(width)\n return `${sliceAnsi(s, 0, width - 1)}…`\n}\n","import type { RenderCtx } from \"../core/ctx.ts\"\nimport type { State } from \"../core/state.ts\"\nimport type { BorderSpec, TitleAlign } from \"../layout/border.ts\"\nimport type { RowItem } from \"../layout/flex.ts\"\nimport type { Style } from \"../style/types.ts\"\nimport type { TextContent } from \"./text.ts\"\n\nimport { stringWidth } from \"@zaly/shared/ansi\"\nimport { Node } from \"../core/node.ts\"\nimport { unwrap } from \"../core/reactive.ts\"\nimport { drawBorder, resolveBorder } from \"../layout/border.ts\"\nimport { allocateRow, isFixedWidth, padRow, stackColumn, zipRow } from \"../layout/flex.ts\"\nimport { clamp, resolveSize } from \"../layout/size.ts\"\nimport { textContent } from \"./text.ts\"\n\nexport type Padding =\n | number\n | readonly [v: number, h: number]\n | readonly [t: number, r: number, b: number, l: number]\n\nexport interface BoxStyle extends Style {\n flexDirection?: \"row\" | \"column\"\n gap?: number\n /** Fixed outer height in rows. When unset, the box's height emerges\n * naturally from its content + padding + border. When set, the\n * content area is truncated or padded with blank rows to land at\n * exactly this many rows of *outer* height. Pair with\n * `verticalAlign` to control which edge is anchored. */\n height?: number\n /** Anchor for the content when `height` truncates or extends.\n * `\"top\"` (default) keeps the top edge: extra rows added at the\n * bottom, overflow truncated from the bottom. `\"bottom\"` keeps the\n * bottom edge: extra rows prepended, overflow truncated from the\n * top. Other CSS-like values (`middle`) are not implemented. */\n verticalAlign?: \"top\" | \"bottom\"\n padding?: Padding\n border?: BorderSpec\n borderTitle?: TextContent\n /** Placement of `borderTitle` along the top border. Defaults to `\"left\"`. */\n borderTitleAlign?: TitleAlign\n /**\n * Style applied to the border glyphs. Either a theme slot name (resolved\n * via the active theme) or an inline `Style`. Defaults to the `\"border\"`\n * theme slot when a border is drawn.\n */\n borderStyle?: string | Style\n /**\n * Style applied to the border title. Defaults to the `\"borderTitle\"` theme\n * slot when a title is set.\n */\n borderTitleStyle?: string | Style\n}\n\nexport class Box<T extends object = {}> extends Node<BoxStyle & T> {\n protected async _render(ctx: RenderCtx): Promise<string[]> {\n const style = this.state\n\n const [padT, padR, padB, padL] = resolvePadding(style.padding)\n const bchars = resolveBorder(style.border)\n const hasBorder = bchars !== undefined\n const chrome = padL + padR + (hasBorder ? 2 : 0)\n\n let outer: number\n let contentRows: string[]\n let inner: number\n\n if (style.width === \"fit\") {\n // `fit`: render children at the parent's max inner width, measure\n // the natural max-row width, then clamp the box to that. Two-pass\n // — the first pass uses the upper bound as a measuring window,\n // the second re-pads each row to the chosen inner width.\n const upper = Math.max(0, ctx.width - chrome)\n const tentative = await this.#layoutChildren(upper, ctx)\n const natural = tentative.reduce((m, r) => Math.max(m, stringWidth(r)), 0)\n const fit = Math.min(ctx.width, natural + chrome)\n outer = clamp(fit, {\n available: ctx.width,\n max: style.maxWidth,\n min: style.minWidth,\n })\n inner = Math.max(0, outer - chrome)\n contentRows = tentative\n } else {\n const requested = resolveSize(style.width ?? \"fill\", ctx.width) ?? ctx.width\n outer = clamp(requested, {\n available: ctx.width,\n max: style.maxWidth,\n min: style.minWidth,\n })\n inner = Math.max(0, outer - chrome)\n contentRows = await this.#layoutChildren(inner, ctx)\n }\n\n const paddedWidth = Math.max(0, outer - (hasBorder ? 2 : 0))\n\n // Ensure each content row is exactly `inner` cells wide (absorbs slack).\n contentRows = contentRows.map((row) => padRow(row, inner))\n\n // Horizontal padding.\n if (padL > 0 || padR > 0) {\n const lp = \" \".repeat(padL)\n const rp = \" \".repeat(padR)\n contentRows = contentRows.map((row) => lp + row + rp)\n }\n\n // Vertical padding.\n const blank = \" \".repeat(paddedWidth)\n const top = Array.from({ length: padT }, () => blank)\n const bot = Array.from({ length: padB }, () => blank)\n let rows = [...top, ...contentRows, ...bot]\n\n // Fixed-height fit. The `height` field is the outer dimension —\n // border takes its 2 rows out before we measure against the\n // content area; padding is already baked into `rows`. `verticalAlign`\n // decides which end gets clipped (when too tall) or padded (when\n // too short). Default `\"top\"` matches the natural reading flow.\n if (style.height !== undefined) {\n const innerH = Math.max(0, style.height - (hasBorder ? 2 : 0))\n if (rows.length > innerH) {\n rows = style.verticalAlign === \"bottom\" ? rows.slice(-innerH) : rows.slice(0, innerH)\n } else if (rows.length < innerH) {\n const filler = Array.from({ length: innerH - rows.length }, () => blank)\n rows = style.verticalAlign === \"bottom\" ? [...filler, ...rows] : [...rows, ...filler]\n }\n }\n\n if (bchars) {\n rows = drawBorder(rows, bchars, {\n borderStyle: ctx.style.add(style.borderStyle ?? \"border\"),\n title: await textContent(style.borderTitle, ctx),\n titleAlign: style.borderTitleAlign,\n titleStyle: ctx.style.add(style.borderTitleStyle ?? \"borderTitle\"),\n })\n }\n\n const wrap = ctx.style.add(style)\n return rows.map((row) => wrap(row))\n }\n\n /**\n * Intrinsic content width derived from children (or the explicit\n * `width` when fixed). Lets parent flex containers size this Box\n * without falling back to a measure-render — important for\n * side-effecting children like `Image` whose first render allocates\n * a KGP placement: rendering twice would emit two placements and the\n * second render's `transmitOnce` returns no bytes, so the bytes from\n * the discarded measure pass would be lost.\n *\n * Row direction → bases sum (plus gaps). Column direction → bases\n * max. Both add chrome (padding + border) at the end.\n *\n * Children without `layout()` contribute 0 — the row allocator's\n * render-measure fallback still kicks in for them at allocation\n * time, but their absence here just means this Box reports a\n * smaller intrinsic. That's the safe direction: under-report and\n * let shrink/grow handle slack, never over-report.\n */\n override async layout(ctx: RenderCtx) {\n const s = this.state\n const [, padR, , padL] = resolvePadding(s.padding)\n const chrome = padL + padR + (resolveBorder(s.border) ? 2 : 0)\n\n // Fixed width wins outright.\n if (isFixedWidth(s.width)) {\n const w = resolveSize(s.width, ctx.width) ?? 0\n return { minWidth: w, width: w }\n }\n\n const kids = layoutNodes(this.children)\n if (kids.length === 0) return { minWidth: chrome, width: chrome }\n\n const isRow = (s.flexDirection ?? \"column\") === \"row\"\n const totalGap = isRow ? (s.gap ?? 0) * Math.max(0, kids.length - 1) : 0\n\n let widthAcc = 0\n let minAcc = 0\n for (const k of kids) {\n // oxlint-disable-next-line no-await-in-loop\n const l = (await k.getLayout(ctx)) ?? { minWidth: 0, width: 0 }\n if (isRow) {\n widthAcc += l.width\n minAcc += l.minWidth\n } else {\n widthAcc = Math.max(widthAcc, l.width)\n minAcc = Math.max(minAcc, l.minWidth)\n }\n }\n\n return { minWidth: minAcc + totalGap + chrome, width: widthAcc + totalGap + chrome }\n }\n\n async #layoutChildren(innerWidth: number, ctx: RenderCtx): Promise<string[]> {\n const children = layoutNodes(this.children)\n if (children.length === 0) return []\n const gap = this.state.gap ?? 0\n return (this.state.flexDirection ?? \"column\") === \"row\"\n ? this.#layoutRow(children, innerWidth, ctx, gap)\n : this.#layoutColumn(children, innerWidth, ctx, gap)\n }\n\n /**\n * Row direction — main axis is horizontal. CSS-style flex:\n * each child sizes to its intrinsic content width unless it claims\n * slack via `flexGrow > 0` or `width: \"fill\"`. Slack distributes by\n * grow weights; deficit distributes by `basis * flexShrink` clamped\n * at each child's `min-content` floor.\n *\n * Sizing strategy per child:\n * 1. `node.layout(ctx)` — sync, content-derived. If implemented,\n * use directly; no render needed for measurement.\n * 2. Otherwise fall back to render-at-innerWidth and measure the\n * widest emitted row. Cached; the paint pass reuses the result\n * whenever the allocated width matches the measurement width.\n *\n * In `fit` mode the parent has no slack to give, so the allocator's\n * available is capped at the natural sum.\n */\n async #layoutRow(\n children: readonly Node[],\n innerWidth: number,\n ctx: RenderCtx,\n gap: number\n ): Promise<string[]> {\n // Phase 1: figure out each child's intrinsic size.\n // - `layout()` short-circuits — sync, no render.\n // - Fallback: render at the upper bound (innerWidth or fixed spec)\n // and measure rows.\n const intrinsics = await Promise.all(children.map((c) => c.getLayout(ctx)))\n // For children with intrinsic sizing, skip the measure render\n // entirely. Others fall back to render-at-upper-bound (their fixed\n // width, or innerWidth if fluid).\n const measureWidths = children.map((c, i) => {\n if (intrinsics[i] !== undefined) return -1\n if (isFixedWidth(c.state.width)) {\n return resolveSize(c.state.width, innerWidth) ?? innerWidth\n }\n return innerWidth\n })\n const measureRows = await Promise.all(\n children.map((c, i): Promise<string[] | undefined> => {\n if (measureWidths[i] === -1) return Promise.resolve(undefined)\n return c.render({ ...ctx, width: measureWidths[i] })\n })\n )\n const naturals = children.map((c, i) => {\n // A fixed `state.width` is what the allocator will actually\n // assign this child — use it directly so the fit-mode\n // `allocAvailable` sum below matches what we'll consume. Falling\n // back to intrinsic when there's no override under-reports a\n // child like `text(\"x\", { width: 2 })` and shrinks every sibling\n // by the missing cells.\n if (isFixedWidth(c.state.width)) {\n return resolveSize(c.state.width, innerWidth) ?? 0\n }\n const intr = intrinsics[i]\n if (intr) return intr.width\n return (measureRows[i] ?? []).reduce((m, r) => Math.max(m, stringWidth(r)), 0)\n })\n const items: RowItem[] = children.map((c, i) => {\n const s = c.state\n return {\n flexGrow: s.flexGrow,\n flexShrink: s.flexShrink,\n intrinsicMin: intrinsics[i]?.minWidth,\n maxWidth: s.maxWidth,\n minWidth: s.minWidth,\n natural: naturals[i],\n width: s.width,\n }\n })\n const allocAvailable =\n this.state.width === \"fit\"\n ? naturals.reduce((a, b) => a + b, 0) + gap * Math.max(0, children.length - 1)\n : innerWidth\n const widths = allocateRow(items, { contentWidth: allocAvailable, gap })\n // Phase 2: paint at allocated widths. Reuse the measure-render when\n // the allocation matches; otherwise render fresh (cached).\n const childRows = await Promise.all(\n children.map((c, i): Promise<string[]> => {\n const cached = measureRows[i]\n if (cached !== undefined && widths[i] === measureWidths[i]) {\n return Promise.resolve(cached)\n }\n return c.render({ ...ctx, width: widths[i] })\n })\n )\n // `zipRow` expects rows to be exactly `widths[i]` wide. Children\n // that emit natural-width rows (text default, code default) get\n // padded here so the contract holds; over-wide rows get clipped.\n const padded = childRows.map((rows, i) => rows.map((row) => padRow(row, widths[i])))\n return zipRow(padded, { gap, widths })\n }\n\n /**\n * Column direction — main axis is vertical, cross axis horizontal.\n * Per CSS `align-items: stretch` (default), children with no\n * explicit `width` fill the cross axis. A child with a fixed `width`\n * (number / `Pct`) takes that width as its cross-axis size, with the\n * leftover padded as right slack (default `flex-start`). `min`/`max`\n * clamp the resolved width.\n *\n * In fit-mode (`width: \"fit\"`), the cross-axis target shrinks to the\n * widest child row instead of stretching to `innerWidth` — symmetric\n * to how row-direction caps allocator-available at the natural sum.\n */\n async #layoutColumn(\n children: readonly Node[],\n innerWidth: number,\n ctx: RenderCtx,\n gap: number\n ): Promise<string[]> {\n const widths = children.map((c) => {\n const s = c.state\n const fixed = isFixedWidth(s.width) ? resolveSize(s.width, innerWidth) : undefined\n const w = fixed ?? innerWidth\n return clamp(w, { available: innerWidth, max: s.maxWidth, min: s.minWidth })\n })\n const childRows = await Promise.all(\n children.map((c, i) => c.render({ ...ctx, width: widths[i] }))\n )\n const target =\n this.state.width === \"fit\"\n ? childRows.reduce((m, rows) => rows.reduce((mm, r) => Math.max(mm, stringWidth(r)), m), 0)\n : innerWidth\n // Pad each child's rows to the cross-axis target. For full-stretch\n // children this absorbs natural-row slack; for fixed-width\n // children it adds right-side slack (default `flex-start`\n // alignment). `stackColumn`'s contract requires uniform width.\n const padded = childRows.map((rows) => rows.map((row) => padRow(row, target)))\n return stackColumn(padded, { gap, width: target })\n }\n}\n\ntype Child = Node | false | null | undefined\n\n/**\n * Factory for `Box`. The style object is required (use `{}` if you don't\n * need any styling) — the previous style-less overload caused TS to fail\n * to discriminate between a Node child and an inferred-empty-state node\n * like `WidgetNode`. Pass `box({}, child1, child2)` for un-styled boxes.\n *\n * Falsy children (`false`, `null`, `undefined`) are filtered out, enabling\n * conditional JSX-like composition: `box({}, cond && child)`.\n */\nexport function box(style: State<BoxStyle>, ...children: Child[]): Box {\n const b = new Box(style)\n for (const c of children) if (c) b.add(c)\n return b\n}\n\n/**\n * Flatten fragment nodes (those that implement the `layoutChildren`\n * protocol — `show`, `errorBoundary`, `suspense`) into their currently\n * active leaves. Recursive: a fragment whose `layoutChildren()`\n * itself contains fragments unfolds completely.\n *\n * The fragment Node still lives in the tree (mounted, propagating\n * invalidates) — layout just sees through it so its children share\n * the parent box's flex distribution, gap, and cross-axis sizing\n * instead of collapsing into a single slot.\n */\nfunction layoutNodes(children: readonly Node[]): readonly Node[] {\n return children.flatMap((c) => c.layoutNodes).filter((c) => unwrap(c.state.visible) ?? true)\n}\n\nfunction resolvePadding(p: Padding | undefined): [t: number, r: number, b: number, l: number] {\n if (p === undefined) return [0, 0, 0, 0]\n if (typeof p === \"number\") return [p, p, p, p]\n if (p.length === 2) return [p[0], p[1], p[0], p[1]]\n return [p[0], p[1], p[2], p[3]]\n}\n"],"mappings":";;;;;;;;AAoBA,MAAa,UAAU;CACrB,QAAQ;EAAE,IAAI;EAAK,IAAI;EAAK,GAAG;EAAK,IAAI;EAAK,IAAI;EAAK,GAAG;CAAI;CAC7D,SAAS;EAAE,IAAI;EAAK,IAAI;EAAK,GAAG;EAAK,IAAI;EAAK,IAAI;EAAK,GAAG;CAAI;CAC9D,QAAQ;EA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,EAAE,OAAO;GAAE,GAAG;GAAK,OAAO,OAAO;EAAG,CAAC,CAAC,CAC/D;EACA,MAAM,SACJ,KAAK,MAAM,UAAU,QACjB,UAAU,QAAQ,GAAG,SAAS,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,YAAY,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IACxF;EAKN,MAAM,SAAS,UAAU,KAAK,SAAS,KAAK,KAAK,QAAQ,OAAO,KAAK,MAAM,CAAC,CAAC;EAC7E,OAAO,YAAY,QAAQ;GAAE;GAAK,OAAO;EAAO,CAAC;CACnD;AACF;;;;;;;;;;AAaA,SAAgB,IAAI,OAAwB,GAAG,UAAwB;CACrE,MAAM,IAAI,IAAI,IAAI,KAAK;CACvB,KAAK,MAAM,KAAK,UAAU,IAAI,GAAG,EAAE,IAAI,CAAC;CACxC,OAAO;AACT;;;;;;;;;;;;AAaA,SAAS,YAAY,UAA4C;CAC/D,OAAO,SAAS,SAAS,MAAM,EAAE,WAAW,CAAC,CAAC,QAAQ,MAAM,OAAO,EAAE,MAAM,OAAO,KAAK,IAAI;AAC7F;AAEA,SAAS,eAAe,GAAsE;CAC5F,IAAI,MAAM,KAAA,GAAW,OAAO;EAAC;EAAG;EAAG;EAAG;CAAC;CACvC,IAAI,OAAO,MAAM,UAAU,OAAO;EAAC;EAAG;EAAG;EAAG;CAAC;CAC7C,IAAI,EAAE,WAAW,GAAG,OAAO;EAAC,EAAE;EAAI,EAAE;EAAI,EAAE;EAAI,EAAE;CAAE;CAClD,OAAO;EAAC,EAAE;EAAI,EAAE;EAAI,EAAE;EAAI,EAAE;CAAE;AAChC"}
|
|
@@ -1,386 +0,0 @@
|
|
|
1
|
-
import { t as defaultTheme } from "./registry-3hLzS4ks.mjs";
|
|
2
|
-
import { a as openAnsi, d as toHex, l as isHexColor, o as reapplyStyle, t as RESET, u as parseHex } from "./ansi-Clq0ozyA.mjs";
|
|
3
|
-
import { clamp } from "@zaly/shared";
|
|
4
|
-
//#region src/style/oklch.ts
|
|
5
|
-
const cache = /* @__PURE__ */ new Map();
|
|
6
|
-
function srgbToLinear(c) {
|
|
7
|
-
return c <= .04045 ? c / 12.92 : ((c + .055) / 1.055) ** 2.4;
|
|
8
|
-
}
|
|
9
|
-
function linearToSrgb(c) {
|
|
10
|
-
return c <= .0031308 ? c * 12.92 : 1.055 * c ** (1 / 2.4) - .055;
|
|
11
|
-
}
|
|
12
|
-
function hexToOklch(hex) {
|
|
13
|
-
const [r8, g8, b8] = parseHex(hex);
|
|
14
|
-
const r = srgbToLinear(r8 / 255);
|
|
15
|
-
const g = srgbToLinear(g8 / 255);
|
|
16
|
-
const b = srgbToLinear(b8 / 255);
|
|
17
|
-
const l = .4122214708 * r + .5363325363 * g + .0514459929 * b;
|
|
18
|
-
const m = .2119034982 * r + .6806995451 * g + .1073969566 * b;
|
|
19
|
-
const s = .0883024619 * r + .2817188376 * g + .6299787005 * b;
|
|
20
|
-
const lp = Math.cbrt(l);
|
|
21
|
-
const mp = Math.cbrt(m);
|
|
22
|
-
const sp = Math.cbrt(s);
|
|
23
|
-
const L = .2104542553 * lp + .793617785 * mp - .0040720468 * sp;
|
|
24
|
-
const a = 1.9779984951 * lp - 2.428592205 * mp + .4505937099 * sp;
|
|
25
|
-
const b2 = .0259040371 * lp + .7827717662 * mp - .808675766 * sp;
|
|
26
|
-
return {
|
|
27
|
-
C: Math.hypot(a, b2),
|
|
28
|
-
L,
|
|
29
|
-
h: (Math.atan2(b2, a) * 180 / Math.PI + 360) % 360
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/** Convert OKLCH → linear sRGB (unclamped — callers can test for gamut). */
|
|
33
|
-
function oklchToLinearRgb({ L, C, h }) {
|
|
34
|
-
const hr = h * Math.PI / 180;
|
|
35
|
-
const a = C * Math.cos(hr);
|
|
36
|
-
const b2 = C * Math.sin(hr);
|
|
37
|
-
const lp = L + .3963377774 * a + .2158037573 * b2;
|
|
38
|
-
const mp = L - .1055613458 * a - .0638541728 * b2;
|
|
39
|
-
const sp = L - .0894841775 * a - 1.291485548 * b2;
|
|
40
|
-
const l = lp ** 3;
|
|
41
|
-
const m = mp ** 3;
|
|
42
|
-
const s = sp ** 3;
|
|
43
|
-
return [
|
|
44
|
-
4.0767416621 * l - 3.3077115913 * m + .2309699292 * s,
|
|
45
|
-
-1.2684380046 * l + 2.6097574011 * m - .3413193965 * s,
|
|
46
|
-
-.0041960863 * l - .7034186147 * m + 1.707614701 * s
|
|
47
|
-
];
|
|
48
|
-
}
|
|
49
|
-
function inGamut([r, g, b], eps = .001) {
|
|
50
|
-
return r >= -eps && r <= 1 + eps && g >= -eps && g <= 1 + eps && b >= -eps && b <= 1 + eps;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Convert OKLCH → hex, reducing chroma via binary search when the
|
|
54
|
-
* straightforward conversion falls outside sRGB. The search keeps `L`
|
|
55
|
-
* and `h` fixed and shrinks `C` toward the achromatic axis until the
|
|
56
|
-
* color fits, which is the CSS Color Level 4-recommended behavior.
|
|
57
|
-
*/
|
|
58
|
-
function oklchToHex(oklch) {
|
|
59
|
-
let rgb = oklchToLinearRgb(oklch);
|
|
60
|
-
if (!inGamut(rgb)) {
|
|
61
|
-
let lo = 0;
|
|
62
|
-
let hi = oklch.C;
|
|
63
|
-
for (let i = 0; i < 24; i++) {
|
|
64
|
-
const mid = (lo + hi) / 2;
|
|
65
|
-
if (inGamut(oklchToLinearRgb({
|
|
66
|
-
...oklch,
|
|
67
|
-
C: mid
|
|
68
|
-
}))) lo = mid;
|
|
69
|
-
else hi = mid;
|
|
70
|
-
}
|
|
71
|
-
rgb = oklchToLinearRgb({
|
|
72
|
-
...oklch,
|
|
73
|
-
C: lo
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
const [r, g, b] = rgb.map((c) => linearToSrgb(Math.max(0, Math.min(1, c))));
|
|
77
|
-
return toHex(r * 255, g * 255, b * 255);
|
|
78
|
-
}
|
|
79
|
-
function shiftLightness(hex, delta) {
|
|
80
|
-
const key = `${hex}:${delta}`;
|
|
81
|
-
let ret = cache.get(key);
|
|
82
|
-
if (ret) return ret;
|
|
83
|
-
const okl = hexToOklch(hex);
|
|
84
|
-
const L = clamp(okl.L + delta, 0, 1);
|
|
85
|
-
const margin = Math.min(L, 1 - L);
|
|
86
|
-
const C = okl.C * Math.min(1, margin / .1);
|
|
87
|
-
cache.set(key, ret = oklchToHex({
|
|
88
|
-
...okl,
|
|
89
|
-
C,
|
|
90
|
-
L
|
|
91
|
-
}));
|
|
92
|
-
return ret;
|
|
93
|
-
}
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/style/style.ts
|
|
96
|
-
/**
|
|
97
|
-
* Build the opening SGR escape for a style descriptor. Returns '' if nothing
|
|
98
|
-
* would be emitted. Unresolvable colors (invalid or 'inherit') are dropped.
|
|
99
|
-
*
|
|
100
|
-
* When `theme` is provided, `fg`/`bg` values matching a theme color slot
|
|
101
|
-
* (e.g. `"primary"`, `"muted"`) are resolved against it first. The output
|
|
102
|
-
* ordering is attrs → fg → bg, combined into a single `\x1b[...m` run.
|
|
103
|
-
*
|
|
104
|
-
* @internal
|
|
105
|
-
*/
|
|
106
|
-
function openStyle(style, theme) {
|
|
107
|
-
const resolver = ThemeResolver.from(theme);
|
|
108
|
-
const ansiStyle = {
|
|
109
|
-
...style,
|
|
110
|
-
bg: style.bg !== void 0 ? resolver.getColor(style.bg, "bg") : void 0,
|
|
111
|
-
fg: style.fg !== void 0 ? resolver.getColor(style.fg, "fg") : void 0
|
|
112
|
-
};
|
|
113
|
-
return openAnsi(ansiStyle);
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Resolve a style-slot reference into a `Style` object. A ref is either a
|
|
117
|
-
* theme slot name (string), an inline `Style`, or `undefined`:
|
|
118
|
-
*
|
|
119
|
-
* - Inline `Style` → returned as-is (no slot lookup).
|
|
120
|
-
* - String ref pointing at a **Color** slot → wrapped as `{ fg: <color> }`.
|
|
121
|
-
* - String ref pointing at a **Style** slot → returned directly.
|
|
122
|
-
* - String ref that doesn't match a slot → treated as a fg color
|
|
123
|
-
* (`{ fg: <ref> }`) and resolved downstream by `colorParams`.
|
|
124
|
-
* - `undefined` → `{}` (emits nothing).
|
|
125
|
-
*
|
|
126
|
-
* @internal
|
|
127
|
-
*/
|
|
128
|
-
function resolveStyle(ref, theme) {
|
|
129
|
-
return ThemeResolver.from(theme).getStyle(ref);
|
|
130
|
-
}
|
|
131
|
-
function parseColor(c) {
|
|
132
|
-
const m = c.match(/^(.+?)([+-]\d{1,3})$/);
|
|
133
|
-
if (!m) return { base: c };
|
|
134
|
-
let lightness = Number(m[2]);
|
|
135
|
-
if (!Number.isFinite(lightness)) throw new TypeError(`Invalid color step in color "${c}": ${m[2]}`);
|
|
136
|
-
lightness = Math.abs(lightness) < 1 ? lightness : lightness / 100;
|
|
137
|
-
return {
|
|
138
|
-
base: m[1],
|
|
139
|
-
lightness
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
var ThemeResolver = class ThemeResolver {
|
|
143
|
-
static #cache = /* @__PURE__ */ new Map();
|
|
144
|
-
static #main = new ThemeResolver();
|
|
145
|
-
#theme;
|
|
146
|
-
#styleCache = /* @__PURE__ */ new Map();
|
|
147
|
-
#colorCache = /* @__PURE__ */ new Map();
|
|
148
|
-
constructor(theme = {}) {
|
|
149
|
-
this.#theme = theme;
|
|
150
|
-
}
|
|
151
|
-
static from(theme) {
|
|
152
|
-
if (theme === void 0) return this.#main;
|
|
153
|
-
let resolver = this.#cache.get(theme);
|
|
154
|
-
if (!resolver) {
|
|
155
|
-
resolver = new ThemeResolver(theme);
|
|
156
|
-
this.#cache.set(theme, resolver);
|
|
157
|
-
}
|
|
158
|
-
return resolver;
|
|
159
|
-
}
|
|
160
|
-
getStyle(ref, seen) {
|
|
161
|
-
if (ref === void 0) return {};
|
|
162
|
-
if (typeof ref === "object") return ref.style ? {
|
|
163
|
-
...this.getStyle(ref.style, seen),
|
|
164
|
-
...ref
|
|
165
|
-
} : ref;
|
|
166
|
-
let ret = this.#styleCache.get(ref);
|
|
167
|
-
if (ret) return ret;
|
|
168
|
-
seen ??= /* @__PURE__ */ new Set();
|
|
169
|
-
if (seen.has(ref)) throw new TypeError(`Circular dependency for theme slot "${ref}".`);
|
|
170
|
-
seen.add(ref);
|
|
171
|
-
const value = this.#theme[ref];
|
|
172
|
-
ret = value === void 0 ? { fg: ref } : this.getStyle(value, seen);
|
|
173
|
-
this.#styleCache.set(ref, ret);
|
|
174
|
-
return ret;
|
|
175
|
-
}
|
|
176
|
-
getColor(ref, kind = "fg", seen) {
|
|
177
|
-
if (ref === void 0) return "inherit";
|
|
178
|
-
const key = `${kind}:${ref}`;
|
|
179
|
-
let ret = this.#colorCache.get(key);
|
|
180
|
-
if (ret) return ret;
|
|
181
|
-
seen ??= /* @__PURE__ */ new Set();
|
|
182
|
-
if (seen.has(ref)) throw new TypeError(`Circular dependency for theme slot "${ref}".`);
|
|
183
|
-
seen.add(ref);
|
|
184
|
-
const { base, lightness } = parseColor(ref);
|
|
185
|
-
let value = this.#theme[base] ?? base;
|
|
186
|
-
if (typeof value === "object") value = this.getColor(value[kind], kind, seen);
|
|
187
|
-
else if (value !== base) value = this.getColor(value, kind, seen);
|
|
188
|
-
ret = lightness !== void 0 && isHexColor(value) ? shiftLightness(value, lightness) : value;
|
|
189
|
-
this.#colorCache.set(key, ret);
|
|
190
|
-
return ret;
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/style/builder.ts
|
|
195
|
-
/**
|
|
196
|
-
* Build styled strings via chainable property access.
|
|
197
|
-
*
|
|
198
|
-
* ```ts
|
|
199
|
-
* style().red.bold("err") // → "\x1b[1;31merr\x1b[0m"
|
|
200
|
-
* style().primary.bgAccent("x") // theme slots via the default theme
|
|
201
|
-
* style(myTheme).primary("x") // override the bound theme
|
|
202
|
-
* style().fg("#82aaff")("x") // hex via the escape hatch
|
|
203
|
-
* style().primary[300]("x") // tonal variant of the last color
|
|
204
|
-
* style().bgDiffAdd[200].fgDiffAdd("x") // per-channel variants on a Style slot
|
|
205
|
-
* ```
|
|
206
|
-
*
|
|
207
|
-
* Each property access returns a fresh builder, so intermediates can be
|
|
208
|
-
* reused and extended without mutation:
|
|
209
|
-
*
|
|
210
|
-
* ```ts
|
|
211
|
-
* const err = style().red.bold
|
|
212
|
-
* err("oops"); err.underline("fatal")
|
|
213
|
-
* ```
|
|
214
|
-
*
|
|
215
|
-
* Calling an empty builder is a no-op: `styleBuilder()("x")` returns `"x"` unchanged.
|
|
216
|
-
*/
|
|
217
|
-
function styleBuilder(theme = defaultTheme) {
|
|
218
|
-
return build({
|
|
219
|
-
current: {},
|
|
220
|
-
last: void 0,
|
|
221
|
-
theme: theme === false ? {
|
|
222
|
-
...defaultTheme,
|
|
223
|
-
enabled: false
|
|
224
|
-
} : theme
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
const ATTRS = /* @__PURE__ */ new Set([
|
|
228
|
-
"bold",
|
|
229
|
-
"dim",
|
|
230
|
-
"italic",
|
|
231
|
-
"underline",
|
|
232
|
-
"inverse",
|
|
233
|
-
"strikethrough"
|
|
234
|
-
]);
|
|
235
|
-
function applyStyle(state, text) {
|
|
236
|
-
if (!text || state.theme.enabled === false) return text;
|
|
237
|
-
const open = openStyle(state.current, state.theme);
|
|
238
|
-
return open === "" ? text : open + reapplyStyle(text, open) + RESET;
|
|
239
|
-
}
|
|
240
|
-
function applyOp(fn, arg) {
|
|
241
|
-
if (typeof arg === "string" || typeof arg === "number") {
|
|
242
|
-
const key = String(arg);
|
|
243
|
-
const hit = fn[key];
|
|
244
|
-
if (hit !== void 0) return hit;
|
|
245
|
-
const child = fulfill(fn.state, arg);
|
|
246
|
-
Reflect.defineProperty(fn, key, {
|
|
247
|
-
configurable: false,
|
|
248
|
-
value: child,
|
|
249
|
-
writable: false
|
|
250
|
-
});
|
|
251
|
-
return child;
|
|
252
|
-
}
|
|
253
|
-
return fulfill(fn.state, arg);
|
|
254
|
-
}
|
|
255
|
-
/** Turn a parked chain + its arg into the real child chain. */
|
|
256
|
-
function fulfill(state, arg) {
|
|
257
|
-
const { current, last, theme, pending } = state;
|
|
258
|
-
switch (pending) {
|
|
259
|
-
case "fg": return build({
|
|
260
|
-
current: {
|
|
261
|
-
...current,
|
|
262
|
-
fg: arg
|
|
263
|
-
},
|
|
264
|
-
last: "fg",
|
|
265
|
-
theme
|
|
266
|
-
});
|
|
267
|
-
case "bg": return build({
|
|
268
|
-
current: {
|
|
269
|
-
...current,
|
|
270
|
-
bg: arg
|
|
271
|
-
},
|
|
272
|
-
last: "bg",
|
|
273
|
-
theme
|
|
274
|
-
});
|
|
275
|
-
case "lighten":
|
|
276
|
-
case "darken": {
|
|
277
|
-
if (last === void 0) return build({
|
|
278
|
-
current,
|
|
279
|
-
last,
|
|
280
|
-
theme
|
|
281
|
-
});
|
|
282
|
-
const existing = current[last];
|
|
283
|
-
if (typeof existing !== "string" || existing === "inherit") return build({
|
|
284
|
-
current,
|
|
285
|
-
last,
|
|
286
|
-
theme
|
|
287
|
-
});
|
|
288
|
-
const next = `${existing.replace(/[+-]\d+$/, "")}${pending === "lighten" ? "+" : "-"}${Math.abs(arg)}`;
|
|
289
|
-
return build({
|
|
290
|
-
current: {
|
|
291
|
-
...current,
|
|
292
|
-
[last]: next
|
|
293
|
-
},
|
|
294
|
-
last,
|
|
295
|
-
theme
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
default: return build({
|
|
299
|
-
current: {
|
|
300
|
-
...current,
|
|
301
|
-
...resolveStyle(arg, theme)
|
|
302
|
-
},
|
|
303
|
-
last,
|
|
304
|
-
theme
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
/** Resolve a single property access on a chain to its child chain. */
|
|
309
|
-
function compileKey(state, key) {
|
|
310
|
-
const { current, last, theme } = state;
|
|
311
|
-
if (key === "fg" || key === "bg" || key === "lighten" || key === "darken" || key === "add") return build({
|
|
312
|
-
current,
|
|
313
|
-
last,
|
|
314
|
-
pending: key,
|
|
315
|
-
theme
|
|
316
|
-
});
|
|
317
|
-
if (ATTRS.has(key)) return build({
|
|
318
|
-
current: {
|
|
319
|
-
...current,
|
|
320
|
-
[key]: true
|
|
321
|
-
},
|
|
322
|
-
last,
|
|
323
|
-
theme
|
|
324
|
-
});
|
|
325
|
-
if (key.startsWith("bg") && key.length > 2 && key[2] === key[2].toUpperCase()) {
|
|
326
|
-
const color = key[2].toLowerCase() + key.slice(3);
|
|
327
|
-
return build({
|
|
328
|
-
current: {
|
|
329
|
-
...current,
|
|
330
|
-
bg: color
|
|
331
|
-
},
|
|
332
|
-
last: "bg",
|
|
333
|
-
theme
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
if (key.startsWith("fg") && key.length > 2 && key[2] === key[2].toUpperCase()) {
|
|
337
|
-
const color = key[2].toLowerCase() + key.slice(3);
|
|
338
|
-
return build({
|
|
339
|
-
current: {
|
|
340
|
-
...current,
|
|
341
|
-
fg: color
|
|
342
|
-
},
|
|
343
|
-
last: "fg",
|
|
344
|
-
theme
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
return build({
|
|
348
|
-
current: {
|
|
349
|
-
...current,
|
|
350
|
-
...resolveStyle(key, theme)
|
|
351
|
-
},
|
|
352
|
-
last: "fg",
|
|
353
|
-
theme
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
/** Shared Proxy handler — one instance, used by every chain. Reads
|
|
357
|
-
* state off the target (the `BuilderFn`), so chain construction
|
|
358
|
-
* doesn't allocate a fresh handler object per `build()` call. */
|
|
359
|
-
const proxyHandler = { get(target, key) {
|
|
360
|
-
if (typeof key !== "string") return void 0;
|
|
361
|
-
const cached = target[key];
|
|
362
|
-
if (cached !== void 0) return cached;
|
|
363
|
-
if (target.state.pending !== void 0) return void 0;
|
|
364
|
-
const child = compileKey(target.state, key);
|
|
365
|
-
if (child === void 0) return void 0;
|
|
366
|
-
Reflect.defineProperty(target, key, {
|
|
367
|
-
configurable: false,
|
|
368
|
-
value: child,
|
|
369
|
-
writable: false
|
|
370
|
-
});
|
|
371
|
-
return child;
|
|
372
|
-
} };
|
|
373
|
-
function build(state) {
|
|
374
|
-
const fn = state.pending === void 0 ? function apply(text) {
|
|
375
|
-
return applyStyle(state, text);
|
|
376
|
-
} : function applyOpCall(arg) {
|
|
377
|
-
return applyOp(fn, arg);
|
|
378
|
-
};
|
|
379
|
-
fn.state = state;
|
|
380
|
-
fn.theme = state.theme;
|
|
381
|
-
return new Proxy(fn, proxyHandler);
|
|
382
|
-
}
|
|
383
|
-
//#endregion
|
|
384
|
-
export { styleBuilder as t };
|
|
385
|
-
|
|
386
|
-
//# sourceMappingURL=builder-DC9byAmK.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"builder-DC9byAmK.mjs","names":[],"sources":["../src/style/oklch.ts","../src/style/style.ts","../src/style/builder.ts"],"sourcesContent":["/**\n * OKLCH-based tonal scale generation for theme colors.\n *\n * Given a base hex color, `variant(hex, step)` returns a hex variant at\n * the Tailwind-v4-ish step (50..950). The base color's hue and chroma\n * are preserved; only lightness moves. When the resulting color falls\n * outside sRGB, chroma is reduced via binary search (CSS Color Level 4\n * \"MinDE chroma reduction\") until the color fits — that avoids the\n * saturation blowout you get from naive HSL lightening at the extremes.\n *\n * Matrix constants come from Björn Ottosson's reference OKLab spec:\n * https://bottosson.github.io/posts/oklab/\n */\n\nimport type { HexColor } from \"./types.ts\"\n\nimport { clamp } from \"@zaly/shared\"\nimport { parseHex, toHex } from \"./color.ts\"\n\nexport interface OKLCH {\n L: number\n C: number\n h: number\n}\n\nconst cache = new Map<string, HexColor>()\n\n// ---------- conversions ----------\n\nfunction srgbToLinear(c: number): number {\n return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\n}\n\nfunction linearToSrgb(c: number): number {\n return c <= 0.0031308 ? c * 12.92 : 1.055 * c ** (1 / 2.4) - 0.055\n}\n\nexport function hexToOklch(hex: string): OKLCH {\n const [r8, g8, b8] = parseHex(hex)\n const r = srgbToLinear(r8 / 255)\n const g = srgbToLinear(g8 / 255)\n const b = srgbToLinear(b8 / 255)\n\n const l = 0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b\n const m = 0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b\n const s = 0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b\n const lp = Math.cbrt(l)\n const mp = Math.cbrt(m)\n const sp = Math.cbrt(s)\n const L = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp\n const a = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp\n const b2 = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp\n const C = Math.hypot(a, b2)\n const h = ((Math.atan2(b2, a) * 180) / Math.PI + 360) % 360\n return { C, L, h }\n}\n\n/** Convert OKLCH → linear sRGB (unclamped — callers can test for gamut). */\nfunction oklchToLinearRgb({ L, C, h }: OKLCH): [number, number, number] {\n const hr = (h * Math.PI) / 180\n const a = C * Math.cos(hr)\n const b2 = C * Math.sin(hr)\n const lp = L + 0.3963377774 * a + 0.2158037573 * b2\n const mp = L - 0.1055613458 * a - 0.0638541728 * b2\n const sp = L - 0.0894841775 * a - 1.291485548 * b2\n const l = lp ** 3\n const m = mp ** 3\n const s = sp ** 3\n const r = 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s\n const g = -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s\n const b = -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s\n return [r, g, b]\n}\n\nfunction inGamut([r, g, b]: [number, number, number], eps = 0.001): boolean {\n return r >= -eps && r <= 1 + eps && g >= -eps && g <= 1 + eps && b >= -eps && b <= 1 + eps\n}\n\n/**\n * Convert OKLCH → hex, reducing chroma via binary search when the\n * straightforward conversion falls outside sRGB. The search keeps `L`\n * and `h` fixed and shrinks `C` toward the achromatic axis until the\n * color fits, which is the CSS Color Level 4-recommended behavior.\n */\nexport function oklchToHex(oklch: OKLCH): HexColor {\n let rgb = oklchToLinearRgb(oklch)\n if (!inGamut(rgb)) {\n // Binary-search on C.\n let lo = 0\n let hi = oklch.C\n for (let i = 0; i < 24; i++) {\n const mid = (lo + hi) / 2\n if (inGamut(oklchToLinearRgb({ ...oklch, C: mid }))) lo = mid\n else hi = mid\n }\n rgb = oklchToLinearRgb({ ...oklch, C: lo })\n }\n const [r, g, b] = rgb.map((c) => linearToSrgb(Math.max(0, Math.min(1, c)))) as [\n number,\n number,\n number,\n ]\n return toHex(r * 255, g * 255, b * 255)\n}\n\nexport function shiftLightness(hex: HexColor, delta: number): HexColor {\n const key = `${hex}:${delta}`\n let ret = cache.get(key)\n if (ret) return ret\n\n const okl = hexToOklch(hex)\n const L = clamp(okl.L + delta, 0, 1)\n // Pull chroma toward 0 as L approaches an extreme. Keeps near-white\n // and near-black from going out of gamut.\n const margin = Math.min(L, 1 - L)\n const C = okl.C * Math.min(1, margin / 0.1)\n cache.set(key, (ret = oklchToHex({ ...okl, C, L })))\n return ret\n}\n","import type { Theme } from \"../themes/types.ts\"\nimport type { AnsiColor, AnsiStyle, Color, Style } from \"./types.ts\"\n\nimport { openAnsi } from \"./ansi.ts\"\nimport { isHexColor } from \"./color.ts\"\nimport { shiftLightness } from \"./oklch.ts\"\n\n/**\n * Build the opening SGR escape for a style descriptor. Returns '' if nothing\n * would be emitted. Unresolvable colors (invalid or 'inherit') are dropped.\n *\n * When `theme` is provided, `fg`/`bg` values matching a theme color slot\n * (e.g. `\"primary\"`, `\"muted\"`) are resolved against it first. The output\n * ordering is attrs → fg → bg, combined into a single `\\x1b[...m` run.\n *\n * @internal\n */\nexport function openStyle(style: Style, theme?: Theme): string {\n const resolver = ThemeResolver.from(theme)\n const ansiStyle: AnsiStyle = {\n ...style,\n bg: style.bg !== undefined ? resolver.getColor(style.bg, \"bg\") : undefined,\n fg: style.fg !== undefined ? resolver.getColor(style.fg, \"fg\") : undefined,\n }\n return openAnsi(ansiStyle)\n}\n\n/**\n * Resolve a style-slot reference into a `Style` object. A ref is either a\n * theme slot name (string), an inline `Style`, or `undefined`:\n *\n * - Inline `Style` → returned as-is (no slot lookup).\n * - String ref pointing at a **Color** slot → wrapped as `{ fg: <color> }`.\n * - String ref pointing at a **Style** slot → returned directly.\n * - String ref that doesn't match a slot → treated as a fg color\n * (`{ fg: <ref> }`) and resolved downstream by `colorParams`.\n * - `undefined` → `{}` (emits nothing).\n *\n * @internal\n */\nexport function resolveStyle(ref: string | Style | undefined, theme?: Theme): Style {\n return ThemeResolver.from(theme).getStyle(ref)\n}\n\nfunction parseColor(c: string): { base: string; lightness?: number } {\n const m = c.match(/^(.+?)([+-]\\d{1,3})$/)\n if (!m) return { base: c }\n let lightness = Number(m[2])\n if (!Number.isFinite(lightness))\n throw new TypeError(`Invalid color step in color \"${c}\": ${m[2]}`)\n lightness = Math.abs(lightness) < 1 ? lightness : lightness / 100\n return { base: m[1], lightness }\n}\n\nclass ThemeResolver {\n static #cache = new Map<Partial<Theme>, ThemeResolver>()\n static #main = new ThemeResolver()\n #theme: Partial<Theme>\n #styleCache = new Map<string, Style>()\n #colorCache = new Map<string, string>()\n\n private constructor(theme: Partial<Theme> = {}) {\n this.#theme = theme\n }\n\n static from(theme?: Theme): ThemeResolver {\n if (theme === undefined) return this.#main\n let resolver = this.#cache.get(theme)\n if (!resolver) {\n resolver = new ThemeResolver(theme)\n this.#cache.set(theme, resolver)\n }\n return resolver\n }\n\n getStyle(ref?: string | Style, seen?: Set<string>): Style {\n if (ref === undefined) return {}\n if (typeof ref === \"object\")\n return ref.style ? { ...this.getStyle(ref.style, seen), ...ref } : ref\n\n let ret = this.#styleCache.get(ref)\n if (ret) return ret\n\n seen ??= new Set<string>()\n if (seen.has(ref)) throw new TypeError(`Circular dependency for theme slot \"${ref}\".`)\n seen.add(ref)\n\n const value = this.#theme[ref as keyof Theme]\n ret = value === undefined ? { fg: ref as Color } : this.getStyle(value, seen)\n this.#styleCache.set(ref, ret)\n return ret\n }\n\n getColor(ref?: string, kind: \"fg\" | \"bg\" = \"fg\", seen?: Set<string>): AnsiColor {\n if (ref === undefined) return \"inherit\"\n\n const key = `${kind}:${ref}`\n let ret = this.#colorCache.get(key)\n if (ret) return ret as AnsiColor\n\n seen ??= new Set<string>()\n if (seen.has(ref)) throw new TypeError(`Circular dependency for theme slot \"${ref}\".`)\n seen.add(ref)\n\n const { base, lightness } = parseColor(ref)\n\n let value = this.#theme[base as keyof Theme] ?? base\n if (typeof value === \"object\") value = this.getColor(value[kind], kind, seen)\n else if (value !== base) value = this.getColor(value, kind, seen)\n ret = lightness !== undefined && isHexColor(value) ? shiftLightness(value, lightness) : value\n this.#colorCache.set(key, ret)\n return ret as AnsiColor\n }\n}\n","import type { Theme } from \"../themes/types.ts\"\nimport type { AnsiColorName, BrightAnsiColorName, Color, Style } from \"./types.ts\"\n\nimport { defaultTheme } from \"../themes/registry.ts\"\nimport { reapplyStyle, RESET } from \"./ansi.ts\"\nimport { openStyle, resolveStyle } from \"./style.ts\"\n\ntype AttrName = \"bold\" | \"dim\" | \"italic\" | \"underline\" | \"inverse\" | \"strikethrough\"\n\ntype AnyThemeKey = Exclude<keyof Theme, \"shiki\" | \"$schema\"> | (string & {})\n\n// Theme color slots that can chain as fg/bg. `fg`/`bg` become setter methods\n// below, so exclude them here to avoid naming collisions. `dim` is an attr on\n// the chain; users wanting theme-slot-dim for fg use `.fg(\"dim\")`.\ntype ChainSlot = Exclude<keyof Theme, \"fg\" | \"bg\" | AttrName>\n\ntype FgChainKey = AnsiColorName | BrightAnsiColorName | ChainSlot\ntype BgChainKey = `bg${Capitalize<FgChainKey>}`\ntype FgExtractKey = `fg${Capitalize<FgChainKey>}`\n\nexport type StyleBuilder = {\n theme: Theme\n (text: string): string\n fg: (color: Color) => StyleBuilder\n bg: (color: Color) => StyleBuilder\n add: (slot?: AnyThemeKey | Style) => StyleBuilder\n lighten: (n: number) => StyleBuilder\n darken: (n: number) => StyleBuilder\n // oxlint-disable-next-line typescript/consistent-indexed-object-style -- mapped over a key union, not an open string index\n} & {\n readonly [K in AttrName | FgChainKey | BgChainKey | FgExtractKey]: StyleBuilder\n}\n\n/**\n * Build styled strings via chainable property access.\n *\n * ```ts\n * style().red.bold(\"err\") // → \"\\x1b[1;31merr\\x1b[0m\"\n * style().primary.bgAccent(\"x\") // theme slots via the default theme\n * style(myTheme).primary(\"x\") // override the bound theme\n * style().fg(\"#82aaff\")(\"x\") // hex via the escape hatch\n * style().primary[300](\"x\") // tonal variant of the last color\n * style().bgDiffAdd[200].fgDiffAdd(\"x\") // per-channel variants on a Style slot\n * ```\n *\n * Each property access returns a fresh builder, so intermediates can be\n * reused and extended without mutation:\n *\n * ```ts\n * const err = style().red.bold\n * err(\"oops\"); err.underline(\"fatal\")\n * ```\n *\n * Calling an empty builder is a no-op: `styleBuilder()(\"x\")` returns `\"x\"` unchanged.\n */\nexport function styleBuilder(theme: Theme | false = defaultTheme): StyleBuilder {\n return build({\n current: {},\n last: undefined,\n theme: theme === false ? { ...defaultTheme, enabled: false } : theme,\n })\n}\n\nconst ATTRS = new Set<string>([\"bold\", \"dim\", \"italic\", \"underline\", \"inverse\", \"strikethrough\"])\n\n/** Pending \"arg-taking\" op on a chain. Set when the caller accesses\n * `.fg` / `.bg` / `.alpha` / `.add` — the chain is \"parked\" waiting\n * for its argument. Calling the parked chain consumes the arg and\n * produces the real child chain. */\ntype PendingOp = \"fg\" | \"bg\" | \"darken\" | \"add\" | \"lighten\"\n\n/** All the inputs a chain needs to behave correctly, gathered in one\n * object so we can pass it around cheaply instead of closing over\n * four separate vars. `current` is the accumulated Style, `last`\n * tracks which of `fg`/`bg` was most recently touched (for `[step]`\n * and `.alpha()`), `theme` is the resolved theme, `pending` is set\n * on parked arg-taking chains. */\ninterface BuilderState {\n current: Style\n last: \"fg\" | \"bg\" | undefined\n theme: Theme & { enabled?: boolean }\n pending?: PendingOp\n}\n\n/** The function wrapped by every chain's Proxy. Carries its own state\n * so module-level handlers can read it without closure gymnastics. */\ntype BuilderFn = {\n state: BuilderState\n theme: Theme\n} & (((text: string) => string) | ((arg: Color | number | Style | undefined) => StyleBuilder))\n\n// --- module-level handlers (shared across every chain) -----------------\n\nfunction applyStyle(state: BuilderState, text: string): string {\n if (!text || state.theme.enabled === false) return text\n const open = openStyle(state.current, state.theme)\n return open === \"\" ? text : open + reapplyStyle(text, open) + RESET\n}\n\nfunction applyOp(fn: BuilderFn, arg: Color | number | Style | undefined): StyleBuilder {\n // Cache primitive args on the call target itself via `defineProperty`\n // — repeated `.fg(\"#82aaff\")` hits the same child chain after the\n // first call, no rebuild. Object args (e.g. raw Style for `add`)\n // can't be property keys (`\"[object Object]\"` collision), so those\n // always rebuild.\n if (typeof arg === \"string\" || typeof arg === \"number\") {\n const key = String(arg)\n const hit = (fn as unknown as Record<string, unknown>)[key]\n if (hit !== undefined) return hit as StyleBuilder\n const child = fulfill(fn.state, arg)\n Reflect.defineProperty(fn, key, { configurable: false, value: child, writable: false })\n return child\n }\n return fulfill(fn.state, arg)\n}\n\n/** Turn a parked chain + its arg into the real child chain. */\nfunction fulfill(state: BuilderState, arg: unknown): StyleBuilder {\n const { current, last, theme, pending } = state\n switch (pending) {\n case \"fg\": {\n return build({ current: { ...current, fg: arg as Color }, last: \"fg\", theme })\n }\n case \"bg\": {\n return build({ current: { ...current, bg: arg as Color }, last: \"bg\", theme })\n }\n case \"lighten\":\n case \"darken\": {\n if (last === undefined) return build({ current, last, theme })\n const existing = current[last]\n if (typeof existing !== \"string\" || existing === \"inherit\") {\n return build({ current, last, theme })\n }\n const stripped = existing.replace(/[+-]\\d+$/, \"\")\n const n = Math.abs(arg as number)\n const next = `${stripped}${pending === \"lighten\" ? \"+\" : \"-\"}${n}` as Color\n return build({ current: { ...current, [last]: next }, last, theme })\n }\n default: {\n // \"add\" — no pending pending? defaults to rebuild with undef arg.\n return build({\n current: { ...current, ...resolveStyle(arg as string | Style | undefined, theme) },\n last,\n theme,\n })\n }\n }\n}\n\n/** Resolve a single property access on a chain to its child chain. */\nfunction compileKey(state: BuilderState, key: string): StyleBuilder | undefined {\n const { current, last, theme } = state\n\n // Arg-taking ops come back as chains parked in the `pending` state.\n if (key === \"fg\" || key === \"bg\" || key === \"lighten\" || key === \"darken\" || key === \"add\") {\n return build({ current, last, pending: key, theme })\n }\n\n if (ATTRS.has(key)) return build({ current: { ...current, [key]: true }, last, theme })\n\n // `bgFoo` / `fgFoo` → set the channel to the color at slot `foo`.\n // When the slot is a Style, `colorParams` extracts that channel.\n if (key.startsWith(\"bg\") && key.length > 2 && key[2] === key[2].toUpperCase()) {\n const color = (key[2].toLowerCase() + key.slice(3)) as Color\n return build({ current: { ...current, bg: color }, last: \"bg\", theme })\n }\n if (key.startsWith(\"fg\") && key.length > 2 && key[2] === key[2].toUpperCase()) {\n const color = (key[2].toLowerCase() + key.slice(3)) as Color\n return build({ current: { ...current, fg: color }, last: \"fg\", theme })\n }\n\n // Style-valued theme slot → merge its fields into the chain.\n // Anything else (ANSI color names, hex, unresolved slot refs) is\n // treated as a fg color by `colorParams` downstream.\n return build({ current: { ...current, ...resolveStyle(key, theme) }, last: \"fg\", theme })\n}\n\n/** Shared Proxy handler — one instance, used by every chain. Reads\n * state off the target (the `BuilderFn`), so chain construction\n * doesn't allocate a fresh handler object per `build()` call. */\nconst proxyHandler: ProxyHandler<BuilderFn> = {\n get(target, key) {\n if (typeof key !== \"string\") return undefined\n const cached = (target as unknown as Record<string, unknown>)[key]\n if (cached !== undefined) return cached\n // Parked chains can't be chained further — they're waiting for a call.\n if (target.state.pending !== undefined) return undefined\n const child = compileKey(target.state, key)\n if (child === undefined) return undefined\n Reflect.defineProperty(target, key, { configurable: false, value: child, writable: false })\n return child\n },\n}\n\nfunction build(state: BuilderState): StyleBuilder {\n // Two dedicated function shapes so V8 sees a stable signature on\n // each hot path — styling text vs. consuming an op arg are both\n // monomorphic after the build-time ternary.\n const fn = (\n state.pending === undefined\n ? function apply(text: string): string {\n return applyStyle(state, text)\n }\n : function applyOpCall(arg: Color | number | Style | undefined): StyleBuilder {\n return applyOp(fn, arg)\n }\n ) as BuilderFn\n fn.state = state\n fn.theme = state.theme\n return new Proxy(fn, proxyHandler) as unknown as StyleBuilder\n}\n"],"mappings":";;;;AAyBA,MAAM,wBAAQ,IAAI,IAAsB;AAIxC,SAAS,aAAa,GAAmB;CACvC,OAAO,KAAK,SAAU,IAAI,UAAU,IAAI,QAAS,UAAU;AAC7D;AAEA,SAAS,aAAa,GAAmB;CACvC,OAAO,KAAK,WAAY,IAAI,QAAQ,QAAQ,MAAM,IAAI,OAAO;AAC/D;AAEA,SAAgB,WAAW,KAAoB;CAC7C,MAAM,CAAC,IAAI,IAAI,MAAM,SAAS,GAAG;CACjC,MAAM,IAAI,aAAa,KAAK,GAAG;CAC/B,MAAM,IAAI,aAAa,KAAK,GAAG;CAC/B,MAAM,IAAI,aAAa,KAAK,GAAG;CAE/B,MAAM,IAAI,cAAe,IAAI,cAAe,IAAI,cAAe;CAC/D,MAAM,IAAI,cAAe,IAAI,cAAe,IAAI,cAAe;CAC/D,MAAM,IAAI,cAAe,IAAI,cAAe,IAAI,cAAe;CAC/D,MAAM,KAAK,KAAK,KAAK,CAAC;CACtB,MAAM,KAAK,KAAK,KAAK,CAAC;CACtB,MAAM,KAAK,KAAK,KAAK,CAAC;CACtB,MAAM,IAAI,cAAe,KAAK,aAAc,KAAK,cAAe;CAChE,MAAM,IAAI,eAAe,KAAK,cAAc,KAAK,cAAe;CAChE,MAAM,KAAK,cAAe,KAAK,cAAe,KAAK,aAAc;CAGjE,OAAO;EAAE,GAFC,KAAK,MAAM,GAAG,EAEf;EAAG;EAAG,IADH,KAAK,MAAM,IAAI,CAAC,IAAI,MAAO,KAAK,KAAK,OAAO;CACvC;AACnB;;AAGA,SAAS,iBAAiB,EAAE,GAAG,GAAG,KAAsC;CACtE,MAAM,KAAM,IAAI,KAAK,KAAM;CAC3B,MAAM,IAAI,IAAI,KA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