@pi-vault/pi-status 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +54 -20
- package/docs/assets/statusline-configuration.png +0 -0
- package/docs/assets/statusline-ui.png +0 -0
- package/package.json +8 -7
- package/src/{config.ts → core/config.ts} +23 -63
- package/src/core/snapshot.ts +75 -0
- package/src/core/usage-runtime.ts +62 -0
- package/src/index.ts +89 -150
- package/src/shared/types.ts +63 -0
- package/src/{ui/statusline-editor.ts → tui/editor.ts} +91 -114
- package/src/{render.ts → tui/render.ts} +25 -82
- package/src/tui/theme.ts +35 -0
- package/src/ui/statusline-theme.ts +0 -67
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// Internal theme adapter for the `/statusline` configuration menu.
|
|
2
|
-
//
|
|
3
|
-
// This module owns the only place where the editor reads from Pi's live theme
|
|
4
|
-
// object. The editor itself only sees the narrow `StatuslineMenuTheme`
|
|
5
|
-
// surface so menu styling stays in one place, and the live Pi theme remains
|
|
6
|
-
// the single source of truth for menu colors while `/statusline` is open.
|
|
7
|
-
//
|
|
8
|
-
// The menu's own color usage is a narrow subset of Pi's palette
|
|
9
|
-
// (`accent`, `borderMuted`, `dim`); the union below is widened to also cover
|
|
10
|
-
// the `buildFooterLine` colors so the same adapted theme can feed the bottom
|
|
11
|
-
// preview line as well. The widened union is a strict superset of
|
|
12
|
-
// `FooterRenderColor` (defined in `../render.ts`), which makes a
|
|
13
|
-
// `StatuslineMenuTheme` assignable to the `ThemeLike` that `buildFooterLine`
|
|
14
|
-
// expects.
|
|
15
|
-
|
|
16
|
-
import type { FooterRenderColor } from "../render.ts";
|
|
17
|
-
|
|
18
|
-
export type StatuslineMenuColor = FooterRenderColor | "borderMuted";
|
|
19
|
-
|
|
20
|
-
export type StatuslineMenuTheme = {
|
|
21
|
-
fg: (color: StatuslineMenuColor, text: string) => string;
|
|
22
|
-
bold: (text: string) => string;
|
|
23
|
-
dim: (text: string) => string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// Shape of the live Pi theme object we care about. Kept narrow on purpose:
|
|
27
|
-
// the adapter only needs `fg` and `bold`; everything else is derived from
|
|
28
|
-
// those two primitives.
|
|
29
|
-
type PiThemeLike = {
|
|
30
|
-
fg: (color: string, text: string) => string;
|
|
31
|
-
bold: (text: string) => string;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
function isPiThemeLike(value: unknown): value is PiThemeLike {
|
|
35
|
-
if (!value || typeof value !== "object") return false;
|
|
36
|
-
const candidate = value as { fg?: unknown; bold?: unknown };
|
|
37
|
-
return (
|
|
38
|
-
typeof candidate.fg === "function" && typeof candidate.bold === "function"
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Passthrough fallback. Used for tests and for any runtime where the live Pi
|
|
43
|
-
// theme is missing the methods we need. All calls return the input text
|
|
44
|
-
// unchanged, so styled output collapses to plain text.
|
|
45
|
-
export const noTheme: StatuslineMenuTheme = {
|
|
46
|
-
fg: (_color, text) => text,
|
|
47
|
-
bold: (text) => text,
|
|
48
|
-
dim: (text) => text,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// Adapt a Pi theme object into the narrow `StatuslineMenuTheme` surface used
|
|
52
|
-
// by the editor. Returns `noTheme` for anything that is missing the required
|
|
53
|
-
// `fg` or `bold` methods so the editor never has to deal with partial
|
|
54
|
-
// runtime themes. The returned object captures the Pi theme by reference, so
|
|
55
|
-
// when Pi swaps the live theme instance the next render picks up the new
|
|
56
|
-
// colors without reopening `/statusline`.
|
|
57
|
-
export function fromPiTheme(theme: unknown): StatuslineMenuTheme {
|
|
58
|
-
if (!isPiThemeLike(theme)) return noTheme;
|
|
59
|
-
const pi = theme;
|
|
60
|
-
return {
|
|
61
|
-
fg: (color, text) => pi.fg(color, text),
|
|
62
|
-
bold: (text) => pi.bold(text),
|
|
63
|
-
// Pi exposes "dim" as a foreground color role, not as a separate method,
|
|
64
|
-
// so the menu's `dim` helper is just a thin wrapper around `fg("dim", …)`.
|
|
65
|
-
dim: (text) => pi.fg("dim", text),
|
|
66
|
-
};
|
|
67
|
-
}
|