@assistant-ui/react-devtools 1.2.6 → 1.2.7
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 +26 -8
- package/dist/DevToolsModal.d.ts +18 -2
- package/dist/DevToolsModal.d.ts.map +1 -1
- package/dist/DevToolsModal.js +25 -232
- package/dist/DevToolsModal.js.map +1 -1
- package/dist/DevToolsModalImpl.d.ts +11 -0
- package/dist/DevToolsModalImpl.d.ts.map +1 -0
- package/dist/DevToolsModalImpl.js +62 -0
- package/dist/DevToolsModalImpl.js.map +1 -0
- package/dist/data/createInProcessClient.d.ts +17 -0
- package/dist/data/createInProcessClient.d.ts.map +1 -0
- package/dist/data/createInProcessClient.js +54 -0
- package/dist/data/createInProcessClient.js.map +1 -0
- package/dist/data/projectApi.d.ts +22 -0
- package/dist/data/projectApi.d.ts.map +1 -0
- package/dist/data/projectApi.js +103 -0
- package/dist/data/projectApi.js.map +1 -0
- package/dist/data/types.d.ts +52 -0
- package/dist/data/types.d.ts.map +1 -0
- package/dist/data/types.js +10 -0
- package/dist/data/types.js.map +1 -0
- package/dist/data/useDevToolsClient.d.ts +19 -0
- package/dist/data/useDevToolsClient.d.ts.map +1 -0
- package/dist/data/useDevToolsClient.js +70 -0
- package/dist/data/useDevToolsClient.js.map +1 -0
- package/dist/index.d.ts +9 -10
- package/dist/index.js +7 -9
- package/dist/shell/DevToolsOverlay.d.ts +23 -0
- package/dist/shell/DevToolsOverlay.d.ts.map +1 -0
- package/dist/shell/DevToolsOverlay.js +106 -0
- package/dist/shell/DevToolsOverlay.js.map +1 -0
- package/dist/shell/DevToolsPanel.d.ts +23 -0
- package/dist/shell/DevToolsPanel.d.ts.map +1 -0
- package/dist/shell/DevToolsPanel.js +256 -0
- package/dist/shell/DevToolsPanel.js.map +1 -0
- package/dist/shell/ShadowRoot.d.ts +24 -0
- package/dist/shell/ShadowRoot.d.ts.map +1 -0
- package/dist/shell/ShadowRoot.js +107 -0
- package/dist/shell/ShadowRoot.js.map +1 -0
- package/dist/shell/SplitLayout.d.ts +28 -0
- package/dist/shell/SplitLayout.d.ts.map +1 -0
- package/dist/shell/SplitLayout.js +67 -0
- package/dist/shell/SplitLayout.js.map +1 -0
- package/dist/shell/registry.d.ts +41 -0
- package/dist/shell/registry.d.ts.map +1 -0
- package/dist/shell/registry.js +36 -0
- package/dist/shell/registry.js.map +1 -0
- package/dist/shell/tabs/ActivityTab.d.ts +13 -0
- package/dist/shell/tabs/ActivityTab.d.ts.map +1 -0
- package/dist/shell/tabs/ActivityTab.js +259 -0
- package/dist/shell/tabs/ActivityTab.js.map +1 -0
- package/dist/shell/tabs/ContextTab.d.ts +11 -0
- package/dist/shell/tabs/ContextTab.d.ts.map +1 -0
- package/dist/shell/tabs/ContextTab.js +210 -0
- package/dist/shell/tabs/ContextTab.js.map +1 -0
- package/dist/shell/tabs/RawTab.d.ts +11 -0
- package/dist/shell/tabs/RawTab.d.ts.map +1 -0
- package/dist/shell/tabs/RawTab.js +238 -0
- package/dist/shell/tabs/RawTab.js.map +1 -0
- package/dist/shell/tabs/ThreadTab.d.ts +12 -0
- package/dist/shell/tabs/ThreadTab.d.ts.map +1 -0
- package/dist/shell/tabs/ThreadTab.js +426 -0
- package/dist/shell/tabs/ThreadTab.js.map +1 -0
- package/dist/shell/tabs/navSelection.d.ts +10 -0
- package/dist/shell/tabs/navSelection.d.ts.map +1 -0
- package/dist/shell/tabs/navSelection.js +37 -0
- package/dist/shell/tabs/navSelection.js.map +1 -0
- package/dist/styles/panel.generated.d.ts +5 -0
- package/dist/styles/panel.generated.d.ts.map +1 -0
- package/dist/styles/panel.generated.js +6 -0
- package/dist/styles/panel.generated.js.map +1 -0
- package/dist/types.d.ts +1 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/common.d.ts +24 -0
- package/dist/utils/common.d.ts.map +1 -0
- package/dist/utils/common.js +64 -0
- package/dist/utils/common.js.map +1 -0
- package/dist/utils/diff.d.ts +16 -0
- package/dist/utils/diff.d.ts.map +1 -0
- package/dist/utils/diff.js +41 -0
- package/dist/utils/diff.js.map +1 -0
- package/dist/utils/serialization.d.ts.map +1 -1
- package/dist/utils/serialization.js +4 -1
- package/dist/utils/serialization.js.map +1 -1
- package/dist/views/activity/EventLogRow.d.ts +28 -0
- package/dist/views/activity/EventLogRow.d.ts.map +1 -0
- package/dist/views/activity/EventLogRow.js +185 -0
- package/dist/views/activity/EventLogRow.js.map +1 -0
- package/dist/views/activity/EventStreamPane.d.ts +11 -0
- package/dist/views/activity/EventStreamPane.d.ts.map +1 -0
- package/dist/views/activity/EventStreamPane.js +98 -0
- package/dist/views/activity/EventStreamPane.js.map +1 -0
- package/dist/views/activity/OrphansPane.d.ts +11 -0
- package/dist/views/activity/OrphansPane.d.ts.map +1 -0
- package/dist/views/activity/OrphansPane.js +39 -0
- package/dist/views/activity/OrphansPane.js.map +1 -0
- package/dist/views/activity/RunDetailPane.d.ts +11 -0
- package/dist/views/activity/RunDetailPane.d.ts.map +1 -0
- package/dist/views/activity/RunDetailPane.js +344 -0
- package/dist/views/activity/RunDetailPane.js.map +1 -0
- package/dist/views/activity/activityNodes.d.ts +39 -0
- package/dist/views/activity/activityNodes.d.ts.map +1 -0
- package/dist/views/activity/activityNodes.js +199 -0
- package/dist/views/activity/activityNodes.js.map +1 -0
- package/dist/views/activity/index.d.ts +6 -0
- package/dist/views/activity/index.js +6 -0
- package/dist/views/attachments/AttachmentList.d.ts +15 -0
- package/dist/views/attachments/AttachmentList.d.ts.map +1 -0
- package/dist/views/attachments/AttachmentList.js +279 -0
- package/dist/views/attachments/AttachmentList.js.map +1 -0
- package/dist/views/attachments/MediaPartView.d.ts +27 -0
- package/dist/views/attachments/MediaPartView.d.ts.map +1 -0
- package/dist/views/attachments/MediaPartView.js +180 -0
- package/dist/views/attachments/MediaPartView.js.map +1 -0
- package/dist/views/attachments/formatBytes.d.ts +8 -0
- package/dist/views/attachments/formatBytes.d.ts.map +1 -0
- package/dist/views/attachments/formatBytes.js +14 -0
- package/dist/views/attachments/formatBytes.js.map +1 -0
- package/dist/views/attachments/index.d.ts +5 -0
- package/dist/views/attachments/index.js +4 -0
- package/dist/views/attachments/parseAttachment.d.ts +8 -0
- package/dist/views/attachments/parseAttachment.d.ts.map +1 -0
- package/dist/views/attachments/parseAttachment.js +58 -0
- package/dist/views/attachments/parseAttachment.js.map +1 -0
- package/dist/views/attachments/types.d.ts +18 -0
- package/dist/views/attachments/types.d.ts.map +1 -0
- package/dist/views/attachments/types.js +0 -0
- package/dist/views/context/ContextDetail.d.ts +14 -0
- package/dist/views/context/ContextDetail.d.ts.map +1 -0
- package/dist/views/context/ContextDetail.js +87 -0
- package/dist/views/context/ContextDetail.js.map +1 -0
- package/dist/views/context/ToolUIsView.d.ts +9 -0
- package/dist/views/context/ToolUIsView.d.ts.map +1 -0
- package/dist/views/context/ToolUIsView.js +80 -0
- package/dist/views/context/ToolUIsView.js.map +1 -0
- package/dist/views/context/contextNodes.d.ts +32 -0
- package/dist/views/context/contextNodes.d.ts.map +1 -0
- package/dist/views/context/contextNodes.js +49 -0
- package/dist/views/context/contextNodes.js.map +1 -0
- package/dist/views/context/index.d.ts +4 -0
- package/dist/views/context/index.js +4 -0
- package/dist/views/mcp/McpView.d.ts +11 -0
- package/dist/views/mcp/McpView.d.ts.map +1 -0
- package/dist/views/mcp/McpView.js +239 -0
- package/dist/views/mcp/McpView.js.map +1 -0
- package/dist/views/mcp/index.d.ts +2 -0
- package/dist/views/mcp/index.js +2 -0
- package/dist/views/mcp/parse.d.ts +7 -0
- package/dist/views/mcp/parse.d.ts.map +1 -0
- package/dist/views/mcp/parse.js +43 -0
- package/dist/views/mcp/parse.js.map +1 -0
- package/dist/views/mcp/types.d.ts +22 -0
- package/dist/views/mcp/types.d.ts.map +1 -0
- package/dist/views/mcp/types.js +0 -0
- package/dist/views/message/ChainOfThought.d.ts +11 -0
- package/dist/views/message/ChainOfThought.d.ts.map +1 -0
- package/dist/views/message/ChainOfThought.js +132 -0
- package/dist/views/message/ChainOfThought.js.map +1 -0
- package/dist/views/message/MessageDetailPane.d.ts +12 -0
- package/dist/views/message/MessageDetailPane.d.ts.map +1 -0
- package/dist/views/message/MessageDetailPane.js +38 -0
- package/dist/views/message/MessageDetailPane.js.map +1 -0
- package/dist/views/message/MessageItem.d.ts +13 -0
- package/dist/views/message/MessageItem.d.ts.map +1 -0
- package/dist/views/message/MessageItem.js +136 -0
- package/dist/views/message/MessageItem.js.map +1 -0
- package/dist/views/message/MessageList.d.ts +13 -0
- package/dist/views/message/MessageList.d.ts.map +1 -0
- package/dist/views/message/MessageList.js +95 -0
- package/dist/views/message/MessageList.js.map +1 -0
- package/dist/views/message/MessageMetrics.d.ts +11 -0
- package/dist/views/message/MessageMetrics.d.ts.map +1 -0
- package/dist/views/message/MessageMetrics.js +93 -0
- package/dist/views/message/MessageMetrics.js.map +1 -0
- package/dist/views/message/MessageTimeline.d.ts +16 -0
- package/dist/views/message/MessageTimeline.d.ts.map +1 -0
- package/dist/views/message/MessageTimeline.js +100 -0
- package/dist/views/message/MessageTimeline.js.map +1 -0
- package/dist/views/message/PartDisclosure.d.ts +18 -0
- package/dist/views/message/PartDisclosure.d.ts.map +1 -0
- package/dist/views/message/PartDisclosure.js +79 -0
- package/dist/views/message/PartDisclosure.js.map +1 -0
- package/dist/views/message/PartView.d.ts +13 -0
- package/dist/views/message/PartView.d.ts.map +1 -0
- package/dist/views/message/PartView.js +416 -0
- package/dist/views/message/PartView.js.map +1 -0
- package/dist/views/message/RoleLabel.d.ts +11 -0
- package/dist/views/message/RoleLabel.d.ts.map +1 -0
- package/dist/views/message/RoleLabel.js +30 -0
- package/dist/views/message/RoleLabel.js.map +1 -0
- package/dist/views/message/StatusBadge.d.ts +17 -0
- package/dist/views/message/StatusBadge.d.ts.map +1 -0
- package/dist/views/message/StatusBadge.js +58 -0
- package/dist/views/message/StatusBadge.js.map +1 -0
- package/dist/views/message/ToolCallView.d.ts +13 -0
- package/dist/views/message/ToolCallView.d.ts.map +1 -0
- package/dist/views/message/ToolCallView.js +289 -0
- package/dist/views/message/ToolCallView.js.map +1 -0
- package/dist/views/message/TtftBar.d.ts +16 -0
- package/dist/views/message/TtftBar.d.ts.map +1 -0
- package/dist/views/message/TtftBar.js +128 -0
- package/dist/views/message/TtftBar.js.map +1 -0
- package/dist/views/message/index.d.ts +6 -0
- package/dist/views/message/index.js +5 -0
- package/dist/views/message/messagePlainText.d.ts +8 -0
- package/dist/views/message/messagePlainText.d.ts.map +1 -0
- package/dist/views/message/messagePlainText.js +39 -0
- package/dist/views/message/messagePlainText.js.map +1 -0
- package/dist/views/message/parse.d.ts +10 -0
- package/dist/views/message/parse.d.ts.map +1 -0
- package/dist/views/message/parse.js +235 -0
- package/dist/views/message/parse.js.map +1 -0
- package/dist/views/message/types.d.ts +114 -0
- package/dist/views/message/types.d.ts.map +1 -0
- package/dist/views/message/types.js +0 -0
- package/dist/views/model-context/ModelContextView.d.ts +26 -0
- package/dist/views/model-context/ModelContextView.d.ts.map +1 -0
- package/dist/views/model-context/ModelContextView.js +214 -0
- package/dist/views/model-context/ModelContextView.js.map +1 -0
- package/dist/views/nav.d.ts +19 -0
- package/dist/views/nav.d.ts.map +1 -0
- package/dist/views/nav.js +8 -0
- package/dist/views/nav.js.map +1 -0
- package/dist/views/raw/RawDetail.d.ts +15 -0
- package/dist/views/raw/RawDetail.d.ts.map +1 -0
- package/dist/views/raw/RawDetail.js +79 -0
- package/dist/views/raw/RawDetail.js.map +1 -0
- package/dist/views/raw/index.d.ts +3 -0
- package/dist/views/raw/index.js +3 -0
- package/dist/views/raw/rawNodes.d.ts +20 -0
- package/dist/views/raw/rawNodes.d.ts.map +1 -0
- package/dist/views/raw/rawNodes.js +78 -0
- package/dist/views/raw/rawNodes.js.map +1 -0
- package/dist/views/raw/statePreview.d.ts +5 -0
- package/dist/views/raw/statePreview.d.ts.map +1 -0
- package/dist/views/raw/statePreview.js +213 -0
- package/dist/views/raw/statePreview.js.map +1 -0
- package/dist/views/runs/PayloadDiff.d.ts +11 -0
- package/dist/views/runs/PayloadDiff.d.ts.map +1 -0
- package/dist/views/runs/PayloadDiff.js +92 -0
- package/dist/views/runs/PayloadDiff.js.map +1 -0
- package/dist/views/runs/parse.d.ts +8 -0
- package/dist/views/runs/parse.d.ts.map +1 -0
- package/dist/views/runs/parse.js +78 -0
- package/dist/views/runs/parse.js.map +1 -0
- package/dist/views/runs/types.d.ts +25 -0
- package/dist/views/runs/types.d.ts.map +1 -0
- package/dist/views/runs/types.js +0 -0
- package/dist/views/scopes/ScopesView.d.ts +9 -0
- package/dist/views/scopes/ScopesView.d.ts.map +1 -0
- package/dist/views/scopes/ScopesView.js +235 -0
- package/dist/views/scopes/ScopesView.js.map +1 -0
- package/dist/views/scopes/index.d.ts +2 -0
- package/dist/views/scopes/index.js +2 -0
- package/dist/views/scopes/parse.d.ts +7 -0
- package/dist/views/scopes/parse.d.ts.map +1 -0
- package/dist/views/scopes/parse.js +23 -0
- package/dist/views/scopes/parse.js.map +1 -0
- package/dist/views/scopes/types.d.ts +10 -0
- package/dist/views/scopes/types.d.ts.map +1 -0
- package/dist/views/scopes/types.js +0 -0
- package/dist/views/thread/ComposerAttachments.d.ts +11 -0
- package/dist/views/thread/ComposerAttachments.d.ts.map +1 -0
- package/dist/views/thread/ComposerAttachments.js +22 -0
- package/dist/views/thread/ComposerAttachments.js.map +1 -0
- package/dist/views/thread/ComposerFlags.d.ts +11 -0
- package/dist/views/thread/ComposerFlags.d.ts.map +1 -0
- package/dist/views/thread/ComposerFlags.js +54 -0
- package/dist/views/thread/ComposerFlags.js.map +1 -0
- package/dist/views/thread/ComposerQueue.d.ts +11 -0
- package/dist/views/thread/ComposerQueue.d.ts.map +1 -0
- package/dist/views/thread/ComposerQueue.js +55 -0
- package/dist/views/thread/ComposerQueue.js.map +1 -0
- package/dist/views/thread/ConversationList.d.ts +18 -0
- package/dist/views/thread/ConversationList.d.ts.map +1 -0
- package/dist/views/thread/ConversationList.js +228 -0
- package/dist/views/thread/ConversationList.js.map +1 -0
- package/dist/views/thread/ConversationStatusDot.d.ts +29 -0
- package/dist/views/thread/ConversationStatusDot.d.ts.map +1 -0
- package/dist/views/thread/ConversationStatusDot.js +91 -0
- package/dist/views/thread/ConversationStatusDot.js.map +1 -0
- package/dist/views/thread/ThreadDetails.d.ts +13 -0
- package/dist/views/thread/ThreadDetails.d.ts.map +1 -0
- package/dist/views/thread/ThreadDetails.js +170 -0
- package/dist/views/thread/ThreadDetails.js.map +1 -0
- package/dist/views/thread/Transcript.d.ts +21 -0
- package/dist/views/thread/Transcript.d.ts.map +1 -0
- package/dist/views/thread/Transcript.js +520 -0
- package/dist/views/thread/Transcript.js.map +1 -0
- package/dist/views/thread/index.d.ts +10 -0
- package/dist/views/thread/index.js +9 -0
- package/dist/views/thread/resolve.d.ts +13 -0
- package/dist/views/thread/resolve.d.ts.map +1 -0
- package/dist/views/thread/resolve.js +29 -0
- package/dist/views/thread/resolve.js.map +1 -0
- package/dist/views/thread/types.d.ts +50 -0
- package/dist/views/thread/types.d.ts.map +1 -0
- package/dist/views/thread/types.js +0 -0
- package/dist/views/thread/utils.d.ts +10 -0
- package/dist/views/thread/utils.d.ts.map +1 -0
- package/dist/views/thread/utils.js +77 -0
- package/dist/views/thread/utils.js.map +1 -0
- package/dist/views/ui/CenteredMessage.d.ts +11 -0
- package/dist/views/ui/CenteredMessage.d.ts.map +1 -0
- package/dist/views/ui/CenteredMessage.js +21 -0
- package/dist/views/ui/CenteredMessage.js.map +1 -0
- package/dist/views/ui/Chip.d.ts +13 -0
- package/dist/views/ui/Chip.d.ts.map +1 -0
- package/dist/views/ui/Chip.js +30 -0
- package/dist/views/ui/Chip.js.map +1 -0
- package/dist/views/ui/ControlButton.d.ts +10 -0
- package/dist/views/ui/ControlButton.d.ts.map +1 -0
- package/dist/views/ui/ControlButton.js +39 -0
- package/dist/views/ui/ControlButton.js.map +1 -0
- package/dist/views/ui/CopyButton.d.ts +19 -0
- package/dist/views/ui/CopyButton.d.ts.map +1 -0
- package/dist/views/ui/CopyButton.js +125 -0
- package/dist/views/ui/CopyButton.js.map +1 -0
- package/dist/views/ui/EmptyState.d.ts +11 -0
- package/dist/views/ui/EmptyState.d.ts.map +1 -0
- package/dist/views/ui/EmptyState.js +21 -0
- package/dist/views/ui/EmptyState.js.map +1 -0
- package/dist/views/ui/InfoCard.d.ts +22 -0
- package/dist/views/ui/InfoCard.d.ts.map +1 -0
- package/dist/views/ui/InfoCard.js +44 -0
- package/dist/views/ui/InfoCard.js.map +1 -0
- package/dist/views/ui/JSONTree.d.ts +16 -0
- package/dist/views/ui/JSONTree.d.ts.map +1 -0
- package/dist/views/ui/JSONTree.js +394 -0
- package/dist/views/ui/JSONTree.js.map +1 -0
- package/dist/views/ui/PaneHeader.d.ts +27 -0
- package/dist/views/ui/PaneHeader.d.ts.map +1 -0
- package/dist/views/ui/PaneHeader.js +71 -0
- package/dist/views/ui/PaneHeader.js.map +1 -0
- package/dist/views/ui/RailTime.d.ts +12 -0
- package/dist/views/ui/RailTime.d.ts.map +1 -0
- package/dist/views/ui/RailTime.js +49 -0
- package/dist/views/ui/RailTime.js.map +1 -0
- package/dist/views/ui/SectionLabel.d.ts +11 -0
- package/dist/views/ui/SectionLabel.d.ts.map +1 -0
- package/dist/views/ui/SectionLabel.js +21 -0
- package/dist/views/ui/SectionLabel.js.map +1 -0
- package/dist/views/ui/SelectableRow.d.ts +18 -0
- package/dist/views/ui/SelectableRow.d.ts.map +1 -0
- package/dist/views/ui/SelectableRow.js +49 -0
- package/dist/views/ui/SelectableRow.js.map +1 -0
- package/dist/views/ui/Sparkline.d.ts +17 -0
- package/dist/views/ui/Sparkline.d.ts.map +1 -0
- package/dist/views/ui/Sparkline.js +96 -0
- package/dist/views/ui/Sparkline.js.map +1 -0
- package/dist/views/ui/SummaryItem.d.ts +23 -0
- package/dist/views/ui/SummaryItem.d.ts.map +1 -0
- package/dist/views/ui/SummaryItem.js +59 -0
- package/dist/views/ui/SummaryItem.js.map +1 -0
- package/dist/views/ui/ToneBadge.d.ts +18 -0
- package/dist/views/ui/ToneBadge.d.ts.map +1 -0
- package/dist/views/ui/ToneBadge.js +34 -0
- package/dist/views/ui/ToneBadge.js.map +1 -0
- package/dist/views/ui/badgeTone.d.ts +21 -0
- package/dist/views/ui/badgeTone.d.ts.map +1 -0
- package/dist/views/ui/badgeTone.js +33 -0
- package/dist/views/ui/badgeTone.js.map +1 -0
- package/dist/views/ui/index.d.ts +16 -0
- package/dist/views/ui/index.js +16 -0
- package/dist/views/ui/useCopyToClipboard.d.ts +12 -0
- package/dist/views/ui/useCopyToClipboard.d.ts.map +1 -0
- package/dist/views/ui/useCopyToClipboard.js +44 -0
- package/dist/views/ui/useCopyToClipboard.js.map +1 -0
- package/package.json +9 -5
- package/src/DevToolsModal.tsx +26 -179
- package/src/DevToolsModalImpl.tsx +60 -0
- package/src/data/createInProcessClient.ts +66 -0
- package/src/data/projectApi.test.ts +100 -0
- package/src/data/projectApi.ts +169 -0
- package/src/data/types.ts +54 -0
- package/src/data/useDevToolsClient.ts +59 -0
- package/src/index.ts +16 -13
- package/src/shell/DevToolsOverlay.tsx +84 -0
- package/src/shell/DevToolsPanel.tsx +192 -0
- package/src/shell/ShadowRoot.tsx +85 -0
- package/src/shell/SplitLayout.tsx +46 -0
- package/src/shell/registry.ts +51 -0
- package/src/shell/tabs/ActivityTab.test.tsx +34 -0
- package/src/shell/tabs/ActivityTab.tsx +161 -0
- package/src/shell/tabs/ContextTab.test.tsx +37 -0
- package/src/shell/tabs/ContextTab.tsx +157 -0
- package/src/shell/tabs/RawTab.test.tsx +43 -0
- package/src/shell/tabs/RawTab.tsx +123 -0
- package/src/shell/tabs/ThreadTab.tsx +220 -0
- package/src/shell/tabs/navSelection.ts +17 -0
- package/src/styles/panel.css +153 -0
- package/src/styles/panel.generated.ts +2 -0
- package/src/types.ts +0 -5
- package/src/utils/common.test.ts +30 -0
- package/src/utils/common.ts +101 -0
- package/src/utils/diff.test.ts +37 -0
- package/src/utils/diff.ts +41 -0
- package/src/utils/serialization.test.ts +31 -0
- package/src/utils/serialization.ts +4 -1
- package/src/views/activity/EventLogRow.tsx +108 -0
- package/src/views/activity/EventStreamPane.tsx +86 -0
- package/src/views/activity/OrphansPane.tsx +23 -0
- package/src/views/activity/RunDetailPane.tsx +128 -0
- package/src/views/activity/activityNodes.test.ts +24 -0
- package/src/views/activity/activityNodes.ts +179 -0
- package/src/views/activity/index.ts +10 -0
- package/src/views/attachments/AttachmentList.tsx +122 -0
- package/src/views/attachments/MediaPartView.tsx +77 -0
- package/src/views/attachments/formatBytes.ts +15 -0
- package/src/views/attachments/index.ts +4 -0
- package/src/views/attachments/parseAttachment.test.ts +37 -0
- package/src/views/attachments/parseAttachment.ts +85 -0
- package/src/views/attachments/types.ts +15 -0
- package/src/views/context/ContextDetail.tsx +37 -0
- package/src/views/context/ToolUIsView.tsx +44 -0
- package/src/views/context/contextNodes.test.ts +31 -0
- package/src/views/context/contextNodes.ts +66 -0
- package/src/views/context/index.ts +4 -0
- package/src/views/mcp/McpView.tsx +125 -0
- package/src/views/mcp/index.ts +1 -0
- package/src/views/mcp/parse.test.ts +63 -0
- package/src/views/mcp/parse.ts +65 -0
- package/src/views/mcp/render.test.tsx +34 -0
- package/src/views/mcp/types.ts +20 -0
- package/src/views/message/ChainOfThought.tsx +74 -0
- package/src/views/message/MessageDetailPane.tsx +26 -0
- package/src/views/message/MessageItem.tsx +94 -0
- package/src/views/message/MessageList.tsx +48 -0
- package/src/views/message/MessageMetrics.tsx +68 -0
- package/src/views/message/MessageTimeline.test.tsx +78 -0
- package/src/views/message/MessageTimeline.tsx +51 -0
- package/src/views/message/PartDisclosure.tsx +32 -0
- package/src/views/message/PartView.tsx +197 -0
- package/src/views/message/RoleLabel.tsx +22 -0
- package/src/views/message/StatusBadge.tsx +28 -0
- package/src/views/message/ToolCallView.tsx +151 -0
- package/src/views/message/TtftBar.tsx +44 -0
- package/src/views/message/index.ts +5 -0
- package/src/views/message/messagePlainText.test.ts +48 -0
- package/src/views/message/messagePlainText.ts +65 -0
- package/src/views/message/parse.test.ts +269 -0
- package/src/views/message/parse.ts +282 -0
- package/src/views/message/render.test.tsx +128 -0
- package/src/views/message/types.ts +137 -0
- package/src/views/model-context/ModelContextView.tsx +71 -0
- package/src/views/model-context/render.test.tsx +24 -0
- package/src/views/nav.ts +18 -0
- package/src/views/raw/RawDetail.tsx +39 -0
- package/src/views/raw/index.ts +3 -0
- package/src/views/raw/rawNodes.test.ts +38 -0
- package/src/views/raw/rawNodes.ts +107 -0
- package/src/views/raw/statePreview.tsx +188 -0
- package/src/views/runs/PayloadDiff.tsx +49 -0
- package/src/views/runs/parse.test.ts +152 -0
- package/src/views/runs/parse.ts +110 -0
- package/src/views/runs/types.ts +23 -0
- package/src/views/scopes/ScopesView.tsx +105 -0
- package/src/views/scopes/index.ts +1 -0
- package/src/views/scopes/parse.test.ts +35 -0
- package/src/views/scopes/parse.ts +30 -0
- package/src/views/scopes/render.test.tsx +35 -0
- package/src/views/scopes/types.ts +6 -0
- package/src/views/thread/ComposerAttachments.test.tsx +36 -0
- package/src/views/thread/ComposerAttachments.tsx +8 -0
- package/src/views/thread/ComposerFlags.test.tsx +23 -0
- package/src/views/thread/ComposerFlags.tsx +19 -0
- package/src/views/thread/ComposerQueue.test.tsx +20 -0
- package/src/views/thread/ComposerQueue.tsx +26 -0
- package/src/views/thread/ConversationList.tsx +127 -0
- package/src/views/thread/ConversationStatusDot.test.ts +86 -0
- package/src/views/thread/ConversationStatusDot.tsx +126 -0
- package/src/views/thread/ThreadDetails.tsx +85 -0
- package/src/views/thread/Transcript.test.tsx +56 -0
- package/src/views/thread/Transcript.tsx +332 -0
- package/src/views/thread/index.ts +19 -0
- package/src/views/thread/render.test.tsx +41 -0
- package/src/views/thread/resolve.ts +36 -0
- package/src/views/thread/types.ts +53 -0
- package/src/views/thread/utils.test.ts +72 -0
- package/src/views/thread/utils.ts +149 -0
- package/src/views/ui/CenteredMessage.tsx +7 -0
- package/src/views/ui/Chip.tsx +17 -0
- package/src/views/ui/ControlButton.tsx +15 -0
- package/src/views/ui/CopyButton.tsx +73 -0
- package/src/views/ui/EmptyState.tsx +7 -0
- package/src/views/ui/InfoCard.tsx +35 -0
- package/src/views/ui/JSONTree.test.tsx +29 -0
- package/src/views/ui/JSONTree.tsx +240 -0
- package/src/views/ui/PaneHeader.tsx +46 -0
- package/src/views/ui/RailTime.tsx +27 -0
- package/src/views/ui/SectionLabel.tsx +7 -0
- package/src/views/ui/SelectableRow.tsx +41 -0
- package/src/views/ui/Sparkline.tsx +49 -0
- package/src/views/ui/SummaryItem.tsx +25 -0
- package/src/views/ui/ToneBadge.tsx +26 -0
- package/src/views/ui/badgeTone.ts +40 -0
- package/src/views/ui/index.ts +20 -0
- package/src/views/ui/useCopyToClipboard.ts +27 -0
- package/dist/DevToolsFrame.d.ts +0 -11
- package/dist/DevToolsFrame.d.ts.map +0 -1
- package/dist/DevToolsFrame.js +0 -66
- package/dist/DevToolsFrame.js.map +0 -1
- package/dist/DevToolsHost.d.ts +0 -38
- package/dist/DevToolsHost.d.ts.map +0 -1
- package/dist/DevToolsHost.js +0 -93
- package/dist/DevToolsHost.js.map +0 -1
- package/dist/ExtensionHost.d.ts +0 -10
- package/dist/ExtensionHost.d.ts.map +0 -1
- package/dist/ExtensionHost.js +0 -42
- package/dist/ExtensionHost.js.map +0 -1
- package/dist/FrameClient.d.ts +0 -38
- package/dist/FrameClient.d.ts.map +0 -1
- package/dist/FrameClient.js +0 -53
- package/dist/FrameClient.js.map +0 -1
- package/dist/FrameHost.d.ts +0 -11
- package/dist/FrameHost.d.ts.map +0 -1
- package/dist/FrameHost.js +0 -26
- package/dist/FrameHost.js.map +0 -1
- package/dist/constants.d.ts +0 -6
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -7
- package/dist/constants.js.map +0 -1
- package/dist/styles/DevToolsModal.styles.d.ts +0 -18
- package/dist/styles/DevToolsModal.styles.d.ts.map +0 -1
- package/dist/styles/DevToolsModal.styles.js +0 -120
- package/dist/styles/DevToolsModal.styles.js.map +0 -1
- package/src/DevToolsFrame.tsx +0 -55
- package/src/DevToolsHost.ts +0 -178
- package/src/ExtensionHost.ts +0 -57
- package/src/FrameClient.ts +0 -99
- package/src/FrameHost.ts +0 -31
- package/src/constants.ts +0 -2
- package/src/styles/DevToolsModal.styles.ts +0 -137
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { STATUS_TONE } from "../ui/badgeTone.js";
|
|
2
|
+
import { CopyButton } from "../ui/CopyButton.js";
|
|
3
|
+
import { ToneBadge } from "../ui/ToneBadge.js";
|
|
4
|
+
import { formatBytes } from "./formatBytes.js";
|
|
5
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import clsx from "clsx";
|
|
8
|
+
//#region src/views/attachments/AttachmentList.tsx
|
|
9
|
+
const statusLabel = (status) => {
|
|
10
|
+
if (status.type === "running" && typeof status.progress === "number") {
|
|
11
|
+
const pct = status.progress <= 1 ? status.progress * 100 : status.progress;
|
|
12
|
+
return `${status.reason ?? "uploading"} ${Math.round(pct)}%`;
|
|
13
|
+
}
|
|
14
|
+
return status.reason ? `${status.type} · ${status.reason}` : status.type;
|
|
15
|
+
};
|
|
16
|
+
const kindIcon = (attachment) => {
|
|
17
|
+
const kind = attachment.kind ?? attachment.contentType ?? "";
|
|
18
|
+
if (kind.includes("image") || attachment.previewUrl) return "img";
|
|
19
|
+
if (kind.includes("audio")) return "aud";
|
|
20
|
+
if (kind.includes("pdf") || kind === "document") return "doc";
|
|
21
|
+
return "file";
|
|
22
|
+
};
|
|
23
|
+
const AttachmentRow = (t0) => {
|
|
24
|
+
const $ = c(47);
|
|
25
|
+
const { attachment } = t0;
|
|
26
|
+
let t1;
|
|
27
|
+
if ($[0] !== attachment.sizeBytes) {
|
|
28
|
+
t1 = formatBytes(attachment.sizeBytes);
|
|
29
|
+
$[0] = attachment.sizeBytes;
|
|
30
|
+
$[1] = t1;
|
|
31
|
+
} else t1 = $[1];
|
|
32
|
+
const size = t1;
|
|
33
|
+
let t2;
|
|
34
|
+
if ($[2] !== attachment.contentType || $[3] !== attachment.kind || $[4] !== size) {
|
|
35
|
+
t2 = [
|
|
36
|
+
attachment.kind,
|
|
37
|
+
attachment.contentType,
|
|
38
|
+
size
|
|
39
|
+
].filter(Boolean);
|
|
40
|
+
$[2] = attachment.contentType;
|
|
41
|
+
$[3] = attachment.kind;
|
|
42
|
+
$[4] = size;
|
|
43
|
+
$[5] = t2;
|
|
44
|
+
} else t2 = $[5];
|
|
45
|
+
const meta = t2.join(" · ");
|
|
46
|
+
let t3;
|
|
47
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
48
|
+
t3 = /* @__PURE__ */ jsx("span", {
|
|
49
|
+
className: "text-muted-foreground inline-block shrink-0 transition-transform group-open:rotate-90",
|
|
50
|
+
children: "›"
|
|
51
|
+
});
|
|
52
|
+
$[6] = t3;
|
|
53
|
+
} else t3 = $[6];
|
|
54
|
+
let t4;
|
|
55
|
+
if ($[7] !== attachment) {
|
|
56
|
+
t4 = kindIcon(attachment);
|
|
57
|
+
$[7] = attachment;
|
|
58
|
+
$[8] = t4;
|
|
59
|
+
} else t4 = $[8];
|
|
60
|
+
let t5;
|
|
61
|
+
if ($[9] !== t4) {
|
|
62
|
+
t5 = /* @__PURE__ */ jsx(ToneBadge, {
|
|
63
|
+
tone: "zinc",
|
|
64
|
+
size: "sm",
|
|
65
|
+
children: t4
|
|
66
|
+
});
|
|
67
|
+
$[9] = t4;
|
|
68
|
+
$[10] = t5;
|
|
69
|
+
} else t5 = $[10];
|
|
70
|
+
let t6;
|
|
71
|
+
if ($[11] !== attachment.name) {
|
|
72
|
+
t6 = /* @__PURE__ */ jsx("span", {
|
|
73
|
+
className: "text-foreground min-w-0 flex-1 truncate font-medium",
|
|
74
|
+
children: attachment.name
|
|
75
|
+
});
|
|
76
|
+
$[11] = attachment.name;
|
|
77
|
+
$[12] = t6;
|
|
78
|
+
} else t6 = $[12];
|
|
79
|
+
let t7;
|
|
80
|
+
if ($[13] !== meta) {
|
|
81
|
+
t7 = meta ? /* @__PURE__ */ jsx("span", {
|
|
82
|
+
className: "text-muted-foreground hidden max-w-[45%] truncate text-[10px] sm:inline",
|
|
83
|
+
children: meta
|
|
84
|
+
}) : null;
|
|
85
|
+
$[13] = meta;
|
|
86
|
+
$[14] = t7;
|
|
87
|
+
} else t7 = $[14];
|
|
88
|
+
let t8;
|
|
89
|
+
if ($[15] !== attachment.status) {
|
|
90
|
+
t8 = attachment.status ? /* @__PURE__ */ jsx(ToneBadge, {
|
|
91
|
+
tone: STATUS_TONE[attachment.status.type] ?? "zinc",
|
|
92
|
+
size: "sm",
|
|
93
|
+
children: statusLabel(attachment.status)
|
|
94
|
+
}) : null;
|
|
95
|
+
$[15] = attachment.status;
|
|
96
|
+
$[16] = t8;
|
|
97
|
+
} else t8 = $[16];
|
|
98
|
+
let t9;
|
|
99
|
+
if ($[17] !== t5 || $[18] !== t6 || $[19] !== t7 || $[20] !== t8) {
|
|
100
|
+
t9 = /* @__PURE__ */ jsxs("summary", {
|
|
101
|
+
className: "hover:bg-accent/40 flex cursor-pointer list-none items-center gap-1.5 px-2 py-1 text-[11px] select-none",
|
|
102
|
+
children: [
|
|
103
|
+
t3,
|
|
104
|
+
t5,
|
|
105
|
+
t6,
|
|
106
|
+
t7,
|
|
107
|
+
t8
|
|
108
|
+
]
|
|
109
|
+
});
|
|
110
|
+
$[17] = t5;
|
|
111
|
+
$[18] = t6;
|
|
112
|
+
$[19] = t7;
|
|
113
|
+
$[20] = t8;
|
|
114
|
+
$[21] = t9;
|
|
115
|
+
} else t9 = $[21];
|
|
116
|
+
let t10;
|
|
117
|
+
if ($[22] !== attachment.name || $[23] !== attachment.previewUrl) {
|
|
118
|
+
t10 = attachment.previewUrl ? /* @__PURE__ */ jsx("img", {
|
|
119
|
+
src: attachment.previewUrl,
|
|
120
|
+
alt: attachment.name,
|
|
121
|
+
className: "border-border max-h-24 max-w-full rounded border object-contain"
|
|
122
|
+
}) : null;
|
|
123
|
+
$[22] = attachment.name;
|
|
124
|
+
$[23] = attachment.previewUrl;
|
|
125
|
+
$[24] = t10;
|
|
126
|
+
} else t10 = $[24];
|
|
127
|
+
let t11;
|
|
128
|
+
if ($[25] !== attachment.id) {
|
|
129
|
+
t11 = attachment.id ? /* @__PURE__ */ jsxs("span", {
|
|
130
|
+
className: "font-mono",
|
|
131
|
+
children: ["id: ", attachment.id]
|
|
132
|
+
}) : null;
|
|
133
|
+
$[25] = attachment.id;
|
|
134
|
+
$[26] = t11;
|
|
135
|
+
} else t11 = $[26];
|
|
136
|
+
let t12;
|
|
137
|
+
if ($[27] !== attachment.kind) {
|
|
138
|
+
t12 = attachment.kind ? /* @__PURE__ */ jsxs("span", { children: ["kind: ", attachment.kind] }) : null;
|
|
139
|
+
$[27] = attachment.kind;
|
|
140
|
+
$[28] = t12;
|
|
141
|
+
} else t12 = $[28];
|
|
142
|
+
let t13;
|
|
143
|
+
if ($[29] !== attachment.contentType) {
|
|
144
|
+
t13 = attachment.contentType ? /* @__PURE__ */ jsxs("span", { children: ["type: ", attachment.contentType] }) : null;
|
|
145
|
+
$[29] = attachment.contentType;
|
|
146
|
+
$[30] = t13;
|
|
147
|
+
} else t13 = $[30];
|
|
148
|
+
let t14;
|
|
149
|
+
if ($[31] !== size) {
|
|
150
|
+
t14 = size ? /* @__PURE__ */ jsx("span", { children: size }) : null;
|
|
151
|
+
$[31] = size;
|
|
152
|
+
$[32] = t14;
|
|
153
|
+
} else t14 = $[32];
|
|
154
|
+
let t15;
|
|
155
|
+
if ($[33] !== t11 || $[34] !== t12 || $[35] !== t13 || $[36] !== t14) {
|
|
156
|
+
t15 = /* @__PURE__ */ jsxs("div", {
|
|
157
|
+
className: "text-muted-foreground flex flex-wrap gap-x-2 gap-y-0.5 text-[10px]",
|
|
158
|
+
children: [
|
|
159
|
+
t11,
|
|
160
|
+
t12,
|
|
161
|
+
t13,
|
|
162
|
+
t14
|
|
163
|
+
]
|
|
164
|
+
});
|
|
165
|
+
$[33] = t11;
|
|
166
|
+
$[34] = t12;
|
|
167
|
+
$[35] = t13;
|
|
168
|
+
$[36] = t14;
|
|
169
|
+
$[37] = t15;
|
|
170
|
+
} else t15 = $[37];
|
|
171
|
+
let t16;
|
|
172
|
+
if ($[38] !== attachment.previewUrl) {
|
|
173
|
+
t16 = attachment.previewUrl ? /* @__PURE__ */ jsx("div", {
|
|
174
|
+
className: "flex justify-end",
|
|
175
|
+
children: /* @__PURE__ */ jsx(CopyButton, {
|
|
176
|
+
value: attachment.previewUrl,
|
|
177
|
+
label: "Copy URL",
|
|
178
|
+
iconOnly: true,
|
|
179
|
+
size: "sm"
|
|
180
|
+
})
|
|
181
|
+
}) : null;
|
|
182
|
+
$[38] = attachment.previewUrl;
|
|
183
|
+
$[39] = t16;
|
|
184
|
+
} else t16 = $[39];
|
|
185
|
+
let t17;
|
|
186
|
+
if ($[40] !== t10 || $[41] !== t15 || $[42] !== t16) {
|
|
187
|
+
t17 = /* @__PURE__ */ jsxs("div", {
|
|
188
|
+
className: "flex flex-col gap-1 px-2 ps-6 pb-1.5",
|
|
189
|
+
children: [
|
|
190
|
+
t10,
|
|
191
|
+
t15,
|
|
192
|
+
t16
|
|
193
|
+
]
|
|
194
|
+
});
|
|
195
|
+
$[40] = t10;
|
|
196
|
+
$[41] = t15;
|
|
197
|
+
$[42] = t16;
|
|
198
|
+
$[43] = t17;
|
|
199
|
+
} else t17 = $[43];
|
|
200
|
+
let t18;
|
|
201
|
+
if ($[44] !== t17 || $[45] !== t9) {
|
|
202
|
+
t18 = /* @__PURE__ */ jsxs("details", {
|
|
203
|
+
className: "group border-border/60 border-b last:border-b-0",
|
|
204
|
+
children: [t9, t17]
|
|
205
|
+
});
|
|
206
|
+
$[44] = t17;
|
|
207
|
+
$[45] = t9;
|
|
208
|
+
$[46] = t18;
|
|
209
|
+
} else t18 = $[46];
|
|
210
|
+
return t18;
|
|
211
|
+
};
|
|
212
|
+
const AttachmentList = (t0) => {
|
|
213
|
+
const $ = c(16);
|
|
214
|
+
const { attachments, label: t1, bordered: t2 } = t0;
|
|
215
|
+
const label = t1 === void 0 ? "Attachments" : t1;
|
|
216
|
+
const bordered = t2 === void 0 ? true : t2;
|
|
217
|
+
if (!attachments.length) return null;
|
|
218
|
+
const t3 = bordered && "border-border overflow-hidden rounded-md border";
|
|
219
|
+
let t4;
|
|
220
|
+
if ($[0] !== t3) {
|
|
221
|
+
t4 = clsx(t3);
|
|
222
|
+
$[0] = t3;
|
|
223
|
+
$[1] = t4;
|
|
224
|
+
} else t4 = $[1];
|
|
225
|
+
const t5 = bordered && "border-border border-b";
|
|
226
|
+
let t6;
|
|
227
|
+
if ($[2] !== t5) {
|
|
228
|
+
t6 = clsx("text-muted-foreground px-2 py-1 text-[10px] font-medium", t5);
|
|
229
|
+
$[2] = t5;
|
|
230
|
+
$[3] = t6;
|
|
231
|
+
} else t6 = $[3];
|
|
232
|
+
let t7;
|
|
233
|
+
if ($[4] !== attachments.length || $[5] !== label || $[6] !== t6) {
|
|
234
|
+
t7 = /* @__PURE__ */ jsxs("div", {
|
|
235
|
+
className: t6,
|
|
236
|
+
children: [
|
|
237
|
+
label,
|
|
238
|
+
" (",
|
|
239
|
+
attachments.length,
|
|
240
|
+
")"
|
|
241
|
+
]
|
|
242
|
+
});
|
|
243
|
+
$[4] = attachments.length;
|
|
244
|
+
$[5] = label;
|
|
245
|
+
$[6] = t6;
|
|
246
|
+
$[7] = t7;
|
|
247
|
+
} else t7 = $[7];
|
|
248
|
+
let t8;
|
|
249
|
+
if ($[8] !== attachments) {
|
|
250
|
+
t8 = attachments.map(_temp);
|
|
251
|
+
$[8] = attachments;
|
|
252
|
+
$[9] = t8;
|
|
253
|
+
} else t8 = $[9];
|
|
254
|
+
let t9;
|
|
255
|
+
if ($[10] !== t8) {
|
|
256
|
+
t9 = /* @__PURE__ */ jsx("div", { children: t8 });
|
|
257
|
+
$[10] = t8;
|
|
258
|
+
$[11] = t9;
|
|
259
|
+
} else t9 = $[11];
|
|
260
|
+
let t10;
|
|
261
|
+
if ($[12] !== t4 || $[13] !== t7 || $[14] !== t9) {
|
|
262
|
+
t10 = /* @__PURE__ */ jsxs("div", {
|
|
263
|
+
className: t4,
|
|
264
|
+
children: [t7, t9]
|
|
265
|
+
});
|
|
266
|
+
$[12] = t4;
|
|
267
|
+
$[13] = t7;
|
|
268
|
+
$[14] = t9;
|
|
269
|
+
$[15] = t10;
|
|
270
|
+
} else t10 = $[15];
|
|
271
|
+
return t10;
|
|
272
|
+
};
|
|
273
|
+
function _temp(attachment, index) {
|
|
274
|
+
return /* @__PURE__ */ jsx(AttachmentRow, { attachment }, attachment.id ?? `${attachment.name}-${index}`);
|
|
275
|
+
}
|
|
276
|
+
//#endregion
|
|
277
|
+
export { AttachmentList };
|
|
278
|
+
|
|
279
|
+
//# sourceMappingURL=AttachmentList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttachmentList.js","names":["clsx","CopyButton","STATUS_TONE","ToneBadge","formatBytes","AttachmentPreview","AttachmentStatusPreview","statusLabel","status","type","progress","pct","reason","Math","round","kindIcon","attachment","kind","contentType","includes","previewUrl","AttachmentRow","t0","$","_c","t1","sizeBytes","size","t2","filter","Boolean","meta","join","t3","Symbol","for","t4","t5","t6","name","t7","t8","t9","t10","t11","id","t12","t13","t14","t15","t16","t17","t18","AttachmentList","attachments","label","bordered","undefined","length","map","_temp","index"],"sources":["../../../src/views/attachments/AttachmentList.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { CopyButton, STATUS_TONE, ToneBadge } from \"../ui\";\nimport { formatBytes } from \"./formatBytes\";\nimport type { AttachmentPreview, AttachmentStatusPreview } from \"./types\";\n\nconst statusLabel = (status: AttachmentStatusPreview) => {\n if (status.type === \"running\" && typeof status.progress === \"number\") {\n const pct = status.progress <= 1 ? status.progress * 100 : status.progress;\n return `${status.reason ?? \"uploading\"} ${Math.round(pct)}%`;\n }\n return status.reason ? `${status.type} · ${status.reason}` : status.type;\n};\n\nconst kindIcon = (attachment: AttachmentPreview) => {\n const kind = attachment.kind ?? attachment.contentType ?? \"\";\n if (kind.includes(\"image\") || attachment.previewUrl) return \"img\";\n if (kind.includes(\"audio\")) return \"aud\";\n if (kind.includes(\"pdf\") || kind === \"document\") return \"doc\";\n return \"file\";\n};\n\nconst AttachmentRow = ({ attachment }: { attachment: AttachmentPreview }) => {\n const size = formatBytes(attachment.sizeBytes);\n const meta = [attachment.kind, attachment.contentType, size]\n .filter(Boolean)\n .join(\" · \");\n\n return (\n <details className=\"group border-border/60 border-b last:border-b-0\">\n <summary className=\"hover:bg-accent/40 flex cursor-pointer list-none items-center gap-1.5 px-2 py-1 text-[11px] select-none\">\n <span className=\"text-muted-foreground inline-block shrink-0 transition-transform group-open:rotate-90\">\n ›\n </span>\n <ToneBadge tone=\"zinc\" size=\"sm\">\n {kindIcon(attachment)}\n </ToneBadge>\n <span className=\"text-foreground min-w-0 flex-1 truncate font-medium\">\n {attachment.name}\n </span>\n {meta ? (\n <span className=\"text-muted-foreground hidden max-w-[45%] truncate text-[10px] sm:inline\">\n {meta}\n </span>\n ) : null}\n {attachment.status ? (\n <ToneBadge\n tone={STATUS_TONE[attachment.status.type] ?? \"zinc\"}\n size=\"sm\"\n >\n {statusLabel(attachment.status)}\n </ToneBadge>\n ) : null}\n </summary>\n <div className=\"flex flex-col gap-1 px-2 ps-6 pb-1.5\">\n {attachment.previewUrl ? (\n <img\n src={attachment.previewUrl}\n alt={attachment.name}\n className=\"border-border max-h-24 max-w-full rounded border object-contain\"\n />\n ) : null}\n <div className=\"text-muted-foreground flex flex-wrap gap-x-2 gap-y-0.5 text-[10px]\">\n {attachment.id ? (\n <span className=\"font-mono\">id: {attachment.id}</span>\n ) : null}\n {attachment.kind ? <span>kind: {attachment.kind}</span> : null}\n {attachment.contentType ? (\n <span>type: {attachment.contentType}</span>\n ) : null}\n {size ? <span>{size}</span> : null}\n </div>\n {attachment.previewUrl ? (\n <div className=\"flex justify-end\">\n <CopyButton\n value={attachment.previewUrl}\n label=\"Copy URL\"\n iconOnly\n size=\"sm\"\n />\n </div>\n ) : null}\n </div>\n </details>\n );\n};\n\nexport const AttachmentList = ({\n attachments,\n label = \"Attachments\",\n bordered = true,\n}: {\n attachments: readonly AttachmentPreview[];\n label?: string;\n bordered?: boolean;\n}) => {\n if (!attachments.length) return null;\n\n return (\n <div\n className={clsx(\n bordered && \"border-border overflow-hidden rounded-md border\",\n )}\n >\n <div\n className={clsx(\n \"text-muted-foreground px-2 py-1 text-[10px] font-medium\",\n bordered && \"border-border border-b\",\n )}\n >\n {label} ({attachments.length})\n </div>\n <div>\n {attachments.map((attachment, index) => (\n <AttachmentRow\n key={attachment.id ?? `${attachment.name}-${index}`}\n attachment={attachment}\n />\n ))}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;AAKA,MAAMO,eAAeC,WAAoC;CACvD,IAAIA,OAAOC,SAAS,aAAa,OAAOD,OAAOE,aAAa,UAAU;EACpE,MAAMC,MAAMH,OAAOE,YAAY,IAAIF,OAAOE,WAAW,MAAMF,OAAOE;EAClE,OAAO,GAAGF,OAAOI,UAAU,YAAW,GAAIC,KAAKC,MAAMH,GAAG,EAAC;CAC3D;CACA,OAAOH,OAAOI,SAAS,GAAGJ,OAAOC,KAAI,KAAMD,OAAOI,WAAWJ,OAAOC;AACtE;AAEA,MAAMM,YAAYC,eAAkC;CAClD,MAAMC,OAAOD,WAAWC,QAAQD,WAAWE,eAAe;CAC1D,IAAID,KAAKE,SAAS,OAAO,KAAKH,WAAWI,YAAY,OAAO;CAC5D,IAAIH,KAAKE,SAAS,OAAO,GAAG,OAAO;CACnC,IAAIF,KAAKE,SAAS,KAAK,KAAKF,SAAS,YAAY,OAAO;CACxD,OAAO;AACT;AAEA,MAAMI,iBAAgBC,OAAA;CAAA,MAAAC,IAAAC,EAAA,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PartPreview, FilePartPreview, ImagePartPreview } from "../message/types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/views/attachments/MediaPartView.d.ts
|
|
4
|
+
declare const ImagePartView: ({
|
|
5
|
+
part,
|
|
6
|
+
compact
|
|
7
|
+
}: {
|
|
8
|
+
part: ImagePartPreview;
|
|
9
|
+
compact?: boolean;
|
|
10
|
+
}) => import("react").JSX.Element;
|
|
11
|
+
declare const FilePartView: ({
|
|
12
|
+
part,
|
|
13
|
+
compact
|
|
14
|
+
}: {
|
|
15
|
+
part: FilePartPreview;
|
|
16
|
+
compact?: boolean;
|
|
17
|
+
}) => import("react").JSX.Element;
|
|
18
|
+
declare const AudioPartView: ({
|
|
19
|
+
part,
|
|
20
|
+
compact
|
|
21
|
+
}: {
|
|
22
|
+
part: AudioPartPreview;
|
|
23
|
+
compact?: boolean;
|
|
24
|
+
}) => import("react").JSX.Element;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { AudioPartView, FilePartView, ImagePartView };
|
|
27
|
+
//# sourceMappingURL=MediaPartView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaPartView.d.ts","names":[],"sources":["../../../src/views/attachments/MediaPartView.tsx"],"mappings":";;;cAQa,aAAA;EAAiB,IAAA;EAAA;AAAA;EAI5B,IAAA,EAAM,gBAAA;EACN,OAAA;AAAA,sBACD,GAAA,CAAA,OAAA;AAAA,cAqBY,YAAA;EAAgB,IAAA;EAAA;AAAA;EAI3B,IAAA,EAAM,eAAA;EACN,OAAA;AAAA,sBACD,GAAA,CAAA,OAAA;AAAA,cAiBY,aAAA;EAAiB,IAAA;EAAA;AAAA;EAI5B,IAAA,EAAM,gBAAA;EACN,OAAA;AAAA,sBACD,GAAA,CAAA,OAAA"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { ToneBadge } from "../ui/ToneBadge.js";
|
|
2
|
+
import { formatBytes } from "./formatBytes.js";
|
|
3
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/views/attachments/MediaPartView.tsx
|
|
6
|
+
const ImagePartView = (t0) => {
|
|
7
|
+
const $ = c(15);
|
|
8
|
+
const { part, compact: t1 } = t0;
|
|
9
|
+
const compact = t1 === void 0 ? false : t1;
|
|
10
|
+
const t2 = compact ? "px-2 py-1.5" : "flex flex-col gap-1";
|
|
11
|
+
let t3;
|
|
12
|
+
if ($[0] !== compact) {
|
|
13
|
+
t3 = !compact ? /* @__PURE__ */ jsx(ToneBadge, {
|
|
14
|
+
tone: "zinc",
|
|
15
|
+
children: "image"
|
|
16
|
+
}) : null;
|
|
17
|
+
$[0] = compact;
|
|
18
|
+
$[1] = t3;
|
|
19
|
+
} else t3 = $[1];
|
|
20
|
+
const t4 = part.filename ?? "image";
|
|
21
|
+
let t5;
|
|
22
|
+
if ($[2] !== part.sizeBytes) {
|
|
23
|
+
t5 = part.sizeBytes ? /* @__PURE__ */ jsx("span", {
|
|
24
|
+
className: "text-muted-foreground ml-1",
|
|
25
|
+
children: formatBytes(part.sizeBytes)
|
|
26
|
+
}) : null;
|
|
27
|
+
$[2] = part.sizeBytes;
|
|
28
|
+
$[3] = t5;
|
|
29
|
+
} else t5 = $[3];
|
|
30
|
+
let t6;
|
|
31
|
+
if ($[4] !== t4 || $[5] !== t5) {
|
|
32
|
+
t6 = /* @__PURE__ */ jsxs("div", {
|
|
33
|
+
className: "text-foreground text-[11px]",
|
|
34
|
+
children: [t4, t5]
|
|
35
|
+
});
|
|
36
|
+
$[4] = t4;
|
|
37
|
+
$[5] = t5;
|
|
38
|
+
$[6] = t6;
|
|
39
|
+
} else t6 = $[6];
|
|
40
|
+
let t7;
|
|
41
|
+
if ($[7] !== part.filename || $[8] !== part.previewUrl) {
|
|
42
|
+
t7 = part.previewUrl ? /* @__PURE__ */ jsx("img", {
|
|
43
|
+
src: part.previewUrl,
|
|
44
|
+
alt: part.filename ?? "image",
|
|
45
|
+
className: "border-border mt-1 max-h-24 max-w-full rounded border object-contain"
|
|
46
|
+
}) : null;
|
|
47
|
+
$[7] = part.filename;
|
|
48
|
+
$[8] = part.previewUrl;
|
|
49
|
+
$[9] = t7;
|
|
50
|
+
} else t7 = $[9];
|
|
51
|
+
let t8;
|
|
52
|
+
if ($[10] !== t2 || $[11] !== t3 || $[12] !== t6 || $[13] !== t7) {
|
|
53
|
+
t8 = /* @__PURE__ */ jsxs("div", {
|
|
54
|
+
className: t2,
|
|
55
|
+
children: [
|
|
56
|
+
t3,
|
|
57
|
+
t6,
|
|
58
|
+
t7
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
$[10] = t2;
|
|
62
|
+
$[11] = t3;
|
|
63
|
+
$[12] = t6;
|
|
64
|
+
$[13] = t7;
|
|
65
|
+
$[14] = t8;
|
|
66
|
+
} else t8 = $[14];
|
|
67
|
+
return t8;
|
|
68
|
+
};
|
|
69
|
+
const FilePartView = (t0) => {
|
|
70
|
+
const $ = c(14);
|
|
71
|
+
const { part, compact: t1 } = t0;
|
|
72
|
+
const compact = t1 === void 0 ? false : t1;
|
|
73
|
+
const t2 = compact ? "px-2 py-1.5" : "flex flex-col gap-1";
|
|
74
|
+
let t3;
|
|
75
|
+
if ($[0] !== compact) {
|
|
76
|
+
t3 = !compact ? /* @__PURE__ */ jsx(ToneBadge, {
|
|
77
|
+
tone: "zinc",
|
|
78
|
+
children: "file"
|
|
79
|
+
}) : null;
|
|
80
|
+
$[0] = compact;
|
|
81
|
+
$[1] = t3;
|
|
82
|
+
} else t3 = $[1];
|
|
83
|
+
const t4 = part.filename ?? "file";
|
|
84
|
+
let t5;
|
|
85
|
+
if ($[2] !== part.mimeType) {
|
|
86
|
+
t5 = part.mimeType ? /* @__PURE__ */ jsx("span", {
|
|
87
|
+
className: "text-muted-foreground ml-1",
|
|
88
|
+
children: part.mimeType
|
|
89
|
+
}) : null;
|
|
90
|
+
$[2] = part.mimeType;
|
|
91
|
+
$[3] = t5;
|
|
92
|
+
} else t5 = $[3];
|
|
93
|
+
let t6;
|
|
94
|
+
if ($[4] !== part.sizeBytes) {
|
|
95
|
+
t6 = part.sizeBytes ? /* @__PURE__ */ jsxs("span", {
|
|
96
|
+
className: "text-muted-foreground ml-1",
|
|
97
|
+
children: ["· ", formatBytes(part.sizeBytes)]
|
|
98
|
+
}) : null;
|
|
99
|
+
$[4] = part.sizeBytes;
|
|
100
|
+
$[5] = t6;
|
|
101
|
+
} else t6 = $[5];
|
|
102
|
+
let t7;
|
|
103
|
+
if ($[6] !== t4 || $[7] !== t5 || $[8] !== t6) {
|
|
104
|
+
t7 = /* @__PURE__ */ jsxs("div", {
|
|
105
|
+
className: "text-foreground text-[11px]",
|
|
106
|
+
children: [
|
|
107
|
+
t4,
|
|
108
|
+
t5,
|
|
109
|
+
t6
|
|
110
|
+
]
|
|
111
|
+
});
|
|
112
|
+
$[6] = t4;
|
|
113
|
+
$[7] = t5;
|
|
114
|
+
$[8] = t6;
|
|
115
|
+
$[9] = t7;
|
|
116
|
+
} else t7 = $[9];
|
|
117
|
+
let t8;
|
|
118
|
+
if ($[10] !== t2 || $[11] !== t3 || $[12] !== t7) {
|
|
119
|
+
t8 = /* @__PURE__ */ jsxs("div", {
|
|
120
|
+
className: t2,
|
|
121
|
+
children: [t3, t7]
|
|
122
|
+
});
|
|
123
|
+
$[10] = t2;
|
|
124
|
+
$[11] = t3;
|
|
125
|
+
$[12] = t7;
|
|
126
|
+
$[13] = t8;
|
|
127
|
+
} else t8 = $[13];
|
|
128
|
+
return t8;
|
|
129
|
+
};
|
|
130
|
+
const AudioPartView = (t0) => {
|
|
131
|
+
const $ = c(11);
|
|
132
|
+
const { part, compact: t1 } = t0;
|
|
133
|
+
const compact = t1 === void 0 ? false : t1;
|
|
134
|
+
const t2 = compact ? "px-2 py-1.5" : "flex flex-col gap-1";
|
|
135
|
+
let t3;
|
|
136
|
+
if ($[0] !== compact) {
|
|
137
|
+
t3 = !compact ? /* @__PURE__ */ jsx(ToneBadge, {
|
|
138
|
+
tone: "zinc",
|
|
139
|
+
children: "audio"
|
|
140
|
+
}) : null;
|
|
141
|
+
$[0] = compact;
|
|
142
|
+
$[1] = t3;
|
|
143
|
+
} else t3 = $[1];
|
|
144
|
+
const t4 = part.format ?? "audio";
|
|
145
|
+
let t5;
|
|
146
|
+
if ($[2] !== part.sizeBytes) {
|
|
147
|
+
t5 = part.sizeBytes ? /* @__PURE__ */ jsxs("span", {
|
|
148
|
+
className: "text-muted-foreground ml-1",
|
|
149
|
+
children: ["· ", formatBytes(part.sizeBytes)]
|
|
150
|
+
}) : null;
|
|
151
|
+
$[2] = part.sizeBytes;
|
|
152
|
+
$[3] = t5;
|
|
153
|
+
} else t5 = $[3];
|
|
154
|
+
let t6;
|
|
155
|
+
if ($[4] !== t4 || $[5] !== t5) {
|
|
156
|
+
t6 = /* @__PURE__ */ jsxs("div", {
|
|
157
|
+
className: "text-foreground text-[11px]",
|
|
158
|
+
children: [t4, t5]
|
|
159
|
+
});
|
|
160
|
+
$[4] = t4;
|
|
161
|
+
$[5] = t5;
|
|
162
|
+
$[6] = t6;
|
|
163
|
+
} else t6 = $[6];
|
|
164
|
+
let t7;
|
|
165
|
+
if ($[7] !== t2 || $[8] !== t3 || $[9] !== t6) {
|
|
166
|
+
t7 = /* @__PURE__ */ jsxs("div", {
|
|
167
|
+
className: t2,
|
|
168
|
+
children: [t3, t6]
|
|
169
|
+
});
|
|
170
|
+
$[7] = t2;
|
|
171
|
+
$[8] = t3;
|
|
172
|
+
$[9] = t6;
|
|
173
|
+
$[10] = t7;
|
|
174
|
+
} else t7 = $[10];
|
|
175
|
+
return t7;
|
|
176
|
+
};
|
|
177
|
+
//#endregion
|
|
178
|
+
export { AudioPartView, FilePartView, ImagePartView };
|
|
179
|
+
|
|
180
|
+
//# sourceMappingURL=MediaPartView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaPartView.js","names":["ToneBadge","AudioPartPreview","FilePartPreview","ImagePartPreview","formatBytes","ImagePartView","t0","$","_c","part","compact","t1","undefined","t2","t3","t4","filename","t5","sizeBytes","t6","t7","previewUrl","t8","FilePartView","mimeType","AudioPartView","format"],"sources":["../../../src/views/attachments/MediaPartView.tsx"],"sourcesContent":["import { ToneBadge } from \"../ui\";\nimport type {\n AudioPartPreview,\n FilePartPreview,\n ImagePartPreview,\n} from \"../message/types\";\nimport { formatBytes } from \"./formatBytes\";\n\nexport const ImagePartView = ({\n part,\n compact = false,\n}: {\n part: ImagePartPreview;\n compact?: boolean;\n}) => (\n <div className={compact ? \"px-2 py-1.5\" : \"flex flex-col gap-1\"}>\n {!compact ? <ToneBadge tone=\"zinc\">image</ToneBadge> : null}\n <div className=\"text-foreground text-[11px]\">\n {part.filename ?? \"image\"}\n {part.sizeBytes ? (\n <span className=\"text-muted-foreground ml-1\">\n {formatBytes(part.sizeBytes)}\n </span>\n ) : null}\n </div>\n {part.previewUrl ? (\n <img\n src={part.previewUrl}\n alt={part.filename ?? \"image\"}\n className=\"border-border mt-1 max-h-24 max-w-full rounded border object-contain\"\n />\n ) : null}\n </div>\n);\n\nexport const FilePartView = ({\n part,\n compact = false,\n}: {\n part: FilePartPreview;\n compact?: boolean;\n}) => (\n <div className={compact ? \"px-2 py-1.5\" : \"flex flex-col gap-1\"}>\n {!compact ? <ToneBadge tone=\"zinc\">file</ToneBadge> : null}\n <div className=\"text-foreground text-[11px]\">\n {part.filename ?? \"file\"}\n {part.mimeType ? (\n <span className=\"text-muted-foreground ml-1\">{part.mimeType}</span>\n ) : null}\n {part.sizeBytes ? (\n <span className=\"text-muted-foreground ml-1\">\n · {formatBytes(part.sizeBytes)}\n </span>\n ) : null}\n </div>\n </div>\n);\n\nexport const AudioPartView = ({\n part,\n compact = false,\n}: {\n part: AudioPartPreview;\n compact?: boolean;\n}) => (\n <div className={compact ? \"px-2 py-1.5\" : \"flex flex-col gap-1\"}>\n {!compact ? <ToneBadge tone=\"zinc\">audio</ToneBadge> : null}\n <div className=\"text-foreground text-[11px]\">\n {part.format ?? \"audio\"}\n {part.sizeBytes ? (\n <span className=\"text-muted-foreground ml-1\">\n · {formatBytes(part.sizeBytes)}\n </span>\n ) : null}\n </div>\n </div>\n);\n"],"mappings":";;;;;AAQA,MAAaK,iBAAgBC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAC,MAAA,EAAAC,MAAAC,SAAAC,OAAAL;CAE5B,MAAAI,UAAAC,OAAAC,KAAAA,IAAA,QAAAD;CAKgB,MAAAE,KAAAH,UAAA,gBAAA;CAA+C,IAAAI;CAAA,IAAAP,EAAA,OAAAG,SAAA;EAC5DI,KAAA,CAACJ,UAAU,oBAAC,WAAD;GAAgB,MAAA;aAAO;EAAb,CAAA,IAArB;EAA0DH,EAAA,KAAAG;EAAAH,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAExD,MAAAQ,KAAAN,KAAIO,YAAJ;CAAwB,IAAAC;CAAA,IAAAV,EAAA,OAAAE,KAAAS,WAAA;EACxBD,KAAAR,KAAIS,YACH,oBAAA,QAAA;GAAgB,WAAA;aACbd,YAAYK,KAAIS,SAAU;EACtB,CAAA,IAHR;EAIOX,EAAA,KAAAE,KAAAS;EAAAX,EAAA,KAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,IAAAY;CAAA,IAAAZ,EAAA,OAAAQ,MAAAR,EAAA,OAAAU,IAAA;EANVE,KAAA,qBAAA,OAAA;GAAe,WAAA;aAAf,CACGJ,IACAE,EAKG;;EAAAV,EAAA,KAAAQ;EAAAR,EAAA,KAAAU;EAAAV,EAAA,KAAAY;CAAA,OAAAA,KAAAZ,EAAA;CAAA,IAAAa;CAAA,IAAAb,EAAA,OAAAE,KAAAO,YAAAT,EAAA,OAAAE,KAAAY,YAAA;EACLD,KAAAX,KAAIY,aACH,oBAAA,OAAA;GACO,KAAAZ,KAAIY;GACJ,KAAAZ,KAAIO,YAAJ;GACK,WAAA;EAAsE,CAAA,IAJnF;EAMOT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AAAX,EAAA,KAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,IAAAY;CAAA,IAAAZ,EAAA,OAAAQ,MAAAR,EAAA,OAAAU,IAAA;EANVE,KAAA,qBAAA,OAAA;GAAe,WAAA;aAAf,CACGJ,IACAE,EAKG;;EAAAV,EAAA,KAAAQ;EAAAR,EAAA,KAAAU;EAAAV,EAAA,KAAAY;CAAA,OAAAA,KAAAZ,EAAA;CAAA,IAAAa;CAAA,IAAAb,EAAA,OAAAM,MAAAN,EAAA,OAAAO,MAAAP,EAAA,OAAAY,IAAA;EATRC,KAAA,qBAAA,OAAA;GAAgB,WAAAP;aAAhB,CACGC,IACDK,EAQI;;EAAAZ,EAAA,KAAAM;EAAAN,EAAA,KAAAO;EAAAP,EAAA,KAAAY;EAAAZ,EAAA,MAAAa;CAAA,OAAAA,KAAAb,EAAA;CAAA,OAVNa;AAUM"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/views/attachments/formatBytes.d.ts
|
|
2
|
+
declare const formatBytes: (bytes: number | undefined) => string | undefined;
|
|
3
|
+
/** Rough size from base64 payload (no decoding). */
|
|
4
|
+
declare const estimateBase64Bytes: (data: string) => number;
|
|
5
|
+
declare const isSafeImagePreviewUrl: (url: string) => boolean;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { estimateBase64Bytes, formatBytes, isSafeImagePreviewUrl };
|
|
8
|
+
//# sourceMappingURL=formatBytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatBytes.d.ts","names":[],"sources":["../../../src/views/attachments/formatBytes.ts"],"mappings":";cAAa,WAAA,GAAe,KAAyB;AAArD;AAAA,cAQa,mBAAA,GAAuB,IAAY;AAAA,cAGnC,qBAAA,GAAyB,GAAW"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/views/attachments/formatBytes.ts
|
|
2
|
+
const formatBytes = (bytes) => {
|
|
3
|
+
if (bytes === void 0 || bytes <= 0) return void 0;
|
|
4
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
5
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
6
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
7
|
+
};
|
|
8
|
+
/** Rough size from base64 payload (no decoding). */
|
|
9
|
+
const estimateBase64Bytes = (data) => Math.max(0, Math.floor(data.length * 3 / 4));
|
|
10
|
+
const isSafeImagePreviewUrl = (url) => url.startsWith("data:image/") || url.startsWith("https://") || url.startsWith("http://");
|
|
11
|
+
//#endregion
|
|
12
|
+
export { estimateBase64Bytes, formatBytes, isSafeImagePreviewUrl };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=formatBytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatBytes.js","names":["formatBytes","bytes","undefined","toFixed","estimateBase64Bytes","data","Math","max","floor","length","isSafeImagePreviewUrl","url","startsWith"],"sources":["../../../src/views/attachments/formatBytes.ts"],"sourcesContent":["export const formatBytes = (bytes: number | undefined): string | undefined => {\n if (bytes === undefined || bytes <= 0) return undefined;\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n};\n\n/** Rough size from base64 payload (no decoding). */\nexport const estimateBase64Bytes = (data: string): number =>\n Math.max(0, Math.floor((data.length * 3) / 4));\n\nexport const isSafeImagePreviewUrl = (url: string): boolean =>\n url.startsWith(\"data:image/\") ||\n url.startsWith(\"https://\") ||\n url.startsWith(\"http://\");\n"],"mappings":";AAAA,MAAaA,eAAeC,UAAkD;CAC5E,IAAIA,UAAUC,KAAAA,KAAaD,SAAS,GAAG,OAAOC,KAAAA;CAC9C,IAAID,QAAQ,MAAM,OAAO,GAAGA,MAAK;CACjC,IAAIA,QAAQ,OAAO,MAAM,OAAO,IAAIA,QAAQ,KAAA,CAAME,QAAQ,CAAC,EAAC;CAC5D,OAAO,IAAIF,SAAS,OAAO,MAAA,CAAOE,QAAQ,CAAC,EAAC;AAC9C;;AAGA,MAAaC,uBAAuBC,SAClCC,KAAKC,IAAI,GAAGD,KAAKE,MAAOH,KAAKI,SAAS,IAAK,CAAC,CAAC;AAE/C,MAAaC,yBAAyBC,QACpCA,IAAIC,WAAW,aAAa,KAC5BD,IAAIC,WAAW,UAAU,KACzBD,IAAIC,WAAW,SAAS"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AttachmentPreview, AttachmentStatusPreview } from "./types.js";
|
|
2
|
+
import { AttachmentList } from "./AttachmentList.js";
|
|
3
|
+
import { formatBytes } from "./formatBytes.js";
|
|
4
|
+
import { parseAttachment, parseAttachments } from "./parseAttachment.js";
|
|
5
|
+
export { AttachmentList, type AttachmentPreview, type AttachmentStatusPreview, formatBytes, parseAttachment, parseAttachments };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AttachmentPreview } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/views/attachments/parseAttachment.d.ts
|
|
4
|
+
declare const parseAttachment: (value: unknown) => AttachmentPreview | null;
|
|
5
|
+
declare const parseAttachments: (value: unknown) => AttachmentPreview[];
|
|
6
|
+
//#endregion
|
|
7
|
+
export { parseAttachment, parseAttachments };
|
|
8
|
+
//# sourceMappingURL=parseAttachment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseAttachment.d.ts","names":[],"sources":["../../../src/views/attachments/parseAttachment.ts"],"mappings":";;;cA6Ca,eAAA,GAAmB,KAAA,cAAiB,iBAAiB;AAAA,cAkCrD,gBAAA,GAAoB,KAAA,cAAiB,iBAAiB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isRecord } from "../../utils/common.js";
|
|
2
|
+
import { estimateBase64Bytes, isSafeImagePreviewUrl } from "./formatBytes.js";
|
|
3
|
+
//#region src/views/attachments/parseAttachment.ts
|
|
4
|
+
const asString = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
5
|
+
const parseAttachmentStatus = (value) => {
|
|
6
|
+
if (!isRecord(value) || typeof value.type !== "string") return void 0;
|
|
7
|
+
return {
|
|
8
|
+
type: value.type,
|
|
9
|
+
...typeof value.reason === "string" ? { reason: value.reason } : {},
|
|
10
|
+
...typeof value.progress === "number" ? { progress: value.progress } : {}
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const mediaFromContent = (content) => {
|
|
14
|
+
if (!Array.isArray(content)) return {};
|
|
15
|
+
for (const part of content) {
|
|
16
|
+
if (!isRecord(part)) continue;
|
|
17
|
+
const type = asString(part.type);
|
|
18
|
+
if (type === "image") {
|
|
19
|
+
const image = asString(part.image);
|
|
20
|
+
if (image && isSafeImagePreviewUrl(image)) {
|
|
21
|
+
const sizeBytes = image.startsWith("data:") ? estimateBase64Bytes(image.split(",", 2)[1] ?? image) : void 0;
|
|
22
|
+
return {
|
|
23
|
+
previewUrl: image,
|
|
24
|
+
...sizeBytes !== void 0 ? { sizeBytes } : {}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (type === "file") {
|
|
29
|
+
const data = asString(part.data);
|
|
30
|
+
if (data) return { sizeBytes: estimateBase64Bytes(data) };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return {};
|
|
34
|
+
};
|
|
35
|
+
const parseAttachment = (value) => {
|
|
36
|
+
if (!isRecord(value)) return null;
|
|
37
|
+
const name = asString(value.name) ?? asString(value.filename) ?? asString(value.id) ?? "(attachment)";
|
|
38
|
+
const status = parseAttachmentStatus(value.status);
|
|
39
|
+
const fromContent = mediaFromContent(value.content);
|
|
40
|
+
const image = asString(value.image);
|
|
41
|
+
const previewUrl = fromContent.previewUrl ?? (image && isSafeImagePreviewUrl(image) ? image : void 0);
|
|
42
|
+
const data = asString(value.data);
|
|
43
|
+
const sizeBytes = fromContent.sizeBytes ?? (data ? estimateBase64Bytes(data) : void 0);
|
|
44
|
+
return {
|
|
45
|
+
name,
|
|
46
|
+
...asString(value.id) ? { id: asString(value.id) } : {},
|
|
47
|
+
...asString(value.type) ? { kind: asString(value.type) } : {},
|
|
48
|
+
...asString(value.contentType) ? { contentType: asString(value.contentType) } : {},
|
|
49
|
+
...status ? { status } : {},
|
|
50
|
+
...previewUrl ? { previewUrl } : {},
|
|
51
|
+
...sizeBytes !== void 0 ? { sizeBytes } : {}
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
const parseAttachments = (value) => Array.isArray(value) ? value.map((item) => parseAttachment(item)).filter((item) => Boolean(item)) : [];
|
|
55
|
+
//#endregion
|
|
56
|
+
export { parseAttachment, parseAttachments };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=parseAttachment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseAttachment.js","names":["isRecord","estimateBase64Bytes","isSafeImagePreviewUrl","AttachmentPreview","AttachmentStatusPreview","asString","value","length","undefined","parseAttachmentStatus","type","reason","progress","mediaFromContent","content","previewUrl","sizeBytes","Array","isArray","part","image","startsWith","split","data","parseAttachment","name","filename","id","status","fromContent","kind","contentType","parseAttachments","map","item","filter","Boolean"],"sources":["../../../src/views/attachments/parseAttachment.ts"],"sourcesContent":["import { isRecord } from \"../../utils/common\";\nimport { estimateBase64Bytes, isSafeImagePreviewUrl } from \"./formatBytes\";\nimport type { AttachmentPreview, AttachmentStatusPreview } from \"./types\";\n\nconst asString = (value: unknown): string | undefined =>\n typeof value === \"string\" && value.length > 0 ? value : undefined;\n\nconst parseAttachmentStatus = (\n value: unknown,\n): AttachmentStatusPreview | undefined => {\n if (!isRecord(value) || typeof value.type !== \"string\") return undefined;\n return {\n type: value.type,\n ...(typeof value.reason === \"string\" ? { reason: value.reason } : {}),\n ...(typeof value.progress === \"number\" ? { progress: value.progress } : {}),\n };\n};\n\nconst mediaFromContent = (\n content: unknown,\n): { previewUrl?: string; sizeBytes?: number } => {\n if (!Array.isArray(content)) return {};\n for (const part of content) {\n if (!isRecord(part)) continue;\n const type = asString(part.type);\n if (type === \"image\") {\n const image = asString(part.image);\n if (image && isSafeImagePreviewUrl(image)) {\n const sizeBytes = image.startsWith(\"data:\")\n ? estimateBase64Bytes(image.split(\",\", 2)[1] ?? image)\n : undefined;\n return {\n previewUrl: image,\n ...(sizeBytes !== undefined ? { sizeBytes } : {}),\n };\n }\n }\n if (type === \"file\") {\n const data = asString(part.data);\n if (data) return { sizeBytes: estimateBase64Bytes(data) };\n }\n }\n return {};\n};\n\nexport const parseAttachment = (value: unknown): AttachmentPreview | null => {\n if (!isRecord(value)) return null;\n\n const name =\n asString(value.name) ??\n asString(value.filename) ??\n asString(value.id) ??\n \"(attachment)\";\n\n const status = parseAttachmentStatus(value.status);\n const fromContent = mediaFromContent(value.content);\n\n const image = asString(value.image);\n const previewUrl =\n fromContent.previewUrl ??\n (image && isSafeImagePreviewUrl(image) ? image : undefined);\n\n const data = asString(value.data);\n const sizeBytes =\n fromContent.sizeBytes ?? (data ? estimateBase64Bytes(data) : undefined);\n\n return {\n name,\n ...(asString(value.id) ? { id: asString(value.id)! } : {}),\n ...(asString(value.type) ? { kind: asString(value.type)! } : {}),\n ...(asString(value.contentType)\n ? { contentType: asString(value.contentType)! }\n : {}),\n ...(status ? { status } : {}),\n ...(previewUrl ? { previewUrl } : {}),\n ...(sizeBytes !== undefined ? { sizeBytes } : {}),\n };\n};\n\nexport const parseAttachments = (value: unknown): AttachmentPreview[] =>\n Array.isArray(value)\n ? value\n .map((item) => parseAttachment(item))\n .filter((item): item is AttachmentPreview => Boolean(item))\n : [];\n"],"mappings":";;;AAIA,MAAMK,YAAYC,UAChB,OAAOA,UAAU,YAAYA,MAAMC,SAAS,IAAID,QAAQE,KAAAA;AAE1D,MAAMC,yBACJH,UACwC;CACxC,IAAI,CAACN,SAASM,KAAK,KAAK,OAAOA,MAAMI,SAAS,UAAU,OAAOF,KAAAA;CAC/D,OAAO;EACLE,MA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