@tangle-network/ui 11.7.0 → 11.8.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 +6 -0
- package/dist/chat.js +8 -7
- package/dist/chunk-4CLN43XT.js +45 -0
- package/dist/{chunk-UYTRNR7Z.js → chunk-565EATZZ.js} +1 -1
- package/dist/{chunk-4ENFLPWQ.js → chunk-BWOUSEHM.js} +1 -1
- package/dist/{chunk-XT4JMYVB.js → chunk-KNYSKNZX.js} +5 -3
- package/dist/{chunk-EIUE5GV2.js → chunk-ND3ZFXQK.js} +1 -44
- package/dist/{chunk-AAUNOHVL.js → chunk-NWECTSOH.js} +1 -1
- package/dist/{chunk-CVX53NCC.js → chunk-OXZRCXJK.js} +5 -5
- package/dist/{chunk-6RIX7M27.js → chunk-Q7ZR6LSD.js} +1 -1
- package/dist/{chunk-VDCZHOOO.js → chunk-X53RZSX6.js} +4 -4
- package/dist/{chunk-PLWRAS5Z.js → chunk-XGOWUDDW.js} +270 -106
- package/dist/{chunk-ZRVH3WCA.js → chunk-XU3HB5QL.js} +21 -1
- package/dist/{chunk-LFVF2HFB.js → chunk-YTO5V6QS.js} +1 -1
- package/dist/files.d.ts +41 -12
- package/dist/files.js +13 -5
- package/dist/hooks.js +8 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -22
- package/dist/run.js +8 -7
- package/dist/sdk-hooks.js +8 -7
- package/dist/tool-previews.js +2 -2
- package/dist/utils.js +6 -4
- package/package.json +1 -1
- package/src/files/file-artifact-pane.stories.tsx +149 -0
- package/src/files/file-artifact-pane.test.tsx +192 -0
- package/src/files/file-artifact-pane.tsx +6 -1
- package/src/files/file-format.ts +42 -4
- package/src/files/file-preview-kind.test.ts +109 -0
- package/src/files/file-preview.tsx +315 -132
- package/src/files/index.ts +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @tangle-network/ui
|
|
2
2
|
|
|
3
|
+
## 11.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3416c80: `FileArtifactPane` (and `FilePreview`, its body) now previews every file kind a sandbox produces, so a product no longer builds its own image, PDF, CSV, video, audio, or spreadsheet viewers. Pass `blobUrl` (an object URL or remote URL) for binary content and the pane renders an image fit to the pane on a checker ground (click for natural size), a PDF at full pane height, or a video/audio player; pass `content` for CSV and the pane parses quoted commas and line breaks (RFC 4180) into a sticky-header table capped at `CSV_PREVIEW_ROW_LIMIT` (500) rows with a "Showing N of M rows" line; an `.xlsx`/`.xls` file renders a download card with the filename, its size when the new optional `size` prop (bytes) is set, and a Download button wired to `onDownload`. A file with no `blobUrl` and no text content renders one sentence, "This file needs a download link to preview.", with the same Download button. Text, code, JSON, YAML, and markdown render as before. `@tangle-network/ui/files` also exports the pure `resolveFilePreviewKind(filename, mimeType)` helper (`FilePreviewKind`: MIME type wins over extension; anything unmatched is `binary`), `parseCsv`, and `CSV_PREVIEW_ROW_LIMIT`; `detectFileFormat` gains the `video` and `audio` formats and the `avif` image extension.
|
|
8
|
+
|
|
3
9
|
## 11.7.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/chat.js
CHANGED
|
@@ -5,17 +5,18 @@ import {
|
|
|
5
5
|
MessageList,
|
|
6
6
|
ThinkingIndicator,
|
|
7
7
|
UserMessage
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-X53RZSX6.js";
|
|
9
|
+
import "./chunk-565EATZZ.js";
|
|
10
|
+
import "./chunk-OXZRCXJK.js";
|
|
11
|
+
import "./chunk-KNYSKNZX.js";
|
|
12
|
+
import "./chunk-ND3ZFXQK.js";
|
|
13
|
+
import "./chunk-NWECTSOH.js";
|
|
14
14
|
import "./chunk-L57WRIND.js";
|
|
15
15
|
import "./chunk-3M7BPSSW.js";
|
|
16
16
|
import "./chunk-GYPQXTJU.js";
|
|
17
|
+
import "./chunk-4CLN43XT.js";
|
|
18
|
+
import "./chunk-XU3HB5QL.js";
|
|
17
19
|
import "./chunk-MKTSMWVD.js";
|
|
18
|
-
import "./chunk-ZRVH3WCA.js";
|
|
19
20
|
import "./chunk-P5F43A65.js";
|
|
20
21
|
import "./chunk-WUQDUBJG.js";
|
|
21
22
|
import "./chunk-RQHJBTEU.js";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/utils/format.ts
|
|
2
|
+
function formatDuration(ms) {
|
|
3
|
+
if (ms < 1e3) return "<1s";
|
|
4
|
+
const seconds = Math.floor(ms / 1e3);
|
|
5
|
+
if (seconds < 60) return `${seconds}s`;
|
|
6
|
+
const minutes = Math.floor(seconds / 60);
|
|
7
|
+
const remaining = seconds % 60;
|
|
8
|
+
return remaining > 0 ? `${minutes}m ${remaining}s` : `${minutes}m`;
|
|
9
|
+
}
|
|
10
|
+
function truncateText(text, max) {
|
|
11
|
+
const cleaned = text.replace(/\s+/g, " ").trim();
|
|
12
|
+
if (cleaned.length <= max) return cleaned;
|
|
13
|
+
return cleaned.slice(0, max).trim() + "...";
|
|
14
|
+
}
|
|
15
|
+
function formatUptime(ms) {
|
|
16
|
+
if (!Number.isFinite(ms) || ms < 0) return "\u2014";
|
|
17
|
+
const totalSeconds = Math.floor(ms / 1e3);
|
|
18
|
+
if (totalSeconds < 60) return `${totalSeconds}s`;
|
|
19
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
20
|
+
const seconds = totalSeconds % 60;
|
|
21
|
+
if (minutes < 60) return `${minutes}m ${seconds}s`;
|
|
22
|
+
const hours = Math.floor(minutes / 60);
|
|
23
|
+
const remMinutes = minutes % 60;
|
|
24
|
+
if (hours < 24) return `${hours}h ${remMinutes}m`;
|
|
25
|
+
const days = Math.floor(hours / 24);
|
|
26
|
+
const remHours = hours % 24;
|
|
27
|
+
return `${days}d ${remHours}h`;
|
|
28
|
+
}
|
|
29
|
+
function formatBytes(bytes) {
|
|
30
|
+
if (!Number.isFinite(bytes) || bytes < 0) return "\u2014";
|
|
31
|
+
if (bytes < 1024) return `${Math.round(bytes)} B`;
|
|
32
|
+
const kb = bytes / 1024;
|
|
33
|
+
if (kb < 1024) return `${kb < 10 ? kb.toFixed(1) : Math.round(kb)} KB`;
|
|
34
|
+
const mb = kb / 1024;
|
|
35
|
+
if (mb < 1024) return `${mb < 10 ? mb.toFixed(1) : Math.round(mb)} MB`;
|
|
36
|
+
const gb = mb / 1024;
|
|
37
|
+
return `${gb < 10 ? gb.toFixed(2) : gb.toFixed(1)} GB`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
formatDuration,
|
|
42
|
+
truncateText,
|
|
43
|
+
formatUptime,
|
|
44
|
+
formatBytes
|
|
45
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
formatDuration,
|
|
3
2
|
getToolCategory,
|
|
4
3
|
getToolDisplayMetadata,
|
|
5
4
|
getToolErrorText
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ND3ZFXQK.js";
|
|
7
6
|
import {
|
|
8
7
|
CommandPreview,
|
|
9
8
|
DiffPreview,
|
|
@@ -12,10 +11,13 @@ import {
|
|
|
12
11
|
QuestionPreview,
|
|
13
12
|
WebSearchPreview,
|
|
14
13
|
WriteFilePreview
|
|
15
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-NWECTSOH.js";
|
|
16
15
|
import {
|
|
17
16
|
TextShimmer
|
|
18
17
|
} from "./chunk-L57WRIND.js";
|
|
18
|
+
import {
|
|
19
|
+
formatDuration
|
|
20
|
+
} from "./chunk-4CLN43XT.js";
|
|
19
21
|
import {
|
|
20
22
|
CodeBlock
|
|
21
23
|
} from "./chunk-WUQDUBJG.js";
|
|
@@ -171,52 +171,9 @@ function getToolErrorText(part, fallback) {
|
|
|
171
171
|
return part.state.error || fallback;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
// src/utils/format.ts
|
|
175
|
-
function formatDuration(ms) {
|
|
176
|
-
if (ms < 1e3) return "<1s";
|
|
177
|
-
const seconds = Math.floor(ms / 1e3);
|
|
178
|
-
if (seconds < 60) return `${seconds}s`;
|
|
179
|
-
const minutes = Math.floor(seconds / 60);
|
|
180
|
-
const remaining = seconds % 60;
|
|
181
|
-
return remaining > 0 ? `${minutes}m ${remaining}s` : `${minutes}m`;
|
|
182
|
-
}
|
|
183
|
-
function truncateText(text, max) {
|
|
184
|
-
const cleaned = text.replace(/\s+/g, " ").trim();
|
|
185
|
-
if (cleaned.length <= max) return cleaned;
|
|
186
|
-
return cleaned.slice(0, max).trim() + "...";
|
|
187
|
-
}
|
|
188
|
-
function formatUptime(ms) {
|
|
189
|
-
if (!Number.isFinite(ms) || ms < 0) return "\u2014";
|
|
190
|
-
const totalSeconds = Math.floor(ms / 1e3);
|
|
191
|
-
if (totalSeconds < 60) return `${totalSeconds}s`;
|
|
192
|
-
const minutes = Math.floor(totalSeconds / 60);
|
|
193
|
-
const seconds = totalSeconds % 60;
|
|
194
|
-
if (minutes < 60) return `${minutes}m ${seconds}s`;
|
|
195
|
-
const hours = Math.floor(minutes / 60);
|
|
196
|
-
const remMinutes = minutes % 60;
|
|
197
|
-
if (hours < 24) return `${hours}h ${remMinutes}m`;
|
|
198
|
-
const days = Math.floor(hours / 24);
|
|
199
|
-
const remHours = hours % 24;
|
|
200
|
-
return `${days}d ${remHours}h`;
|
|
201
|
-
}
|
|
202
|
-
function formatBytes(bytes) {
|
|
203
|
-
if (!Number.isFinite(bytes) || bytes < 0) return "\u2014";
|
|
204
|
-
if (bytes < 1024) return `${Math.round(bytes)} B`;
|
|
205
|
-
const kb = bytes / 1024;
|
|
206
|
-
if (kb < 1024) return `${kb < 10 ? kb.toFixed(1) : Math.round(kb)} KB`;
|
|
207
|
-
const mb = kb / 1024;
|
|
208
|
-
if (mb < 1024) return `${mb < 10 ? mb.toFixed(1) : Math.round(mb)} MB`;
|
|
209
|
-
const gb = mb / 1024;
|
|
210
|
-
return `${gb < 10 ? gb.toFixed(2) : gb.toFixed(1)} GB`;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
174
|
export {
|
|
214
175
|
TOOL_CATEGORY_ICONS,
|
|
215
176
|
getToolCategory,
|
|
216
177
|
getToolDisplayMetadata,
|
|
217
|
-
getToolErrorText
|
|
218
|
-
formatDuration,
|
|
219
|
-
truncateText,
|
|
220
|
-
formatUptime,
|
|
221
|
-
formatBytes
|
|
178
|
+
getToolErrorText
|
|
222
179
|
};
|
|
@@ -2,17 +2,17 @@ import {
|
|
|
2
2
|
ExpandableContent,
|
|
3
3
|
InlineToolItem,
|
|
4
4
|
RunRowShell
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import {
|
|
7
|
-
formatDuration,
|
|
8
|
-
truncateText
|
|
9
|
-
} from "./chunk-EIUE5GV2.js";
|
|
5
|
+
} from "./chunk-KNYSKNZX.js";
|
|
10
6
|
import {
|
|
11
7
|
TextShimmer
|
|
12
8
|
} from "./chunk-L57WRIND.js";
|
|
13
9
|
import {
|
|
14
10
|
OpenUIArtifactRenderer
|
|
15
11
|
} from "./chunk-3M7BPSSW.js";
|
|
12
|
+
import {
|
|
13
|
+
formatDuration,
|
|
14
|
+
truncateText
|
|
15
|
+
} from "./chunk-4CLN43XT.js";
|
|
16
16
|
import {
|
|
17
17
|
Markdown
|
|
18
18
|
} from "./chunk-P5F43A65.js";
|
|
@@ -2,18 +2,18 @@ import {
|
|
|
2
2
|
useAutoScroll,
|
|
3
3
|
useRunCollapseState,
|
|
4
4
|
useRunGroups
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-565EATZZ.js";
|
|
6
6
|
import {
|
|
7
7
|
InlineThinkingItem,
|
|
8
8
|
RunGroup
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OXZRCXJK.js";
|
|
10
10
|
import {
|
|
11
11
|
ToolCallGroup,
|
|
12
12
|
ToolCallStep
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-KNYSKNZX.js";
|
|
14
14
|
import {
|
|
15
15
|
getToolDisplayMetadata
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-ND3ZFXQK.js";
|
|
17
17
|
import {
|
|
18
18
|
OpenUIArtifactRenderer
|
|
19
19
|
} from "./chunk-3M7BPSSW.js";
|