@cmodjs/core 8.8.4 → 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 +40 -4
- package/runtime/interfaces.d.ts +1 -1
- package/runtime/interfaces.d.ts.map +1 -1
- package/runtime/interfaces.js +1 -1
- 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 +9 -4
- package/src/records.ts +12 -4
- package/src/register.ts +1 -0
- package/src/runtime/claude.ts +2 -0
- package/src/runtime/conversations.ts +37 -4
- package/src/runtime/interfaces.ts +1 -1
- package/src/runtime/lifecycle.ts +10 -2
- package/src/runtime/sessions.ts +1 -1
- package/src/runtime/web.ts +9 -4
- package/src/testing/fake-claude.ts +1 -0
- package/src/ui/components.ts +50 -15
- 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 +6 -1
- package/ui/components.d.ts.map +1 -1
- package/ui/components.js +43 -12
- package/ui/elements.d.ts +5 -1
- package/ui/elements.d.ts.map +1 -1
- package/ui/elements.js +10 -3
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');
|