@tangle-network/ui 11.30.2 → 11.31.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/index.d.ts +8 -3
  3. package/dist/index.js +7 -2
  4. package/dist/markdown/code-block.d.ts +11 -4
  5. package/dist/markdown/code-block.js +239 -107
  6. package/dist/markdown/code-meta.d.ts +11 -0
  7. package/dist/markdown/code-meta.js +98 -0
  8. package/dist/markdown/markdown-table.d.ts +8 -0
  9. package/dist/markdown/markdown-table.js +169 -0
  10. package/dist/markdown/markdown.d.ts +17 -4
  11. package/dist/markdown/markdown.js +96 -34
  12. package/dist/markdown.d.ts +5 -3
  13. package/dist/markdown.js +4 -2
  14. package/dist/run/approval-card.d.ts +46 -0
  15. package/dist/run/approval-card.js +162 -0
  16. package/dist/run/run-phase-list.d.ts +18 -0
  17. package/dist/run/run-phase-list.js +56 -0
  18. package/dist/run/task-list.d.ts +33 -0
  19. package/dist/run/task-list.js +138 -0
  20. package/dist/run.d.ts +4 -1
  21. package/dist/run.js +4 -1
  22. package/package.json +3 -4
  23. package/src/markdown/code-block.test.tsx +35 -26
  24. package/src/markdown/code-block.tsx +197 -110
  25. package/src/markdown/code-meta.ts +68 -0
  26. package/src/markdown/index.ts +10 -2
  27. package/src/markdown/markdown-table.test.tsx +63 -0
  28. package/src/markdown/markdown-table.tsx +191 -0
  29. package/src/markdown/markdown.test.tsx +27 -0
  30. package/src/markdown/markdown.tsx +126 -48
  31. package/src/run/approval-card.test.tsx +41 -0
  32. package/src/run/approval-card.tsx +146 -0
  33. package/src/run/index.ts +17 -0
  34. package/src/run/run-phase-list.test.tsx +25 -0
  35. package/src/run/run-phase-list.tsx +56 -0
  36. package/src/run/task-list.test.tsx +35 -0
  37. package/src/run/task-list.tsx +117 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @tangle-network/ui
2
2
 
3
+ ## 11.31.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 05857b3: The `.tangle-prose` table rules (`display: block`, a sideways scroll on the table itself, and cell borders) now skip the Markdown table card, which marks its table `data-markdown-table` and scrolls inside its card. The prose link color and underline skip link chips (`data-link-chip`).
8
+
9
+ ## 11.31.0
10
+
11
+ ### Minor Changes
12
+
13
+ - f09ecc4: Chat-grade components:
14
+
15
+ - **Markdown tables** render as cards with a header row, subtle row lines, right-aligned tabular figures, a Copy CSV control, and horizontal scrolling inside the card on narrow screens.
16
+ - **Code blocks** highlight with Shiki in Brand's syntax colors, name their file from the fence (`title="src/x.ts"`, `ts:src/x.ts`, or a bare path), and render single-line fences as blocks. react-syntax-highlighter is no longer a dependency.
17
+ - **Link chips:** a host can render links to known objects as icon chips with `Markdown`'s new `linkChip` resolver.
18
+ - **Run components:** `ui/run` adds `TaskList` (status pills, with priority shown only when tasks differ), `ApprovalCard` with `ApprovalDiffSummary` (plain-language title, plan step, files with +/− lines, raw input behind Details), and `RunPhaseList` (tool runs grouped by step, one line each).
19
+
3
20
  ## 11.30.2
4
21
 
