@jackice/pi-ui 0.4.2 → 0.5.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/CHANGELOG.md +8 -0
- package/README.md +49 -47
- package/dist/components/inline-gauge.d.ts +32 -0
- package/dist/components/inline-gauge.d.ts.map +1 -0
- package/dist/components/inline-gauge.js +96 -0
- package/dist/components/inline-gauge.js.map +1 -0
- package/dist/components/segment-bar.d.ts +54 -0
- package/dist/components/segment-bar.d.ts.map +1 -0
- package/dist/components/segment-bar.js +176 -0
- package/dist/components/segment-bar.js.map +1 -0
- package/dist/components/separator.d.ts +5 -0
- package/dist/components/separator.d.ts.map +1 -0
- package/dist/components/separator.js +16 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
- 新增 `SegmentBar` / `layoutSegmentBar`:左右分段、弹性 gauge、优先级降级、宽窄矩阵安全、确定性布局
|
|
6
|
+
- 新增 `renderSeparator` / `separatorText`:ascii/pipe/slash/dot/none 五种分隔符
|
|
7
|
+
- 新增 `InlineGauge`:未知/0-100/>100 百分比、标签避让、缓存、ASCII 与阈值标记
|
|
8
|
+
- 三个组件通过根导出 `.` 暴露;既有 `.`、`./diff`、`./views/*` 入口保持兼容
|
|
9
|
+
- 测试增至 16 个文件 / 106 个用例
|
|
10
|
+
|
|
3
11
|
## 0.4.2
|
|
4
12
|
|
|
5
13
|
- 优化带行号栏的 ANSI 行宽计算;中文、emoji 和其他转义仍使用 Pi TUI 的宽度规则。
|
package/README.md
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
# @jackice/pi-ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A terminal UI library for Pi extensions. It provides theme adapters, ANSI-aware layout, and components for panels, status lines, code diffs, trees, session tasks, and approval prompts.
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
- 不注册工具、不持久化业务数据、不读取工作区、不批准命令、不持有 AgentSession
|
|
5
|
+
- Verified with Pi `1.6.0` and `@earendil-works/pi-tui` `1.6.0`. Requires Node `>=22`.
|
|
6
|
+
- This preview includes UI components only. It does not register tools, persist tasks, access the workspace, retain an `AgentSession`, or authorize commands.
|
|
8
7
|
|
|
9
|
-
##
|
|
8
|
+
## Installation
|
|
10
9
|
|
|
11
10
|
```bash
|
|
12
11
|
pnpm add @jackice/pi-ui@next
|
|
13
12
|
```
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
Use the `next` dist-tag to opt in to preview releases.
|
|
16
15
|
|
|
17
|
-
`@earendil-works/pi-tui`
|
|
16
|
+
`@earendil-works/pi-tui` is a peer dependency. The library uses the host's copy rather than bundling another Pi runtime.
|
|
18
17
|
|
|
19
|
-
##
|
|
18
|
+
## Usage
|
|
20
19
|
|
|
21
20
|
```ts
|
|
22
21
|
import { fromPiTheme, Panel } from "@jackice/pi-ui";
|
|
@@ -54,45 +53,48 @@ export default function (pi: ExtensionAPI) {
|
|
|
54
53
|
|
|
55
54
|
## API
|
|
56
55
|
|
|
57
|
-
|
|
|
56
|
+
| Export | Description |
|
|
58
57
|
|---|---|
|
|
59
|
-
| `UiTheme` / `Tone` |
|
|
60
|
-
| `fromPiTheme(theme)` |
|
|
61
|
-
| `plainTheme()` |
|
|
62
|
-
| `displayWidth` |
|
|
63
|
-
| `sanitizeLine` / `sanitizeText` |
|
|
64
|
-
| `truncate` / `pad` / `wrap` / `middleTruncate` |
|
|
65
|
-
| `Panel` |
|
|
66
|
-
| `StatusLine` |
|
|
67
|
-
| `
|
|
68
|
-
| `
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
-
|
|
91
|
-
- `
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
58
|
+
| `UiTheme` / `Tone` | Semantic tones: `text`, `muted`, `accent`, `success`, `warning`, `error`, `border`, `added`, and `removed`. |
|
|
59
|
+
| `fromPiTheme(theme)` | Adapts Pi's `Theme.fg` and `bold`, mapping `added` to `success` and `removed` to `error`. Falls back to unstyled text for unsupported tokens. |
|
|
60
|
+
| `plainTheme()` | Deterministic, ANSI-free theme for tests and the gallery. |
|
|
61
|
+
| `displayWidth` | Measures terminal columns, accounting for CJK text, emoji, combining marks, and ANSI sequences. |
|
|
62
|
+
| `sanitizeLine` / `sanitizeText` | Strip terminal control sequences and remaining control characters. |
|
|
63
|
+
| `truncate` / `pad` / `wrap` / `middleTruncate` | Column-aware text helpers. `pad` hard-truncates text that does not fit. |
|
|
64
|
+
| `Panel` | Left and right titles, rounded or square borders, a borderless mode, horizontal and vertical padding, and width-based caching. |
|
|
65
|
+
| `StatusLine` | Icon, title, middle-truncated path, and right-aligned metadata. Prioritizes metadata at narrow widths. |
|
|
66
|
+
| `SegmentBar` / `layoutSegmentBar` | Left/right segments, elastic center gauge, priority-based compaction, deterministic ANSI-safe layout. |
|
|
67
|
+
| `renderSeparator` / `separatorText` | `ascii`, `pipe`, `slash`, `dot`, and `none` separators. |
|
|
68
|
+
| `InlineGauge` | Elastic character gauge with unknown/0–100/>100 percent, label avoidance, markers, ASCII fallback, and caching. |
|
|
69
|
+
| `CodeFrame` | Old and new line numbers, diff markers and colors, visible tabs, hanging indents, and folding notices. |
|
|
70
|
+
| `adaptHashlineDetails(details)` | Converts Hashline `details` version 1 to an `EditViewModel`. Returns `undefined` for unsupported versions. |
|
|
71
|
+
| `EditView` | Multi-file diffs and partial, failed, or unwritten edit results, with folding and source truncation notices. |
|
|
72
|
+
| `TreeList` | Generic tree with connector lines, collapsible branches, an ASCII fallback, and a row limit. |
|
|
73
|
+
| `TodoView` | Phase progress, active task highlighting, completed and abandoned markers, collapsed future phases, and hidden task counts. |
|
|
74
|
+
| `ApprovalView` | Displays the command, working directory, reason, and risk. Supports scrolling, an arming hint, and Allow once or Deny choices. |
|
|
75
|
+
| `joinSides` / `rule` / `fitLine` | Layout primitives. |
|
|
76
|
+
|
|
77
|
+
Update components with `setProps` or `setTheme` and invalidate them with `invalidate()` when needed. Invalidation is idempotent. `render(width)` is synchronous, performs no I/O, and never returns a line wider than `width`.
|
|
78
|
+
|
|
79
|
+
## Terminal safety and width
|
|
80
|
+
|
|
81
|
+
- Width is measured in terminal columns, not JavaScript string length.
|
|
82
|
+
- Widths of `0`, `1`, and `2` are supported. `Panel` drops its border when it cannot fit.
|
|
83
|
+
- Sanitize untrusted text with `sanitizeLine` or `sanitizeText`. `Panel` titles and `StatusLine` fields are sanitized automatically.
|
|
84
|
+
- Components preserve their own ANSI styling.
|
|
85
|
+
- Rendering does not register event handlers, start timers, or access files.
|
|
86
|
+
|
|
87
|
+
## Compatibility and limitations
|
|
88
|
+
|
|
89
|
+
- Compatibility has been verified only against Pi `1.6.0`.
|
|
90
|
+
- `EditView` consumes Hashline `details` version 1. Install [`@jackice/hashline@0.1.2`](https://github.com/jackice/hashline#use-as-a-pi-extension) to use it; Hashline `0.1.1` does not provide these details.
|
|
91
|
+
- Fall back to the original text renderer when `adaptHashlineDetails` returns `undefined` for older or unsupported results.
|
|
92
|
+
- `TodoView` only renders task data. Install [`@jackice/pi-session-todo@0.1.1`](https://github.com/jackice/pi-session-todo#installation) for the `session_todo` tool, persistence, `/session-todo` command, and HUD.
|
|
93
|
+
- `ApprovalView` returns a UI choice, not authorization to run a command. The separate approval extension is not part of this preview and remains pending security review.
|
|
94
|
+
|
|
95
|
+
See the [integration examples](docs/integration.md), [compatibility notes](docs/compatibility.md), and [implementation status](docs/implementation-status.md).
|
|
96
|
+
|
|
97
|
+
## Development
|
|
96
98
|
|
|
97
99
|
```bash
|
|
98
100
|
pnpm install
|
|
@@ -106,4 +108,4 @@ pnpm bench:heap
|
|
|
106
108
|
pnpm bench:coldstart
|
|
107
109
|
```
|
|
108
110
|
|
|
109
|
-
|
|
111
|
+
The gallery runs offline without an LLM or file writes.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Tone, UiTheme } from "../core/theme.js";
|
|
2
|
+
export interface GaugeMarker {
|
|
3
|
+
percent: number;
|
|
4
|
+
glyph: string;
|
|
5
|
+
tone: Tone;
|
|
6
|
+
}
|
|
7
|
+
export interface InlineGaugeProps {
|
|
8
|
+
percent?: number;
|
|
9
|
+
label?: string;
|
|
10
|
+
endLabel?: string;
|
|
11
|
+
markers?: readonly GaugeMarker[];
|
|
12
|
+
tone: Tone;
|
|
13
|
+
}
|
|
14
|
+
export interface InlineGaugeOptions {
|
|
15
|
+
ascii?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare class InlineGauge {
|
|
18
|
+
private props;
|
|
19
|
+
private theme;
|
|
20
|
+
private ascii;
|
|
21
|
+
private revision;
|
|
22
|
+
private cache;
|
|
23
|
+
constructor(theme: UiTheme, props: InlineGaugeProps, options?: InlineGaugeOptions);
|
|
24
|
+
setProps(props: Partial<InlineGaugeProps>): void;
|
|
25
|
+
setTheme(theme: UiTheme): void;
|
|
26
|
+
setAscii(ascii: boolean): void;
|
|
27
|
+
invalidate(): void;
|
|
28
|
+
render(width: number): string;
|
|
29
|
+
private build;
|
|
30
|
+
private renderTrack;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=inline-gauge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-gauge.d.ts","sourceRoot":"","sources":["../../src/components/inline-gauge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEtD,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IACjC,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAWD,qBAAa,WAAW;IACtB,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,KAAK,CAAgE;gBAEjE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,GAAE,kBAAuB;IAMrF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI;IAKhD,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAK9B,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAM9B,UAAU,IAAI,IAAI;IAKlB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAW7B,OAAO,CAAC,KAAK;IAuBb,OAAO,CAAC,WAAW;CA8BpB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { displayWidth, normalizeWidth, sanitizeLine, truncate } from "../core/ansi.js";
|
|
2
|
+
function isKnownPercent(value) {
|
|
3
|
+
return value !== undefined && Number.isFinite(value);
|
|
4
|
+
}
|
|
5
|
+
function markerGlyph(marker) {
|
|
6
|
+
const glyph = sanitizeLine(marker.glyph);
|
|
7
|
+
return displayWidth(glyph) === 1 ? glyph : undefined;
|
|
8
|
+
}
|
|
9
|
+
export class InlineGauge {
|
|
10
|
+
props;
|
|
11
|
+
theme;
|
|
12
|
+
ascii;
|
|
13
|
+
revision = 0;
|
|
14
|
+
cache;
|
|
15
|
+
constructor(theme, props, options = {}) {
|
|
16
|
+
this.theme = theme;
|
|
17
|
+
this.props = props;
|
|
18
|
+
this.ascii = options.ascii ?? false;
|
|
19
|
+
}
|
|
20
|
+
setProps(props) {
|
|
21
|
+
this.props = { ...this.props, ...props };
|
|
22
|
+
this.invalidate();
|
|
23
|
+
}
|
|
24
|
+
setTheme(theme) {
|
|
25
|
+
this.theme = theme;
|
|
26
|
+
this.invalidate();
|
|
27
|
+
}
|
|
28
|
+
setAscii(ascii) {
|
|
29
|
+
if (this.ascii === ascii)
|
|
30
|
+
return;
|
|
31
|
+
this.ascii = ascii;
|
|
32
|
+
this.invalidate();
|
|
33
|
+
}
|
|
34
|
+
invalidate() {
|
|
35
|
+
this.revision++;
|
|
36
|
+
this.cache = undefined;
|
|
37
|
+
}
|
|
38
|
+
render(width) {
|
|
39
|
+
const limit = normalizeWidth(width);
|
|
40
|
+
if (limit === 0)
|
|
41
|
+
return "";
|
|
42
|
+
if (this.cache && this.cache.width === limit && this.cache.revision === this.revision) {
|
|
43
|
+
return this.cache.line;
|
|
44
|
+
}
|
|
45
|
+
const line = this.build(limit);
|
|
46
|
+
this.cache = { width: limit, revision: this.revision, line };
|
|
47
|
+
return line;
|
|
48
|
+
}
|
|
49
|
+
build(width) {
|
|
50
|
+
const known = isKnownPercent(this.props.percent);
|
|
51
|
+
const label = truncate(sanitizeLine(this.props.label ?? (known ? `${Math.round(this.props.percent)}%` : "?")), width);
|
|
52
|
+
const labelWidth = displayWidth(label);
|
|
53
|
+
const endLabel = truncate(sanitizeLine(this.props.endLabel ?? ""), Math.max(0, width - labelWidth - 1));
|
|
54
|
+
const endWidth = displayWidth(endLabel);
|
|
55
|
+
const gap = 1;
|
|
56
|
+
const trackWidth = width - labelWidth - endWidth - (endLabel ? gap * 2 : gap);
|
|
57
|
+
if (trackWidth < 1) {
|
|
58
|
+
const kept = endLabel && labelWidth + gap + endWidth <= width ? `${label} ${endLabel}` : label;
|
|
59
|
+
return truncate(kept, width);
|
|
60
|
+
}
|
|
61
|
+
const track = this.renderTrack(trackWidth, known ? this.props.percent : undefined);
|
|
62
|
+
const head = this.theme.fg(known ? this.props.tone : "muted", label);
|
|
63
|
+
const tail = endLabel ? ` ${this.theme.fg("muted", endLabel)}` : "";
|
|
64
|
+
return `${head} ${track}${tail}`;
|
|
65
|
+
}
|
|
66
|
+
renderTrack(width, percent) {
|
|
67
|
+
const fillChar = this.ascii ? "=" : "━";
|
|
68
|
+
const emptyChar = this.ascii ? "-" : "─";
|
|
69
|
+
const known = percent !== undefined;
|
|
70
|
+
const filled = known
|
|
71
|
+
? Math.min(width, Math.max(0, Math.round((Math.min(100, Math.max(0, percent)) / 100) * width)))
|
|
72
|
+
: 0;
|
|
73
|
+
if (!known) {
|
|
74
|
+
return this.theme.fg("muted", emptyChar.repeat(width));
|
|
75
|
+
}
|
|
76
|
+
const cells = new Array(width);
|
|
77
|
+
for (let i = 0; i < width; i++) {
|
|
78
|
+
cells[i] = i < filled ? this.theme.fg(this.props.tone, fillChar) : this.theme.fg("muted", emptyChar);
|
|
79
|
+
}
|
|
80
|
+
const occupied = new Set();
|
|
81
|
+
for (const marker of this.props.markers ?? []) {
|
|
82
|
+
if (!Number.isFinite(marker.percent) || marker.percent < 0)
|
|
83
|
+
continue;
|
|
84
|
+
const glyph = markerGlyph(marker);
|
|
85
|
+
if (!glyph)
|
|
86
|
+
continue;
|
|
87
|
+
const column = Math.min(width - 1, Math.max(0, Math.round((Math.min(100, Math.max(0, marker.percent)) / 100) * (width - 1))));
|
|
88
|
+
if (occupied.has(column))
|
|
89
|
+
continue;
|
|
90
|
+
occupied.add(column);
|
|
91
|
+
cells[column] = this.theme.fg(marker.tone, glyph);
|
|
92
|
+
}
|
|
93
|
+
return cells.join("");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=inline-gauge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-gauge.js","sourceRoot":"","sources":["../../src/components/inline-gauge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAqBvF,SAAS,cAAc,CAAC,KAAyB;IAC/C,OAAO,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,WAAW,CAAC,MAAmB;IACtC,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC;AAED,MAAM,OAAO,WAAW;IACd,KAAK,CAAmB;IACxB,KAAK,CAAU;IACf,KAAK,CAAU;IACf,QAAQ,GAAG,CAAC,CAAC;IACb,KAAK,CAAgE;IAE7E,YAAY,KAAc,EAAE,KAAuB,EAAE,UAA8B,EAAE;QACnF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IACtC,CAAC;IAED,QAAQ,CAAC,KAAgC;QACvC,IAAI,CAAC,KAAK,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED,QAAQ,CAAC,KAAc;QACrB,IAAI,CAAC,KAAK,GA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C;QAED,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;QACnC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;YAC9C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,GAAG,CAAC;gBAAE,SAAS;YACrE,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;YAClC,IAAI,CAAC,KAAK;gBAAE,SAAS;YACrB,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9H,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC;gBAAE,SAAS;YACnC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACrB,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACpD,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Tone, UiTheme } from "../core/theme.js";
|
|
2
|
+
import { type SeparatorStyle } from "./separator.js";
|
|
3
|
+
export interface SegmentVariant {
|
|
4
|
+
text: string;
|
|
5
|
+
tone?: Tone;
|
|
6
|
+
}
|
|
7
|
+
export interface SegmentSpec {
|
|
8
|
+
id: string;
|
|
9
|
+
side: "left" | "right";
|
|
10
|
+
/** 数值越大,在压缩布局中保留得越久。 */
|
|
11
|
+
priority: number;
|
|
12
|
+
full: SegmentVariant;
|
|
13
|
+
compact?: SegmentVariant;
|
|
14
|
+
min?: SegmentVariant;
|
|
15
|
+
}
|
|
16
|
+
export interface GaugeSlot {
|
|
17
|
+
/** gauge 的最小宽度;空间不足时先牺牲其他分段。 */
|
|
18
|
+
minWidth?: number;
|
|
19
|
+
render(width: number): string;
|
|
20
|
+
}
|
|
21
|
+
export interface SegmentBarOptions {
|
|
22
|
+
width: number;
|
|
23
|
+
left?: readonly SegmentSpec[];
|
|
24
|
+
right?: readonly SegmentSpec[];
|
|
25
|
+
gauge?: GaugeSlot;
|
|
26
|
+
separator?: SeparatorStyle;
|
|
27
|
+
theme: UiTheme;
|
|
28
|
+
}
|
|
29
|
+
export interface SegmentBarWidths {
|
|
30
|
+
left: number;
|
|
31
|
+
gauge: number;
|
|
32
|
+
right: number;
|
|
33
|
+
}
|
|
34
|
+
export interface SegmentBarResult {
|
|
35
|
+
line: string;
|
|
36
|
+
left: string;
|
|
37
|
+
gauge: string;
|
|
38
|
+
right: string;
|
|
39
|
+
hiddenIds: readonly string[];
|
|
40
|
+
widths: SegmentBarWidths;
|
|
41
|
+
}
|
|
42
|
+
export declare function layoutSegmentBar(options: SegmentBarOptions): SegmentBarResult;
|
|
43
|
+
export declare class SegmentBar {
|
|
44
|
+
private theme;
|
|
45
|
+
private options;
|
|
46
|
+
private revision;
|
|
47
|
+
private cache;
|
|
48
|
+
constructor(theme: UiTheme, options: SegmentBarOptions);
|
|
49
|
+
setOptions(options: Partial<SegmentBarOptions>): void;
|
|
50
|
+
setTheme(theme: UiTheme): void;
|
|
51
|
+
invalidate(): void;
|
|
52
|
+
render(): SegmentBarResult;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=segment-bar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segment-bar.d.ts","sourceRoot":"","sources":["../../src/components/segment-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;AA6DD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAiG7E;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,KAAK,CAA6D;gBAE9D,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB;IAKtD,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAKrD,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAK9B,UAAU,IAAI,IAAI;IAKlB,MAAM,IAAI,gBAAgB;CAM3B"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { displayWidth, normalizeWidth, sanitizeLine, truncate } from "../core/ansi.js";
|
|
2
|
+
import { renderSeparator, separatorText } from "./separator.js";
|
|
3
|
+
function variantsOf(spec) {
|
|
4
|
+
const variants = [spec.full];
|
|
5
|
+
if (spec.compact)
|
|
6
|
+
variants.push(spec.compact);
|
|
7
|
+
if (spec.min)
|
|
8
|
+
variants.push(spec.min);
|
|
9
|
+
return variants;
|
|
10
|
+
}
|
|
11
|
+
function joinSpecs(entries, theme, separator) {
|
|
12
|
+
const visible = entries.filter((entry) => entry.level < entry.variants.length);
|
|
13
|
+
const sep = renderSeparator(separator, theme);
|
|
14
|
+
const sepWidth = displayWidth(separatorText(separator));
|
|
15
|
+
let text = "";
|
|
16
|
+
let width = 0;
|
|
17
|
+
visible.forEach((entry, index) => {
|
|
18
|
+
const variant = entry.variants[entry.level];
|
|
19
|
+
if (!variant)
|
|
20
|
+
return;
|
|
21
|
+
const value = sanitizeLine(variant.text).replace(/[\r\n\t]+/g, " ").trim();
|
|
22
|
+
if (index > 0) {
|
|
23
|
+
text += sep;
|
|
24
|
+
width += sepWidth;
|
|
25
|
+
}
|
|
26
|
+
text += theme.fg(variant.tone ?? "text", value);
|
|
27
|
+
width += displayWidth(value);
|
|
28
|
+
});
|
|
29
|
+
return { text, width };
|
|
30
|
+
}
|
|
31
|
+
function degradeCandidate(entries, compactOnly) {
|
|
32
|
+
let chosen;
|
|
33
|
+
for (const entry of entries) {
|
|
34
|
+
if (entry.level >= entry.variants.length)
|
|
35
|
+
continue;
|
|
36
|
+
if (compactOnly && entry.level !== 0)
|
|
37
|
+
continue;
|
|
38
|
+
if (compactOnly && entry.variants.length < 2)
|
|
39
|
+
continue;
|
|
40
|
+
if (!chosen) {
|
|
41
|
+
chosen = entry;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const priority = entry.spec.priority - chosen.spec.priority;
|
|
45
|
+
if (priority < 0) {
|
|
46
|
+
chosen = entry;
|
|
47
|
+
}
|
|
48
|
+
else if (priority === 0) {
|
|
49
|
+
const side = (entry.spec.side === "right" ? 0 : 1) - (chosen.spec.side === "right" ? 0 : 1);
|
|
50
|
+
if (side < 0 || (side === 0 && entry.order > chosen.order))
|
|
51
|
+
chosen = entry;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return chosen;
|
|
55
|
+
}
|
|
56
|
+
export function layoutSegmentBar(options) {
|
|
57
|
+
const limit = normalizeWidth(options.width);
|
|
58
|
+
const theme = options.theme;
|
|
59
|
+
const separator = options.separator ?? "none";
|
|
60
|
+
const leftSpecs = options.left ?? [];
|
|
61
|
+
const rightSpecs = options.right ?? [];
|
|
62
|
+
if (limit === 0) {
|
|
63
|
+
return {
|
|
64
|
+
line: "",
|
|
65
|
+
left: "",
|
|
66
|
+
gauge: "",
|
|
67
|
+
right: "",
|
|
68
|
+
hiddenIds: leftSpecs.concat(rightSpecs).map((spec) => spec.id),
|
|
69
|
+
widths: { left: 0, gauge: 0, right: 0 },
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const entries = [];
|
|
73
|
+
for (const spec of leftSpecs) {
|
|
74
|
+
entries.push({ spec, order: entries.length, variants: variantsOf(spec), level: 0 });
|
|
75
|
+
}
|
|
76
|
+
for (const spec of rightSpecs) {
|
|
77
|
+
entries.push({ spec, order: entries.length, variants: variantsOf(spec), level: 0 });
|
|
78
|
+
}
|
|
79
|
+
const leftEntries = entries.filter((entry) => entry.spec.side === "left");
|
|
80
|
+
const rightEntries = entries.filter((entry) => entry.spec.side === "right");
|
|
81
|
+
const gaugeMin = Math.max(0, Math.floor(options.gauge?.minWidth ?? 0));
|
|
82
|
+
let gaugeEnabled = options.gauge !== undefined;
|
|
83
|
+
let compactOnly = true;
|
|
84
|
+
const maxSteps = entries.reduce((sum, entry) => sum + entry.variants.length, 0) + 2;
|
|
85
|
+
for (let step = 0; step < maxSteps; step++) {
|
|
86
|
+
const left = joinSpecs(leftEntries, theme, separator);
|
|
87
|
+
const right = joinSpecs(rightEntries, theme, separator);
|
|
88
|
+
const gaps = gaugeEnabled ? (left.width > 0 ? 1 : 0) + (right.width > 0 ? 1 : 0) : left.width > 0 && right.width > 0 ? 1 : 0;
|
|
89
|
+
const available = limit - left.width - right.width - gaps;
|
|
90
|
+
if (gaugeEnabled && available >= gaugeMin) {
|
|
91
|
+
const gaugeText = options.gauge ? options.gauge.render(available) : "";
|
|
92
|
+
const line = `${left.text}${left.width > 0 ? " " : ""}${gaugeText}${right.width > 0 ? " " : ""}${right.text}`;
|
|
93
|
+
return {
|
|
94
|
+
line: truncate(line, limit),
|
|
95
|
+
left: left.text,
|
|
96
|
+
gauge: gaugeText,
|
|
97
|
+
right: right.text,
|
|
98
|
+
hiddenIds: entries.filter((entry) => entry.level >= entry.variants.length).map((entry) => entry.spec.id),
|
|
99
|
+
widths: { left: left.width, gauge: displayWidth(gaugeText), right: right.width },
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (!gaugeEnabled && available >= 0) {
|
|
103
|
+
const line = right.width > 0 ? `${left.text} ${right.text}` : left.text;
|
|
104
|
+
return {
|
|
105
|
+
line: truncate(line, limit),
|
|
106
|
+
left: left.text,
|
|
107
|
+
gauge: "",
|
|
108
|
+
right: right.text,
|
|
109
|
+
hiddenIds: entries.filter((entry) => entry.level >= entry.variants.length).map((entry) => entry.spec.id),
|
|
110
|
+
widths: { left: left.width, gauge: 0, right: right.width },
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const candidate = degradeCandidate(entries, compactOnly);
|
|
114
|
+
if (candidate) {
|
|
115
|
+
candidate.level++;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (compactOnly) {
|
|
119
|
+
compactOnly = false;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (gaugeEnabled) {
|
|
123
|
+
gaugeEnabled = false;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const line = right.width > 0 ? `${left.text} ${right.text}` : left.text;
|
|
127
|
+
return {
|
|
128
|
+
line: truncate(line, limit),
|
|
129
|
+
left: left.text,
|
|
130
|
+
gauge: "",
|
|
131
|
+
right: right.text,
|
|
132
|
+
hiddenIds: entries.filter((entry) => entry.level >= entry.variants.length).map((entry) => entry.spec.id),
|
|
133
|
+
widths: { left: left.width, gauge: 0, right: right.width },
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const left = joinSpecs(leftEntries, theme, separator);
|
|
137
|
+
const right = joinSpecs(rightEntries, theme, separator);
|
|
138
|
+
return {
|
|
139
|
+
line: truncate(left.text + right.text, limit),
|
|
140
|
+
left: left.text,
|
|
141
|
+
gauge: "",
|
|
142
|
+
right: right.text,
|
|
143
|
+
hiddenIds: entries.filter((entry) => entry.level >= entry.variants.length).map((entry) => entry.spec.id),
|
|
144
|
+
widths: { left: left.width, gauge: 0, right: right.width },
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export class SegmentBar {
|
|
148
|
+
theme;
|
|
149
|
+
options;
|
|
150
|
+
revision = 0;
|
|
151
|
+
cache;
|
|
152
|
+
constructor(theme, options) {
|
|
153
|
+
this.theme = theme;
|
|
154
|
+
this.options = options;
|
|
155
|
+
}
|
|
156
|
+
setOptions(options) {
|
|
157
|
+
this.options = { ...this.options, ...options };
|
|
158
|
+
this.invalidate();
|
|
159
|
+
}
|
|
160
|
+
setTheme(theme) {
|
|
161
|
+
this.theme = theme;
|
|
162
|
+
this.invalidate();
|
|
163
|
+
}
|
|
164
|
+
invalidate() {
|
|
165
|
+
this.revision++;
|
|
166
|
+
this.cache = undefined;
|
|
167
|
+
}
|
|
168
|
+
render() {
|
|
169
|
+
if (this.cache && this.cache.revision === this.revision)
|
|
170
|
+
return this.cache.result;
|
|
171
|
+
const result = layoutSegmentBar({ ...this.options, theme: this.theme });
|
|
172
|
+
this.cache = { revision: this.revision, result };
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=segment-bar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segment-bar.js","sourceRoot":"","sources":["../../src/components/segment-bar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEvF,OAAO,EAAE,eAAe,EAAE,aAAa,EAAuB,MAAM,gBAAgB,CAAC;AAsDrF,SAAS,UAAU,CAAC,IAAiB;IACnC,MAAM,QAAQ,GAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/C,IAAI,IAAI,CAAC,OAAO;QAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,IAAI,CAAC,GAAG;QAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,SAAS,CAChB,OAAyB,EACzB,KAAc,EACd,SAAyB;IAEzB,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAA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AAC;IACpB,CAAC;IAED,UAAU;QACR,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QAClF,MAAM,MAAM,GAAG,gBAAgB,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,KAAK,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QACjD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Tone, UiTheme } from "../core/theme.js";
|
|
2
|
+
export type SeparatorStyle = "ascii" | "pipe" | "slash" | "dot" | "none";
|
|
3
|
+
export declare function separatorText(style: SeparatorStyle): string;
|
|
4
|
+
export declare function renderSeparator(style: SeparatorStyle, theme: UiTheme, tone?: Tone): string;
|
|
5
|
+
//# sourceMappingURL=separator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"separator.d.ts","sourceRoot":"","sources":["../../src/components/separator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEtD,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAUzE,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAE3D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,GAAE,IAAc,GAAG,MAAM,CAGnG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { sanitizeLine } from "../core/ansi.js";
|
|
2
|
+
const SEPARATOR_TEXT = {
|
|
3
|
+
ascii: " > ",
|
|
4
|
+
pipe: " | ",
|
|
5
|
+
slash: " / ",
|
|
6
|
+
dot: " · ",
|
|
7
|
+
none: "",
|
|
8
|
+
};
|
|
9
|
+
export function separatorText(style) {
|
|
10
|
+
return SEPARATOR_TEXT[style] ?? "";
|
|
11
|
+
}
|
|
12
|
+
export function renderSeparator(style, theme, tone = "muted") {
|
|
13
|
+
const text = sanitizeLine(separatorText(style));
|
|
14
|
+
return text.length === 0 ? "" : theme.fg(tone, text);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=separator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"separator.js","sourceRoot":"","sources":["../../src/components/separator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAK/C,MAAM,cAAc,GAA6C;IAC/D,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,KAAK;IACZ,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,EAAE;CACT,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,KAAqB;IACjD,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAqB,EAAE,KAAc,EAAE,OAAa,OAAO;IACzF,MAAM,IAAI,GAAG,YAAY,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACvD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export { fromPiTheme, plainTheme, TONE_TO_TOKEN, type ThemeLike, type Tone, type
|
|
|
3
3
|
export { BORDERS, fitLine, joinSides, renderChildLines, rule, type BorderChars, type BorderStyle, type Renderable, } from "./core/layout.js";
|
|
4
4
|
export { Panel, type PanelProps } from "./components/panel.js";
|
|
5
5
|
export { StatusLine, type StatusLineProps } from "./components/status-line.js";
|
|
6
|
+
export { layoutSegmentBar, SegmentBar, type GaugeSlot, type SegmentBarOptions, type SegmentBarResult, type SegmentBarWidths, type SegmentSpec, type SegmentVariant, } from "./components/segment-bar.js";
|
|
7
|
+
export { renderSeparator, separatorText, type SeparatorStyle } from "./components/separator.js";
|
|
8
|
+
export { InlineGauge, type GaugeMarker, type InlineGaugeOptions, type InlineGaugeProps, } from "./components/inline-gauge.js";
|
|
6
9
|
export { CodeFrame, type CodeFrameProps } from "./components/code-frame.js";
|
|
7
10
|
export { TreeList, type TreeNode, type TreeListProps } from "./components/tree-list.js";
|
|
8
11
|
export { adaptHashlineDetails, type AdaptOptions } from "./diff/adapter.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC/H,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,IAAI,EAAE,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAClH,OAAO,EACL,OAAO,EACP,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,IAAI,EACJ,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC/D,O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B,GACvB,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,9 @@ export { fromPiTheme, plainTheme, TONE_TO_TOKEN } from "./core/theme.js";
|
|
|
3
3
|
export { BORDERS, fitLine, joinSides, renderChildLines, rule, } from "./core/layout.js";
|
|
4
4
|
export { Panel } from "./components/panel.js";
|
|
5
5
|
export { StatusLine } from "./components/status-line.js";
|
|
6
|
+
export { layoutSegmentBar, SegmentBar, } from "./components/segment-bar.js";
|
|
7
|
+
export { renderSeparator, separatorText } from "./components/separator.js";
|
|
8
|
+
export { InlineGauge, } from "./components/inline-gauge.js";
|
|
6
9
|
export { CodeFrame } from "./components/code-frame.js";
|
|
7
10
|
export { TreeList } from "./components/tree-list.js";
|
|
8
11
|
export { adaptHashlineDetails } from "./diff/adapter.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC/H,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAA2C,MAAM,iBAAiB,CAAC;AAClH,OAAO,EACL,OAAO,EACP,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,IAAI,GAIL,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAmB,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAwB,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAuB,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAqC,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,oBAAoB,EAAqB,MAAM,mBAAmB,CAAC;AAW5E,OAAO,EAAE,QAAQ,EAAsB,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EACL,QAAQ,GAMT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,YAAY,GAMb,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC/H,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAA2C,MAAM,iBAAiB,CAAC;AAClH,OAAO,EACL,OAAO,EACP,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,IAAI,GAIL,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAmB,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAwB,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EACL,gBAAgB,EAChB,UAAU,GAOX,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAuB,MAAM,2BAA2B,CAAC;AAChG,OAAO,EACL,WAAW,GAIZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAuB,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAqC,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,oBAAoB,EAAqB,MAAM,mBAAmB,CAAC;AAW5E,OAAO,EAAE,QAAQ,EAAsB,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EACL,QAAQ,GAMT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,YAAY,GAMb,MAAM,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jackice/pi-ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Terminal UI components for Pi extensions: theme mapping, ANSI-safe layout, panels, status lines, diff frames, Edit/TODO/Approval views.",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Terminal UI components for Pi extensions: theme mapping, ANSI-safe layout, panels, status lines, segment bars, gauges, diff frames, Edit/TODO/Approval views.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "jackice",
|