@cmodjs/core 8.8.3 → 8.9.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/docs/commands.md +27 -7
- package/docs/ui.md +2 -2
- package/package.json +1 -1
- package/records.d.ts +8 -1
- package/records.d.ts.map +1 -1
- package/records.js +7 -3
- package/register.d.ts.map +1 -1
- package/register.js +1 -0
- package/runtime/claude.d.ts +2 -0
- package/runtime/claude.d.ts.map +1 -1
- package/runtime/conversations.d.ts.map +1 -1
- package/runtime/conversations.js +48 -4
- package/runtime/interfaces.d.ts +1 -1
- package/runtime/interfaces.d.ts.map +1 -1
- package/runtime/interfaces.js +23 -4
- package/runtime/lifecycle.d.ts.map +1 -1
- package/runtime/lifecycle.js +9 -2
- package/runtime/sessions.d.ts +1 -1
- package/runtime/sessions.d.ts.map +1 -1
- package/runtime/sessions.js +1 -1
- package/runtime/web.js +12 -1
- package/runtime/widgets.js +6 -6
- package/src/records.ts +12 -4
- package/src/register.ts +1 -0
- package/src/runtime/claude.ts +2 -0
- package/src/runtime/conversations.ts +43 -4
- package/src/runtime/interfaces.ts +19 -3
- package/src/runtime/lifecycle.ts +10 -2
- package/src/runtime/sessions.ts +1 -1
- package/src/runtime/web.ts +11 -1
- package/src/runtime/widgets.ts +6 -6
- package/src/testing/fake-claude.ts +1 -0
- package/src/ui/components.ts +64 -5
- package/src/ui/elements.ts +16 -4
- package/testing/fake-claude.d.ts.map +1 -1
- package/testing/fake-claude.js +1 -0
- package/ui/components.d.ts +16 -2
- package/ui/components.d.ts.map +1 -1
- package/ui/components.js +52 -4
- package/ui/elements.d.ts +5 -1
- package/ui/elements.d.ts.map +1 -1
- package/ui/elements.js +10 -3
package/ui/components.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Color } from './elements.js';
|
|
1
2
|
export type Tab = {
|
|
2
3
|
readonly key: string;
|
|
3
4
|
readonly label: string;
|
|
@@ -45,11 +46,24 @@ export declare const Pagination: (props: {
|
|
|
45
46
|
readonly pages: number;
|
|
46
47
|
readonly onPage: (page: number) => void;
|
|
47
48
|
}) => JSX.Element;
|
|
48
|
-
export
|
|
49
|
+
export type ProgressSection = {
|
|
49
50
|
readonly value: number;
|
|
51
|
+
} & ({
|
|
52
|
+
readonly tone?: Tone;
|
|
53
|
+
} | {
|
|
54
|
+
readonly color: Color;
|
|
55
|
+
});
|
|
56
|
+
type ProgressProps = ({
|
|
57
|
+
readonly value: number;
|
|
58
|
+
readonly tone?: Tone;
|
|
59
|
+
} | {
|
|
60
|
+
readonly sections: readonly ProgressSection[];
|
|
61
|
+
}) & {
|
|
62
|
+
readonly buffer?: number;
|
|
50
63
|
readonly width?: number;
|
|
51
64
|
readonly label?: string;
|
|
52
|
-
}
|
|
65
|
+
};
|
|
66
|
+
export declare const Progress: (props: ProgressProps) => JSX.Element;
|
|
53
67
|
export declare const List: (props: {
|
|
54
68
|
readonly label: string;
|
|
55
69
|
readonly children?: JSX.Children;
|
package/ui/components.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/ui/components.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/ui/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6C,KAAK,KAAK,EAAE,MAAM,eAAe,CAAA;AAErF,MAAM,MAAM,GAAG,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE5F,MAAM,MAAM,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAA;AAE1E,KAAK,OAAO,GAAG,MAAM,IAAI,CAAA;AASzB,eAAO,MAAM,IAAI;mBAE2C,SAAS,GAAG,EA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AAC,QAAQ;iBAEzF,CAAA;AAOD,eAAO,MAAM,MAAM;oBAE+C,IAAI;qBAAmB,MAAM;wBAAsB,GAAG,CAAC,QAAQ;uBAAqB,GAAG,CAAC,QAAQ;iBAUjK,CAAA"}
|
package/ui/components.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Box, Button, hostComponent, Text } from './elements.js';
|
|
1
|
+
import { Box, Button, drawnIn, hostComponent, Text } from './elements.js';
|
|
2
2
|
const toneColors = { neutral: undefined, info: 'suggestion', success: 'success', warning: 'warning', critical: 'error' };
|
|
3
3
|
const textOf = (tone) => {
|
|
4
4
|
const color = toneColors[tone];
|
|
@@ -59,10 +59,58 @@ export const Pagination = hostComponent('Pagination', ({ page, pages, onPage })
|
|
|
59
59
|
onNext === undefined ? Text({ dimColor: true, children: 'n: Next' }) : Button({ plain: true, hotkey: 'n', label: 'Next', onPress: onNext }),
|
|
60
60
|
],
|
|
61
61
|
}));
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const eighths = ['', '▏', '▎', '▍', '▌', '▋', '▊', '▉'];
|
|
63
|
+
const roundedLeft = '\u{E0B6}';
|
|
64
|
+
const roundedRight = '\u{E0B4}';
|
|
65
|
+
const barColors = { neutral: 'inactive', info: 'suggestion', success: 'success', warning: 'warning', critical: 'error' };
|
|
66
|
+
function filledSections(sections) {
|
|
67
|
+
let reached = 0;
|
|
68
|
+
return sections.map((section) => {
|
|
69
|
+
const filled = Math.min(Math.max(section.value, 0), 100 - reached);
|
|
70
|
+
reached += filled;
|
|
71
|
+
return { ...section, value: filled };
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export const Progress = hostComponent('Progress', ({ width = 24, label, buffer, ...given }) => {
|
|
75
|
+
const sections = 'sections' in given ? filledSections(given.sections) : given.tone === undefined ? undefined : filledSections([given]);
|
|
76
|
+
const value = sections === undefined && 'value' in given ? Math.min(Math.max(given.value, 0), 100) : (sections ?? []).reduce((sum, each) => sum + each.value, 0);
|
|
77
|
+
const buffered = buffer === undefined ? undefined : Math.min(Math.max(buffer, value), 100);
|
|
78
|
+
return { value, width, ...(label === undefined ? {} : { label }), ...(sections === undefined ? {} : { sections }), ...(buffered === undefined || buffered === value ? {} : { buffer: buffered }) };
|
|
79
|
+
}, ({ value, width, sections, buffer }) => {
|
|
80
|
+
const isRounded = drawnIn().hasNerdFont && width > 2;
|
|
81
|
+
const cells = isRounded ? width - 2 : width;
|
|
82
|
+
const units = cells * eighths.length;
|
|
83
|
+
let reached = 0;
|
|
84
|
+
const ends = (sections ?? [{ value }]).map((section) => {
|
|
85
|
+
reached += section.value;
|
|
86
|
+
return { end: Math.round((reached / 100) * units), color: 'color' in section ? section.color : section.tone === undefined ? 'claude' : barColors[section.tone] };
|
|
87
|
+
});
|
|
88
|
+
const buffered = Math.round(((buffer ?? 0) / 100) * units);
|
|
89
|
+
const colorAt = (unit) => ends.find(({ end }) => unit < end)?.color ?? (unit < buffered ? 'promptBorder' : 'subtle');
|
|
90
|
+
const drawn = [];
|
|
91
|
+
for (let cell = 0; cell < cells; cell++) {
|
|
92
|
+
const from = cell * eighths.length;
|
|
93
|
+
const left = colorAt(from);
|
|
94
|
+
const right = colorAt(from + eighths.length - 1);
|
|
95
|
+
let edge = 1;
|
|
96
|
+
while (edge < eighths.length && colorAt(from + edge) === left)
|
|
97
|
+
edge++;
|
|
98
|
+
drawn.push(left === right ? { color: left, children: '█' } : { color: left, backgroundColor: right, children: eighths[edge] ?? '█' });
|
|
99
|
+
}
|
|
100
|
+
const capped = isRounded ? [{ color: colorAt(0), children: roundedLeft }, ...drawn, { color: colorAt(units - 1), children: roundedRight }] : drawn;
|
|
101
|
+
return Text({ children: runsOf(capped).map((run) => Text(run)) });
|
|
65
102
|
});
|
|
103
|
+
function runsOf(cells) {
|
|
104
|
+
const runs = [];
|
|
105
|
+
for (const cell of cells) {
|
|
106
|
+
const last = runs.at(-1);
|
|
107
|
+
if (last !== undefined && last.color === cell.color && last.backgroundColor === cell.backgroundColor && last.children !== roundedLeft && cell.children !== roundedRight)
|
|
108
|
+
last.children += cell.children;
|
|
109
|
+
else
|
|
110
|
+
runs.push({ ...cell });
|
|
111
|
+
}
|
|
112
|
+
return runs;
|
|
113
|
+
}
|
|
66
114
|
export const List = hostComponent('List', ({ label, children }) => ({ label, ...(children === undefined ? {} : { children }) }), ({ children }) => Box({ flexDirection: 'column', children }));
|
|
67
115
|
const statusOf = (tone) => (tone === undefined ? [] : [tone === 'off' ? Text({ dimColor: true, children: '○ ' }) : Text({ ...textOf(tone), children: '● ' })]);
|
|
68
116
|
function treeRow({ key, label, description, leading, trailing, tone, isSelected, depth = 0, isOpen, onToggle, onPress }) {
|
package/ui/elements.d.ts
CHANGED
|
@@ -27,6 +27,10 @@ export type ButtonProps = Omit<ClaudeButtonProps, 'onPress'> & ({
|
|
|
27
27
|
readonly href: string;
|
|
28
28
|
readonly onPress?: never;
|
|
29
29
|
});
|
|
30
|
+
export type DrawnIn = {
|
|
31
|
+
readonly hasNerdFont: boolean;
|
|
32
|
+
};
|
|
33
|
+
export declare function drawnIn(): DrawnIn;
|
|
30
34
|
export declare function hostComponent<Props extends object, Canonical extends object>(name: string, canonical: (props: Props) => Canonical, lower: (props: Canonical) => JSX.Element): (props: Props) => JSX.Element;
|
|
31
35
|
export declare function drawWith<Drawn>(table: ElementTable, draw: () => Drawn, markdown?: (props: MarkdownProps) => RenderElement): Drawn;
|
|
32
36
|
export declare function drawKeyed<Drawn>(keyPrefix: string, draw: () => Drawn): Drawn;
|
|
@@ -34,7 +38,7 @@ export type Handler = (...args: unknown[]) => unknown;
|
|
|
34
38
|
export declare function elementData(value: unknown, numberOf: (run: Handler) => number): unknown;
|
|
35
39
|
export declare function elementOf(data: unknown, keyPrefix: string, press: (handler: number, args: readonly unknown[]) => void): unknown;
|
|
36
40
|
export declare function drawsFocusable(data: unknown, key: string): boolean;
|
|
37
|
-
export declare function forClaudeCode(table: ElementTable, surface: RenderSurface, open: (href: string, press: UiPressArgument) => void): ElementTable;
|
|
41
|
+
export declare function forClaudeCode(table: ElementTable, surface: RenderSurface, open: (href: string, press: UiPressArgument) => void, { hasNerdFont }?: DrawnIn): ElementTable;
|
|
38
42
|
export declare const Box: ElementConstructor<ClaudeBoxProps>;
|
|
39
43
|
export declare const Text: ElementConstructor<ClaudeTextProps>;
|
|
40
44
|
export declare const Button: ElementConstructor<ButtonProps>;
|
package/ui/elements.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../src/ui/elements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,IAAI,cAAc,EAC1B,WAAW,IAAI,iBAAiB,EAChC,WAAW,IAAI,iBAAiB,EAChC,SAAS,IAAI,eAAe,EAC5B,KAAK,IAAI,WAAW,EACpB,kBAAkB,EAElB,YAAY,EAEZ,UAAU,IAAI,gBAAgB,EAC9B,UAAU,IAAI,gBAAgB,EAC9B,aAAa,IAAI,mBAAmB,EACpC,WAAW,IAAI,iBAAiB,EAChC,aAAa,EACb,aAAa,EACb,WAAW,IAAI,iBAAiB,EAChC,QAAQ,IAAI,cAAc,EAC1B,SAAS,IAAI,eAAe,EAC5B,eAAe,EAChB,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAExC,MAAM,MAAM,QAAQ,GAAG,cAAc,CAAA;AACrC,MAAM,MAAM,SAAS,GAAG,eAAe,CAAA;AACvC,MAAM,MAAM,SAAS,GAAG,eAAe,CAAA;AACvC,MAAM,MAAM,aAAa,GAAG,mBAAmB,CAAA;AAC/C,MAAM,MAAM,UAAU,GAAG,gBAAgB,CAAA;AACzC,MAAM,MAAM,WAAW,GAAG,iBAAiB,CAAA;AAC3C,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;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,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,KAAK,IAAI,EAAE,EAAE,WAAW,EAAE,GAAE,OAAuB,GAAG,YAAY,CAiBvL;AAED,eAAO,MAAM,GAAG,oCAAiB,CAAA;AACjC,eAAO,MAAM,IAAI,qCAAkB,CAAA;AACnC,eAAO,MAAM,MAAM,EAAmC,kBAAkB,CAAC,WAAW,CAAC,CAAA;AAErF,eAAO,MAAM,IAAI,qCAAkB,CAAA;AACnC,eAAO,MAAM,QAAQ,yCAAsB,CAAA;AAC3C,eAAO,MAAM,KAAK,sCAAmB,CAAA;AACrC,eAAO,MAAM,MAAM,uCAAoB,CAAA;AACvC,eAAO,MAAM,KAAK,EAAkC,kBAAkB,CAAC,UAAU,CAAC,CAAA;AAClF,eAAO,MAAM,GAAG,EAAgC,kBAAkB,CAAC,QAAQ,CAAC,CAAA;AAC5E,eAAO,MAAM,MAAM,EAAmC,kBAAkB,CAAC,WAAW,CAAC,CAAA;AACrF,eAAO,MAAM,MAAM,uCAAoB,CAAA"}
|
package/ui/elements.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
const tableFacts = new WeakMap();
|
|
2
|
+
const plainTerminal = { hasNerdFont: false };
|
|
3
|
+
export function drawnIn() {
|
|
4
|
+
return drawing?.drawnIn ?? plainTerminal;
|
|
5
|
+
}
|
|
1
6
|
const unbuilt = Symbol('an element built outside a render');
|
|
2
7
|
let drawing;
|
|
3
8
|
const lowerings = new Map();
|
|
@@ -10,7 +15,7 @@ function elementNamed(name, props) {
|
|
|
10
15
|
}
|
|
11
16
|
export function drawWith(table, draw, markdown) {
|
|
12
17
|
const outer = drawing;
|
|
13
|
-
const current = { table: table, markdown };
|
|
18
|
+
const current = { table: table, markdown, drawnIn: tableFacts.get(table) ?? plainTerminal };
|
|
14
19
|
drawing = current;
|
|
15
20
|
try {
|
|
16
21
|
return built(current, draw());
|
|
@@ -108,7 +113,7 @@ export function drawsFocusable(data, key) {
|
|
|
108
113
|
return true;
|
|
109
114
|
return Object.values(fields).some((each) => drawsFocusable(each, key));
|
|
110
115
|
}
|
|
111
|
-
export function forClaudeCode(table, surface, open) {
|
|
116
|
+
export function forClaudeCode(table, surface, open, { hasNerdFont } = plainTerminal) {
|
|
112
117
|
const { Button: button, Link: link, Image: image, Svg: svg, Raster: raster } = table;
|
|
113
118
|
const opening = (props) => {
|
|
114
119
|
const { href, ...rest } = props;
|
|
@@ -121,7 +126,9 @@ export function forClaudeCode(table, surface, open) {
|
|
|
121
126
|
return button({ ...rest, onPress: (press) => open(href, press) });
|
|
122
127
|
};
|
|
123
128
|
const named = (draw) => ({ label, ...rest }) => draw({ alt: label, ...rest });
|
|
124
|
-
|
|
129
|
+
const resolved = { ...table, Button: opening, Image: named(image), Svg: named(svg), Raster: ({ label, ...rest }) => raster(rest) };
|
|
130
|
+
tableFacts.set(resolved, { hasNerdFont: hasNerdFont && surface === 'terminal' });
|
|
131
|
+
return resolved;
|
|
125
132
|
}
|
|
126
133
|
export const Box = element('Box');
|
|
127
134
|
export const Text = element('Text');
|