@zaly/tui 0.0.12 → 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 +226 -1046
- package/assets/themes/andromeeda.json +97 -0
- package/assets/themes/ayu-dark.json +31 -25
- package/assets/themes/ayu-light.json +106 -0
- package/assets/themes/ayu-mirage.json +106 -0
- package/assets/themes/catppuccin-frappe.json +43 -40
- package/assets/themes/catppuccin-latte.json +43 -40
- package/assets/themes/catppuccin-macchiato.json +43 -40
- package/assets/themes/catppuccin-mocha.json +43 -40
- package/assets/themes/dark-plus.json +99 -0
- package/assets/themes/dracula.json +47 -47
- package/assets/themes/everforest-dark.json +28 -26
- package/assets/themes/everforest-light.json +28 -26
- 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 -29
- 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 -49
- package/assets/themes/kanagawa-lotus.json +105 -0
- package/assets/themes/kanagawa-wave.json +56 -50
- 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 -45
- package/assets/themes/material-theme.json +102 -0
- package/assets/themes/min-dark.json +69 -14
- package/assets/themes/min-light.json +68 -17
- package/assets/themes/monokai.json +54 -47
- package/assets/themes/night-owl-light.json +105 -0
- package/assets/themes/night-owl.json +57 -49
- package/assets/themes/nord.json +53 -39
- package/assets/themes/one-dark-pro.json +46 -38
- package/assets/themes/one-light.json +52 -41
- package/assets/themes/poimandres.json +51 -49
- package/assets/themes/rose-pine-dawn.json +99 -0
- package/assets/themes/rose-pine-moon.json +99 -0
- package/assets/themes/rose-pine.json +50 -33
- package/assets/themes/solarized-dark.json +38 -31
- package/assets/themes/solarized-light.json +40 -33
- package/assets/themes/synthwave-84.json +47 -30
- package/assets/themes/tokyonight-day.json +3 -3
- package/assets/themes/tokyonight-moon.json +3 -2
- package/assets/themes/tokyonight-night.json +3 -2
- package/assets/themes/tokyonight-storm.json +3 -2
- package/assets/themes/vesper.json +50 -42
- package/assets/themes/vitesse-black.json +103 -0
- package/assets/themes/vitesse-dark.json +26 -30
- package/assets/themes/vitesse-light.json +26 -30
- package/dist/{actions-Dc4D4uSf.d.mts → actions--ODlgCQ5.d.mts} +4 -4
- package/dist/{actions-Dc4D4uSf.d.mts.map → actions--ODlgCQ5.d.mts.map} +1 -1
- package/dist/{ansi-DZlXaItJ.mjs → ansi-CMv71xVr.mjs} +3 -31
- package/dist/ansi-CMv71xVr.mjs.map +1 -0
- package/dist/ansi.d.mts +1 -1
- package/dist/ansi.mjs +1 -1
- package/dist/{autocomplete-StW1QJZJ.d.mts → autocomplete-CD30kSe_.d.mts} +4 -4
- package/dist/{autocomplete-StW1QJZJ.d.mts.map → autocomplete-CD30kSe_.d.mts.map} +1 -1
- package/dist/{box-BkP4MF82.mjs → box-C_N_7ChP.mjs} +2 -2
- package/dist/{box-BkP4MF82.mjs.map → box-C_N_7ChP.mjs.map} +1 -1
- package/dist/builder-Chwtk0nQ.mjs +196 -0
- package/dist/builder-Chwtk0nQ.mjs.map +1 -0
- package/dist/{callbacks-BwWTCqPJ.mjs → callbacks-DLecWn7G.mjs} +4 -4
- package/dist/{callbacks-BwWTCqPJ.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-B7BmPUCD.mjs → ctx-BaQ2hP5u.mjs} +3 -3
- package/dist/{ctx-B7BmPUCD.mjs.map → ctx-BaQ2hP5u.mjs.map} +1 -1
- package/dist/ctx-CndlTp1T.mjs +1 -0
- package/dist/{divider-TSx9NhI_.mjs → divider-BlNNN2OS.mjs} +2 -2
- package/dist/{divider-TSx9NhI_.mjs.map → divider-BlNNN2OS.mjs.map} +1 -1
- package/dist/{files-7DUYSeNc.d.mts → files-B_5HDBPp.d.mts} +3 -3
- package/dist/{files-7DUYSeNc.d.mts.map → files-B_5HDBPp.d.mts.map} +1 -1
- package/dist/{github-C1KfXk98.d.mts → github-CyRwUQ3y.d.mts} +3 -3
- package/dist/{github-C1KfXk98.d.mts.map → github-CyRwUQ3y.d.mts.map} +1 -1
- package/dist/{image-VaT7AN-S.d.mts → image-BLls2F4t.d.mts} +2 -2
- package/dist/{image-VaT7AN-S.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-BGTTujDN.mjs → input-ET2YEMcl.mjs} +2 -2
- package/dist/{input-BGTTujDN.mjs.map → input-ET2YEMcl.mjs.map} +1 -1
- package/dist/{input-BAYux7qo.d.mts → input-NuD8TH8N.d.mts} +3 -3
- package/dist/{input-BAYux7qo.d.mts.map → input-NuD8TH8N.d.mts.map} +1 -1
- package/dist/{inspect-CfNydMgO.d.mts → inspect-B1uXxdKC.d.mts} +2 -2
- package/dist/{inspect-CfNydMgO.d.mts.map → inspect-B1uXxdKC.d.mts.map} +1 -1
- package/dist/{inspect-jG_W4njH.mjs → inspect-Cxzs-W0g.mjs} +2 -2
- package/dist/{inspect-jG_W4njH.mjs.map → inspect-Cxzs-W0g.mjs.map} +1 -1
- package/dist/kitty-DKQYsQfH.mjs +1 -0
- package/dist/{log-ByKlM4iI.mjs → log-B4djzy2m.mjs} +4 -4
- package/dist/{log-ByKlM4iI.mjs.map → log-B4djzy2m.mjs.map} +1 -1
- package/dist/{logger-DSQb0sLP.mjs → logger-CvJCITzP.mjs} +3 -3
- package/dist/{logger-DSQb0sLP.mjs.map → logger-CvJCITzP.mjs.map} +1 -1
- package/dist/{markdown-CwRmWuU6.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-BnvOKtGT.mjs → overlay-LvOjG7kn.mjs} +2 -2
- package/dist/{overlay-BnvOKtGT.mjs.map → overlay-LvOjG7kn.mjs.map} +1 -1
- package/dist/{picker-DQs_IW77.d.mts → picker-B-OxKKnD.d.mts} +5 -5
- package/dist/{picker-DQs_IW77.d.mts.map → picker-B-OxKKnD.d.mts.map} +1 -1
- package/dist/{picker-Dh5IUrTk.mjs → picker-f6xjgACX.mjs} +2 -2
- package/dist/{picker-Dh5IUrTk.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-BDX8mcl5.d.mts → queries-C75-wG1B.d.mts} +19 -4
- package/dist/{queries-BDX8mcl5.d.mts.map → queries-C75-wG1B.d.mts.map} +1 -1
- package/dist/{registry-D-suU3g0.mjs → registry-DUWpSPoo.mjs} +202 -57
- package/dist/registry-DUWpSPoo.mjs.map +1 -0
- package/dist/{render-DEIUNLkh.mjs → render-B7LfNM5K.mjs} +2 -2
- package/dist/{render-DEIUNLkh.mjs.map → render-B7LfNM5K.mjs.map} +1 -1
- package/dist/{renderer-zDNlAovy.mjs → renderer-BLsd-wrG.mjs} +110 -14
- package/dist/renderer-BLsd-wrG.mjs.map +1 -0
- package/dist/renderer-YHbR7JZ4.mjs +1 -0
- package/dist/{renderer-MQue4Da5.mjs → renderer-aAtkFgll.mjs} +8 -7
- package/dist/renderer-aAtkFgll.mjs.map +1 -0
- package/dist/{select-J2KtwxyK.d.mts → select-BKE5LzdN.d.mts} +3 -3
- package/dist/{select-J2KtwxyK.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-CkQ7Irmt.mjs → text-BoJdKXLU.mjs} +2 -2
- package/dist/{text-CkQ7Irmt.mjs.map → text-BoJdKXLU.mjs.map} +1 -1
- package/dist/{text-CCYs9RB2.d.mts → text-CmxbA8lk.d.mts} +3 -3
- package/dist/{text-CCYs9RB2.d.mts.map → text-CmxbA8lk.d.mts.map} +1 -1
- package/dist/{text-XvPfweeg.mjs → text-DPrhma4x.mjs} +2 -2
- package/dist/{text-XvPfweeg.mjs.map → text-DPrhma4x.mjs.map} +1 -1
- 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-DJl5W_B7.d.mts → tree-CTvSpF9b.d.mts} +3 -3
- package/dist/{tree-DJl5W_B7.d.mts.map → tree-CTvSpF9b.d.mts.map} +1 -1
- package/dist/{types-D2EYlzmK.d.mts → types-C9ceMsbJ.d.mts} +136 -128
- package/dist/types-C9ceMsbJ.d.mts.map +1 -0
- package/dist/{widget-DPqBbB57.d.mts → widget-DlF32PRp.d.mts} +2 -2
- package/dist/{widget-DPqBbB57.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 +2 -2
- 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 +2 -2
- 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 -100
- package/assets/themes/github-dark.json +0 -104
- package/assets/themes/github-light.json +0 -104
- package/dist/ansi-DZlXaItJ.mjs.map +0 -1
- package/dist/builder-1z5ewEWK.mjs +0 -386
- package/dist/builder-1z5ewEWK.mjs.map +0 -1
- package/dist/client-C2GXKfJ1.mjs.map +0 -1
- package/dist/client-bzdHIDL2.mjs +0 -1
- package/dist/ctx-D_JgJ8Eo.mjs +0 -1
- package/dist/image-Cm5T-uw-.mjs +0 -108
- package/dist/image-Cm5T-uw-.mjs.map +0 -1
- package/dist/markdown-CwRmWuU6.mjs.map +0 -1
- package/dist/queries-B_lOwEiE.mjs.map +0 -1
- package/dist/registry-D-suU3g0.mjs.map +0 -1
- package/dist/renderer-DhqbEVVR.mjs +0 -1
- package/dist/renderer-MQue4Da5.mjs.map +0 -1
- package/dist/renderer-zDNlAovy.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/theme.config-B3Yx--C2.mjs +0 -855
- package/dist/theme.config-B3Yx--C2.mjs.map +0 -1
- package/dist/types-D2EYlzmK.d.mts.map +0 -1
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
import { Simplify } from "@zaly/shared";
|
|
1
2
|
import { BundledLanguage, BundledTheme } from "shiki/types";
|
|
2
3
|
//#region src/shiki/types.d.ts
|
|
3
4
|
type ShikiTheme = BundledTheme;
|
|
4
5
|
type ShikiLanguage = BundledLanguage;
|
|
6
|
+
type ShikiSelection = "auto" | ShikiTheme;
|
|
7
|
+
type GeneratedShikiTheme = {
|
|
8
|
+
name: string;
|
|
9
|
+
appearance: "dark" | "light";
|
|
10
|
+
styles: AnsiStyle[];
|
|
11
|
+
};
|
|
12
|
+
type ShikiThemeInput = ShikiTheme | GeneratedShikiTheme;
|
|
5
13
|
type ShikiRequest = {
|
|
6
14
|
key?: string;
|
|
7
15
|
code: string;
|
|
8
16
|
lang: string;
|
|
9
|
-
theme?:
|
|
17
|
+
theme?: ShikiThemeInput;
|
|
10
18
|
signal?: AbortSignal;
|
|
11
19
|
};
|
|
12
20
|
type ShikiWorkerRequest = Omit<ShikiRequest, "lang" | "key"> & {
|
|
@@ -29,68 +37,16 @@ type ShikiWorkerMessage = {
|
|
|
29
37
|
type: "result";
|
|
30
38
|
});
|
|
31
39
|
type ShikiOpts = {
|
|
32
|
-
theme?:
|
|
40
|
+
theme?: ShikiThemeInput;
|
|
33
41
|
signal?: AbortSignal;
|
|
34
42
|
};
|
|
35
43
|
//#endregion
|
|
36
|
-
//#region src/
|
|
37
|
-
type
|
|
38
|
-
/** Alpha percentage for `/<alpha>` suffix on Color values. Any integer
|
|
39
|
-
* 0..100 is accepted at runtime; the template literal uses `${number}`
|
|
40
|
-
* so odd values like `/98` typecheck without a cast. */
|
|
41
|
-
type ColorLightness = `${number}`;
|
|
42
|
-
/** Standard ANSI color names. */
|
|
43
|
-
type AnsiColorName = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey";
|
|
44
|
-
/** Bright ANSI variants — `brightRed`, `brightBlue`, etc. */
|
|
45
|
-
type BrightAnsiColorName = `bright${Capitalize<AnsiColorName>}`;
|
|
46
|
-
type AnsiColor = AnsiColorName | BrightAnsiColorName | HexColor | "inherit";
|
|
47
|
-
/** Hex color string. Matches `#rgb` / `#rgba` / `#rrggbb` / `#rrggbbaa`
|
|
48
|
-
* (any case; runtime validates). Alpha is native to the hex form, so
|
|
49
|
-
* there is no separate `/<alpha>` suffix for hex. */
|
|
50
|
-
type HexColor = `#${string}`;
|
|
51
|
-
type ThemeKey = Exclude<keyof Theme, "shiki" | "$schema" | "id">;
|
|
52
|
-
/**
|
|
53
|
-
* A color value. Accepted forms:
|
|
54
|
-
* - `#rgb` / `#rrggbb` hex
|
|
55
|
-
* - ANSI color names (`red`, `cyan`, `gray`, …)
|
|
56
|
-
* - Bright ANSI variants (`brightRed`, `brightBlue`, …)
|
|
57
|
-
* - Theme slot keys from `keyof Theme` (`primary`, `muted`, …)
|
|
58
|
-
* - `'inherit'` — use the parent's color (renders as no escape).
|
|
59
|
-
* - Variant suffix `-<step>` on hex or theme slots — e.g. `primary-300`,
|
|
60
|
-
* `#82aaff-900`. The base color gets resolved through the theme
|
|
61
|
-
* (extracting the channel when needed), then `variant(base, step)`
|
|
62
|
-
* shifts it along the OKLCH tonal scale.
|
|
63
|
-
*/
|
|
64
|
-
type Color<Ansi extends boolean = true> = HexColor | (Ansi extends true ? AnsiColorName : never) | (Ansi extends true ? BrightAnsiColorName : never) | ThemeKey | "inherit" | `${HexColor | ThemeKey}-${ColorLightness}` | `${HexColor | ThemeKey}+${ColorLightness}`;
|
|
65
|
-
interface AnsiStyle {
|
|
66
|
-
fg?: AnsiColor;
|
|
67
|
-
bg?: AnsiColor;
|
|
68
|
-
bold?: boolean;
|
|
69
|
-
dim?: boolean;
|
|
70
|
-
italic?: boolean;
|
|
71
|
-
underline?: boolean;
|
|
72
|
-
inverse?: boolean;
|
|
73
|
-
strikethrough?: boolean;
|
|
74
|
-
}
|
|
75
|
-
/** Base style shared by every node type. Box/Text/etc. extend this.
|
|
76
|
-
* Pure styling — no layout or lifecycle fields. Widget state interfaces
|
|
77
|
-
* extend `StyleState` to pick up the `visible` base-state bits alongside
|
|
78
|
-
* these style fields. */
|
|
79
|
-
type Style<Ansi extends boolean = true> = Omit<AnsiStyle, "fg" | "bg"> & {
|
|
44
|
+
//#region src/themes/types.d.ts
|
|
45
|
+
type ThemeStyle<Ansi extends boolean = true> = Simplify<Omit<AnsiStyle, "fg" | "bg"> & {
|
|
80
46
|
fg?: Color<Ansi>;
|
|
81
47
|
bg?: Color<Ansi>;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
type AnyStyle<Ansi extends boolean = false> = Style<Ansi> | Color<Ansi>;
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/themes/types.d.ts
|
|
87
|
-
/**
|
|
88
|
-
* A theme slot value. Color shortcuts expand to `{ fg: <color> }` at resolve
|
|
89
|
-
* time; Style objects are used as-is and may carry attrs (`bold`, `underline`,
|
|
90
|
-
* etc.) and a `bg`. Use Color for simple fg-only slots; escalate to Style when
|
|
91
|
-
* the part needs more than just a foreground color.
|
|
92
|
-
*/
|
|
93
|
-
type ThemeValue = Color | Style;
|
|
48
|
+
}>;
|
|
49
|
+
type ThemeValue<Ansi extends boolean = true> = ThemeStyle<Ansi> | Color<Ansi>;
|
|
94
50
|
/**
|
|
95
51
|
* A theme is a flat record mapping semantic slots to `ThemeValue`s. Callers
|
|
96
52
|
* reference slots by key (`fg: "primary"` for colors, `borderStyle: "border"`
|
|
@@ -107,103 +63,155 @@ type ThemeValue = Color | Style;
|
|
|
107
63
|
* **Surface tiers**: `ui` → `subtle` → `overlay` (bottom → top).
|
|
108
64
|
* `highlight` is orthogonal — a tinted accent surface, not a tier.
|
|
109
65
|
*/
|
|
110
|
-
type Theme = {
|
|
66
|
+
type Theme<Ansi extends boolean = true, T = ThemeValue<Ansi>> = {
|
|
111
67
|
id: string;
|
|
68
|
+
/** Dark/light appearance, inferred from bg when omitted in a theme file. */
|
|
69
|
+
appearance: "dark" | "light";
|
|
112
70
|
name?: string;
|
|
113
|
-
/**
|
|
114
|
-
*
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
fg: Color;
|
|
119
|
-
bg: Color;
|
|
71
|
+
/** Matching bundled Shiki theme. Unset or "auto" generates highlighting
|
|
72
|
+
* from the syntax slots. */
|
|
73
|
+
shiki?: ShikiSelection;
|
|
74
|
+
fg: Color<Ansi, Ansi>;
|
|
75
|
+
bg: Color<Ansi, Ansi>;
|
|
120
76
|
/** Brand / primary accent. */
|
|
121
|
-
primary: Color
|
|
77
|
+
primary: Color<Ansi>;
|
|
122
78
|
/** Secondary accent — distinct hue from `primary`. */
|
|
123
|
-
accent: Color
|
|
79
|
+
accent: Color<Ansi>;
|
|
124
80
|
/** Secondary text — first tier of the quietness ladder
|
|
125
81
|
* (`muted` → `quiet` → `comment`). Slightly faded but readable;
|
|
126
82
|
* good for timestamps, captions, less-prominent labels. */
|
|
127
|
-
muted:
|
|
83
|
+
muted: T;
|
|
128
84
|
/** De-emphasized but still readable. Reasoning / thinking text,
|
|
129
85
|
* secondary annotations, hints. */
|
|
130
|
-
quiet:
|
|
86
|
+
quiet: T;
|
|
131
87
|
/** Editor-comment tier — soft, often tinted. Used for code
|
|
132
88
|
* annotations, line-number labels, italic quotes. */
|
|
133
|
-
comment:
|
|
89
|
+
comment: T;
|
|
134
90
|
/** Section / panel titles. Typically `bold` + a fg color. */
|
|
135
|
-
title:
|
|
91
|
+
title: T;
|
|
136
92
|
/** Structural separators — borders, dividers, gutter lines. */
|
|
137
|
-
delim:
|
|
93
|
+
delim: T;
|
|
138
94
|
/** Default UI surface. Bottom of the stack. */
|
|
139
|
-
ui:
|
|
95
|
+
ui: T;
|
|
140
96
|
/** Popup / modal surface. One tier above `ui`. */
|
|
141
|
-
overlay:
|
|
97
|
+
overlay: T;
|
|
142
98
|
/** Tinted region for emphasized content within the stream — user
|
|
143
99
|
* bubble bg, focused row, callout. Distinct from `code`, which is
|
|
144
100
|
* reserved for code-block bg. */
|
|
145
|
-
highlight:
|
|
101
|
+
highlight: T;
|
|
146
102
|
/** Separators between messages or sections. */
|
|
147
|
-
divider:
|
|
103
|
+
divider: T;
|
|
148
104
|
/** Highlighted text in inputs, lists, autocomplete. */
|
|
149
|
-
selection:
|
|
105
|
+
selection: T;
|
|
150
106
|
/** Line-number column, diff markers. */
|
|
151
|
-
gutter:
|
|
107
|
+
gutter: T;
|
|
152
108
|
/** Main input-prompt styling. */
|
|
153
|
-
prompt:
|
|
109
|
+
prompt: T;
|
|
154
110
|
/** Structural border around panels, boxes, tables. */
|
|
155
|
-
border:
|
|
111
|
+
border: T;
|
|
156
112
|
/** Title text inside a bordered region (slightly stronger than
|
|
157
113
|
* `border`). */
|
|
158
|
-
borderTitle:
|
|
114
|
+
borderTitle: T;
|
|
159
115
|
/** Code-block surface (bg + optional fg). Default for `mdCodeBlock`. */
|
|
160
|
-
code:
|
|
116
|
+
code: T;
|
|
161
117
|
/** Title above a code block (e.g. file path). */
|
|
162
|
-
codeTitle:
|
|
163
|
-
success: Color
|
|
164
|
-
info: Color
|
|
165
|
-
warn: Color
|
|
166
|
-
error: Color
|
|
167
|
-
syntaxBoolean:
|
|
168
|
-
syntaxBracket:
|
|
169
|
-
syntaxConstant:
|
|
170
|
-
syntaxDelimiter:
|
|
171
|
-
syntaxField:
|
|
172
|
-
syntaxFunction:
|
|
173
|
-
syntaxNumber:
|
|
174
|
-
syntaxSpecial:
|
|
175
|
-
syntaxString:
|
|
176
|
-
mdBold:
|
|
177
|
-
mdCode:
|
|
178
|
-
mdCodeBlock:
|
|
179
|
-
mdCodeBlockTitle:
|
|
180
|
-
mdHeading1:
|
|
181
|
-
mdHeading2:
|
|
182
|
-
mdHeading3:
|
|
183
|
-
mdHeading4:
|
|
184
|
-
mdHeading5:
|
|
185
|
-
mdHeading6:
|
|
186
|
-
mdHeading:
|
|
187
|
-
mdHr:
|
|
188
|
-
mdItalic:
|
|
189
|
-
mdLink:
|
|
190
|
-
mdListBullet:
|
|
191
|
-
mdListChecked:
|
|
192
|
-
mdListUnchecked:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
118
|
+
codeTitle: T;
|
|
119
|
+
success: Color<Ansi>;
|
|
120
|
+
info: Color<Ansi>;
|
|
121
|
+
warn: Color<Ansi>;
|
|
122
|
+
error: Color<Ansi>;
|
|
123
|
+
syntaxBoolean: T;
|
|
124
|
+
syntaxBracket: T;
|
|
125
|
+
syntaxConstant: T;
|
|
126
|
+
syntaxDelimiter: T;
|
|
127
|
+
syntaxField: T;
|
|
128
|
+
syntaxFunction: T;
|
|
129
|
+
syntaxNumber: T;
|
|
130
|
+
syntaxSpecial: T;
|
|
131
|
+
syntaxString: T;
|
|
132
|
+
mdBold: T;
|
|
133
|
+
mdCode: T;
|
|
134
|
+
mdCodeBlock: T;
|
|
135
|
+
mdCodeBlockTitle: T;
|
|
136
|
+
mdHeading1: T;
|
|
137
|
+
mdHeading2: T;
|
|
138
|
+
mdHeading3: T;
|
|
139
|
+
mdHeading4: T;
|
|
140
|
+
mdHeading5: T;
|
|
141
|
+
mdHeading6: T;
|
|
142
|
+
mdHeading: T;
|
|
143
|
+
mdHr: T;
|
|
144
|
+
mdItalic: T;
|
|
145
|
+
mdLink: T;
|
|
146
|
+
mdListBullet: T;
|
|
147
|
+
mdListChecked: T;
|
|
148
|
+
mdListUnchecked: T;
|
|
149
|
+
mdMath: T;
|
|
150
|
+
mdQuote: T;
|
|
151
|
+
mdStrikethrough: T;
|
|
152
|
+
mdTable: T;
|
|
153
|
+
mdTableHeader: T;
|
|
154
|
+
optionName: T;
|
|
155
|
+
optionDesc: T;
|
|
199
156
|
/** Currently-highlighted entry. */
|
|
200
|
-
optionActive:
|
|
201
|
-
diffAdd:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
157
|
+
optionActive: T;
|
|
158
|
+
diffAdd: T;
|
|
159
|
+
diffDel: T;
|
|
160
|
+
diffContext: T;
|
|
161
|
+
diffAddNum: T;
|
|
162
|
+
diffDelNum: T;
|
|
163
|
+
diffContextNum: T;
|
|
206
164
|
};
|
|
207
165
|
//#endregion
|
|
208
|
-
|
|
209
|
-
|
|
166
|
+
//#region src/style/types.d.ts
|
|
167
|
+
type RGB = [r: number, g: number, b: number];
|
|
168
|
+
/** Alpha percentage for `/<alpha>` suffix on Color values. Any integer
|
|
169
|
+
* 0..100 is accepted at runtime; the template literal uses `${number}`
|
|
170
|
+
* so odd values like `/98` typecheck without a cast. */
|
|
171
|
+
type ColorLightness = `${number}`;
|
|
172
|
+
/** Standard ANSI color names. */
|
|
173
|
+
type AnsiColorName = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey";
|
|
174
|
+
/** Bright ANSI variants — `brightRed`, `brightBlue`, etc. */
|
|
175
|
+
type BrightAnsiColorName = `bright${Capitalize<AnsiColorName>}`;
|
|
176
|
+
type AnsiColor = AnsiColorName | BrightAnsiColorName | HexColor | "inherit";
|
|
177
|
+
/** Hex color string. Matches `#rgb` / `#rgba` / `#rrggbb` / `#rrggbbaa`
|
|
178
|
+
* (any case; runtime validates). Alpha is native to the hex form, so
|
|
179
|
+
* there is no separate `/<alpha>` suffix for hex. */
|
|
180
|
+
type HexColor = `#${string}`;
|
|
181
|
+
type ThemeKey = Exclude<keyof Theme<false, unknown>, "shiki" | "$schema" | "id" | "name" | "appearance">;
|
|
182
|
+
/**
|
|
183
|
+
* A color value. Accepted forms:
|
|
184
|
+
* - `#rgb` / `#rrggbb` hex
|
|
185
|
+
* - ANSI color names (`red`, `cyan`, `gray`, …)
|
|
186
|
+
* - Bright ANSI variants (`brightRed`, `brightBlue`, …)
|
|
187
|
+
* - Theme slot keys from `keyof Theme` (`primary`, `muted`, …)
|
|
188
|
+
* - `'inherit'` — use the parent's color (renders as no escape).
|
|
189
|
+
* - Variant suffix `-<step>` on hex or theme slots — e.g. `primary-300`,
|
|
190
|
+
* `#82aaff-900`. The base color gets resolved through the theme
|
|
191
|
+
* (extracting the channel when needed), then `variant(base, step)`
|
|
192
|
+
* shifts it along the OKLCH tonal scale.
|
|
193
|
+
*/
|
|
194
|
+
type Color<Ansi extends boolean = true, I = true> = HexColor | (Ansi extends true ? AnsiColorName : never) | (Ansi extends true ? BrightAnsiColorName : never) | ThemeKey | (I extends true ? "inherit" : never) | `${HexColor | ThemeKey}-${ColorLightness}` | `${HexColor | ThemeKey}+${ColorLightness}`;
|
|
195
|
+
interface AnsiStyle {
|
|
196
|
+
fg?: AnsiColor;
|
|
197
|
+
bg?: AnsiColor;
|
|
198
|
+
bold?: boolean;
|
|
199
|
+
dim?: boolean;
|
|
200
|
+
italic?: boolean;
|
|
201
|
+
underline?: boolean;
|
|
202
|
+
inverse?: boolean;
|
|
203
|
+
strikethrough?: boolean;
|
|
204
|
+
}
|
|
205
|
+
/** Base style shared by every node type. Box/Text/etc. extend this.
|
|
206
|
+
* Pure styling — no layout or lifecycle fields. Widget state interfaces
|
|
207
|
+
* extend `StyleState` to pick up the `visible` base-state bits alongside
|
|
208
|
+
* these style fields. */
|
|
209
|
+
type Style<Ansi extends boolean = true> = Simplify<Omit<AnsiStyle, "fg" | "bg"> & {
|
|
210
|
+
fg?: Color<Ansi>;
|
|
211
|
+
bg?: Color<Ansi>;
|
|
212
|
+
style?: AnyStyle<Ansi>;
|
|
213
|
+
}>;
|
|
214
|
+
type AnyStyle<Ansi extends boolean = false> = Style<Ansi> | Color<Ansi>;
|
|
215
|
+
//#endregion
|
|
216
|
+
export { ShikiThemeInput as C, ShikiTheme as S, ShikiWorkerRequest as T, ShikiLanguage as _, BrightAnsiColorName as a, ShikiResult as b, HexColor as c, ThemeKey as d, Theme as f, ShikiJob as g, GeneratedShikiTheme as h, AnyStyle as i, RGB as l, ThemeValue as m, AnsiColorName as n, Color as o, ThemeStyle as p, AnsiStyle as r, ColorLightness as s, AnsiColor as t, Style as u, ShikiOpts as v, ShikiWorkerMessage as w, ShikiSelection as x, ShikiRequest as y };
|
|
217
|
+
//# sourceMappingURL=types-C9ceMsbJ.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-C9ceMsbJ.d.mts","names":[],"sources":["../src/shiki/types.ts","../src/themes/types.ts","../src/style/types.ts"],"mappings":";;;KAGY,aAAa;KACb,gBAAgB;KAChB,0BAA0B;KAC1B;EACV;EACA;EACA,QAAQ;;KAEE,kBAAkB,aAAa;KAE/B;EACV;EACA;EACA;EACA,QAAQ;EACR,SAAS;;KAGC,qBAAqB,KAAK;EACpC;EACA,MAAM;EACN;;KAGU,WAAW,qBACrB,kBAAkB,QAAQ,cAAc;EACtC;;KAGQ;EACV;EACA;EACA;EACA;;KAGU;EAAuB;KAAmB;EAAgB;;KAE1D;EACV,QAAQ;EACR,SAAS;;;;KCvCC,WAAW,+BAA+B,SACpD,KAAK;EACH,KAAK,MAAM;EACX,KAAK,MAAM;;KAGH,WAAW,+BAA+B,WAAW,QAAQ,MAAM;;;;;;;;;;;;;;;;;KAkBnE,MAAM,6BAA6B,IAAI,WAAW;EAC5D;;EAEA;EACA;;;EAGA,QAAQ;EAIR,IAAI,MAAM,MAAM;EAChB,IAAI,MAAM,MAAM;;EAEhB,SAAS,MAAM;;EAEf,QAAQ,MAAM;;;;EAOd,OAAO;;;EAGP,OAAO;;;EAGP,SAAS;;EAET,OAAO;;EAEP,OAAO;;EAKP,IAAI;;EAEJ,SAAS;;;;EAIT,WAAW;;EAKX,SAAS;;EAET,WAAW;;EAEX,QAAQ;;EAER,QAAQ;;EAER,QAAQ;;;EAGR,aAAa;;EAKb,MAAM;;EAEN,WAAW;EAIX,SAAS,MAAM;EACf,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,OAAO,MAAM;EAGb,eAAe;EACf,eAAe;EACf,gBAAgB;EAChB,iBAAiB;EACjB,aAAa;EACb,gBAAgB;EAChB,cAAc;EACd,eAAe;EACf,cAAc;EAId,QAAQ;EACR,QAAQ;EACR,aAAa;EACb,kBAAkB;EAClB,YAAY;EACZ,YAAY;EACZ,YAAY;EACZ,YAAY;EACZ,YAAY;EACZ,YAAY;EACZ,WAAW;EACX,MAAM;EACN,UAAU;EACV,QAAQ;EACR,cAAc;EACd,eAAe;EACf,iBAAiB;EACjB,QAAQ;EACR,SAAS;EACT,iBAAiB;EACjB,SAAS;EACT,eAAe;EAIf,YAAY;EACZ,YAAY;;EAEZ,cAAc;EAGd,SAAS;EACT,SAAS;EACT,aAAa;EACb,YAAY;EACZ,YAAY;EACZ,gBAAgB;;;;KCtJN,OAAO,WAAW,WAAW;;;;KAK7B;;KAGA;;KAaA,+BAA+B,WAAW;KAE1C,YAAY,gBAAgB,sBAAsB;;;;KAKlD;KACA,WAAW,cACf;;;;;;;;;;;;;KAgBI,MAAM,6BAA6B,YAC3C,YACC,oBAAoB,0BACpB,oBAAoB,+BACrB,YACC,yCACE,WAAW,YAAY,sBACvB,WAAW,YAAY;UAEb;EACf,KAAK;EACL,KAAK;EACL;EACA;EACA;EACA;EACA;EACA;;;;;;KAOU,MAAM,+BAA+B,SAC/C,KAAK;EACH,KAAK,MAAM;EACX,KAAK,MAAM;EACX,QAAQ,SAAS;;KAIT,SAAS,gCAAgC,MAAM,QAAQ,MAAM"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as Node } from "./queries-C75-wG1B.mjs";
|
|
2
2
|
//#region src/widgets/widget.d.ts
|
|
3
3
|
type Props = Record<string, unknown>;
|
|
4
4
|
/**
|
|
@@ -46,4 +46,4 @@ type Widget<A extends unknown[] = never[], N extends Node = Node> = (...args: A)
|
|
|
46
46
|
declare function widget<T extends Widget>(fn: T): T;
|
|
47
47
|
//#endregion
|
|
48
48
|
export { Widget as n, widget as r, Props as t };
|
|
49
|
-
//# sourceMappingURL=widget-
|
|
49
|
+
//# sourceMappingURL=widget-DlF32PRp.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-
|
|
1
|
+
{"version":3,"file":"widget-DlF32PRp.d.mts","names":[],"sources":["../src/widgets/widget.ts"],"mappings":";;KAIY,QAAQ;;;;;;;;;;;KAYR,OAAO,+BAA+B,UAAU,OAAO,YAAY,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkC3E,OAAO,UAAU,QAAQ,IAAI,IAAI"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as AutocompleteState, i as AutocompleteOptions, n as Autocomplete, o as CompletionSource, r as AutocompleteEvents, s as autocomplete, t as AcceptFn } from "../autocomplete-
|
|
1
|
+
import { a as AutocompleteState, i as AutocompleteOptions, n as Autocomplete, o as CompletionSource, r as AutocompleteEvents, s as autocomplete, t as AcceptFn } from "../autocomplete-CD30kSe_.mjs";
|
|
2
2
|
export { AcceptFn, Autocomplete, AutocompleteEvents, AutocompleteOptions, AutocompleteState, CompletionSource, autocomplete };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { S as unwrap, f as effect, h as memo, y as signal } from "../reactive-f7NpAi69.mjs";
|
|
2
2
|
import { t as Node } from "../node-BZ7f6HzU.mjs";
|
|
3
|
-
import { t as picker } from "../picker-
|
|
4
|
-
import { t as Input } from "../input-
|
|
3
|
+
import { t as picker } from "../picker-f6xjgACX.mjs";
|
|
4
|
+
import { t as Input } from "../input-ET2YEMcl.mjs";
|
|
5
5
|
//#region src/widgets/autocomplete.ts
|
|
6
6
|
/**
|
|
7
7
|
* Autocomplete popup bound to an `Input`. Watches the input's value and
|
package/dist/widgets/box.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { B as
|
|
1
|
+
import { B as Box, H as Padding, U as box, V as BoxStyle } from "../queries-C75-wG1B.mjs";
|
|
2
2
|
export { Box, BoxStyle, Padding, box };
|
package/dist/widgets/box.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as Box, n as box } from "../box-
|
|
1
|
+
export { t as Box, n as box } from "../box-C_N_7ChP.mjs";
|
package/dist/widgets/code.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { i as AnyStyle } from "../types-C9ceMsbJ.mjs";
|
|
2
|
+
import { B as Box, Q as State, it as Reactive } from "../queries-C75-wG1B.mjs";
|
|
3
|
+
import { t as WrapMode } from "../text-CmxbA8lk.mjs";
|
|
3
4
|
//#region src/widgets/code.d.ts
|
|
4
5
|
export interface CodeState {
|
|
5
6
|
/** Source to render. Plain string or reactive accessor — pass a
|
|
@@ -23,6 +24,7 @@ export interface CodeState {
|
|
|
23
24
|
offset?: Reactive<number | undefined>;
|
|
24
25
|
limit?: Reactive<number | undefined>;
|
|
25
26
|
more?: (more: number, msg: string) => string;
|
|
27
|
+
wrap?: WrapMode;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* Standalone code block: shiki-highlighted body inside a `code`-styled
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.d.mts","names":["_$__box_ts0.Box"],"sources":["../../src/widgets/code.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"code.d.mts","names":["_$__box_ts0.Box"],"sources":["../../src/widgets/code.ts"],"mappings":";;;;iBAgBiB;;;EAGf,MAAM;;;EAGN,OAAO;;;;EAIP;;;EAGA,QAAQ;;EAER;EACA,QAAQ;EACR;EACA,eAAe;EACf,SAAS;EACT,QAAQ;EACR,QAAQ,cAAc;EACtB,OAAO;;;;;;;;;;;;;;;;;;;;qBAqBI,OAAI,OAAkB,MAAM,eAANA"}
|
package/dist/widgets/code.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { S as unwrap, h as memo, r as createAsync, w as useContext } from "../reactive-f7NpAi69.mjs";
|
|
2
|
-
import { n as box } from "../box-
|
|
3
|
-
import { a as formatLines } from "../text-
|
|
4
|
-
import { n as text } from "../text-
|
|
5
|
-
import { t as RenderContext } from "../render-
|
|
6
|
-
import { t as codeToAnsi } from "../shiki
|
|
2
|
+
import { n as box } from "../box-C_N_7ChP.mjs";
|
|
3
|
+
import { a as formatLines } from "../text-BoJdKXLU.mjs";
|
|
4
|
+
import { n as text } from "../text-DPrhma4x.mjs";
|
|
5
|
+
import { t as RenderContext } from "../render-B7LfNM5K.mjs";
|
|
6
|
+
import { t as codeToAnsi } from "../shiki-CJauRusM.mjs";
|
|
7
|
+
import { t as shikiTheme } from "../theme-C8LkcoaK.mjs";
|
|
7
8
|
import { t as widget } from "../widget-BkMwhY2p.mjs";
|
|
8
9
|
import { t as show } from "../show-DR2x1YFc.mjs";
|
|
9
10
|
import { extname } from "pathe";
|
|
@@ -36,7 +37,7 @@ const code = widget((props) => {
|
|
|
36
37
|
const body = createAsync(async () => {
|
|
37
38
|
const source = plain();
|
|
38
39
|
if (!lang || !syntax) return source;
|
|
39
|
-
return await codeToAnsi(source, lang, { theme: context
|
|
40
|
+
return await codeToAnsi(source, lang, { theme: context ? shikiTheme(context.style().theme) : void 0 });
|
|
40
41
|
}, { initialValue: plain() });
|
|
41
42
|
const formatted = memo(() => formatLines(body().split("\n"), {
|
|
42
43
|
limit: unwrap(props.limit),
|
|
@@ -51,7 +52,7 @@ const code = widget((props) => {
|
|
|
51
52
|
padding: props.style === false ? void 0 : [0, 1],
|
|
52
53
|
style: props.style === false ? void 0 : props.style ?? "code",
|
|
53
54
|
width: "fit"
|
|
54
|
-
}, show({ when: title }, () => text((ctx) => ctx.style.codeTitle(title() ?? ""), { wrap: "none" })), text(formatted, { wrap: "none" }));
|
|
55
|
+
}, show({ when: title }, () => text((ctx) => ctx.style.codeTitle(title() ?? ""), { wrap: "none" })), text(formatted, { wrap: props.wrap ?? "none" }));
|
|
55
56
|
});
|
|
56
57
|
//#endregion
|
|
57
58
|
export { code };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.mjs","names":[],"sources":["../../src/widgets/code.ts"],"sourcesContent":["import type { Reactive } from \"../core/reactive.ts\"\nimport type { State } from \"../core/state.ts\"\nimport type { AnyStyle } from \"../style/types.ts\"\n\nimport { extname } from \"pathe\"\nimport { createAsync, memo, unwrap, useContext } from \"../core/reactive.ts\"\nimport { RenderContext } from \"../core/render.ts\"\nimport { formatLines } from \"../layout/text.ts\"\nimport { codeToAnsi } from \"../shiki/shiki.ts\"\nimport { box } from \"./box.ts\"\nimport { show } from \"./show.ts\"\nimport { text } from \"./text.ts\"\nimport { widget } from \"./widget.ts\"\n\nexport interface CodeState {\n /** Source to render. Plain string or reactive accessor — pass a\n * signal for streaming bash output / tool results. */\n code: Reactive<string>\n /** Optional file path. Drives the default `lang` (extension) and\n * `title` (path) when those aren't set explicitly. */\n path?: Reactive<string>\n /** Language for syntax highlighting (any shiki-bundled name or\n * alias). Defaults to `extname(path).slice(1)` when `path` is set.\n * Unknown langs fall through to plain rendering. */\n lang?: string\n /** Title line shown above the block. May contain ANSI. Defaults to\n * `path` when set. */\n title?: Reactive<string>\n /** Disable syntax highlighting even if `lang` is set. Default: `true`. */\n syntax?: boolean\n style?: AnyStyle | false\n numbered?: boolean\n numberOffset?: Reactive<number | undefined>\n offset?: Reactive<number | undefined>\n limit?: Reactive<number | undefined>\n more?: (more: number, msg: string) => string\n}\n\n/**\n * Standalone code block: shiki-highlighted body inside a `code`-styled\n * shrink-to-content backdrop, optionally titled.\n *\n * Composition over custom layout — the backdrop is `box({ bg: \"code\",\n * width: \"fit\" })`, the body is plain `text(...)`. Ambient theme/style\n * arrive via `useContext(RenderContext)`; the async closure reads\n * `style()?.theme` so it stays correct across theme swaps.\n *\n * Async highlighting flows through `createAsync`: signal reads inside\n * the async closure auto-track, so `props.code` (or any other reactive\n * source) drives a re-fire. The accessor returns `initialValue` (the\n * plain source) until shiki resolves, then swaps to the highlighted\n * version. When called inside a Stream surface's `append`, the surface\n * installs a `SuspenseContext` boundary; Stream awaits it before\n * painting, so rows committed to scrollback always reflect the\n * resolved highlight rather than the initial plain source.\n */\nexport const code = widget((props: State<CodeState>) => {\n const path = unwrap(props.path)\n const lang = props.lang ?? (path !== undefined ? extname(path).slice(1).toLowerCase() : undefined)\n const syntax = props.syntax ?? true\n\n // Theme is sourced from a render-time hook since the async closure\n // runs outside the render phase.\n\n const context = useContext(RenderContext)\n\n const title = memo(() => unwrap(props.title) ?? path)\n\n const plain = () => unwrap(props.code).replace(/\\n+$/, \"\")\n\n const body = createAsync(\n async () => {\n const source = plain()\n if (!lang || !syntax) return source\n return await codeToAnsi(source, lang, {
|
|
1
|
+
{"version":3,"file":"code.mjs","names":[],"sources":["../../src/widgets/code.ts"],"sourcesContent":["import type { Reactive } from \"../core/reactive.ts\"\nimport type { State } from \"../core/state.ts\"\nimport type { WrapMode } from \"../layout/text.ts\"\nimport type { AnyStyle } from \"../style/types.ts\"\n\nimport { extname } from \"pathe\"\nimport { createAsync, memo, unwrap, useContext } from \"../core/reactive.ts\"\nimport { RenderContext } from \"../core/render.ts\"\nimport { formatLines } from \"../layout/text.ts\"\nimport { codeToAnsi } from \"../shiki/shiki.ts\"\nimport { shikiTheme } from \"../shiki/theme.ts\"\nimport { box } from \"./box.ts\"\nimport { show } from \"./show.ts\"\nimport { text } from \"./text.ts\"\nimport { widget } from \"./widget.ts\"\n\nexport interface CodeState {\n /** Source to render. Plain string or reactive accessor — pass a\n * signal for streaming bash output / tool results. */\n code: Reactive<string>\n /** Optional file path. Drives the default `lang` (extension) and\n * `title` (path) when those aren't set explicitly. */\n path?: Reactive<string>\n /** Language for syntax highlighting (any shiki-bundled name or\n * alias). Defaults to `extname(path).slice(1)` when `path` is set.\n * Unknown langs fall through to plain rendering. */\n lang?: string\n /** Title line shown above the block. May contain ANSI. Defaults to\n * `path` when set. */\n title?: Reactive<string>\n /** Disable syntax highlighting even if `lang` is set. Default: `true`. */\n syntax?: boolean\n style?: AnyStyle | false\n numbered?: boolean\n numberOffset?: Reactive<number | undefined>\n offset?: Reactive<number | undefined>\n limit?: Reactive<number | undefined>\n more?: (more: number, msg: string) => string\n wrap?: WrapMode\n}\n\n/**\n * Standalone code block: shiki-highlighted body inside a `code`-styled\n * shrink-to-content backdrop, optionally titled.\n *\n * Composition over custom layout — the backdrop is `box({ bg: \"code\",\n * width: \"fit\" })`, the body is plain `text(...)`. Ambient theme/style\n * arrive via `useContext(RenderContext)`; the async closure reads\n * `style()?.theme` so it stays correct across theme swaps.\n *\n * Async highlighting flows through `createAsync`: signal reads inside\n * the async closure auto-track, so `props.code` (or any other reactive\n * source) drives a re-fire. The accessor returns `initialValue` (the\n * plain source) until shiki resolves, then swaps to the highlighted\n * version. When called inside a Stream surface's `append`, the surface\n * installs a `SuspenseContext` boundary; Stream awaits it before\n * painting, so rows committed to scrollback always reflect the\n * resolved highlight rather than the initial plain source.\n */\nexport const code = widget((props: State<CodeState>) => {\n const path = unwrap(props.path)\n const lang = props.lang ?? (path !== undefined ? extname(path).slice(1).toLowerCase() : undefined)\n const syntax = props.syntax ?? true\n\n // Theme is sourced from a render-time hook since the async closure\n // runs outside the render phase.\n\n const context = useContext(RenderContext)\n\n const title = memo(() => unwrap(props.title) ?? path)\n\n const plain = () => unwrap(props.code).replace(/\\n+$/, \"\")\n\n const body = createAsync(\n async () => {\n const source = plain()\n if (!lang || !syntax) return source\n return await codeToAnsi(source, lang, {\n theme: context ? shikiTheme(context.style().theme) : undefined,\n })\n },\n { initialValue: plain() }\n )\n\n const formatted = memo(() =>\n formatLines(body().split(\"\\n\"), {\n limit: unwrap(props.limit),\n more: props.more,\n numberOffset: unwrap(props.numberOffset),\n numbered: props.numbered,\n offset: unwrap(props.offset),\n style: context?.style().gutter,\n }).join(\"\\n\")\n )\n\n return box(\n {\n flexDirection: \"column\",\n padding: props.style === false ? undefined : [0, 1],\n style: props.style === false ? undefined : (props.style ?? \"code\"),\n width: \"fit\",\n },\n show({ when: title }, () =>\n text((ctx) => ctx.style.codeTitle(title() ?? \"\"), { wrap: \"none\" })\n ),\n text(formatted, { wrap: props.wrap ?? \"none\" })\n )\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAa,OAAO,QAAQ,UAA4B;CACtD,MAAM,OAAO,OAAO,MAAM,IAAI;CAC9B,MAAM,OAAO,MAAM,SAAS,SAAS,KAAA,IAAY,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,IAAI,KAAA;CACxF,MAAM,SAAS,MAAM,UAAU;CAK/B,MAAM,UAAU,WAAW,aAAa;CAExC,MAAM,QAAQ,WAAW,OAAO,MAAM,KAAK,KAAK,IAAI;CAEpD,MAAM,cAAc,OAAO,MAAM,IAAI,CAAC,CAAC,QAAQ,QAAQ,EAAE;CAEzD,MAAM,OAAO,YACX,YAAY;EACV,MAAM,SAAS,MAAM;EACrB,IAAI,CAAC,QAAQ,CAAC,QAAQ,OAAO;EAC7B,OAAO,MAAM,WAAW,QAAQ,MAAM,EACpC,OAAO,UAAU,WAAW,QAAQ,MAAM,CAAC,CAAC,KAAK,IAAI,KAAA,EACvD,CAAC;CACH,GACA,EAAE,cAAc,MAAM,EAAE,CAC1B;CAEA,MAAM,YAAY,WAChB,YAAY,KAAK,CAAC,CAAC,MAAM,IAAI,GAAG;EAC9B,OAAO,OAAO,MAAM,KAAK;EACzB,MAAM,MAAM;EACZ,cAAc,OAAO,MAAM,YAAY;EACvC,UAAU,MAAM;EAChB,QAAQ,OAAO,MAAM,MAAM;EAC3B,OAAO,SAAS,MAAM,CAAC,CAAC;CAC1B,CAAC,CAAC,CAAC,KAAK,IAAI,CACd;CAEA,OAAO,IACL;EACE,eAAe;EACf,SAAS,MAAM,UAAU,QAAQ,KAAA,IAAY,CAAC,GAAG,CAAC;EAClD,OAAO,MAAM,UAAU,QAAQ,KAAA,IAAa,MAAM,SAAS;EAC3D,OAAO;CACT,GACA,KAAK,EAAE,MAAM,MAAM,SACjB,MAAM,QAAQ,IAAI,MAAM,UAAU,MAAM,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,CACpE,GACA,KAAK,WAAW,EAAE,MAAM,MAAM,QAAQ,OAAO,CAAC,CAChD;AACF,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as ActionsSourceOptions, r as actionsSource, t as ActionCompletionItem } from "../../actions
|
|
1
|
+
import { n as ActionsSourceOptions, r as actionsSource, t as ActionCompletionItem } from "../../actions--ODlgCQ5.mjs";
|
|
2
2
|
export { ActionCompletionItem, ActionsSourceOptions, actionsSource };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as filesSource, t as FilesSourceOptions } from "../../files-
|
|
1
|
+
import { n as filesSource, t as FilesSourceOptions } from "../../files-B_5HDBPp.mjs";
|
|
2
2
|
export { FilesSourceOptions, filesSource };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as githubSource, i as GithubState, n as GithubItem, r as GithubSourceOptions, t as GithubFetcher } from "../../github-
|
|
1
|
+
import { a as githubSource, i as GithubState, n as GithubItem, r as GithubSourceOptions, t as GithubFetcher } from "../../github-CyRwUQ3y.mjs";
|
|
2
2
|
export { GithubFetcher, GithubItem, GithubSourceOptions, GithubState, githubSource };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ActionsSourceOptions, r as actionsSource, t as ActionCompletionItem } from "../../actions
|
|
2
|
-
import { n as filesSource, t as FilesSourceOptions } from "../../files-
|
|
3
|
-
import { a as githubSource, i as GithubState, n as GithubItem, r as GithubSourceOptions, t as GithubFetcher } from "../../github-
|
|
1
|
+
import { n as ActionsSourceOptions, r as actionsSource, t as ActionCompletionItem } from "../../actions--ODlgCQ5.mjs";
|
|
2
|
+
import { n as filesSource, t as FilesSourceOptions } from "../../files-B_5HDBPp.mjs";
|
|
3
|
+
import { a as githubSource, i as GithubState, n as GithubItem, r as GithubSourceOptions, t as GithubFetcher } from "../../github-CyRwUQ3y.mjs";
|
|
4
4
|
export { ActionCompletionItem, ActionsSourceOptions, FilesSourceOptions, GithubFetcher, GithubItem, GithubSourceOptions, GithubState, actionsSource, filesSource, githubSource };
|
package/dist/widgets/diff.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as WrapMode } from "../text-
|
|
1
|
+
import { I as RenderCtx, Q as State, X as Layout, h as Node, it as Reactive } from "../queries-C75-wG1B.mjs";
|
|
2
|
+
import { t as WrapMode } from "../text-CmxbA8lk.mjs";
|
|
3
3
|
//#region src/widgets/diff.d.ts
|
|
4
4
|
export interface DiffState {
|
|
5
5
|
/** Pre-state file content. Plain string or reactive accessor —
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.mts","names":[],"sources":["../../src/widgets/diff.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"diff.d.mts","names":[],"sources":["../../src/widgets/diff.ts"],"mappings":";;;iBAgBiB;;;EAGf,UAAU;;;EAGV,UAAU;;;;EAIV,OAAO;;;EAGP;;EAEA;EACA,OAAO;;;;;;;;;;;;;qBA2BI,aAAa,KAAK;;EAI7B,YAAY,OAAO;MA+Bf;IAAW;IAAkB;;YAOjB,QAAQ,KAAK,YAAY;EAqBhC,UAAU;;;;;;;;;;;;;wBA+BL,KAAK,OAAO,MAAM,aAAa"}
|
package/dist/widgets/diff.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { S as unwrap, h as memo, r as createAsync, w as useContext } from "../reactive-f7NpAi69.mjs";
|
|
2
2
|
import { t as Node } from "../node-BZ7f6HzU.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { t as RenderContext } from "../render-
|
|
5
|
-
import { t as codeToAnsi } from "../shiki
|
|
3
|
+
import { t as calcLayout } from "../text-BoJdKXLU.mjs";
|
|
4
|
+
import { t as RenderContext } from "../render-B7LfNM5K.mjs";
|
|
5
|
+
import { t as codeToAnsi } from "../shiki-CJauRusM.mjs";
|
|
6
|
+
import { t as shikiTheme } from "../theme-C8LkcoaK.mjs";
|
|
6
7
|
import { splitAnsi, stringWidth, wrapAnsi } from "@zaly/shared/ansi";
|
|
7
8
|
import { basename, extname } from "pathe";
|
|
8
9
|
//#region src/widgets/diff.ts
|
|
10
|
+
const NO_NEWLINE = String.raw``;
|
|
9
11
|
/**
|
|
10
12
|
* Show a unified diff between two file contents with syntax-highlighted
|
|
11
13
|
* rows. Added rows carry a green backdrop and `+` prefix; removed rows
|
|
@@ -34,7 +36,7 @@ var Diff = class extends Node {
|
|
|
34
36
|
const lang = this.#lang();
|
|
35
37
|
const input = this.input;
|
|
36
38
|
if (!lang) return input;
|
|
37
|
-
const theme = context
|
|
39
|
+
const theme = context ? shikiTheme(context.style().theme) : void 0;
|
|
38
40
|
const [original, modified] = await Promise.all([codeToAnsi(input.original, lang, { theme }), codeToAnsi(input.modified, lang, { theme })]);
|
|
39
41
|
return {
|
|
40
42
|
modified,
|
|
@@ -56,16 +58,18 @@ var Diff = class extends Node {
|
|
|
56
58
|
const input = this.input;
|
|
57
59
|
const layout = this.layout();
|
|
58
60
|
const width = Math.min(ctx.width, layout.width);
|
|
61
|
+
const original = splitLines(input.original);
|
|
62
|
+
const modified = splitLines(input.modified);
|
|
59
63
|
const opts = {
|
|
60
64
|
context: this.state.context ?? 3,
|
|
61
65
|
ctx: {
|
|
62
66
|
...ctx,
|
|
63
67
|
width
|
|
64
68
|
},
|
|
65
|
-
modified
|
|
66
|
-
modifiedHi: highlighted.modified.
|
|
67
|
-
original
|
|
68
|
-
originalHi: highlighted.original.
|
|
69
|
+
modified,
|
|
70
|
+
modifiedHi: splitAnsi(highlighted.modified).slice(0, modified.length),
|
|
71
|
+
original,
|
|
72
|
+
originalHi: splitAnsi(highlighted.original).slice(0, original.length)
|
|
69
73
|
};
|
|
70
74
|
this.state.wrap ??= "word";
|
|
71
75
|
return await buildDiffRows(opts);
|
|
@@ -74,10 +78,12 @@ var Diff = class extends Node {
|
|
|
74
78
|
const input = this.input;
|
|
75
79
|
const original = calcLayout(input.original, { wrap: this.state.wrap });
|
|
76
80
|
const modified = calcLayout(input.modified, { wrap: this.state.wrap });
|
|
77
|
-
const
|
|
81
|
+
const numWidth = Math.max(1, splitLines(input.original).length, splitLines(input.modified).length).toString().length;
|
|
82
|
+
const markerWidth = [input.original, input.modified].some((s) => s !== "" && !s.endsWith("\n")) ? stringWidth(NO_NEWLINE) : 0;
|
|
83
|
+
const padding = numWidth * 2 + 4 + 4;
|
|
78
84
|
return {
|
|
79
85
|
minWidth: Math.max(original.minWidth, modified.minWidth) + padding,
|
|
80
|
-
width: Math.max(original.width, modified.width) + padding
|
|
86
|
+
width: Math.max(original.width, modified.width, markerWidth) + padding
|
|
81
87
|
};
|
|
82
88
|
}
|
|
83
89
|
};
|
|
@@ -95,10 +101,20 @@ var Diff = class extends Node {
|
|
|
95
101
|
function diff(state) {
|
|
96
102
|
return new Diff(state);
|
|
97
103
|
}
|
|
104
|
+
function splitLines(text) {
|
|
105
|
+
if (text === "") return [];
|
|
106
|
+
const terminated = text.endsWith("\n");
|
|
107
|
+
const lines = text.split("\n");
|
|
108
|
+
if (terminated) lines.pop();
|
|
109
|
+
return lines.map((line, i) => ({
|
|
110
|
+
terminated: i < lines.length - 1 || terminated,
|
|
111
|
+
text: line
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
98
114
|
async function buildDiffRows(opts) {
|
|
99
115
|
const context = opts.context;
|
|
100
116
|
const { diffArrays } = await import("diff");
|
|
101
|
-
const segments = diffArrays(opts.original, opts.modified);
|
|
117
|
+
const segments = diffArrays(opts.original, opts.modified, { comparator: (a, b) => a.text === b.text && a.terminated === b.terminated });
|
|
102
118
|
const { original: origLines, modified: modLines, originalHi: origHi, modifiedHi: modHi, ctx } = opts;
|
|
103
119
|
const ann = [];
|
|
104
120
|
let oI = 0;
|
|
@@ -136,16 +152,19 @@ async function buildDiffRows(opts) {
|
|
|
136
152
|
content: modHi[a.modIdx] ?? origHi[a.origIdx] ?? "",
|
|
137
153
|
newNum: a.modIdx + 1,
|
|
138
154
|
origNum: a.origIdx + 1,
|
|
155
|
+
terminated: modLines[a.modIdx].terminated,
|
|
139
156
|
type: "context"
|
|
140
157
|
});
|
|
141
158
|
else if (a.kind === "remove") rows.push({
|
|
142
159
|
content: origHi[a.origIdx] ?? "",
|
|
143
160
|
origNum: a.origIdx + 1,
|
|
161
|
+
terminated: origLines[a.origIdx].terminated,
|
|
144
162
|
type: "remove"
|
|
145
163
|
});
|
|
146
164
|
else rows.push({
|
|
147
165
|
content: modHi[a.modIdx] ?? "",
|
|
148
166
|
newNum: a.modIdx + 1,
|
|
167
|
+
terminated: modLines[a.modIdx].terminated,
|
|
149
168
|
type: "add"
|
|
150
169
|
});
|
|
151
170
|
}
|
|
@@ -166,7 +185,7 @@ function renderRows(ctx, rows, origTotal, modTotal) {
|
|
|
166
185
|
for (const r of rows) {
|
|
167
186
|
const origStr = r.type === "add" ? "" : String(r.origNum);
|
|
168
187
|
const newStr = r.type === "remove" ? "" : String(r.newNum);
|
|
169
|
-
const gutterStyle = s
|
|
188
|
+
const gutterStyle = s[`${styles[r.type]}Num`] ?? ((x) => x);
|
|
170
189
|
const gutter = gutterStyle(` ${pad(origStr, numWidth)} ${pad(newStr, numWidth)} `);
|
|
171
190
|
const prefix = r.type === "add" ? " + " : r.type === "remove" ? " - " : " ";
|
|
172
191
|
const innerWidth = Math.max(0, contentWidth - stringWidth(prefix) - 1);
|
|
@@ -179,6 +198,10 @@ function renderRows(ctx, rows, origTotal, modTotal) {
|
|
|
179
198
|
const styledBody = rowStyle?.(bodyLine) ?? bodyLine;
|
|
180
199
|
out.push((i === 0 ? gutter : gutterStyle(blankGutter)) + styledBody);
|
|
181
200
|
}
|
|
201
|
+
if (!r.terminated) {
|
|
202
|
+
const marker = wrapAnsi(NO_NEWLINE, Math.max(1, contentWidth), { mode: "word" });
|
|
203
|
+
for (const line of splitAnsi(marker)) out.push(" ".repeat(gutterWidth) + s.dim(line));
|
|
204
|
+
}
|
|
182
205
|
}
|
|
183
206
|
return out;
|
|
184
207
|
}
|