5
22
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import { ReasoningPart, SessionPart, TextPart, ToolPart, ToolState, ToolStatus,
7
7
  import { AgentBranding } from "./types/branding.js";
8
8
  import { CustomToolRenderer, DisplayVariant, ToolDisplayMetadata } from "./types/tool-display.js";
9
9
  import { FinalTextPart, GroupedMessage, MessageRun, MessageUser, Run, RunStats, ToolCategory } from "./types/run.js";
10
- import { Markdown, MarkdownProps, getSanitizedMarkdownHeadingIdFromRawFragment } from "./markdown/markdown.js";
10
+ import { Markdown, MarkdownLinkChip, MarkdownLinkChipResolver, MarkdownProps, getSanitizedMarkdownHeadingIdFromRawFragment } from "./markdown/markdown.js";
11
11
  import { OpenUIAction, OpenUIActionsNode, OpenUIArtifactRenderer, OpenUIArtifactRendererProps, OpenUIBadgeNode, OpenUICardNode, OpenUICodeNode, OpenUIComponentNode, OpenUIGridNode, OpenUIHeadingNode, OpenUIKeyValueNode, OpenUIMarkdownNode, OpenUIPrimitive, OpenUISeparatorNode, OpenUIStackNode, OpenUIStatNode, OpenUITableNode, OpenUITextNode } from "./openui/openui-artifact-renderer.js";
12
12
  import { ChatContainer, ChatContainerProps } from "./chat/chat-container.js";
13
13
  import { MessageList, MessageListProps } from "./chat/message-list.js";
@@ -81,7 +81,7 @@ import { TerminalCursor, TerminalDisplay, TerminalInput, TerminalLine } from "./
81
81
  import { DropZone, DropZoneProps } from "./primitives/drop-zone.js";
82
82
  import { UploadFile, UploadProgress, UploadProgressProps } from "./primitives/upload-progress.js";
83
83
  import { SidebarDropZone, SidebarDropZoneProps } from "./primitives/sidebar-drop-zone.js";
84
- import { CodeBlock, CodeBlockProps, CopyButton } from "./markdown/code-block.js";
84
+ import { CodeBlock, CodeBlockProps, CopyButton, codeBlockGrammar } from "./markdown/code-block.js";
85
85
  import { InlineCode, InlineCodeProps } from "./primitives/code-block.js";
86
86
  import { ThemeToggle, useTheme } from "./primitives/theme-toggle.js";
87
87
  import { Heading, HeadingProps, HeadingVariant } from "./primitives/heading.js";
@@ -101,10 +101,15 @@ import { InlineToolItem, InlineToolItemProps } from "./run/inline-tool-item.js";
101
101
  import { InlineThinkingItem, InlineThinkingItemProps } from "./run/inline-thinking-item.js";
102
102
  import { ExpandedToolDetail, ExpandedToolDetailProps } from "./run/expanded-tool-detail.js";
103
103
  import { LiveDuration } from "./run/run-item-primitives.js";
104
+ import { TaskList, TaskListItem, TaskListProps, TaskStatus, showsTaskPriority, taskProgress, taskStatus } from "./run/task-list.js";
105
+ import { ApprovalCard, ApprovalCardProps, ApprovalDiffFile, ApprovalDiffSummary, ApprovalPlanStep } from "./run/approval-card.js";
106
+ import { RunPhase, RunPhaseList } from "./run/run-phase-list.js";
104
107
  import "./run.js";
105
108
  import { OPENUI_NODE_JSON_SCHEMA, OPENUI_NODE_TYPES } from "./openui/schema-data.js";
106
109
  import { OpenUISchemaIssue, OpenUISchemaValidation, findUnsupportedOpenUINode, validateOpenUIJsonArtifact, validateOpenUIJsonNode } from "./openui-schema.js";
107
110
  import "./openui.js";
111
+ import { fenceInfo } from "./markdown/code-meta.js";
112
+ import { numericColumns, tableCsv } from "./markdown/markdown-table.js";
108
113
  import "./markdown.js";
109
114
  import { addMessage, addParts, clearChat, isStreamingAtom, messagesAtom, partMapAtom, updatePart } from "./stores/chat-store.js";
110
115
  import "./types.js";
@@ -124,4 +129,4 @@ import { QuestionPreview, QuestionPreviewProps } from "./tool-previews/question-
124
129
  import { DiffPreview, DiffPreviewProps } from "./tool-previews/diff-preview.js";
125
130
  import { RedactedDocSegment, RedactedDocument, RedactedDocumentData, RedactedDocumentProps, RevealResult } from "./redaction/redacted-document.js";
126
131
  import "./redaction.js";
127
- export { ActiveProjectActivity, ActiveSessionActivityOptions, ActiveSessionConnectionOptions, ActiveSessionConnectionState, ActiveSessionReconnectState, ActiveSessionRecord, ActiveSessionStatus, ActiveSessionTransportMode, ActiveSessionsState, AgentBranding, AgentStreamEvent, AgentTimeline, type AgentTimelineArtifactItem, type AgentTimelineCustomItem, type AgentTimelineItem, type AgentTimelineMessageItem, type AgentTimelineProps, type AgentTimelineStatusItem, type AgentTimelineTone, type AgentTimelineToolGroupItem, type AgentTimelineToolItem, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, type AlertProps, AlertTitle, type AlertTone, AppendUserMessageOptions, ApplySdkEventOptions, ArtifactPane, type ArtifactPaneProps, AuthHeader, type AuthHeaderProps, AuthUser, AutomationStreamEvent, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeProps, BeginAssistantMessageOptions, BotStreamEvent, Button, type ButtonProps, CATEGORY_TONES, CSV_PREVIEW_ROW_LIMIT, Calendar, type CalendarDate, type CalendarProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CardTitleProps, type CategoryTone, ChatAuthor, ChatContainer, type ChatContainerProps, ChatMessage, type ChatMessageProps, Checkbox, Chip, type ChipProps, CodeBlock, type CodeBlockProps, Collapsible, CollapsibleContent, CollapsibleTrigger, CommandPreview, type CommandPreviewProps, CompleteAssistantMessageOptions, ConnectionState, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CopyButton, CustomToolRenderer, DatePicker, type DatePickerProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiffPreview, type DiffPreviewProps, DisplayVariant, DropZone, type DropZoneProps, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, type EmptyStateProps, ExpandedToolDetail, type ExpandedToolDetailProps, type FeedSegment, FileArtifactPane, type FileArtifactPaneProps, FileCard, type FileCardProps, type FileDetails, type FileFormat, FileList, type FileListItem, type FileListProps, type FileNode, FilePreview, type FilePreviewKind, type FilePreviewProps, type FileTabData, FileTabs, type FileTabsProps, FileTree, type FileTreeProps, type FileTreeVisibilityOptions, type FileUploader, FilterField, type FilterFieldProps, FinalTextPart, GitHubLoginButton, type GitHubLoginButtonProps, GlobResultsPreview, type GlobResultsPreviewProps, GrepResultsPreview, type GrepResultsPreviewProps, GroupedMessage, Heading, type HeadingProps, type HeadingVariant, HelpText, type HelpTextProps, IconTile, type IconTileProps, InlineCode, type InlineCodeProps, InlineThinkingItem, type InlineThinkingItemProps, InlineToolItem, type InlineToolItemProps, Input, type InputProps, Label, LiveDuration, LoginLayout, type LoginLayoutProps, Logo, type LogoProps, Markdown, type MarkdownProps, MessageAuthor, type MessageAuthorProps, MessageList, type MessageListProps, type MessageRole, MessageRun, MessageUser, Metric, type MetricProps, MetricStrip, type MetricStripProps, OPENUI_NODE_JSON_SCHEMA, OPENUI_NODE_TYPES, type OpenUIAction, type OpenUIActionsNode, OpenUIArtifactRenderer, type OpenUIArtifactRendererProps, type OpenUIBadgeNode, type OpenUICardNode, type OpenUICodeNode, type OpenUIComponentNode, type OpenUIGridNode, type OpenUIHeadingNode, type OpenUIKeyValueNode, type OpenUIMarkdownNode, type OpenUIPrimitive, type OpenUISchemaIssue, type OpenUISchemaValidation, type OpenUISeparatorNode, type OpenUIStackNode, type OpenUIStatNode, type OpenUITableNode, type OpenUITextNode, PageHeader, type PageHeaderProps, PageShell, type PageShellProps, Pagination, type PaginationProps, PdfViewer, type PdfViewerConfig, type PdfViewerProps, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, QuestionPreview, type QuestionPreviewProps, RadioGroup, RadioGroupItem, RealtimeSessionOptions, RealtimeSessionRegistry, RealtimeSessionRegistryProps, RealtimeSessionState, RealtimeSessionTarget, ReasoningPart, type RedactedDocSegment, RedactedDocument, type RedactedDocumentData, type RedactedDocumentProps, RegisterActiveSessionOptions, type RevealResult, RichFileTree, type RichFileTreeGitEntry, type RichFileTreeGitStatus, type RichFileTreeProps, type RichFileTreeThemeVars, Run, RunGroup, type RunGroupProps, RunRowShell, type RunRowShellProps, type RunRowStatus, RunRowStatusDot, RunStats, SSEEvent, SdkSessionAttachment, SdkSessionEvent, SdkSessionSeed, SegmentedControl, type SegmentedControlOption, type SegmentedControlProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SessionMessage, SessionPart, SessionProjectKey, type SessionUser, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, SidebarDropZone, type SidebarDropZoneProps, Skeleton, SkeletonCard, SkeletonTable, Slider, StatCard, type StatCardProps, StatusPill, type StatusPillProps, type StatusTone, Switch, TONE_CLASSES, TOOL_CATEGORY_ICONS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, type TableProps, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, type TagProps, TangleKnot, TaskStreamEvent, TerminalCursor, TerminalDisplay, TerminalInput, TerminalLine, TerminalStreamEvent, TextPart, TextShimmer, type TextShimmerProps, Textarea, type TextareaProps, ThemeToggle, ThinkingIndicator, type ThinkingIndicatorProps, TimeSelect, type TimeSelectProps, type Toast, ToastContainer, ToastProvider, type Tone, type ToneClasses, type ToolCallData, ToolCallFeed, type ToolCallFeedProps, type ToolCallStatus, type ToolCallType, ToolCategory, ToolDisplayMetadata, ToolPart, ToolState, ToolStatus, ToolTime, Toolbar, type ToolbarProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UploadFile, UploadProgress, type UploadProgressProps, UseAuthOptions, UseAuthResult, UseRunGroupsOptions, UseSSEStreamOptions, UseSSEStreamResult, UseSdkSessionOptions, UseSdkSessionReturn, UseToolCallStreamReturn, UserMenu, type UserMenuProps, UserMessage, type UserMessageProps, WebSearchPreview, type WebSearchPreviewProps, WriteFilePreview, type WriteFilePreviewProps, activeSessionsAtom, addMessage, addParts, badgeVariants, bumpActiveSessionActivity, buttonVariants, clearChat, cn, configurePdfViewer, copyText, createAuthFetcher, detectFileFormat, fileExtension, filterFileTree, findUnsupportedOpenUINode, focusField, focusFieldInvalid, focusFieldWithin, focusRing, focusRingInset, formatBytes, formatCalendarDate, formatDuration, formatUptime, getActiveSession, getAllActiveSessions, getAllProjectActivity, getCodeLanguage, getFormatLabel, getSanitizedMarkdownHeadingIdFromRawFragment, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getSyntaxLanguage, getToolCategory, getToolDisplayMetadata, getToolErrorText, getTotalRunningSessionCount, hasBackgroundRunningSessions, initialsOf, isStreamingAtom, isViewerMessage, localToday, messagesAtom, parseCalendarDate, parseCsv, parseToolEvent, partMapAtom, registerActiveSession, resetActiveSessions, resolveFilePreviewKind, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, timeAgo, toneFor, truncateText, unregisterActiveSession, updateActiveSessionMeta, updatePart, useActiveSession, useActiveSessions, useActiveSessionsState, useApiKey, useAuth, useAutoScroll, useDropdownMenu, useHasBackgroundRunningSessions, useLiveTime, useNavbarSessions, useProjectActivity, useProjectSessions, useRealtimeSession, useRunCollapseState, useRunGroups, useSSEStream, useSdkSession, useSessionsByActivity, useTheme, useToast, useToolCallStream, useTotalRunningSessions, validateOpenUIJsonArtifact, validateOpenUIJsonNode };
132
+ export { ActiveProjectActivity, ActiveSessionActivityOptions, ActiveSessionConnectionOptions, ActiveSessionConnectionState, ActiveSessionReconnectState, ActiveSessionRecord, ActiveSessionStatus, ActiveSessionTransportMode, ActiveSessionsState, AgentBranding, AgentStreamEvent, AgentTimeline, type AgentTimelineArtifactItem, type AgentTimelineCustomItem, type AgentTimelineItem, type AgentTimelineMessageItem, type AgentTimelineProps, type AgentTimelineStatusItem, type AgentTimelineTone, type AgentTimelineToolGroupItem, type AgentTimelineToolItem, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, type AlertProps, AlertTitle, type AlertTone, AppendUserMessageOptions, ApplySdkEventOptions, ApprovalCard, type ApprovalCardProps, type ApprovalDiffFile, ApprovalDiffSummary, type ApprovalPlanStep, ArtifactPane, type ArtifactPaneProps, AuthHeader, type AuthHeaderProps, AuthUser, AutomationStreamEvent, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeProps, BeginAssistantMessageOptions, BotStreamEvent, Button, type ButtonProps, CATEGORY_TONES, CSV_PREVIEW_ROW_LIMIT, Calendar, type CalendarDate, type CalendarProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CardTitleProps, type CategoryTone, ChatAuthor, ChatContainer, type ChatContainerProps, ChatMessage, type ChatMessageProps, Checkbox, Chip, type ChipProps, CodeBlock, type CodeBlockProps, Collapsible, CollapsibleContent, CollapsibleTrigger, CommandPreview, type CommandPreviewProps, CompleteAssistantMessageOptions, ConnectionState, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CopyButton, CustomToolRenderer, DatePicker, type DatePickerProps, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiffPreview, type DiffPreviewProps, DisplayVariant, DropZone, type DropZoneProps, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, type EmptyStateProps, ExpandedToolDetail, type ExpandedToolDetailProps, type FeedSegment, FileArtifactPane, type FileArtifactPaneProps, FileCard, type FileCardProps, type FileDetails, type FileFormat, FileList, type FileListItem, type FileListProps, type FileNode, FilePreview, type FilePreviewKind, type FilePreviewProps, type FileTabData, FileTabs, type FileTabsProps, FileTree, type FileTreeProps, type FileTreeVisibilityOptions, type FileUploader, FilterField, type FilterFieldProps, FinalTextPart, GitHubLoginButton, type GitHubLoginButtonProps, GlobResultsPreview, type GlobResultsPreviewProps, GrepResultsPreview, type GrepResultsPreviewProps, GroupedMessage, Heading, type HeadingProps, type HeadingVariant, HelpText, type HelpTextProps, IconTile, type IconTileProps, InlineCode, type InlineCodeProps, InlineThinkingItem, type InlineThinkingItemProps, InlineToolItem, type InlineToolItemProps, Input, type InputProps, Label, LiveDuration, LoginLayout, type LoginLayoutProps, Logo, type LogoProps, Markdown, type MarkdownLinkChip, type MarkdownLinkChipResolver, type MarkdownProps, MessageAuthor, type MessageAuthorProps, MessageList, type MessageListProps, type MessageRole, MessageRun, MessageUser, Metric, type MetricProps, MetricStrip, type MetricStripProps, OPENUI_NODE_JSON_SCHEMA, OPENUI_NODE_TYPES, type OpenUIAction, type OpenUIActionsNode, OpenUIArtifactRenderer, type OpenUIArtifactRendererProps, type OpenUIBadgeNode, type OpenUICardNode, type OpenUICodeNode, type OpenUIComponentNode, type OpenUIGridNode, type OpenUIHeadingNode, type OpenUIKeyValueNode, type OpenUIMarkdownNode, type OpenUIPrimitive, type OpenUISchemaIssue, type OpenUISchemaValidation, type OpenUISeparatorNode, type OpenUIStackNode, type OpenUIStatNode, type OpenUITableNode, type OpenUITextNode, PageHeader, type PageHeaderProps, PageShell, type PageShellProps, Pagination, type PaginationProps, PdfViewer, type PdfViewerConfig, type PdfViewerProps, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, QuestionPreview, type QuestionPreviewProps, RadioGroup, RadioGroupItem, RealtimeSessionOptions, RealtimeSessionRegistry, RealtimeSessionRegistryProps, RealtimeSessionState, RealtimeSessionTarget, ReasoningPart, type RedactedDocSegment, RedactedDocument, type RedactedDocumentData, type RedactedDocumentProps, RegisterActiveSessionOptions, type RevealResult, RichFileTree, type RichFileTreeGitEntry, type RichFileTreeGitStatus, type RichFileTreeProps, type RichFileTreeThemeVars, Run, RunGroup, type RunGroupProps, type RunPhase, RunPhaseList, RunRowShell, type RunRowShellProps, type RunRowStatus, RunRowStatusDot, RunStats, SSEEvent, SdkSessionAttachment, SdkSessionEvent, SdkSessionSeed, SegmentedControl, type SegmentedControlOption, type SegmentedControlProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, SessionMessage, SessionPart, SessionProjectKey, type SessionUser, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, SidebarDropZone, type SidebarDropZoneProps, Skeleton, SkeletonCard, SkeletonTable, Slider, StatCard, type StatCardProps, StatusPill, type StatusPillProps, type StatusTone, Switch, TONE_CLASSES, TOOL_CATEGORY_ICONS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, type TableProps, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, type TagProps, TangleKnot, TaskList, type TaskListItem, type TaskListProps, type TaskStatus, TaskStreamEvent, TerminalCursor, TerminalDisplay, TerminalInput, TerminalLine, TerminalStreamEvent, TextPart, TextShimmer, type TextShimmerProps, Textarea, type TextareaProps, ThemeToggle, ThinkingIndicator, type ThinkingIndicatorProps, TimeSelect, type TimeSelectProps, type Toast, ToastContainer, ToastProvider, type Tone, type ToneClasses, type ToolCallData, ToolCallFeed, type ToolCallFeedProps, type ToolCallStatus, type ToolCallType, ToolCategory, ToolDisplayMetadata, ToolPart, ToolState, ToolStatus, ToolTime, Toolbar, type ToolbarProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UploadFile, UploadProgress, type UploadProgressProps, UseAuthOptions, UseAuthResult, UseRunGroupsOptions, UseSSEStreamOptions, UseSSEStreamResult, UseSdkSessionOptions, UseSdkSessionReturn, UseToolCallStreamReturn, UserMenu, type UserMenuProps, UserMessage, type UserMessageProps, WebSearchPreview, type WebSearchPreviewProps, WriteFilePreview, type WriteFilePreviewProps, activeSessionsAtom, addMessage, addParts, badgeVariants, bumpActiveSessionActivity, buttonVariants, clearChat, cn, codeBlockGrammar, configurePdfViewer, copyText, createAuthFetcher, detectFileFormat, fenceInfo, fileExtension, filterFileTree, findUnsupportedOpenUINode, focusField, focusFieldInvalid, focusFieldWithin, focusRing, focusRingInset, formatBytes, formatCalendarDate, formatDuration, formatUptime, getActiveSession, getAllActiveSessions, getAllProjectActivity, getCodeLanguage, getFormatLabel, getSanitizedMarkdownHeadingIdFromRawFragment, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getSyntaxLanguage, getToolCategory, getToolDisplayMetadata, getToolErrorText, getTotalRunningSessionCount, hasBackgroundRunningSessions, initialsOf, isStreamingAtom, isViewerMessage, localToday, messagesAtom, numericColumns, parseCalendarDate, parseCsv, parseToolEvent, partMapAtom, registerActiveSession, resetActiveSessions, resolveFilePreviewKind, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, showsTaskPriority, tableCsv, taskProgress, taskStatus, timeAgo, toneFor, truncateText, unregisterActiveSession, updateActiveSessionMeta, updatePart, useActiveSession, useActiveSessions, useActiveSessionsState, useApiKey, useAuth, useAutoScroll, useDropdownMenu, useHasBackgroundRunningSessions, useLiveTime, useNavbarSessions, useProjectActivity, useProjectSessions, useRealtimeSession, useRunCollapseState, useRunGroups, useSSEStream, useSdkSession, useSessionsByActivity, useTheme, useToast, useToolCallStream, useTotalRunningSessions, validateOpenUIJsonArtifact, validateOpenUIJsonNode };
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ import { DropZone } from "./primitives/drop-zone.js";
39
39
  import { UploadProgress } from "./primitives/upload-progress.js";
40
40
  import { SidebarDropZone } from "./primitives/sidebar-drop-zone.js";
41
41
  import { ArtifactPane } from "./primitives/artifact-pane.js";
42
- import { CodeBlock, CopyButton } from "./markdown/code-block.js";
42
+ import { CodeBlock, CopyButton, codeBlockGrammar } from "./markdown/code-block.js";
43
43
  import { InlineCode } from "./primitives/code-block.js";
44
44
  import { ThemeToggle, useTheme } from "./primitives/theme-toggle.js";
45
45
  import { PageShell } from "./primitives/page-shell.js";
@@ -70,6 +70,8 @@ import { DiffPreview } from "./tool-previews/diff-preview.js";
70
70
  import { ExpandedToolDetail } from "./run/expanded-tool-detail.js";
71
71
  import { RunRowShell, RunRowStatusDot } from "./run/run-row-shell.js";
72
72
  import { InlineToolItem } from "./run/inline-tool-item.js";
73
+ import { fenceInfo } from "./markdown/code-meta.js";
74
+ import { numericColumns, tableCsv } from "./markdown/markdown-table.js";
73
75
  import { Markdown, getSanitizedMarkdownHeadingIdFromRawFragment } from "./markdown/markdown.js";
74
76
  import { InlineThinkingItem } from "./run/inline-thinking-item.js";
75
77
  import { OPENUI_NODE_JSON_SCHEMA, OPENUI_NODE_TYPES } from "./openui/schema-data.js";
@@ -85,6 +87,9 @@ import { ChatContainer } from "./chat/chat-container.js";
85
87
  import { ChatMessage } from "./chat/chat-message.js";
86
88
  import { LiveDuration } from "./run/run-item-primitives.js";
87
89
  import { ToolCallFeed, parseToolEvent } from "./run/tool-call-feed.js";
90
+ import { TaskList, showsTaskPriority, taskProgress, taskStatus } from "./run/task-list.js";
91
+ import { ApprovalCard, ApprovalDiffSummary } from "./run/approval-card.js";
92
+ import { RunPhaseList } from "./run/run-phase-list.js";
88
93
  import { FileTree, filterFileTree } from "./files/file-tree.js";
89
94
  import { RichFileTree } from "./files/rich-file-tree.js";
90
95
  import { FileCard } from "./files/file-card.js";
@@ -108,4 +113,4 @@ import { addMessage, addParts, clearChat, isStreamingAtom, messagesAtom, partMap
108
113
  import { copyText } from "./utils/copy-text.js";
109
114
  import { timeAgo } from "./utils/time-ago.js";
110
115
  import { RedactedDocument } from "./redaction/redacted-document.js";
111
- export { AgentTimeline, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, ArtifactPane, AuthHeader, Avatar, AvatarFallback, AvatarImage, Badge, Button, CATEGORY_TONES, CSV_PREVIEW_ROW_LIMIT, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChatContainer, ChatMessage, Checkbox, Chip, CodeBlock, Collapsible, CollapsibleContent, CollapsibleTrigger, CommandPreview, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CopyButton, DatePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiffPreview, DropZone, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, ExpandedToolDetail, FileArtifactPane, FileCard, FileList, FilePreview, FileTabs, FileTree, FilterField, GitHubLoginButton, GlobResultsPreview, GrepResultsPreview, Heading, HelpText, IconTile, InlineCode, InlineThinkingItem, InlineToolItem, Input, Label, LiveDuration, LoginLayout, Logo, Markdown, MessageAuthor, MessageList, Metric, MetricStrip, OPENUI_NODE_JSON_SCHEMA, OPENUI_NODE_TYPES, OpenUIArtifactRenderer, PageHeader, PageShell, Pagination, PdfViewer, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, QuestionPreview, RadioGroup, RadioGroupItem, RealtimeSessionRegistry, RedactedDocument, RichFileTree, RunGroup, RunRowShell, RunRowStatusDot, SegmentedControl, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, SidebarDropZone, Skeleton, SkeletonCard, SkeletonTable, Slider, StatCard, StatusPill, Switch, TONE_CLASSES, TOOL_CATEGORY_ICONS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, TangleKnot, TerminalCursor, TerminalDisplay, TerminalInput, TerminalLine, TextShimmer, Textarea, ThemeToggle, ThinkingIndicator, TimeSelect, ToastContainer, ToastProvider, ToolCallFeed, Toolbar, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UploadProgress, UserMenu, UserMessage, WebSearchPreview, WriteFilePreview, activeSessionsAtom, addMessage, addParts, badgeVariants, bumpActiveSessionActivity, buttonVariants, clearChat, cn, configurePdfViewer, copyText, createAuthFetcher, detectFileFormat, fileExtension, filterFileTree, findUnsupportedOpenUINode, focusField, focusFieldInvalid, focusFieldWithin, focusRing, focusRingInset, formatBytes, formatCalendarDate, formatDuration, formatUptime, getActiveSession, getAllActiveSessions, getAllProjectActivity, getCodeLanguage, getFormatLabel, getSanitizedMarkdownHeadingIdFromRawFragment, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getSyntaxLanguage, getToolCategory, getToolDisplayMetadata, getToolErrorText, getTotalRunningSessionCount, hasBackgroundRunningSessions, initialsOf, isStreamingAtom, isViewerMessage, localToday, messagesAtom, parseCalendarDate, parseCsv, parseToolEvent, partMapAtom, registerActiveSession, resetActiveSessions, resolveFilePreviewKind, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, timeAgo, toneFor, truncateText, unregisterActiveSession, updateActiveSessionMeta, updatePart, useActiveSession, useActiveSessions, useActiveSessionsState, useApiKey, useAuth, useAutoScroll, useDropdownMenu, useHasBackgroundRunningSessions, useLiveTime, useNavbarSessions, useProjectActivity, useProjectSessions, useRealtimeSession, useRunCollapseState, useRunGroups, useSSEStream, useSdkSession, useSessionsByActivity, useTheme, useToast, useToolCallStream, useTotalRunningSessions, validateOpenUIJsonArtifact, validateOpenUIJsonNode };
116
+ export { AgentTimeline, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, ApprovalCard, ApprovalDiffSummary, ArtifactPane, AuthHeader, Avatar, AvatarFallback, AvatarImage, Badge, Button, CATEGORY_TONES, CSV_PREVIEW_ROW_LIMIT, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChatContainer, ChatMessage, Checkbox, Chip, CodeBlock, Collapsible, CollapsibleContent, CollapsibleTrigger, CommandPreview, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CopyButton, DatePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiffPreview, DropZone, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, ExpandedToolDetail, FileArtifactPane, FileCard, FileList, FilePreview, FileTabs, FileTree, FilterField, GitHubLoginButton, GlobResultsPreview, GrepResultsPreview, Heading, HelpText, IconTile, InlineCode, InlineThinkingItem, InlineToolItem, Input, Label, LiveDuration, LoginLayout, Logo, Markdown, MessageAuthor, MessageList, Metric, MetricStrip, OPENUI_NODE_JSON_SCHEMA, OPENUI_NODE_TYPES, OpenUIArtifactRenderer, PageHeader, PageShell, Pagination, PdfViewer, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, QuestionPreview, RadioGroup, RadioGroupItem, RealtimeSessionRegistry, RedactedDocument, RichFileTree, RunGroup, RunPhaseList, RunRowShell, RunRowStatusDot, SegmentedControl, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, SidebarDropZone, Skeleton, SkeletonCard, SkeletonTable, Slider, StatCard, StatusPill, Switch, TONE_CLASSES, TOOL_CATEGORY_ICONS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, TangleKnot, TaskList, TerminalCursor, TerminalDisplay, TerminalInput, TerminalLine, TextShimmer, Textarea, ThemeToggle, ThinkingIndicator, TimeSelect, ToastContainer, ToastProvider, ToolCallFeed, Toolbar, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UploadProgress, UserMenu, UserMessage, WebSearchPreview, WriteFilePreview, activeSessionsAtom, addMessage, addParts, badgeVariants, bumpActiveSessionActivity, buttonVariants, clearChat, cn, codeBlockGrammar, configurePdfViewer, copyText, createAuthFetcher, detectFileFormat, fenceInfo, fileExtension, filterFileTree, findUnsupportedOpenUINode, focusField, focusFieldInvalid, focusFieldWithin, focusRing, focusRingInset, formatBytes, formatCalendarDate, formatDuration, formatUptime, getActiveSession, getAllActiveSessions, getAllProjectActivity, getCodeLanguage, getFormatLabel, getSanitizedMarkdownHeadingIdFromRawFragment, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getSyntaxLanguage, getToolCategory, getToolDisplayMetadata, getToolErrorText, getTotalRunningSessionCount, hasBackgroundRunningSessions, initialsOf, isStreamingAtom, isViewerMessage, localToday, messagesAtom, numericColumns, parseCalendarDate, parseCsv, parseToolEvent, partMapAtom, registerActiveSession, resetActiveSessions, resolveFilePreviewKind, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, showsTaskPriority, tableCsv, taskProgress, taskStatus, timeAgo, toneFor, truncateText, unregisterActiveSession, updateActiveSessionMeta, updatePart, useActiveSession, useActiveSessions, useActiveSessionsState, useApiKey, useAuth, useAutoScroll, useDropdownMenu, useHasBackgroundRunningSessions, useLiveTime, useNavbarSessions, useProjectActivity, useProjectSessions, useRealtimeSession, useRunCollapseState, useRunGroups, useSSEStream, useSdkSession, useSessionsByActivity, useTheme, useToast, useToolCallStream, useTotalRunningSessions, validateOpenUIJsonArtifact, validateOpenUIJsonNode };
@@ -1,20 +1,27 @@
1
1
  import { HTMLAttributes, ReactNode } from "react";
2
2
  //#region src/markdown/code-block.d.ts
3
+ /** The Shiki grammar for a fence language, or undefined for plain text. */
4
+ export declare function codeBlockGrammar(language: string | undefined): string | undefined;
3
5
  export interface CodeBlockProps extends HTMLAttributes<HTMLDivElement> {
4
6
  code: string;
5
7
  language?: string;
6
8
  /**
7
- * Header text. Defaults to `language`. Set this when the display name differs
8
- * from the highlight.js language id — e.g. a file extension ("BASHRC") whose
9
- * content highlights as a known language, or none.
9
+ * Header text. Defaults to the language's name. Set this when the display
10
+ * name differs from the language id, e.g. a file extension ("BASHRC").
10
11
  */
11
12
  label?: string;
13
+ /** The file the code belongs to, shown in the header with the language. */
14
+ filename?: string;
12
15
  showLineNumbers?: boolean;
13
16
  /** Force light (true) or dark (false); omitted inherits the nearest theme. */
14
17
  light?: boolean;
15
18
  children?: ReactNode;
16
19
  }
17
- export declare const CodeBlock: import("react").MemoExoticComponent<({ code, language, label, showLineNumbers, light, className, children, ...props }: CodeBlockProps) => import("react").JSX.Element>;
20
+ /**
21
+ * Code with Shiki highlighting in Brand's syntax colors. It renders readable
22
+ * plain code first (and on the server), then highlights once its grammar loads.
23
+ */
24
+ export declare const CodeBlock: import("react").MemoExoticComponent<({ code, language, label, filename, showLineNumbers, light, className, children, ...props }: CodeBlockProps) => import("react").JSX.Element>;
18
25
  /** Copy-to-clipboard button for use inside CodeBlock. */
19
26
  export declare const CopyButton: import("react").MemoExoticComponent<({ text }: {
20
27
  text: string;
@@ -2,145 +2,277 @@ import { focusRing, focusRingInset } from "../lib/focus.js";
2
2
  import { cn } from "../lib/utils.js";
3
3
  import { memo, useCallback, useEffect, useRef, useState } from "react";
4
4
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
5
- import { Check, Copy } from "lucide-react";
5
+ import { Check, Copy, FileCode2 } from "lucide-react";
6
6
  //#region src/markdown/code-block.tsx
7
- const syntaxTheme = (() => {
8
- const comment = "var(--syntax-comment, currentColor)";
9
- const keyword = "var(--syntax-keyword, currentColor)";
10
- const string = "var(--syntax-string, currentColor)";
11
- const fn = "var(--syntax-function, currentColor)";
12
- const number = "var(--syntax-number, currentColor)";
13
- const meta = "var(--syntax-meta, currentColor)";
14
- const error = "var(--syntax-error, currentColor)";
15
- const variable = "var(--syntax-variable, currentColor)";
16
- return {
17
- "hljs-comment": {
18
- color: comment,
19
- fontStyle: "italic"
20
- },
21
- "hljs-quote": {
22
- color: comment,
23
- fontStyle: "italic"
24
- },
25
- "hljs-doctag": { color: comment },
26
- "hljs-keyword": { color: keyword },
27
- "hljs-selector-tag": { color: keyword },
28
- "hljs-literal": { color: keyword },
29
- "hljs-type": { color: keyword },
30
- "hljs-class": { color: keyword },
31
- "hljs-string": { color: string },
32
- "hljs-template-tag": { color: string },
33
- "hljs-template-variable": { color: string },
34
- "hljs-addition": { color: string },
35
- "hljs-regexp": { color: string },
36
- "hljs-title": { color: fn },
37
- "hljs-section": { color: fn },
38
- "hljs-built_in": { color: fn },
39
- "hljs-name": { color: fn },
40
- "hljs-function": { color: fn },
41
- "hljs-selector-id": { color: fn },
42
- "hljs-selector-class": { color: fn },
43
- "hljs-attribute": { color: fn },
44
- "hljs-number": { color: number },
45
- "hljs-symbol": { color: number },
46
- "hljs-bullet": { color: number },
47
- "hljs-link": {
48
- color: number,
49
- textDecoration: "underline"
50
- },
51
- "hljs-meta": { color: meta },
52
- "hljs-selector-pseudo": { color: meta },
53
- "hljs-deletion": { color: error },
54
- "hljs-params": { color: variable },
55
- "hljs-variable": { color: variable },
56
- "hljs-tag": { color: variable },
57
- "hljs-attr": { color: variable },
58
- "hljs-subst": { color: variable },
59
- "hljs-strong": { fontWeight: "bold" },
60
- "hljs-emphasis": { fontStyle: "italic" },
61
- "hljs": {
62
- color: "var(--syntax-foreground, currentColor)",
63
- background: "transparent"
64
- }
65
- };
66
- })();
7
+ const SYNTAX = {
8
+ comment: "var(--syntax-comment, currentColor)",
9
+ keyword: "var(--syntax-keyword, currentColor)",
10
+ string: "var(--syntax-string, currentColor)",
11
+ function: "var(--syntax-function, currentColor)",
12
+ number: "var(--syntax-number, currentColor)",
13
+ variable: "var(--syntax-variable, currentColor)",
14
+ foreground: "var(--syntax-foreground, currentColor)"
15
+ };
16
+ const SHIKI_THEME = "tangle-syntax";
17
+ const BRAND_COLOR_FOR_SHIKI = {
18
+ "var(--shiki-foreground)": SYNTAX.foreground,
19
+ "var(--shiki-token-comment)": SYNTAX.comment,
20
+ "var(--shiki-token-keyword)": SYNTAX.keyword,
21
+ "var(--shiki-token-string)": SYNTAX.string,
22
+ "var(--shiki-token-string-expression)": SYNTAX.string,
23
+ "var(--shiki-token-function)": SYNTAX.function,
24
+ "var(--shiki-token-constant)": SYNTAX.number,
25
+ "var(--shiki-token-link)": SYNTAX.number,
26
+ "var(--shiki-token-parameter)": SYNTAX.variable,
27
+ "var(--shiki-token-punctuation)": SYNTAX.foreground
28
+ };
29
+ const GRAMMARS = {
30
+ typescript: () => import("shiki/langs/typescript.mjs"),
31
+ tsx: () => import("shiki/langs/tsx.mjs"),
32
+ javascript: () => import("shiki/langs/javascript.mjs"),
33
+ jsx: () => import("shiki/langs/jsx.mjs"),
34
+ json: () => import("shiki/langs/json.mjs"),
35
+ jsonc: () => import("shiki/langs/jsonc.mjs"),
36
+ bash: () => import("shiki/langs/bash.mjs"),
37
+ python: () => import("shiki/langs/python.mjs"),
38
+ html: () => import("shiki/langs/html.mjs"),
39
+ css: () => import("shiki/langs/css.mjs"),
40
+ scss: () => import("shiki/langs/scss.mjs"),
41
+ markdown: () => import("shiki/langs/markdown.mjs"),
42
+ mdx: () => import("shiki/langs/mdx.mjs"),
43
+ yaml: () => import("shiki/langs/yaml.mjs"),
44
+ toml: () => import("shiki/langs/toml.mjs"),
45
+ sql: () => import("shiki/langs/sql.mjs"),
46
+ diff: () => import("shiki/langs/diff.mjs"),
47
+ go: () => import("shiki/langs/go.mjs"),
48
+ rust: () => import("shiki/langs/rust.mjs"),
49
+ solidity: () => import("shiki/langs/solidity.mjs"),
50
+ ruby: () => import("shiki/langs/ruby.mjs"),
51
+ java: () => import("shiki/langs/java.mjs"),
52
+ kotlin: () => import("shiki/langs/kotlin.mjs"),
53
+ swift: () => import("shiki/langs/swift.mjs"),
54
+ php: () => import("shiki/langs/php.mjs"),
55
+ c: () => import("shiki/langs/c.mjs"),
56
+ cpp: () => import("shiki/langs/cpp.mjs"),
57
+ csharp: () => import("shiki/langs/csharp.mjs"),
58
+ graphql: () => import("shiki/langs/graphql.mjs"),
59
+ xml: () => import("shiki/langs/xml.mjs"),
60
+ dockerfile: () => import("shiki/langs/dockerfile.mjs")
61
+ };
62
+ const LANGUAGE_ALIASES = {
63
+ ts: "typescript",
64
+ mts: "typescript",
65
+ cts: "typescript",
66
+ js: "javascript",
67
+ mjs: "javascript",
68
+ cjs: "javascript",
69
+ node: "javascript",
70
+ sh: "bash",
71
+ shell: "bash",
72
+ zsh: "bash",
73
+ console: "bash",
74
+ shellscript: "bash",
75
+ py: "python",
76
+ python3: "python",
77
+ yml: "yaml",
78
+ md: "markdown",
79
+ rs: "rust",
80
+ sol: "solidity",
81
+ rb: "ruby",
82
+ kt: "kotlin",
83
+ cs: "csharp",
84
+ "c#": "csharp",
85
+ "c++": "cpp",
86
+ gql: "graphql",
87
+ svg: "xml",
88
+ docker: "dockerfile",
89
+ patch: "diff",
90
+ htm: "html"
91
+ };
92
+ const LANGUAGE_NAMES = {
93
+ typescript: "TypeScript",
94
+ tsx: "TSX",
95
+ javascript: "JavaScript",
96
+ jsx: "JSX",
97
+ json: "JSON",
98
+ jsonc: "JSONC",
99
+ bash: "Bash",
100
+ python: "Python",
101
+ html: "HTML",
102
+ css: "CSS",
103
+ scss: "SCSS",
104
+ markdown: "Markdown",
105
+ mdx: "MDX",
106
+ yaml: "YAML",
107
+ toml: "TOML",
108
+ sql: "SQL",
109
+ diff: "Diff",
110
+ go: "Go",
111
+ rust: "Rust",
112
+ solidity: "Solidity",
113
+ ruby: "Ruby",
114
+ java: "Java",
115
+ kotlin: "Kotlin",
116
+ swift: "Swift",
117
+ php: "PHP",
118
+ c: "C",
119
+ cpp: "C++",
120
+ csharp: "C#",
121
+ graphql: "GraphQL",
122
+ xml: "XML",
123
+ dockerfile: "Dockerfile"
124
+ };
125
+ /** The Shiki grammar for a fence language, or undefined for plain text. */
126
+ function codeBlockGrammar(language) {
127
+ if (!language) return void 0;
128
+ const id = language.toLowerCase();
129
+ const resolved = LANGUAGE_ALIASES[id] ?? id;
130
+ return GRAMMARS[resolved] ? resolved : void 0;
131
+ }
67
132
  let highlighterPromise;
133
+ const grammarLoads = /* @__PURE__ */ new Map();
68
134
  function loadHighlighter() {
69
- return highlighterPromise ??= import("react-syntax-highlighter/dist/esm/default-highlight").then((module) => module.default).catch((error) => {
135
+ return highlighterPromise ??= Promise.all([import("shiki/core"), import("shiki/engine/javascript")]).then(([core, engine]) => core.createHighlighterCore({
136
+ themes: [core.createCssVariablesTheme({
137
+ name: SHIKI_THEME,
138
+ variablePrefix: "--shiki-",
139
+ fontStyle: true
140
+ })],
141
+ langs: [],
142
+ engine: engine.createJavaScriptRegexEngine()
143
+ })).catch((error) => {
70
144
  highlighterPromise = void 0;
71
145
  throw error;
72
146
  });
73
147
  }
74
- const CodeBlock = memo(({ code, language, label, showLineNumbers = false, light, className, children, ...props }) => {
75
- const [Highlighter, setHighlighter] = useState(null);
148
+ async function tokenize(code, grammar) {
149
+ const highlighter = await loadHighlighter();
150
+ let load = grammarLoads.get(grammar);
151
+ if (!load) {
152
+ load = GRAMMARS[grammar]().then((module) => highlighter.loadLanguage(module.default));
153
+ load.catch(() => grammarLoads.delete(grammar));
154
+ grammarLoads.set(grammar, load);
155
+ }
156
+ await load;
157
+ return highlighter.codeToTokensBase(code, {
158
+ lang: grammar,
159
+ theme: SHIKI_THEME
160
+ });
161
+ }
162
+ function tokenStyle(token) {
163
+ const color = token.color ? BRAND_COLOR_FOR_SHIKI[token.color] ?? SYNTAX.foreground : void 0;
164
+ const style = token.fontStyle ?? 0;
165
+ if (!color && !style) return void 0;
166
+ return {
167
+ ...color ? { color } : {},
168
+ ...style & 1 ? { fontStyle: "italic" } : {},
169
+ ...style & 2 ? { fontWeight: "bold" } : {},
170
+ ...style & 4 ? { textDecoration: "underline" } : {}
171
+ };
172
+ }
173
+ /**
174
+ * Code with Shiki highlighting in Brand's syntax colors. It renders readable
175
+ * plain code first (and on the server), then highlights once its grammar loads.
176
+ */
177
+ const CodeBlock = memo(({ code, language, label, filename, showLineNumbers = false, light, className, children, ...props }) => {
178
+ const grammar = codeBlockGrammar(language);
179
+ const [highlighted, setHighlighted] = useState(null);
76
180
  useEffect(() => {
181
+ if (!grammar) return;
77
182
  let active = true;
78
- loadHighlighter().then((component) => {
79
- if (active) setHighlighter(() => component);
183
+ tokenize(code, grammar).then((lines) => {
184
+ if (active) setHighlighted({
185
+ code,
186
+ grammar,
187
+ lines
188
+ });
80
189
  }).catch(() => {});
81
190
  return () => {
82
191
  active = false;
83
192
  };
84
- }, []);
85
- const headerLabel = label ?? language;
193
+ }, [code, grammar]);
194
+ const languageName = grammar ? LANGUAGE_NAMES[grammar] : language;
195
+ const headerLabel = label ?? (filename ? void 0 : languageName);
196
+ const hasHeader = Boolean(filename || headerLabel);
86
197
  const mode = light === void 0 ? {} : { "data-theme": light ? "light" : "dark" };
87
- const customStyle = {
198
+ const preStyle = {
88
199
  margin: 0,
89
200
  padding: "var(--code-padding-y, 0.625rem) var(--code-padding-x, 0.75rem)",
90
201
  background: "transparent",
202
+ color: SYNTAX.foreground,
91
203
  fontSize: "var(--code-font-size, 0.8125rem)",
92
204
  lineHeight: "var(--code-line-height, 1.5)",
93
205
  overflowX: "auto"
94
206
  };
95
- const codeTagProps = { style: { fontFamily: "var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)" } };
96
- const scrollRegion = {
97
- tabIndex: 0,
98
- role: "region",
99
- "aria-label": headerLabel ? `${headerLabel} code` : "Code",
100
- className: focusRingInset
207
+ const codeStyle = {
208
+ fontFamily: "var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)",
209
+ whiteSpace: "pre"
101
210
  };
211
+ const isHighlighted = Boolean(highlighted && highlighted.code === code && highlighted.grammar === grammar);
212
+ const lines = isHighlighted ? highlighted.lines.map((line) => line.map((token) => ({
213
+ content: token.content,
214
+ style: tokenStyle(token)
215
+ }))) : code.split("\n").map((line) => [{ content: line }]);
216
+ const regionName = filename ?? headerLabel;
102
217
  return /* @__PURE__ */ jsxs("div", {
103
218
  className: cn("group relative overflow-hidden rounded-lg border font-mono", "bg-card border-border", className),
219
+ "data-highlighted": isHighlighted ? "true" : void 0,
104
220
  ...props,
105
221
  ...mode,
106
222
  children: [
107
- headerLabel && /* @__PURE__ */ jsxs("div", {
108
- className: "flex items-center justify-between border-b border-border px-3 py-1 bg-[var(--code-header-bg,hsl(var(--background)))]",
109
- children: [/* @__PURE__ */ jsx("span", {
110
- className: "text-xs font-mono font-medium uppercase tracking-widest text-muted-foreground",
223
+ hasHeader && /* @__PURE__ */ jsxs("div", {
224
+ className: "flex items-center justify-between gap-3 border-b border-border px-3 py-1.5 bg-[var(--code-header-bg,hsl(var(--background)))]",
225
+ children: [filename ? /* @__PURE__ */ jsxs("span", {
226
+ className: "flex min-w-0 items-center gap-2 font-sans text-sm",
227
+ children: [
228
+ /* @__PURE__ */ jsx(FileCode2, {
229
+ "aria-hidden": true,
230
+ className: "size-4 shrink-0 text-muted-foreground"
231
+ }),
232
+ /* @__PURE__ */ jsx("span", {
233
+ className: "min-w-0 truncate font-mono font-medium text-foreground",
234
+ title: filename,
235
+ children: filename
236
+ }),
237
+ languageName && /* @__PURE__ */ jsx("span", {
238
+ className: "shrink-0 text-muted-foreground",
239
+ children: languageName
240
+ })
241
+ ]
242
+ }) : /* @__PURE__ */ jsx("span", {
243
+ className: "font-sans text-sm font-medium text-muted-foreground",
111
244
  children: headerLabel
112
245
  }), children]
113
246
  }),
114
- !headerLabel && children && /* @__PURE__ */ jsx("div", {
115
- className: "absolute right-2 top-2 z-10 flex items-center gap-2 opacity-0 transition-opacity group-hover:opacity-100",
247
+ !hasHeader && children && /* @__PURE__ */ jsx("div", {
248
+ className: "absolute right-2 top-2 z-10 flex items-center gap-2 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",
116
249
  children
117
250
  }),
118
- Highlighter ? /* @__PURE__ */ jsx(Highlighter, {
119
- language: language ?? "text",
120
- style: syntaxTheme,
121
- showLineNumbers,
122
- lineNumberStyle: {
123
- color: "var(--syntax-comment, currentColor)",
124
- minWidth: "2.5em",
125
- paddingRight: "1em"
126
- },
127
- customStyle,
128
- codeTagProps,
129
- wrapLines: false,
130
- ...scrollRegion,
131
- children: code
132
- }) : /* @__PURE__ */ jsx("pre", {
133
- ...scrollRegion,
134
- style: {
135
- ...syntaxTheme.hljs,
136
- ...customStyle
137
- },
251
+ /* @__PURE__ */ jsx("pre", {
252
+ tabIndex: 0,
253
+ role: "region",
254
+ "aria-label": regionName ? `${regionName} code` : "Code",
255
+ className: focusRingInset,
256
+ style: preStyle,
138
257
  children: /* @__PURE__ */ jsx("code", {
139
- style: {
140
- ...codeTagProps.style,
141
- whiteSpace: "pre"
142
- },
143
- children: code
258
+ style: codeStyle,
259
+ children: !isHighlighted && !showLineNumbers ? code : lines.map((line, index) => /* @__PURE__ */ jsxs("span", { children: [
260
+ showLineNumbers && /* @__PURE__ */ jsx("span", {
261
+ "aria-hidden": "true",
262
+ "data-line-number": true,
263
+ className: "inline-block select-none pr-4 text-right",
264
+ style: {
265
+ color: SYNTAX.comment,
266
+ minWidth: "2.5em"
267
+ },
268
+ children: index + 1
269
+ }),
270
+ line.map((token, tokenIndex) => /* @__PURE__ */ jsx("span", {
271
+ style: token.style,
272
+ children: token.content
273
+ }, tokenIndex)),
274
+ index < lines.length - 1 ? "\n" : null
275
+ ] }, index))
144
276
  })
145
277
  })
146
278
  ]
@@ -197,4 +329,4 @@ const CopyButton = memo(({ text }) => {
197
329
  });
198
330
  CopyButton.displayName = "CopyButton";
199
331
  //#endregion
200
- export { CodeBlock, CopyButton };
332
+ export { CodeBlock, CopyButton, codeBlockGrammar };
@@ -0,0 +1,11 @@
1
+ //#region src/markdown/code-meta.d.ts
2
+ /**
3
+ * The language and file name of a fenced block, from its class and info
4
+ * string: ```ts title="src/x.ts"```, ```ts filename=src/x.ts```,
5
+ * ```ts src/x.ts```, ```ts:src/x.ts``` and ```src/x.ts``` all name the file.
6
+ */
7
+ export declare function fenceInfo(className: string | undefined, meta: unknown): {
8
+ language?: string;
9
+ filename?: string;
10
+ };
11
+ //#endregion