@locusgraph/loop 0.1.0 → 0.2.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/README.md +2 -0
- package/dist/agent/pulse/gradient-label.js +86 -15
- package/dist/agent/pulse/marks/bars-mark.js +46 -10
- package/dist/agent/pulse/marks/glyph-mark.js +56 -11
- package/dist/agent/pulse/marks/locus-mark.js +63 -28
- package/dist/agent/pulse/marks/orb-mark.js +31 -8
- package/dist/agent/pulse/marks/spinner-mark.js +29 -1
- package/dist/agent/pulse/pulse.js +150 -35
- package/dist/agent/pulse/use-loop-animation.js +36 -17
- package/dist/agent/steps/step-icon.js +110 -24
- package/dist/agent/steps/steps.js +235 -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 +38 -11
- package/dist/agent/tool/tool-status.js +51 -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 +321 -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 +250 -18
- package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
- package/dist/approval/inbox/virtual-inbox-list.js +129 -0
- package/dist/approval/memory/memory-choices.js +27 -22
- package/dist/approval/memory/memory-review.js +242 -17
- package/dist/approval/memory/memory-row.js +215 -19
- package/dist/approval/plan/plan-review.js +279 -28
- package/dist/approval/plan/plan-step-row.js +194 -43
- package/dist/approval/plan/plan-steps.js +24 -23
- package/dist/approval/plan/question-choices.js +158 -39
- package/dist/approval/plan/question.d.ts +1 -1
- package/dist/approval/plan/question.js +223 -26
- package/dist/approval/run/run-bar.js +178 -22
- package/dist/approval/shared/decision-line.js +1 -1
- package/dist/approval/shared/risk-badge.js +47 -16
- package/dist/approval/shared/time.js +5 -8
- package/dist/approval/shared/use-focus-on-mount.js +23 -6
- package/dist/approval/spend/raise-cap-form.js +235 -17
- package/dist/approval/spend/spend-gate.js +239 -21
- package/dist/approval/spend/spend-math.js +7 -8
- package/dist/approval/spend/spend-meter.js +362 -34
- package/dist/approval/tool/approval.js +272 -27
- package/dist/approval/tool/args/args-editor.js +262 -26
- package/dist/approval/tool/args/args-field.js +259 -19
- package/dist/approval/tool/args/args-validation.js +38 -47
- package/dist/approval/tool/deny-form.js +130 -10
- package/dist/approval/tool/tool-inputs.js +127 -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 +123 -47
- package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
- package/dist/chat/chat/virtual-chat-items.js +153 -0
- package/dist/chat/composer/composer-actions.js +151 -16
- package/dist/chat/composer/composer.js +330 -32
- package/dist/chat/composer/use-auto-grow.js +24 -9
- package/dist/chat/files/file-meta.js +19 -19
- package/dist/chat/files/files.js +316 -28
- package/dist/chat/reply/fenced-code.js +45 -21
- package/dist/chat/reply/markdown-components.js +137 -17
- package/dist/chat/reply/reply.js +105 -10
- package/dist/chat/turn/group-parts.js +43 -29
- package/dist/chat/turn/turn.js +238 -30
- package/dist/cost/context.js +321 -23
- package/dist/cost/cost-steps.js +220 -14
- package/dist/cost/cost.js +521 -27
- package/dist/cost/model-picker.js +181 -6
- package/dist/cost/shared/context-breakdown.js +299 -10
- package/dist/cost/shared/meter-marks.js +107 -9
- package/dist/cost/shared/model-option-row.js +178 -21
- package/dist/cost/shared/step-cost-row.js +248 -20
- package/dist/cost/shared/usage-totals.js +22 -18
- package/dist/memory/cite.js +182 -11
- package/dist/memory/memorized.js +217 -11
- package/dist/memory/recall.js +296 -17
- package/dist/memory/shared/host-label.js +19 -22
- package/dist/memory/shared/source-mark.js +39 -3
- package/dist/memory/sources.js +255 -13
- package/dist/shared/decision-summary.js +133 -14
- package/dist/shared/panel-empty.js +78 -3
- package/dist/shared/panel.js +243 -13
- package/dist/shared/status-dot.js +38 -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 +65 -3
- package/dist/thread/actions/actions.js +184 -13
- package/dist/thread/actions/branch-switcher.js +102 -5
- package/dist/thread/canvas/canvas.js +205 -5
- package/dist/thread/canvas/version-switcher.js +149 -8
- package/dist/thread/code/code.js +186 -24
- package/dist/thread/code/copy-code-button.js +61 -13
- 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 +137 -0
- package/dist/thread/history/row/thread-item-menu.js +84 -0
- package/dist/thread/history/row/thread-title-editor.js +81 -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 +107 -0
- package/dist/thread/index.d.ts +1 -1
- package/dist/thread/starters/starters.js +92 -7
- package/dist/thread/use-copied.js +45 -15
- 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,14 +1,29 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
1
2
|
import { useLayoutEffect } from "react";
|
|
2
3
|
function supportsFieldSizing() {
|
|
3
|
-
|
|
4
|
+
return typeof CSS !== "undefined" && CSS.supports?.("field-sizing", "content") === true;
|
|
4
5
|
}
|
|
5
6
|
export function useAutoGrow(textareaRef, text) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const $ = _c(4);
|
|
8
|
+
let t0;
|
|
9
|
+
let t1;
|
|
10
|
+
if ($[0] !== text || $[1] !== textareaRef) {
|
|
11
|
+
t0 = () => {
|
|
12
|
+
const textarea = textareaRef.current;
|
|
13
|
+
if (!textarea || supportsFieldSizing() || text === undefined) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
textarea.style.height = "auto";
|
|
17
|
+
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
18
|
+
};
|
|
19
|
+
t1 = [textareaRef, text];
|
|
20
|
+
$[0] = text;
|
|
21
|
+
$[1] = textareaRef;
|
|
22
|
+
$[2] = t0;
|
|
23
|
+
$[3] = t1;
|
|
24
|
+
} else {
|
|
25
|
+
t0 = $[2];
|
|
26
|
+
t1 = $[3];
|
|
27
|
+
}
|
|
28
|
+
useLayoutEffect(t0, t1);
|
|
14
29
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
const byteUnits = ["B", "KB", "MB", "GB"];
|
|
2
2
|
export function formatBytes(bytes) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
let value = bytes;
|
|
4
|
+
let unitIndex = 0;
|
|
5
|
+
while (value >= 1024 && unitIndex < byteUnits.length - 1) {
|
|
6
|
+
value /= 1024;
|
|
7
|
+
unitIndex += 1;
|
|
8
|
+
}
|
|
9
|
+
const rounded = unitIndex === 0 || value >= 10 ? Math.round(value) : Math.round(value * 10) / 10;
|
|
10
|
+
return `${rounded} ${byteUnits[unitIndex]}`;
|
|
11
11
|
}
|
|
12
12
|
export function isImageFile(item) {
|
|
13
|
-
|
|
13
|
+
return Boolean(item.url && item.mediaType?.startsWith("image/"));
|
|
14
14
|
}
|
|
15
15
|
export function fileExtensionLabel(item) {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const extension = item.name.includes(".") ? item.name.split(".").at(-1) : undefined;
|
|
17
|
+
return extension ? extension.toUpperCase() : undefined;
|
|
18
18
|
}
|
|
19
19
|
export function filenameFromUrl(url) {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const lastSegment = url.split(/[?#]/)[0]?.split("/").at(-1);
|
|
21
|
+
return lastSegment && !url.startsWith("data:") ? decodeURIComponent(lastSegment) : "Attachment";
|
|
22
22
|
}
|
|
23
23
|
export function fileFromFilePart(part, index) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
return {
|
|
25
|
+
id: `${index}:${part.url.slice(0, 64)}`,
|
|
26
|
+
name: part.filename ?? filenameFromUrl(part.url),
|
|
27
|
+
mediaType: part.mediaType,
|
|
28
|
+
url: part.url
|
|
29
|
+
};
|
|
30
30
|
}
|
package/dist/chat/files/files.js
CHANGED
|
@@ -1,39 +1,327 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Code as FileCodeIcon, DocumentBlank as FileIcon, DataTable as FileSpreadsheetIcon, Document as FileTextIcon, Close as XIcon
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { Code as FileCodeIcon, DocumentBlank as FileIcon, DataTable as FileSpreadsheetIcon, Document as FileTextIcon, Close as XIcon } from "@carbon/icons-react";
|
|
3
3
|
import { cn } from "@locusgraph/components";
|
|
4
4
|
import { fileExtensionLabel, formatBytes, isImageFile } from "./file-meta.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[/json|javascript|typescript|xml|x-python/, FileCodeIcon],
|
|
8
|
-
[/text|pdf|markdown|word/, FileTextIcon],
|
|
9
|
-
];
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
const iconsByMediaType = [[/csv|spreadsheet|excel/, FileSpreadsheetIcon], [/json|javascript|typescript|xml|x-python/, FileCodeIcon], [/text|pdf|markdown|word/, FileTextIcon]];
|
|
10
7
|
function iconForMediaType(mediaType) {
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const match = iconsByMediaType.find(([pattern]) => mediaType && pattern.test(mediaType));
|
|
9
|
+
return match ? match[1] : FileIcon;
|
|
13
10
|
}
|
|
14
11
|
function describeFile(item) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
];
|
|
19
|
-
const description = parts.filter(Boolean).join(" · ");
|
|
20
|
-
return description || undefined;
|
|
12
|
+
const parts = [fileExtensionLabel(item), item.sizeBytes === undefined ? undefined : formatBytes(item.sizeBytes)];
|
|
13
|
+
const description = parts.filter(Boolean).join(" · ");
|
|
14
|
+
return description || undefined;
|
|
21
15
|
}
|
|
22
|
-
function FilePreview(
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
function FilePreview(t0) {
|
|
17
|
+
const $ = _c(11);
|
|
18
|
+
const {
|
|
19
|
+
item,
|
|
20
|
+
isGrid
|
|
21
|
+
} = t0;
|
|
22
|
+
let t1;
|
|
23
|
+
if ($[0] !== item.mediaType) {
|
|
24
|
+
t1 = iconForMediaType(item.mediaType);
|
|
25
|
+
$[0] = item.mediaType;
|
|
26
|
+
$[1] = t1;
|
|
27
|
+
} else {
|
|
28
|
+
t1 = $[1];
|
|
29
|
+
}
|
|
30
|
+
const Icon = t1;
|
|
31
|
+
const t2 = isGrid ? "aspect-[16/10] w-full" : "size-10";
|
|
32
|
+
let t3;
|
|
33
|
+
if ($[2] !== t2) {
|
|
34
|
+
t3 = cn("grid shrink-0 place-items-center overflow-hidden bg-muted text-muted-foreground", t2);
|
|
35
|
+
$[2] = t2;
|
|
36
|
+
$[3] = t3;
|
|
37
|
+
} else {
|
|
38
|
+
t3 = $[3];
|
|
39
|
+
}
|
|
40
|
+
let t4;
|
|
41
|
+
if ($[4] !== Icon || $[5] !== isGrid || $[6] !== item) {
|
|
42
|
+
t4 = isImageFile(item) ? /*#__PURE__*/_jsx("img", {
|
|
43
|
+
src: item.url,
|
|
44
|
+
alt: "",
|
|
45
|
+
loading: "lazy",
|
|
46
|
+
className: "size-full object-cover"
|
|
47
|
+
}) : /*#__PURE__*/_jsx(Icon, {
|
|
48
|
+
"aria-hidden": "true",
|
|
49
|
+
className: isGrid ? "size-6" : "size-4"
|
|
50
|
+
});
|
|
51
|
+
$[4] = Icon;
|
|
52
|
+
$[5] = isGrid;
|
|
53
|
+
$[6] = item;
|
|
54
|
+
$[7] = t4;
|
|
55
|
+
} else {
|
|
56
|
+
t4 = $[7];
|
|
57
|
+
}
|
|
58
|
+
let t5;
|
|
59
|
+
if ($[8] !== t3 || $[9] !== t4) {
|
|
60
|
+
t5 = /*#__PURE__*/_jsx("span", {
|
|
61
|
+
"data-slot": "files-preview",
|
|
62
|
+
className: t3,
|
|
63
|
+
children: t4
|
|
64
|
+
});
|
|
65
|
+
$[8] = t3;
|
|
66
|
+
$[9] = t4;
|
|
67
|
+
$[10] = t5;
|
|
68
|
+
} else {
|
|
69
|
+
t5 = $[10];
|
|
70
|
+
}
|
|
71
|
+
return t5;
|
|
25
72
|
}
|
|
26
|
-
function RemoveButton(
|
|
27
|
-
|
|
73
|
+
function RemoveButton(t0) {
|
|
74
|
+
const $ = _c(10);
|
|
75
|
+
const {
|
|
76
|
+
item,
|
|
77
|
+
isGrid,
|
|
78
|
+
onRemove
|
|
79
|
+
} = t0;
|
|
80
|
+
const t1 = `Remove ${item.name}`;
|
|
81
|
+
let t2;
|
|
82
|
+
if ($[0] !== item.id || $[1] !== onRemove) {
|
|
83
|
+
t2 = () => onRemove(item.id);
|
|
84
|
+
$[0] = item.id;
|
|
85
|
+
$[1] = onRemove;
|
|
86
|
+
$[2] = t2;
|
|
87
|
+
} else {
|
|
88
|
+
t2 = $[2];
|
|
89
|
+
}
|
|
90
|
+
const t3 = isGrid && "absolute top-1 right-1 bg-card/90";
|
|
91
|
+
let t4;
|
|
92
|
+
if ($[3] !== t3) {
|
|
93
|
+
t4 = cn("grid size-6 shrink-0 place-items-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring", t3);
|
|
94
|
+
$[3] = t3;
|
|
95
|
+
$[4] = t4;
|
|
96
|
+
} else {
|
|
97
|
+
t4 = $[4];
|
|
98
|
+
}
|
|
99
|
+
let t5;
|
|
100
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
101
|
+
t5 = /*#__PURE__*/_jsx(XIcon, {
|
|
102
|
+
"aria-hidden": "true",
|
|
103
|
+
className: "size-3.5"
|
|
104
|
+
});
|
|
105
|
+
$[5] = t5;
|
|
106
|
+
} else {
|
|
107
|
+
t5 = $[5];
|
|
108
|
+
}
|
|
109
|
+
let t6;
|
|
110
|
+
if ($[6] !== t1 || $[7] !== t2 || $[8] !== t4) {
|
|
111
|
+
t6 = /*#__PURE__*/_jsx("button", {
|
|
112
|
+
type: "button",
|
|
113
|
+
"aria-label": t1,
|
|
114
|
+
onClick: t2,
|
|
115
|
+
className: t4,
|
|
116
|
+
children: t5
|
|
117
|
+
});
|
|
118
|
+
$[6] = t1;
|
|
119
|
+
$[7] = t2;
|
|
120
|
+
$[8] = t4;
|
|
121
|
+
$[9] = t6;
|
|
122
|
+
} else {
|
|
123
|
+
t6 = $[9];
|
|
124
|
+
}
|
|
125
|
+
return t6;
|
|
28
126
|
}
|
|
29
|
-
function FileChip(
|
|
30
|
-
|
|
31
|
-
|
|
127
|
+
function FileChip(t0) {
|
|
128
|
+
const $ = _c(27);
|
|
129
|
+
const {
|
|
130
|
+
item,
|
|
131
|
+
isGrid,
|
|
132
|
+
onRemove
|
|
133
|
+
} = t0;
|
|
134
|
+
let t1;
|
|
135
|
+
if ($[0] !== item) {
|
|
136
|
+
t1 = describeFile(item);
|
|
137
|
+
$[0] = item;
|
|
138
|
+
$[1] = t1;
|
|
139
|
+
} else {
|
|
140
|
+
t1 = $[1];
|
|
141
|
+
}
|
|
142
|
+
const description = t1;
|
|
143
|
+
const t2 = isGrid ? "flex-col" : "w-60 max-w-full items-center gap-2.5 pr-1";
|
|
144
|
+
const t3 = !isGrid && !onRemove && "pr-3";
|
|
145
|
+
let t4;
|
|
146
|
+
if ($[2] !== t2 || $[3] !== t3) {
|
|
147
|
+
t4 = cn("relative flex min-w-0 bg-card text-card-foreground ring-1 ring-border", t2, t3);
|
|
148
|
+
$[2] = t2;
|
|
149
|
+
$[3] = t3;
|
|
150
|
+
$[4] = t4;
|
|
151
|
+
} else {
|
|
152
|
+
t4 = $[4];
|
|
153
|
+
}
|
|
154
|
+
let t5;
|
|
155
|
+
if ($[5] !== isGrid || $[6] !== item) {
|
|
156
|
+
t5 = /*#__PURE__*/_jsx(FilePreview, {
|
|
157
|
+
item: item,
|
|
158
|
+
isGrid: isGrid
|
|
159
|
+
});
|
|
160
|
+
$[5] = isGrid;
|
|
161
|
+
$[6] = item;
|
|
162
|
+
$[7] = t5;
|
|
163
|
+
} else {
|
|
164
|
+
t5 = $[7];
|
|
165
|
+
}
|
|
166
|
+
const t6 = isGrid && "px-2.5 py-2";
|
|
167
|
+
let t7;
|
|
168
|
+
if ($[8] !== t6) {
|
|
169
|
+
t7 = cn("flex min-w-0 flex-1 flex-col gap-0.5", t6);
|
|
170
|
+
$[8] = t6;
|
|
171
|
+
$[9] = t7;
|
|
172
|
+
} else {
|
|
173
|
+
t7 = $[9];
|
|
174
|
+
}
|
|
175
|
+
let t8;
|
|
176
|
+
if ($[10] !== item.name) {
|
|
177
|
+
t8 = /*#__PURE__*/_jsx("span", {
|
|
178
|
+
title: item.name,
|
|
179
|
+
className: "truncate text-xs leading-tight font-medium",
|
|
180
|
+
children: item.name
|
|
181
|
+
});
|
|
182
|
+
$[10] = item.name;
|
|
183
|
+
$[11] = t8;
|
|
184
|
+
} else {
|
|
185
|
+
t8 = $[11];
|
|
186
|
+
}
|
|
187
|
+
let t9;
|
|
188
|
+
if ($[12] !== description) {
|
|
189
|
+
t9 = description && /*#__PURE__*/_jsx("span", {
|
|
190
|
+
className: "truncate font-mono text-xs leading-tight text-muted-foreground tabular-nums",
|
|
191
|
+
children: description
|
|
192
|
+
});
|
|
193
|
+
$[12] = description;
|
|
194
|
+
$[13] = t9;
|
|
195
|
+
} else {
|
|
196
|
+
t9 = $[13];
|
|
197
|
+
}
|
|
198
|
+
let t10;
|
|
199
|
+
if ($[14] !== t7 || $[15] !== t8 || $[16] !== t9) {
|
|
200
|
+
t10 = /*#__PURE__*/_jsxs("span", {
|
|
201
|
+
className: t7,
|
|
202
|
+
children: [t8, t9]
|
|
203
|
+
});
|
|
204
|
+
$[14] = t7;
|
|
205
|
+
$[15] = t8;
|
|
206
|
+
$[16] = t9;
|
|
207
|
+
$[17] = t10;
|
|
208
|
+
} else {
|
|
209
|
+
t10 = $[17];
|
|
210
|
+
}
|
|
211
|
+
let t11;
|
|
212
|
+
if ($[18] !== isGrid || $[19] !== item || $[20] !== onRemove) {
|
|
213
|
+
t11 = onRemove && /*#__PURE__*/_jsx(RemoveButton, {
|
|
214
|
+
item: item,
|
|
215
|
+
isGrid: isGrid,
|
|
216
|
+
onRemove: onRemove
|
|
217
|
+
});
|
|
218
|
+
$[18] = isGrid;
|
|
219
|
+
$[19] = item;
|
|
220
|
+
$[20] = onRemove;
|
|
221
|
+
$[21] = t11;
|
|
222
|
+
} else {
|
|
223
|
+
t11 = $[21];
|
|
224
|
+
}
|
|
225
|
+
let t12;
|
|
226
|
+
if ($[22] !== t10 || $[23] !== t11 || $[24] !== t4 || $[25] !== t5) {
|
|
227
|
+
t12 = /*#__PURE__*/_jsxs("li", {
|
|
228
|
+
"data-slot": "files-item",
|
|
229
|
+
className: t4,
|
|
230
|
+
children: [t5, t10, t11]
|
|
231
|
+
});
|
|
232
|
+
$[22] = t10;
|
|
233
|
+
$[23] = t11;
|
|
234
|
+
$[24] = t4;
|
|
235
|
+
$[25] = t5;
|
|
236
|
+
$[26] = t12;
|
|
237
|
+
} else {
|
|
238
|
+
t12 = $[26];
|
|
239
|
+
}
|
|
240
|
+
return t12;
|
|
32
241
|
}
|
|
33
|
-
export function Files(
|
|
34
|
-
|
|
35
|
-
|
|
242
|
+
export function Files(t0) {
|
|
243
|
+
const $ = _c(21);
|
|
244
|
+
let className;
|
|
245
|
+
let items;
|
|
246
|
+
let onRemove;
|
|
247
|
+
let props;
|
|
248
|
+
let t1;
|
|
249
|
+
if ($[0] !== t0) {
|
|
250
|
+
({
|
|
251
|
+
items,
|
|
252
|
+
layout: t1,
|
|
253
|
+
onRemove,
|
|
254
|
+
className,
|
|
255
|
+
...props
|
|
256
|
+
} = t0);
|
|
257
|
+
$[0] = t0;
|
|
258
|
+
$[1] = className;
|
|
259
|
+
$[2] = items;
|
|
260
|
+
$[3] = onRemove;
|
|
261
|
+
$[4] = props;
|
|
262
|
+
$[5] = t1;
|
|
263
|
+
} else {
|
|
264
|
+
className = $[1];
|
|
265
|
+
items = $[2];
|
|
266
|
+
onRemove = $[3];
|
|
267
|
+
props = $[4];
|
|
268
|
+
t1 = $[5];
|
|
269
|
+
}
|
|
270
|
+
const layout = t1 === undefined ? "inline" : t1;
|
|
271
|
+
if (items.length === 0) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
const isGrid = layout === "grid";
|
|
275
|
+
const t2 = isGrid ? "grid grid-cols-2 gap-2 sm:grid-cols-3" : "flex flex-wrap gap-2";
|
|
276
|
+
let t3;
|
|
277
|
+
if ($[6] !== className || $[7] !== t2) {
|
|
278
|
+
t3 = cn(t2, className);
|
|
279
|
+
$[6] = className;
|
|
280
|
+
$[7] = t2;
|
|
281
|
+
$[8] = t3;
|
|
282
|
+
} else {
|
|
283
|
+
t3 = $[8];
|
|
284
|
+
}
|
|
285
|
+
let t4;
|
|
286
|
+
if ($[9] !== isGrid || $[10] !== items || $[11] !== onRemove) {
|
|
287
|
+
let t5;
|
|
288
|
+
if ($[13] !== isGrid || $[14] !== onRemove) {
|
|
289
|
+
t5 = item => /*#__PURE__*/_jsx(FileChip, {
|
|
290
|
+
item: item,
|
|
291
|
+
isGrid: isGrid,
|
|
292
|
+
onRemove: onRemove
|
|
293
|
+
}, item.id);
|
|
294
|
+
$[13] = isGrid;
|
|
295
|
+
$[14] = onRemove;
|
|
296
|
+
$[15] = t5;
|
|
297
|
+
} else {
|
|
298
|
+
t5 = $[15];
|
|
36
299
|
}
|
|
37
|
-
|
|
38
|
-
|
|
300
|
+
t4 = items.map(t5);
|
|
301
|
+
$[9] = isGrid;
|
|
302
|
+
$[10] = items;
|
|
303
|
+
$[11] = onRemove;
|
|
304
|
+
$[12] = t4;
|
|
305
|
+
} else {
|
|
306
|
+
t4 = $[12];
|
|
307
|
+
}
|
|
308
|
+
let t5;
|
|
309
|
+
if ($[16] !== layout || $[17] !== props || $[18] !== t3 || $[19] !== t4) {
|
|
310
|
+
t5 = /*#__PURE__*/_jsx("ul", {
|
|
311
|
+
"data-slot": "files",
|
|
312
|
+
"data-layout": layout,
|
|
313
|
+
"aria-label": "Files",
|
|
314
|
+
className: t3,
|
|
315
|
+
...props,
|
|
316
|
+
children: t4
|
|
317
|
+
});
|
|
318
|
+
$[16] = layout;
|
|
319
|
+
$[17] = props;
|
|
320
|
+
$[18] = t3;
|
|
321
|
+
$[19] = t4;
|
|
322
|
+
$[20] = t5;
|
|
323
|
+
} else {
|
|
324
|
+
t5 = $[20];
|
|
325
|
+
}
|
|
326
|
+
return t5;
|
|
39
327
|
}
|
|
@@ -1,29 +1,53 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { Code } from "../../thread/code/code.js";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
4
|
function textOf(child) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return child.children.map(textOf).join("");
|
|
8
|
-
return "";
|
|
5
|
+
if (child.type === "text") return child.value;
|
|
6
|
+
if (child.type === "element") return child.children.map(textOf).join("");
|
|
7
|
+
return "";
|
|
9
8
|
}
|
|
10
9
|
function languageOf(className) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const classes = Array.isArray(className) ? className.map(String) : [];
|
|
11
|
+
const language = classes.find(value => value.startsWith("language-"));
|
|
12
|
+
return language ? language.slice("language-".length) : "text";
|
|
14
13
|
}
|
|
15
14
|
export function fencedCode(node) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
15
|
+
const code = node?.children.find(child => child.type === "element" && child.tagName === "code");
|
|
16
|
+
if (!code) return null;
|
|
17
|
+
return {
|
|
18
|
+
code: code.children.map(textOf).join("").replace(/\n$/, ""),
|
|
19
|
+
language: languageOf(code.properties.className)
|
|
20
|
+
};
|
|
23
21
|
}
|
|
24
|
-
export function FencedCode(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
export function FencedCode(t0) {
|
|
23
|
+
const $ = _c(5);
|
|
24
|
+
const {
|
|
25
|
+
node
|
|
26
|
+
} = t0;
|
|
27
|
+
let t1;
|
|
28
|
+
if ($[0] !== node) {
|
|
29
|
+
t1 = fencedCode(node);
|
|
30
|
+
$[0] = node;
|
|
31
|
+
$[1] = t1;
|
|
32
|
+
} else {
|
|
33
|
+
t1 = $[1];
|
|
34
|
+
}
|
|
35
|
+
const fenced = t1;
|
|
36
|
+
if (!fenced) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
let t2;
|
|
40
|
+
if ($[2] !== fenced.code || $[3] !== fenced.language) {
|
|
41
|
+
t2 = /*#__PURE__*/_jsx(Code, {
|
|
42
|
+
code: fenced.code,
|
|
43
|
+
language: fenced.language,
|
|
44
|
+
className: "mt-4 first:mt-0"
|
|
45
|
+
});
|
|
46
|
+
$[2] = fenced.code;
|
|
47
|
+
$[3] = fenced.language;
|
|
48
|
+
$[4] = t2;
|
|
49
|
+
} else {
|
|
50
|
+
t2 = $[4];
|
|
51
|
+
}
|
|
52
|
+
return t2;
|
|
29
53
|
}
|
|
@@ -1,22 +1,142 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import { cn } from "@locusgraph/components";
|
|
3
2
|
import { FencedCode, fencedCode } from "./fenced-code.js";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
const blockGap = "mt-4 first:mt-0";
|
|
5
5
|
export const markdownComponents = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
p: ({
|
|
7
|
+
node: _node,
|
|
8
|
+
className,
|
|
9
|
+
...props
|
|
10
|
+
}) => /*#__PURE__*/_jsx("p", {
|
|
11
|
+
className: cn("leading-relaxed text-pretty [&:not(:first-child)]:mt-3", className),
|
|
12
|
+
...props
|
|
13
|
+
}),
|
|
14
|
+
a: ({
|
|
15
|
+
node: _node,
|
|
16
|
+
className,
|
|
17
|
+
...props
|
|
18
|
+
}) => /*#__PURE__*/_jsx("a", {
|
|
19
|
+
target: "_blank",
|
|
20
|
+
rel: "noopener noreferrer",
|
|
21
|
+
className: cn("font-medium text-foreground underline decoration-muted-foreground/50 underline-offset-3 transition-colors hover:decoration-foreground", className),
|
|
22
|
+
...props
|
|
23
|
+
}),
|
|
24
|
+
h1: ({
|
|
25
|
+
node: _node,
|
|
26
|
+
className,
|
|
27
|
+
...props
|
|
28
|
+
}) => /*#__PURE__*/_jsx("h1", {
|
|
29
|
+
className: cn("mt-7 mb-2 text-base font-semibold tracking-tight first:mt-0", className),
|
|
30
|
+
...props
|
|
31
|
+
}),
|
|
32
|
+
h2: ({
|
|
33
|
+
node: _node,
|
|
34
|
+
className,
|
|
35
|
+
...props
|
|
36
|
+
}) => /*#__PURE__*/_jsx("h2", {
|
|
37
|
+
className: cn("mt-6 mb-2 text-base font-semibold tracking-tight first:mt-0", className),
|
|
38
|
+
...props
|
|
39
|
+
}),
|
|
40
|
+
h3: ({
|
|
41
|
+
node: _node,
|
|
42
|
+
className,
|
|
43
|
+
...props
|
|
44
|
+
}) => /*#__PURE__*/_jsx("h3", {
|
|
45
|
+
className: cn("mt-5 mb-1.5 text-sm font-semibold first:mt-0", className),
|
|
46
|
+
...props
|
|
47
|
+
}),
|
|
48
|
+
h4: ({
|
|
49
|
+
node: _node,
|
|
50
|
+
className,
|
|
51
|
+
...props
|
|
52
|
+
}) => /*#__PURE__*/_jsx("h4", {
|
|
53
|
+
className: cn("eyebrow mt-5 mb-1.5 first:mt-0", className),
|
|
54
|
+
...props
|
|
55
|
+
}),
|
|
56
|
+
ul: ({
|
|
57
|
+
node: _node,
|
|
58
|
+
className,
|
|
59
|
+
...props
|
|
60
|
+
}) => /*#__PURE__*/_jsx("ul", {
|
|
61
|
+
className: cn("mt-3 list-disc space-y-1.5 pl-5 first:mt-0 [li_&]:mt-1.5", className),
|
|
62
|
+
...props
|
|
63
|
+
}),
|
|
64
|
+
ol: ({
|
|
65
|
+
node: _node,
|
|
66
|
+
className,
|
|
67
|
+
...props
|
|
68
|
+
}) => /*#__PURE__*/_jsx("ol", {
|
|
69
|
+
className: cn("mt-3 list-decimal space-y-1.5 pl-5 first:mt-0 marker:tabular-nums [li_&]:mt-1.5", className),
|
|
70
|
+
...props
|
|
71
|
+
}),
|
|
72
|
+
li: ({
|
|
73
|
+
node: _node,
|
|
74
|
+
className,
|
|
75
|
+
...props
|
|
76
|
+
}) => /*#__PURE__*/_jsx("li", {
|
|
77
|
+
className: cn("pl-1 leading-relaxed marker:text-muted-foreground [&>p]:mt-0", className),
|
|
78
|
+
...props
|
|
79
|
+
}),
|
|
80
|
+
blockquote: ({
|
|
81
|
+
node: _node,
|
|
82
|
+
className,
|
|
83
|
+
...props
|
|
84
|
+
}) => /*#__PURE__*/_jsx("blockquote", {
|
|
85
|
+
className: cn("border-l-2 border-border pl-4 text-muted-foreground", blockGap, className),
|
|
86
|
+
...props
|
|
87
|
+
}),
|
|
88
|
+
hr: ({
|
|
89
|
+
node: _node,
|
|
90
|
+
className,
|
|
91
|
+
...props
|
|
92
|
+
}) => /*#__PURE__*/_jsx("hr", {
|
|
93
|
+
className: cn("my-6 border-border", className),
|
|
94
|
+
...props
|
|
95
|
+
}),
|
|
96
|
+
pre: ({
|
|
97
|
+
node,
|
|
98
|
+
className,
|
|
99
|
+
...props
|
|
100
|
+
}) => fencedCode(node) ? /*#__PURE__*/_jsx(FencedCode, {
|
|
101
|
+
node: node
|
|
102
|
+
}) : /*#__PURE__*/_jsx("pre", {
|
|
103
|
+
className: cn("overflow-x-auto bg-muted/40 p-3 font-mono text-xs leading-relaxed", blockGap, className),
|
|
104
|
+
...props
|
|
105
|
+
}),
|
|
106
|
+
code: ({
|
|
107
|
+
node: _node,
|
|
108
|
+
className,
|
|
109
|
+
...props
|
|
110
|
+
}) => /*#__PURE__*/_jsx("code", {
|
|
111
|
+
className: cn("bg-muted px-1.5 py-0.5 font-mono text-[0.85em] text-foreground [pre_&]:bg-transparent [pre_&]:p-0", className),
|
|
112
|
+
...props
|
|
113
|
+
}),
|
|
114
|
+
table: ({
|
|
115
|
+
node: _node,
|
|
116
|
+
className,
|
|
117
|
+
...props
|
|
118
|
+
}) => /*#__PURE__*/_jsx("div", {
|
|
119
|
+
"data-slot": "reply-table",
|
|
120
|
+
className: cn("overflow-x-auto ring-1 ring-border", blockGap),
|
|
121
|
+
children: /*#__PURE__*/_jsx("table", {
|
|
122
|
+
className: cn("w-full border-collapse text-sm [&_td:not(:first-child)]:tabular-nums", className),
|
|
123
|
+
...props
|
|
124
|
+
})
|
|
125
|
+
}),
|
|
126
|
+
th: ({
|
|
127
|
+
node: _node,
|
|
128
|
+
className,
|
|
129
|
+
...props
|
|
130
|
+
}) => /*#__PURE__*/_jsx("th", {
|
|
131
|
+
className: cn("eyebrow border-b bg-muted/30 px-3 py-2 text-left font-normal", className),
|
|
132
|
+
...props
|
|
133
|
+
}),
|
|
134
|
+
td: ({
|
|
135
|
+
node: _node,
|
|
136
|
+
className,
|
|
137
|
+
...props
|
|
138
|
+
}) => /*#__PURE__*/_jsx("td", {
|
|
139
|
+
className: cn("border-b px-3 py-2 align-top [tr:last-child_&]:border-b-0", className),
|
|
140
|
+
...props
|
|
141
|
+
})
|
|
22
142
|
};
|