@locusgraph/loop 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/README.md +2 -0
- package/dist/agent/pulse/gradient-label.js +36 -15
- package/dist/agent/pulse/marks/bars-mark.js +24 -10
- package/dist/agent/pulse/marks/glyph-mark.js +17 -11
- package/dist/agent/pulse/marks/locus-mark.js +39 -28
- package/dist/agent/pulse/marks/orb-mark.js +21 -8
- package/dist/agent/pulse/marks/spinner-mark.js +20 -1
- package/dist/agent/pulse/pulse.js +63 -35
- package/dist/agent/pulse/use-loop-animation.js +14 -16
- package/dist/agent/steps/step-icon.js +40 -24
- package/dist/agent/steps/steps.js +72 -25
- package/dist/agent/thinking/thinking.js +203 -23
- package/dist/agent/thinking/thought-duration.js +7 -9
- package/dist/agent/tool/json-block.js +18 -11
- package/dist/agent/tool/tool-status.js +28 -18
- package/dist/agent/tool/tool.js +184 -6
- package/dist/approval/inbox/inbox-row.d.ts +3 -2
- package/dist/approval/inbox/inbox-row.js +96 -7
- package/dist/approval/inbox/inbox-selection.js +7 -13
- package/dist/approval/inbox/inbox.d.ts +2 -1
- package/dist/approval/inbox/inbox.js +99 -18
- package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
- package/dist/approval/inbox/virtual-inbox-list.js +53 -0
- package/dist/approval/memory/memory-choices.js +27 -22
- package/dist/approval/memory/memory-review.js +108 -17
- package/dist/approval/memory/memory-row.js +80 -19
- package/dist/approval/plan/plan-review.js +129 -28
- package/dist/approval/plan/plan-step-row.js +91 -44
- package/dist/approval/plan/plan-steps.js +24 -23
- package/dist/approval/plan/question-choices.js +73 -40
- package/dist/approval/plan/question.d.ts +1 -1
- package/dist/approval/plan/question.js +108 -27
- package/dist/approval/run/run-bar.js +94 -22
- package/dist/approval/shared/decision-line.js +1 -1
- package/dist/approval/shared/risk-badge.js +32 -16
- package/dist/approval/shared/time.js +5 -8
- package/dist/approval/shared/use-focus-on-mount.js +7 -6
- package/dist/approval/spend/raise-cap-form.js +64 -19
- package/dist/approval/spend/spend-gate.js +124 -21
- package/dist/approval/spend/spend-math.js +7 -8
- package/dist/approval/spend/spend-meter.js +136 -35
- package/dist/approval/tool/approval.js +113 -27
- package/dist/approval/tool/args/args-editor.js +104 -26
- package/dist/approval/tool/args/args-field.js +79 -22
- package/dist/approval/tool/args/args-validation.js +38 -47
- package/dist/approval/tool/deny-form.js +43 -10
- package/dist/approval/tool/tool-inputs.js +62 -38
- package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
- package/dist/chat/chat/chat-item-spacing.js +19 -0
- package/dist/chat/chat/chat.d.ts +2 -1
- package/dist/chat/chat/chat.js +181 -5
- package/dist/chat/chat/use-stick-to-bottom.js +71 -48
- package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
- package/dist/chat/chat/virtual-chat-items.js +60 -0
- package/dist/chat/composer/composer-actions.js +69 -17
- package/dist/chat/composer/composer.js +330 -32
- package/dist/chat/composer/use-auto-grow.js +9 -9
- package/dist/chat/files/file-meta.js +19 -19
- package/dist/chat/files/files.js +92 -29
- package/dist/chat/reply/fenced-code.js +23 -21
- package/dist/chat/reply/markdown-components.js +137 -17
- package/dist/chat/reply/reply.js +30 -10
- package/dist/chat/turn/group-parts.js +43 -29
- package/dist/chat/turn/turn.js +87 -30
- package/dist/cost/context.js +104 -23
- package/dist/cost/cost-steps.js +67 -14
- package/dist/cost/cost.js +128 -23
- package/dist/cost/model-picker.js +51 -6
- package/dist/cost/shared/context-breakdown.js +83 -10
- package/dist/cost/shared/meter-marks.js +49 -9
- package/dist/cost/shared/model-option-row.js +56 -22
- package/dist/cost/shared/step-cost-row.js +65 -22
- package/dist/cost/shared/usage-totals.js +22 -18
- package/dist/memory/cite.js +62 -12
- package/dist/memory/memorized.js +65 -11
- package/dist/memory/recall.js +101 -17
- package/dist/memory/shared/host-label.js +19 -22
- package/dist/memory/shared/source-mark.js +11 -3
- package/dist/memory/sources.js +78 -14
- package/dist/shared/decision-summary.js +51 -14
- package/dist/shared/panel-empty.js +20 -3
- package/dist/shared/panel.js +69 -13
- package/dist/shared/status-dot.js +16 -8
- package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
- package/dist/shared/virtual/use-list-virtualizer.js +68 -0
- package/dist/thread/actions/action-button.js +22 -3
- package/dist/thread/actions/actions.js +184 -13
- package/dist/thread/actions/branch-switcher.js +28 -5
- package/dist/thread/canvas/canvas.js +205 -5
- package/dist/thread/canvas/version-switcher.js +54 -8
- package/dist/thread/code/code.js +186 -24
- package/dist/thread/code/copy-code-button.js +30 -14
- package/dist/thread/code/highlight.js +30 -29
- package/dist/thread/history/history-rows.d.ts +16 -0
- package/dist/thread/history/history-rows.js +23 -0
- package/dist/thread/history/history.d.ts +3 -2
- package/dist/thread/history/history.js +174 -5
- package/dist/thread/history/{history-row.d.ts → row/history-row.d.ts} +3 -2
- package/dist/thread/history/row/history-row.js +58 -0
- package/dist/thread/history/row/thread-item-menu.js +31 -0
- package/dist/thread/history/row/thread-title-editor.js +38 -0
- package/dist/thread/history/thread-groups.d.ts +1 -1
- package/dist/thread/history/thread-groups.js +40 -34
- package/dist/thread/history/virtual-history-list.d.ts +11 -0
- package/dist/thread/history/virtual-history-list.js +71 -0
- package/dist/thread/index.d.ts +1 -1
- package/dist/thread/starters/starters.js +33 -8
- package/dist/thread/use-copied.js +18 -16
- package/dist/types.js +1 -1
- package/package.json +6 -4
- package/dist/thread/history/history-row.js +0 -17
- package/dist/thread/history/thread-item-menu.js +0 -6
- package/dist/thread/history/thread-title-editor.js +0 -25
- /package/dist/thread/history/{thread-item-menu.d.ts → row/thread-item-menu.d.ts} +0 -0
- /package/dist/thread/history/{thread-title-editor.d.ts → row/thread-title-editor.d.ts} +0 -0
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ChevronLeft as ChevronLeftIcon, ChevronRight as ChevronRightIcon, } from "@carbon/icons-react";
|
|
1
|
+
import { ChevronLeft as ChevronLeftIcon, ChevronRight as ChevronRightIcon } from "@carbon/icons-react";
|
|
3
2
|
import { ActionButton } from "./action-button.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
export function BranchSwitcher({
|
|
5
|
+
branch,
|
|
6
|
+
onBranchChange
|
|
7
|
+
}) {
|
|
8
|
+
const position = branch.index + 1;
|
|
9
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
10
|
+
"data-slot": "branch-switcher",
|
|
11
|
+
role: "group",
|
|
12
|
+
"aria-label": "Reply versions",
|
|
13
|
+
className: "flex items-center",
|
|
14
|
+
children: [/*#__PURE__*/_jsx(ActionButton, {
|
|
15
|
+
label: "Previous version",
|
|
16
|
+
disabled: branch.index <= 0,
|
|
17
|
+
onClick: () => onBranchChange(branch.index - 1),
|
|
18
|
+
children: /*#__PURE__*/_jsx(ChevronLeftIcon, {})
|
|
19
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
20
|
+
"aria-live": "polite",
|
|
21
|
+
className: "min-w-9 text-center font-mono text-xs text-muted-foreground tabular-nums",
|
|
22
|
+
children: `${position} / ${branch.count}`
|
|
23
|
+
}), /*#__PURE__*/_jsx(ActionButton, {
|
|
24
|
+
label: "Next version",
|
|
25
|
+
disabled: position >= branch.count,
|
|
26
|
+
onClick: () => onBranchChange(branch.index + 1),
|
|
27
|
+
children: /*#__PURE__*/_jsx(ChevronRightIcon, {})
|
|
28
|
+
})]
|
|
29
|
+
});
|
|
7
30
|
}
|
|
@@ -1,12 +1,212 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
4
|
import { Close as XIcon } from "@carbon/icons-react";
|
|
4
5
|
import { Button, cn, ScrollArea } from "@locusgraph/components";
|
|
5
6
|
import { VersionSwitcher } from "./version-switcher.js";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
8
|
function currentVersionOf(versions, versionId) {
|
|
7
|
-
|
|
9
|
+
return versions.find(version => version.id === versionId) ?? versions.at(-1);
|
|
8
10
|
}
|
|
9
|
-
export function Canvas(
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
export function Canvas(t0) {
|
|
12
|
+
const $ = _c(46);
|
|
13
|
+
let actions;
|
|
14
|
+
let children;
|
|
15
|
+
let className;
|
|
16
|
+
let kind;
|
|
17
|
+
let onClose;
|
|
18
|
+
let onVersionChange;
|
|
19
|
+
let props;
|
|
20
|
+
let t1;
|
|
21
|
+
let title;
|
|
22
|
+
let versionId;
|
|
23
|
+
if ($[0] !== t0) {
|
|
24
|
+
({
|
|
25
|
+
title,
|
|
26
|
+
kind,
|
|
27
|
+
versions: t1,
|
|
28
|
+
versionId,
|
|
29
|
+
onVersionChange,
|
|
30
|
+
actions,
|
|
31
|
+
onClose,
|
|
32
|
+
children,
|
|
33
|
+
className,
|
|
34
|
+
...props
|
|
35
|
+
} = t0);
|
|
36
|
+
$[0] = t0;
|
|
37
|
+
$[1] = actions;
|
|
38
|
+
$[2] = children;
|
|
39
|
+
$[3] = className;
|
|
40
|
+
$[4] = kind;
|
|
41
|
+
$[5] = onClose;
|
|
42
|
+
$[6] = onVersionChange;
|
|
43
|
+
$[7] = props;
|
|
44
|
+
$[8] = t1;
|
|
45
|
+
$[9] = title;
|
|
46
|
+
$[10] = versionId;
|
|
47
|
+
} else {
|
|
48
|
+
actions = $[1];
|
|
49
|
+
children = $[2];
|
|
50
|
+
className = $[3];
|
|
51
|
+
kind = $[4];
|
|
52
|
+
onClose = $[5];
|
|
53
|
+
onVersionChange = $[6];
|
|
54
|
+
props = $[7];
|
|
55
|
+
t1 = $[8];
|
|
56
|
+
title = $[9];
|
|
57
|
+
versionId = $[10];
|
|
58
|
+
}
|
|
59
|
+
let t2;
|
|
60
|
+
if ($[11] !== t1) {
|
|
61
|
+
t2 = t1 === undefined ? [] : t1;
|
|
62
|
+
$[11] = t1;
|
|
63
|
+
$[12] = t2;
|
|
64
|
+
} else {
|
|
65
|
+
t2 = $[12];
|
|
66
|
+
}
|
|
67
|
+
const versions = t2;
|
|
68
|
+
let t3;
|
|
69
|
+
if ($[13] !== versionId || $[14] !== versions) {
|
|
70
|
+
t3 = currentVersionOf(versions, versionId);
|
|
71
|
+
$[13] = versionId;
|
|
72
|
+
$[14] = versions;
|
|
73
|
+
$[15] = t3;
|
|
74
|
+
} else {
|
|
75
|
+
t3 = $[15];
|
|
76
|
+
}
|
|
77
|
+
const current = t3;
|
|
78
|
+
let t4;
|
|
79
|
+
if ($[16] !== className) {
|
|
80
|
+
t4 = cn("flex h-full min-h-0 min-w-0 flex-col bg-card text-card-foreground ring-1 ring-border", className);
|
|
81
|
+
$[16] = className;
|
|
82
|
+
$[17] = t4;
|
|
83
|
+
} else {
|
|
84
|
+
t4 = $[17];
|
|
85
|
+
}
|
|
86
|
+
let t5;
|
|
87
|
+
if ($[18] !== kind) {
|
|
88
|
+
t5 = kind && /*#__PURE__*/_jsx("span", {
|
|
89
|
+
className: "eyebrow",
|
|
90
|
+
children: kind
|
|
91
|
+
});
|
|
92
|
+
$[18] = kind;
|
|
93
|
+
$[19] = t5;
|
|
94
|
+
} else {
|
|
95
|
+
t5 = $[19];
|
|
96
|
+
}
|
|
97
|
+
let t6;
|
|
98
|
+
if ($[20] !== title) {
|
|
99
|
+
t6 = /*#__PURE__*/_jsx("h2", {
|
|
100
|
+
className: "truncate font-sans text-base leading-snug font-semibold tracking-tight",
|
|
101
|
+
children: title
|
|
102
|
+
});
|
|
103
|
+
$[20] = title;
|
|
104
|
+
$[21] = t6;
|
|
105
|
+
} else {
|
|
106
|
+
t6 = $[21];
|
|
107
|
+
}
|
|
108
|
+
let t7;
|
|
109
|
+
if ($[22] !== t5 || $[23] !== t6) {
|
|
110
|
+
t7 = /*#__PURE__*/_jsxs("div", {
|
|
111
|
+
className: "flex min-w-0 flex-1 flex-col gap-1",
|
|
112
|
+
children: [t5, t6]
|
|
113
|
+
});
|
|
114
|
+
$[22] = t5;
|
|
115
|
+
$[23] = t6;
|
|
116
|
+
$[24] = t7;
|
|
117
|
+
} else {
|
|
118
|
+
t7 = $[24];
|
|
119
|
+
}
|
|
120
|
+
let t8;
|
|
121
|
+
if ($[25] !== onClose) {
|
|
122
|
+
t8 = onClose && /*#__PURE__*/_jsx(Button, {
|
|
123
|
+
type: "button",
|
|
124
|
+
variant: "ghost",
|
|
125
|
+
size: "icon-sm",
|
|
126
|
+
"aria-label": "Close panel",
|
|
127
|
+
className: "text-muted-foreground hover:text-foreground",
|
|
128
|
+
onClick: onClose,
|
|
129
|
+
children: /*#__PURE__*/_jsx(XIcon, {})
|
|
130
|
+
});
|
|
131
|
+
$[25] = onClose;
|
|
132
|
+
$[26] = t8;
|
|
133
|
+
} else {
|
|
134
|
+
t8 = $[26];
|
|
135
|
+
}
|
|
136
|
+
let t9;
|
|
137
|
+
if ($[27] !== actions || $[28] !== t8) {
|
|
138
|
+
t9 = /*#__PURE__*/_jsxs("div", {
|
|
139
|
+
className: "-mr-2 flex shrink-0 items-center gap-0.5 text-muted-foreground",
|
|
140
|
+
children: [actions, t8]
|
|
141
|
+
});
|
|
142
|
+
$[27] = actions;
|
|
143
|
+
$[28] = t8;
|
|
144
|
+
$[29] = t9;
|
|
145
|
+
} else {
|
|
146
|
+
t9 = $[29];
|
|
147
|
+
}
|
|
148
|
+
let t10;
|
|
149
|
+
if ($[30] !== t7 || $[31] !== t9) {
|
|
150
|
+
t10 = /*#__PURE__*/_jsxs("header", {
|
|
151
|
+
className: "flex items-start gap-3 border-b px-5 pt-3.5 pb-3",
|
|
152
|
+
children: [t7, t9]
|
|
153
|
+
});
|
|
154
|
+
$[30] = t7;
|
|
155
|
+
$[31] = t9;
|
|
156
|
+
$[32] = t10;
|
|
157
|
+
} else {
|
|
158
|
+
t10 = $[32];
|
|
159
|
+
}
|
|
160
|
+
let t11;
|
|
161
|
+
if ($[33] !== children) {
|
|
162
|
+
t11 = /*#__PURE__*/_jsx(ScrollArea, {
|
|
163
|
+
className: "min-h-0 flex-1",
|
|
164
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
165
|
+
"data-slot": "canvas-content",
|
|
166
|
+
className: "px-5 py-4 has-[>[data-slot=code]:only-child]:p-0 [&>[data-slot=code]:only-child]:ring-0",
|
|
167
|
+
children: children
|
|
168
|
+
})
|
|
169
|
+
});
|
|
170
|
+
$[33] = children;
|
|
171
|
+
$[34] = t11;
|
|
172
|
+
} else {
|
|
173
|
+
t11 = $[34];
|
|
174
|
+
}
|
|
175
|
+
let t12;
|
|
176
|
+
if ($[35] !== current || $[36] !== onVersionChange || $[37] !== versions) {
|
|
177
|
+
t12 = current && /*#__PURE__*/_jsx("footer", {
|
|
178
|
+
className: "flex h-10 items-center gap-2 border-t bg-muted/30 pr-3 pl-5",
|
|
179
|
+
children: /*#__PURE__*/_jsx(VersionSwitcher, {
|
|
180
|
+
versions: versions,
|
|
181
|
+
current: current,
|
|
182
|
+
onVersionChange: onVersionChange
|
|
183
|
+
})
|
|
184
|
+
});
|
|
185
|
+
$[35] = current;
|
|
186
|
+
$[36] = onVersionChange;
|
|
187
|
+
$[37] = versions;
|
|
188
|
+
$[38] = t12;
|
|
189
|
+
} else {
|
|
190
|
+
t12 = $[38];
|
|
191
|
+
}
|
|
192
|
+
let t13;
|
|
193
|
+
if ($[39] !== props || $[40] !== t10 || $[41] !== t11 || $[42] !== t12 || $[43] !== t4 || $[44] !== title) {
|
|
194
|
+
t13 = /*#__PURE__*/_jsxs("aside", {
|
|
195
|
+
"data-slot": "canvas",
|
|
196
|
+
"aria-label": title,
|
|
197
|
+
className: t4,
|
|
198
|
+
...props,
|
|
199
|
+
children: [t10, t11, t12]
|
|
200
|
+
});
|
|
201
|
+
$[39] = props;
|
|
202
|
+
$[40] = t10;
|
|
203
|
+
$[41] = t11;
|
|
204
|
+
$[42] = t12;
|
|
205
|
+
$[43] = t4;
|
|
206
|
+
$[44] = title;
|
|
207
|
+
$[45] = t13;
|
|
208
|
+
} else {
|
|
209
|
+
t13 = $[45];
|
|
210
|
+
}
|
|
211
|
+
return t13;
|
|
12
212
|
}
|
|
@@ -1,11 +1,57 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { ChevronDown as ChevronDownIcon } from "@carbon/icons-react";
|
|
3
|
-
import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger
|
|
2
|
+
import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger } from "@locusgraph/components";
|
|
4
3
|
import { formatDate } from "@locusgraph/utils";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
export function VersionSwitcher({
|
|
6
|
+
versions,
|
|
7
|
+
current,
|
|
8
|
+
onVersionChange
|
|
9
|
+
}) {
|
|
10
|
+
const label = /*#__PURE__*/_jsxs("span", {
|
|
11
|
+
className: "flex items-center gap-2 font-mono text-[11px] tabular-nums",
|
|
12
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
13
|
+
"data-slot": "canvas-current-version",
|
|
14
|
+
children: current.label
|
|
15
|
+
}), versions.length > 1 && /*#__PURE__*/_jsxs("span", {
|
|
16
|
+
className: "text-muted-foreground",
|
|
17
|
+
children: ["of ", versions.length]
|
|
18
|
+
}), /*#__PURE__*/_jsx("time", {
|
|
19
|
+
dateTime: current.createdAt,
|
|
20
|
+
className: "text-muted-foreground",
|
|
21
|
+
children: formatDate(current.createdAt)
|
|
22
|
+
})]
|
|
23
|
+
});
|
|
24
|
+
if (versions.length < 2 || !onVersionChange) {
|
|
25
|
+
return label;
|
|
26
|
+
}
|
|
27
|
+
return /*#__PURE__*/_jsxs(DropdownMenu, {
|
|
28
|
+
children: [/*#__PURE__*/_jsx(DropdownMenuTrigger, {
|
|
29
|
+
asChild: true,
|
|
30
|
+
children: /*#__PURE__*/_jsxs(Button, {
|
|
31
|
+
type: "button",
|
|
32
|
+
variant: "ghost",
|
|
33
|
+
size: "xs",
|
|
34
|
+
className: "-ml-2 font-normal",
|
|
35
|
+
"aria-label": `Version ${current.label}, choose another version`,
|
|
36
|
+
children: [label, /*#__PURE__*/_jsx(ChevronDownIcon, {})]
|
|
37
|
+
})
|
|
38
|
+
}), /*#__PURE__*/_jsx(DropdownMenuContent, {
|
|
39
|
+
align: "start",
|
|
40
|
+
sideOffset: 6,
|
|
41
|
+
children: /*#__PURE__*/_jsx(DropdownMenuRadioGroup, {
|
|
42
|
+
value: current.id,
|
|
43
|
+
onValueChange: onVersionChange,
|
|
44
|
+
children: versions.map(version => /*#__PURE__*/_jsxs(DropdownMenuRadioItem, {
|
|
45
|
+
value: version.id,
|
|
46
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
47
|
+
className: "font-mono text-xs",
|
|
48
|
+
children: version.label
|
|
49
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
50
|
+
className: "ml-auto pl-4 text-xs text-muted-foreground",
|
|
51
|
+
children: formatDate(version.createdAt)
|
|
52
|
+
})]
|
|
53
|
+
}, version.id))
|
|
54
|
+
})
|
|
55
|
+
})]
|
|
56
|
+
});
|
|
11
57
|
}
|
package/dist/thread/code/code.js
CHANGED
|
@@ -1,33 +1,195 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
4
|
import { cn } from "@locusgraph/components";
|
|
4
5
|
import { useEffect, useState } from "react";
|
|
5
6
|
import { CopyCodeButton } from "./copy-code-button.js";
|
|
6
7
|
import { highlightToHtml } from "./highlight.js";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
9
|
const codeAreaClass = cn("overflow-x-auto bg-muted/40 px-4 py-3 font-mono text-xs leading-relaxed", "[&_pre]:bg-transparent! [&_pre]:outline-none", "[&_.shiki_span]:text-(--shiki-light) dark:[&_.shiki_span]:text-(--shiki-dark)");
|
|
8
10
|
function useHighlightedHtml(code, language) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
const $ = _c(4);
|
|
12
|
+
const [html, setHtml] = useState(null);
|
|
13
|
+
let t0;
|
|
14
|
+
let t1;
|
|
15
|
+
if ($[0] !== code || $[1] !== language) {
|
|
16
|
+
t0 = () => {
|
|
17
|
+
let current = true;
|
|
18
|
+
setHtml(null);
|
|
19
|
+
highlightToHtml(code, language).then(highlighted => {
|
|
20
|
+
if (current) {
|
|
21
|
+
setHtml(highlighted);
|
|
22
|
+
}
|
|
23
|
+
}).catch(() => {
|
|
24
|
+
if (current) {
|
|
25
|
+
setHtml(null);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return () => {
|
|
29
|
+
current = false;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
t1 = [code, language];
|
|
33
|
+
$[0] = code;
|
|
34
|
+
$[1] = language;
|
|
35
|
+
$[2] = t0;
|
|
36
|
+
$[3] = t1;
|
|
37
|
+
} else {
|
|
38
|
+
t0 = $[2];
|
|
39
|
+
t1 = $[3];
|
|
40
|
+
}
|
|
41
|
+
useEffect(t0, t1);
|
|
42
|
+
return html;
|
|
29
43
|
}
|
|
30
|
-
export function Code(
|
|
31
|
-
|
|
32
|
-
|
|
44
|
+
export function Code(t0) {
|
|
45
|
+
const $ = _c(35);
|
|
46
|
+
let className;
|
|
47
|
+
let code;
|
|
48
|
+
let filename;
|
|
49
|
+
let onCopy;
|
|
50
|
+
let props;
|
|
51
|
+
let t1;
|
|
52
|
+
let t2;
|
|
53
|
+
if ($[0] !== t0) {
|
|
54
|
+
({
|
|
55
|
+
code,
|
|
56
|
+
language: t1,
|
|
57
|
+
filename,
|
|
58
|
+
showCopy: t2,
|
|
59
|
+
onCopy,
|
|
60
|
+
className,
|
|
61
|
+
...props
|
|
62
|
+
} = t0);
|
|
63
|
+
$[0] = t0;
|
|
64
|
+
$[1] = className;
|
|
65
|
+
$[2] = code;
|
|
66
|
+
$[3] = filename;
|
|
67
|
+
$[4] = onCopy;
|
|
68
|
+
$[5] = props;
|
|
69
|
+
$[6] = t1;
|
|
70
|
+
$[7] = t2;
|
|
71
|
+
} else {
|
|
72
|
+
className = $[1];
|
|
73
|
+
code = $[2];
|
|
74
|
+
filename = $[3];
|
|
75
|
+
onCopy = $[4];
|
|
76
|
+
props = $[5];
|
|
77
|
+
t1 = $[6];
|
|
78
|
+
t2 = $[7];
|
|
79
|
+
}
|
|
80
|
+
const language = t1 === undefined ? "text" : t1;
|
|
81
|
+
const showCopy = t2 === undefined ? true : t2;
|
|
82
|
+
const html = useHighlightedHtml(code, language);
|
|
83
|
+
let t3;
|
|
84
|
+
if ($[8] !== className) {
|
|
85
|
+
t3 = cn("min-w-0 bg-card text-card-foreground ring-1 ring-border", className);
|
|
86
|
+
$[8] = className;
|
|
87
|
+
$[9] = t3;
|
|
88
|
+
} else {
|
|
89
|
+
t3 = $[9];
|
|
90
|
+
}
|
|
91
|
+
let t4;
|
|
92
|
+
if ($[10] !== filename || $[11] !== language) {
|
|
93
|
+
t4 = filename ? /*#__PURE__*/_jsx("span", {
|
|
94
|
+
className: "min-w-0 truncate font-mono text-xs text-foreground",
|
|
95
|
+
children: filename
|
|
96
|
+
}) : /*#__PURE__*/_jsx("span", {
|
|
97
|
+
className: "eyebrow",
|
|
98
|
+
children: language
|
|
99
|
+
});
|
|
100
|
+
$[10] = filename;
|
|
101
|
+
$[11] = language;
|
|
102
|
+
$[12] = t4;
|
|
103
|
+
} else {
|
|
104
|
+
t4 = $[12];
|
|
105
|
+
}
|
|
106
|
+
let t5;
|
|
107
|
+
if ($[13] !== filename || $[14] !== language) {
|
|
108
|
+
t5 = filename && /*#__PURE__*/_jsx("span", {
|
|
109
|
+
className: "eyebrow",
|
|
110
|
+
children: language
|
|
111
|
+
});
|
|
112
|
+
$[13] = filename;
|
|
113
|
+
$[14] = language;
|
|
114
|
+
$[15] = t5;
|
|
115
|
+
} else {
|
|
116
|
+
t5 = $[15];
|
|
117
|
+
}
|
|
118
|
+
let t6;
|
|
119
|
+
if ($[16] !== code || $[17] !== onCopy || $[18] !== showCopy) {
|
|
120
|
+
t6 = showCopy && /*#__PURE__*/_jsx(CopyCodeButton, {
|
|
121
|
+
code: code,
|
|
122
|
+
onCopy: onCopy
|
|
123
|
+
});
|
|
124
|
+
$[16] = code;
|
|
125
|
+
$[17] = onCopy;
|
|
126
|
+
$[18] = showCopy;
|
|
127
|
+
$[19] = t6;
|
|
128
|
+
} else {
|
|
129
|
+
t6 = $[19];
|
|
130
|
+
}
|
|
131
|
+
let t7;
|
|
132
|
+
if ($[20] !== t5 || $[21] !== t6) {
|
|
133
|
+
t7 = /*#__PURE__*/_jsxs("span", {
|
|
134
|
+
className: "flex shrink-0 items-center gap-2",
|
|
135
|
+
children: [t5, t6]
|
|
136
|
+
});
|
|
137
|
+
$[20] = t5;
|
|
138
|
+
$[21] = t6;
|
|
139
|
+
$[22] = t7;
|
|
140
|
+
} else {
|
|
141
|
+
t7 = $[22];
|
|
142
|
+
}
|
|
143
|
+
let t8;
|
|
144
|
+
if ($[23] !== t4 || $[24] !== t7) {
|
|
145
|
+
t8 = /*#__PURE__*/_jsxs("figcaption", {
|
|
146
|
+
className: "flex h-8 items-center justify-between gap-2 border-b pr-1 pl-3",
|
|
147
|
+
children: [t4, t7]
|
|
148
|
+
});
|
|
149
|
+
$[23] = t4;
|
|
150
|
+
$[24] = t7;
|
|
151
|
+
$[25] = t8;
|
|
152
|
+
} else {
|
|
153
|
+
t8 = $[25];
|
|
154
|
+
}
|
|
155
|
+
let t9;
|
|
156
|
+
if ($[26] !== code || $[27] !== html) {
|
|
157
|
+
t9 = html ? /*#__PURE__*/_jsx("div", {
|
|
158
|
+
"data-slot": "code-area",
|
|
159
|
+
className: codeAreaClass,
|
|
160
|
+
dangerouslySetInnerHTML: {
|
|
161
|
+
__html: html
|
|
162
|
+
}
|
|
163
|
+
}) : /*#__PURE__*/_jsx("pre", {
|
|
164
|
+
"data-slot": "code-area",
|
|
165
|
+
className: codeAreaClass,
|
|
166
|
+
children: /*#__PURE__*/_jsx("code", {
|
|
167
|
+
children: code
|
|
168
|
+
})
|
|
169
|
+
});
|
|
170
|
+
$[26] = code;
|
|
171
|
+
$[27] = html;
|
|
172
|
+
$[28] = t9;
|
|
173
|
+
} else {
|
|
174
|
+
t9 = $[28];
|
|
175
|
+
}
|
|
176
|
+
let t10;
|
|
177
|
+
if ($[29] !== language || $[30] !== props || $[31] !== t3 || $[32] !== t8 || $[33] !== t9) {
|
|
178
|
+
t10 = /*#__PURE__*/_jsxs("figure", {
|
|
179
|
+
"data-slot": "code",
|
|
180
|
+
"data-language": language,
|
|
181
|
+
className: t3,
|
|
182
|
+
...props,
|
|
183
|
+
children: [t8, t9]
|
|
184
|
+
});
|
|
185
|
+
$[29] = language;
|
|
186
|
+
$[30] = props;
|
|
187
|
+
$[31] = t3;
|
|
188
|
+
$[32] = t8;
|
|
189
|
+
$[33] = t9;
|
|
190
|
+
$[34] = t10;
|
|
191
|
+
} else {
|
|
192
|
+
t10 = $[34];
|
|
193
|
+
}
|
|
194
|
+
return t10;
|
|
33
195
|
}
|
|
@@ -1,18 +1,34 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import { Checkmark as CheckIcon, Copy as CopyIcon } from "@carbon/icons-react";
|
|
3
2
|
import { Button } from "@locusgraph/components";
|
|
4
3
|
import { useCopied, writeToClipboard } from "../use-copied.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
export function CopyCodeButton({
|
|
6
|
+
code,
|
|
7
|
+
onCopy
|
|
8
|
+
}) {
|
|
9
|
+
const {
|
|
10
|
+
copied,
|
|
11
|
+
markCopied
|
|
12
|
+
} = useCopied();
|
|
13
|
+
const copy = async () => {
|
|
14
|
+
if (onCopy) {
|
|
15
|
+
onCopy(code);
|
|
16
|
+
markCopied();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (await writeToClipboard(code)) {
|
|
20
|
+
markCopied();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return /*#__PURE__*/_jsx(Button, {
|
|
24
|
+
type: "button",
|
|
25
|
+
variant: "ghost",
|
|
26
|
+
size: "icon-xs",
|
|
27
|
+
"aria-label": copied ? "Copied" : "Copy code",
|
|
28
|
+
className: "text-muted-foreground hover:text-foreground",
|
|
29
|
+
onClick: copy,
|
|
30
|
+
children: copied ? /*#__PURE__*/_jsx(CheckIcon, {
|
|
31
|
+
className: "text-good"
|
|
32
|
+
}) : /*#__PURE__*/_jsx(CopyIcon, {})
|
|
33
|
+
});
|
|
18
34
|
}
|
|
@@ -2,38 +2,39 @@ const lightTheme = "github-light";
|
|
|
2
2
|
const darkTheme = "github-dark";
|
|
3
3
|
let highlighter;
|
|
4
4
|
function loadHighlighter() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
langs: [],
|
|
12
|
-
engine: engine.createJavaScriptRegexEngine(),
|
|
13
|
-
}));
|
|
14
|
-
return highlighter;
|
|
5
|
+
highlighter ??= Promise.all([import("shiki/core"), import("shiki/engine/javascript"), import("shiki/themes")]).then(([core, engine, themes]) => core.createHighlighterCore({
|
|
6
|
+
themes: [themes.bundledThemes[lightTheme](), themes.bundledThemes[darkTheme]()],
|
|
7
|
+
langs: [],
|
|
8
|
+
engine: engine.createJavaScriptRegexEngine()
|
|
9
|
+
}));
|
|
10
|
+
return highlighter;
|
|
15
11
|
}
|
|
16
12
|
async function loadLanguage(loaded, language) {
|
|
17
|
-
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
const { bundledLanguages } = await import("shiki/langs");
|
|
21
|
-
const loader = bundledLanguages[language];
|
|
22
|
-
if (!loader) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
await loaded.loadLanguage(loader());
|
|
13
|
+
if (loaded.getLoadedLanguages().includes(language)) {
|
|
26
14
|
return true;
|
|
15
|
+
}
|
|
16
|
+
const {
|
|
17
|
+
bundledLanguages
|
|
18
|
+
} = await import("shiki/langs");
|
|
19
|
+
const loader = bundledLanguages[language];
|
|
20
|
+
if (!loader) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
await loaded.loadLanguage(loader());
|
|
24
|
+
return true;
|
|
27
25
|
}
|
|
28
26
|
export async function highlightToHtml(code, language) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
const normalized = language.toLowerCase();
|
|
28
|
+
const loaded = await loadHighlighter();
|
|
29
|
+
if (!(await loadLanguage(loaded, normalized))) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return loaded.codeToHtml(code, {
|
|
33
|
+
lang: normalized,
|
|
34
|
+
themes: {
|
|
35
|
+
light: lightTheme,
|
|
36
|
+
dark: darkTheme
|
|
37
|
+
},
|
|
38
|
+
defaultColor: false
|
|
39
|
+
});
|
|
39
40
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HistoryItem } from "./row/history-row.js";
|
|
2
|
+
import type { ThreadGroup } from "./thread-groups.js";
|
|
3
|
+
export type HistoryListRow = {
|
|
4
|
+
kind: "group";
|
|
5
|
+
key: string;
|
|
6
|
+
groupKey: string;
|
|
7
|
+
label: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: "thread";
|
|
10
|
+
key: string;
|
|
11
|
+
thread: HistoryItem;
|
|
12
|
+
position: number;
|
|
13
|
+
groupSize: number;
|
|
14
|
+
};
|
|
15
|
+
export declare function historyListRows(groups: ThreadGroup[]): HistoryListRow[];
|
|
16
|
+
export declare function estimatedRowHeight(row: HistoryListRow, index: number): number;
|