@crafter/rn-ai-elements 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/chatbot/AIImage.js +126 -0
- package/lib/commonjs/chatbot/AIImage.js.map +1 -0
- package/lib/commonjs/chatbot/Attachments.js +317 -0
- package/lib/commonjs/chatbot/Attachments.js.map +1 -0
- package/lib/commonjs/chatbot/ChatErrorBoundary.js +201 -0
- package/lib/commonjs/chatbot/ChatErrorBoundary.js.map +1 -0
- package/lib/commonjs/chatbot/ChatMessageItem.js +169 -0
- package/lib/commonjs/chatbot/ChatMessageItem.js.map +1 -0
- package/lib/commonjs/chatbot/Conversation.js +415 -0
- package/lib/commonjs/chatbot/Conversation.js.map +1 -0
- package/lib/commonjs/chatbot/ConversationScrollButton.js +131 -0
- package/lib/commonjs/chatbot/ConversationScrollButton.js.map +1 -0
- package/lib/commonjs/chatbot/Message.js +203 -0
- package/lib/commonjs/chatbot/Message.js.map +1 -0
- package/lib/commonjs/chatbot/PromptInput.js +352 -0
- package/lib/commonjs/chatbot/PromptInput.js.map +1 -0
- package/lib/commonjs/chatbot/Reasoning.js +184 -0
- package/lib/commonjs/chatbot/Reasoning.js.map +1 -0
- package/lib/commonjs/chatbot/Shimmer.js +116 -0
- package/lib/commonjs/chatbot/Shimmer.js.map +1 -0
- package/lib/commonjs/chatbot/Sources.js +212 -0
- package/lib/commonjs/chatbot/Sources.js.map +1 -0
- package/lib/commonjs/chatbot/Suggestion.js +99 -0
- package/lib/commonjs/chatbot/Suggestion.js.map +1 -0
- package/lib/commonjs/chatbot/Tool.js +307 -0
- package/lib/commonjs/chatbot/Tool.js.map +1 -0
- package/lib/commonjs/chatbot/adapters/uiMessageAdapter.js +141 -0
- package/lib/commonjs/chatbot/adapters/uiMessageAdapter.js.map +1 -0
- package/lib/commonjs/chatbot/index.js +140 -0
- package/lib/commonjs/chatbot/index.js.map +1 -0
- package/lib/commonjs/chatbot/types.js +6 -0
- package/lib/commonjs/chatbot/types.js.map +1 -0
- package/lib/commonjs/hooks/index.js +34 -0
- package/lib/commonjs/hooks/index.js.map +1 -0
- package/lib/commonjs/hooks/useAutoScroll.js +39 -0
- package/lib/commonjs/hooks/useAutoScroll.js.map +1 -0
- package/lib/commonjs/hooks/useClipboard.js +44 -0
- package/lib/commonjs/hooks/useClipboard.js.map +1 -0
- package/lib/commonjs/hooks/useCollapsible.js +35 -0
- package/lib/commonjs/hooks/useCollapsible.js.map +1 -0
- package/lib/commonjs/hooks/useStickToBottom.js +68 -0
- package/lib/commonjs/hooks/useStickToBottom.js.map +1 -0
- package/lib/commonjs/index.js +257 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/primitives/Badge.js +119 -0
- package/lib/commonjs/primitives/Badge.js.map +1 -0
- package/lib/commonjs/primitives/Button.js +185 -0
- package/lib/commonjs/primitives/Button.js.map +1 -0
- package/lib/commonjs/primitives/Card.js +166 -0
- package/lib/commonjs/primitives/Card.js.map +1 -0
- package/lib/commonjs/primitives/Collapsible.js +137 -0
- package/lib/commonjs/primitives/Collapsible.js.map +1 -0
- package/lib/commonjs/primitives/ScrollArea.js +40 -0
- package/lib/commonjs/primitives/ScrollArea.js.map +1 -0
- package/lib/commonjs/primitives/index.js +83 -0
- package/lib/commonjs/primitives/index.js.map +1 -0
- package/lib/commonjs/streaming/StreamingMarkdown.js +252 -0
- package/lib/commonjs/streaming/StreamingMarkdown.js.map +1 -0
- package/lib/commonjs/streaming/index.js +13 -0
- package/lib/commonjs/streaming/index.js.map +1 -0
- package/lib/commonjs/streaming/parser.js +482 -0
- package/lib/commonjs/streaming/parser.js.map +1 -0
- package/lib/commonjs/streaming/renderers/BlockquoteRenderer.js +35 -0
- package/lib/commonjs/streaming/renderers/BlockquoteRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/CodeRenderer.js +128 -0
- package/lib/commonjs/streaming/renderers/CodeRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/HeadingRenderer.js +61 -0
- package/lib/commonjs/streaming/renderers/HeadingRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/ImageRenderer.js +53 -0
- package/lib/commonjs/streaming/renderers/ImageRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/LinkRenderer.js +49 -0
- package/lib/commonjs/streaming/renderers/LinkRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/ListRenderer.js +63 -0
- package/lib/commonjs/streaming/renderers/ListRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/TableRenderer.js +77 -0
- package/lib/commonjs/streaming/renderers/TableRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/TextRenderer.js +41 -0
- package/lib/commonjs/streaming/renderers/TextRenderer.js.map +1 -0
- package/lib/commonjs/streaming/renderers/index.js +76 -0
- package/lib/commonjs/streaming/renderers/index.js.map +1 -0
- package/lib/commonjs/streaming/renderers/renderInlineChildren.js +112 -0
- package/lib/commonjs/streaming/renderers/renderInlineChildren.js.map +1 -0
- package/lib/commonjs/streaming/renderers/renderNode.js +81 -0
- package/lib/commonjs/streaming/renderers/renderNode.js.map +1 -0
- package/lib/commonjs/theme/ThemeProvider.js +68 -0
- package/lib/commonjs/theme/ThemeProvider.js.map +1 -0
- package/lib/commonjs/theme/defaultTheme.js +96 -0
- package/lib/commonjs/theme/defaultTheme.js.map +1 -0
- package/lib/commonjs/theme/index.js +32 -0
- package/lib/commonjs/theme/index.js.map +1 -0
- package/lib/commonjs/theme/tokens.js +2 -0
- package/lib/commonjs/theme/tokens.js.map +1 -0
- package/lib/commonjs/types.d.js +2 -0
- package/lib/commonjs/types.d.js.map +1 -0
- package/lib/commonjs/voice/index.js +13 -0
- package/lib/commonjs/voice/index.js.map +1 -0
- package/lib/commonjs/voice/useSpeechRecognition.js +172 -0
- package/lib/commonjs/voice/useSpeechRecognition.js.map +1 -0
- package/lib/module/chatbot/AIImage.js +121 -0
- package/lib/module/chatbot/AIImage.js.map +1 -0
- package/lib/module/chatbot/Attachments.js +312 -0
- package/lib/module/chatbot/Attachments.js.map +1 -0
- package/lib/module/chatbot/ChatErrorBoundary.js +196 -0
- package/lib/module/chatbot/ChatErrorBoundary.js.map +1 -0
- package/lib/module/chatbot/ChatMessageItem.js +164 -0
- package/lib/module/chatbot/ChatMessageItem.js.map +1 -0
- package/lib/module/chatbot/Conversation.js +412 -0
- package/lib/module/chatbot/Conversation.js.map +1 -0
- package/lib/module/chatbot/ConversationScrollButton.js +126 -0
- package/lib/module/chatbot/ConversationScrollButton.js.map +1 -0
- package/lib/module/chatbot/Message.js +198 -0
- package/lib/module/chatbot/Message.js.map +1 -0
- package/lib/module/chatbot/PromptInput.js +347 -0
- package/lib/module/chatbot/PromptInput.js.map +1 -0
- package/lib/module/chatbot/Reasoning.js +179 -0
- package/lib/module/chatbot/Reasoning.js.map +1 -0
- package/lib/module/chatbot/Shimmer.js +111 -0
- package/lib/module/chatbot/Shimmer.js.map +1 -0
- package/lib/module/chatbot/Sources.js +207 -0
- package/lib/module/chatbot/Sources.js.map +1 -0
- package/lib/module/chatbot/Suggestion.js +94 -0
- package/lib/module/chatbot/Suggestion.js.map +1 -0
- package/lib/module/chatbot/Tool.js +303 -0
- package/lib/module/chatbot/Tool.js.map +1 -0
- package/lib/module/chatbot/adapters/uiMessageAdapter.js +137 -0
- package/lib/module/chatbot/adapters/uiMessageAdapter.js.map +1 -0
- package/lib/module/chatbot/index.js +39 -0
- package/lib/module/chatbot/index.js.map +1 -0
- package/lib/module/chatbot/types.js +4 -0
- package/lib/module/chatbot/types.js.map +1 -0
- package/lib/module/hooks/index.js +7 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/useAutoScroll.js +35 -0
- package/lib/module/hooks/useAutoScroll.js.map +1 -0
- package/lib/module/hooks/useClipboard.js +40 -0
- package/lib/module/hooks/useClipboard.js.map +1 -0
- package/lib/module/hooks/useCollapsible.js +31 -0
- package/lib/module/hooks/useCollapsible.js.map +1 -0
- package/lib/module/hooks/useStickToBottom.js +64 -0
- package/lib/module/hooks/useStickToBottom.js.map +1 -0
- package/lib/module/index.js +19 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/primitives/Badge.js +114 -0
- package/lib/module/primitives/Badge.js.map +1 -0
- package/lib/module/primitives/Button.js +180 -0
- package/lib/module/primitives/Button.js.map +1 -0
- package/lib/module/primitives/Card.js +156 -0
- package/lib/module/primitives/Card.js.map +1 -0
- package/lib/module/primitives/Collapsible.js +130 -0
- package/lib/module/primitives/Collapsible.js.map +1 -0
- package/lib/module/primitives/ScrollArea.js +35 -0
- package/lib/module/primitives/ScrollArea.js.map +1 -0
- package/lib/module/primitives/index.js +8 -0
- package/lib/module/primitives/index.js.map +1 -0
- package/lib/module/streaming/StreamingMarkdown.js +246 -0
- package/lib/module/streaming/StreamingMarkdown.js.map +1 -0
- package/lib/module/streaming/index.js +4 -0
- package/lib/module/streaming/index.js.map +1 -0
- package/lib/module/streaming/parser.js +477 -0
- package/lib/module/streaming/parser.js.map +1 -0
- package/lib/module/streaming/renderers/BlockquoteRenderer.js +30 -0
- package/lib/module/streaming/renderers/BlockquoteRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/CodeRenderer.js +123 -0
- package/lib/module/streaming/renderers/CodeRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/HeadingRenderer.js +56 -0
- package/lib/module/streaming/renderers/HeadingRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/ImageRenderer.js +48 -0
- package/lib/module/streaming/renderers/ImageRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/LinkRenderer.js +44 -0
- package/lib/module/streaming/renderers/LinkRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/ListRenderer.js +58 -0
- package/lib/module/streaming/renderers/ListRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/TableRenderer.js +72 -0
- package/lib/module/streaming/renderers/TableRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/TextRenderer.js +36 -0
- package/lib/module/streaming/renderers/TextRenderer.js.map +1 -0
- package/lib/module/streaming/renderers/index.js +13 -0
- package/lib/module/streaming/renderers/index.js.map +1 -0
- package/lib/module/streaming/renderers/renderInlineChildren.js +107 -0
- package/lib/module/streaming/renderers/renderInlineChildren.js.map +1 -0
- package/lib/module/streaming/renderers/renderNode.js +78 -0
- package/lib/module/streaming/renderers/renderNode.js.map +1 -0
- package/lib/module/theme/ThemeProvider.js +62 -0
- package/lib/module/theme/ThemeProvider.js.map +1 -0
- package/lib/module/theme/defaultTheme.js +92 -0
- package/lib/module/theme/defaultTheme.js.map +1 -0
- package/lib/module/theme/index.js +5 -0
- package/lib/module/theme/index.js.map +1 -0
- package/lib/module/theme/tokens.js +2 -0
- package/lib/module/theme/tokens.js.map +1 -0
- package/lib/module/types.d.js +2 -0
- package/lib/module/types.d.js.map +1 -0
- package/lib/module/voice/index.js +14 -0
- package/lib/module/voice/index.js.map +1 -0
- package/lib/module/voice/useSpeechRecognition.js +169 -0
- package/lib/module/voice/useSpeechRecognition.js.map +1 -0
- package/lib/typescript/src/chatbot/AIImage.d.ts +24 -0
- package/lib/typescript/src/chatbot/AIImage.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Attachments.d.ts +20 -0
- package/lib/typescript/src/chatbot/Attachments.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/ChatErrorBoundary.d.ts +57 -0
- package/lib/typescript/src/chatbot/ChatErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/ChatMessageItem.d.ts +45 -0
- package/lib/typescript/src/chatbot/ChatMessageItem.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Conversation.d.ts +94 -0
- package/lib/typescript/src/chatbot/Conversation.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/ConversationScrollButton.d.ts +62 -0
- package/lib/typescript/src/chatbot/ConversationScrollButton.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Message.d.ts +39 -0
- package/lib/typescript/src/chatbot/Message.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/PromptInput.d.ts +93 -0
- package/lib/typescript/src/chatbot/PromptInput.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Reasoning.d.ts +14 -0
- package/lib/typescript/src/chatbot/Reasoning.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Shimmer.d.ts +13 -0
- package/lib/typescript/src/chatbot/Shimmer.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Sources.d.ts +17 -0
- package/lib/typescript/src/chatbot/Sources.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Suggestion.d.ts +15 -0
- package/lib/typescript/src/chatbot/Suggestion.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/Tool.d.ts +30 -0
- package/lib/typescript/src/chatbot/Tool.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/adapters/uiMessageAdapter.d.ts +24 -0
- package/lib/typescript/src/chatbot/adapters/uiMessageAdapter.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/index.d.ts +29 -0
- package/lib/typescript/src/chatbot/index.d.ts.map +1 -0
- package/lib/typescript/src/chatbot/types.d.ts +49 -0
- package/lib/typescript/src/chatbot/types.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +9 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useAutoScroll.d.ts +23 -0
- package/lib/typescript/src/hooks/useAutoScroll.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useClipboard.d.ts +22 -0
- package/lib/typescript/src/hooks/useClipboard.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useCollapsible.d.ts +28 -0
- package/lib/typescript/src/hooks/useCollapsible.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useStickToBottom.d.ts +39 -0
- package/lib/typescript/src/hooks/useStickToBottom.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +11 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/primitives/Badge.d.ts +10 -0
- package/lib/typescript/src/primitives/Badge.d.ts.map +1 -0
- package/lib/typescript/src/primitives/Button.d.ts +16 -0
- package/lib/typescript/src/primitives/Button.d.ts.map +1 -0
- package/lib/typescript/src/primitives/Card.d.ts +33 -0
- package/lib/typescript/src/primitives/Card.d.ts.map +1 -0
- package/lib/typescript/src/primitives/Collapsible.d.ts +20 -0
- package/lib/typescript/src/primitives/Collapsible.d.ts.map +1 -0
- package/lib/typescript/src/primitives/ScrollArea.d.ts +10 -0
- package/lib/typescript/src/primitives/ScrollArea.d.ts.map +1 -0
- package/lib/typescript/src/primitives/index.d.ts +11 -0
- package/lib/typescript/src/primitives/index.d.ts.map +1 -0
- package/lib/typescript/src/streaming/StreamingMarkdown.d.ts +47 -0
- package/lib/typescript/src/streaming/StreamingMarkdown.d.ts.map +1 -0
- package/lib/typescript/src/streaming/index.d.ts +3 -0
- package/lib/typescript/src/streaming/index.d.ts.map +1 -0
- package/lib/typescript/src/streaming/parser.d.ts +41 -0
- package/lib/typescript/src/streaming/parser.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/BlockquoteRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/BlockquoteRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/CodeRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/CodeRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/HeadingRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/HeadingRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/ImageRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/ImageRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/LinkRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/LinkRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/ListRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/ListRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/TableRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/TableRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/TextRenderer.d.ts +7 -0
- package/lib/typescript/src/streaming/renderers/TextRenderer.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/index.d.ts +19 -0
- package/lib/typescript/src/streaming/renderers/index.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/renderInlineChildren.d.ts +12 -0
- package/lib/typescript/src/streaming/renderers/renderInlineChildren.d.ts.map +1 -0
- package/lib/typescript/src/streaming/renderers/renderNode.d.ts +8 -0
- package/lib/typescript/src/streaming/renderers/renderNode.d.ts.map +1 -0
- package/lib/typescript/src/theme/ThemeProvider.d.ts +14 -0
- package/lib/typescript/src/theme/ThemeProvider.d.ts.map +1 -0
- package/lib/typescript/src/theme/defaultTheme.d.ts +4 -0
- package/lib/typescript/src/theme/defaultTheme.d.ts.map +1 -0
- package/lib/typescript/src/theme/index.d.ts +5 -0
- package/lib/typescript/src/theme/index.d.ts.map +1 -0
- package/lib/typescript/src/theme/tokens.d.ts +66 -0
- package/lib/typescript/src/theme/tokens.d.ts.map +1 -0
- package/lib/typescript/src/voice/index.d.ts +3 -0
- package/lib/typescript/src/voice/index.d.ts.map +1 -0
- package/lib/typescript/src/voice/useSpeechRecognition.d.ts +77 -0
- package/lib/typescript/src/voice/useSpeechRecognition.d.ts.map +1 -0
- package/package.json +132 -0
- package/src/chatbot/AIImage.tsx +166 -0
- package/src/chatbot/Attachments.tsx +382 -0
- package/src/chatbot/ChatErrorBoundary.tsx +230 -0
- package/src/chatbot/ChatMessageItem.tsx +195 -0
- package/src/chatbot/Conversation.tsx +537 -0
- package/src/chatbot/ConversationScrollButton.tsx +149 -0
- package/src/chatbot/Message.tsx +266 -0
- package/src/chatbot/PromptInput.tsx +532 -0
- package/src/chatbot/Reasoning.tsx +198 -0
- package/src/chatbot/Shimmer.tsx +146 -0
- package/src/chatbot/Sources.tsx +263 -0
- package/src/chatbot/Suggestion.tsx +123 -0
- package/src/chatbot/Tool.tsx +340 -0
- package/src/chatbot/adapters/uiMessageAdapter.ts +177 -0
- package/src/chatbot/index.ts +97 -0
- package/src/chatbot/types.ts +66 -0
- package/src/hooks/index.ts +17 -0
- package/src/hooks/useAutoScroll.ts +43 -0
- package/src/hooks/useClipboard.ts +46 -0
- package/src/hooks/useCollapsible.ts +42 -0
- package/src/hooks/useStickToBottom.ts +82 -0
- package/src/index.ts +139 -0
- package/src/primitives/Badge.tsx +119 -0
- package/src/primitives/Button.tsx +213 -0
- package/src/primitives/Card.tsx +221 -0
- package/src/primitives/Collapsible.tsx +168 -0
- package/src/primitives/ScrollArea.tsx +53 -0
- package/src/primitives/index.ts +36 -0
- package/src/streaming/StreamingMarkdown.tsx +282 -0
- package/src/streaming/index.ts +2 -0
- package/src/streaming/parser.ts +506 -0
- package/src/streaming/renderers/BlockquoteRenderer.tsx +42 -0
- package/src/streaming/renderers/CodeRenderer.tsx +158 -0
- package/src/streaming/renderers/HeadingRenderer.tsx +64 -0
- package/src/streaming/renderers/ImageRenderer.tsx +62 -0
- package/src/streaming/renderers/LinkRenderer.tsx +53 -0
- package/src/streaming/renderers/ListRenderer.tsx +65 -0
- package/src/streaming/renderers/TableRenderer.tsx +103 -0
- package/src/streaming/renderers/TextRenderer.tsx +39 -0
- package/src/streaming/renderers/index.ts +26 -0
- package/src/streaming/renderers/renderInlineChildren.tsx +115 -0
- package/src/streaming/renderers/renderNode.tsx +72 -0
- package/src/theme/ThemeProvider.tsx +77 -0
- package/src/theme/defaultTheme.ts +93 -0
- package/src/theme/index.ts +4 -0
- package/src/theme/tokens.ts +69 -0
- package/src/types.d.ts +71 -0
- package/src/voice/index.ts +15 -0
- package/src/voice/useSpeechRecognition.ts +230 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AIImage = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _theme = require("../theme");
|
|
10
|
+
var _Shimmer = require("./Shimmer");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Types
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Helpers
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
function resolveImageUri(source) {
|
|
22
|
+
if ('uri' in source && source.uri) {
|
|
23
|
+
return source.uri;
|
|
24
|
+
}
|
|
25
|
+
const mime = source.mimeType ?? 'image/png';
|
|
26
|
+
return `data:${mime};base64,${source.base64}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
// Component
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
function AIImageComponent({
|
|
34
|
+
source,
|
|
35
|
+
alt,
|
|
36
|
+
width: explicitWidth,
|
|
37
|
+
height: explicitHeight,
|
|
38
|
+
resizeMode = 'cover',
|
|
39
|
+
style,
|
|
40
|
+
onPress
|
|
41
|
+
}) {
|
|
42
|
+
const theme = (0, _theme.useAIElementsTheme)();
|
|
43
|
+
const [isLoading, setIsLoading] = (0, _react.useState)(true);
|
|
44
|
+
const [containerWidth, setContainerWidth] = (0, _react.useState)(0);
|
|
45
|
+
const [aspectRatio, setAspectRatio] = (0, _react.useState)(explicitWidth && explicitHeight ? explicitWidth / explicitHeight : undefined);
|
|
46
|
+
const uri = resolveImageUri(source);
|
|
47
|
+
|
|
48
|
+
// Measure natural aspect ratio when not provided
|
|
49
|
+
const handleLoad = (0, _react.useCallback)(() => {
|
|
50
|
+
setIsLoading(false);
|
|
51
|
+
if (!explicitWidth || !explicitHeight) {
|
|
52
|
+
_reactNative.Image.getSize(uri, (w, h) => {
|
|
53
|
+
if (h > 0) {
|
|
54
|
+
setAspectRatio(w / h);
|
|
55
|
+
}
|
|
56
|
+
}, () => {
|
|
57
|
+
// fallback: keep undefined, image will use container size
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}, [uri, explicitWidth, explicitHeight]);
|
|
61
|
+
const handleLayout = (0, _react.useCallback)(event => {
|
|
62
|
+
setContainerWidth(event.nativeEvent.layout.width);
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
// Determine display dimensions
|
|
66
|
+
const displayWidth = explicitWidth ?? containerWidth;
|
|
67
|
+
const displayHeight = explicitHeight ?? (aspectRatio ? displayWidth / aspectRatio : 200);
|
|
68
|
+
const imageContent = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
69
|
+
onLayout: handleLayout,
|
|
70
|
+
style: [styles.container, {
|
|
71
|
+
borderRadius: theme.radius.md,
|
|
72
|
+
overflow: 'hidden',
|
|
73
|
+
width: explicitWidth ?? '100%',
|
|
74
|
+
height: displayHeight
|
|
75
|
+
}, style],
|
|
76
|
+
children: [isLoading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
77
|
+
style: _reactNative.StyleSheet.absoluteFill,
|
|
78
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Shimmer.Shimmer, {
|
|
79
|
+
width: "100%",
|
|
80
|
+
height: displayHeight,
|
|
81
|
+
borderRadius: theme.radius.md
|
|
82
|
+
})
|
|
83
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
|
|
84
|
+
source: {
|
|
85
|
+
uri
|
|
86
|
+
},
|
|
87
|
+
accessibilityLabel: alt,
|
|
88
|
+
resizeMode: resizeMode,
|
|
89
|
+
onLoad: handleLoad,
|
|
90
|
+
style: [_reactNative.StyleSheet.absoluteFill, {
|
|
91
|
+
opacity: isLoading ? 0 : 1
|
|
92
|
+
}]
|
|
93
|
+
})]
|
|
94
|
+
});
|
|
95
|
+
if (onPress) {
|
|
96
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
97
|
+
onPress: onPress,
|
|
98
|
+
style: ({
|
|
99
|
+
pressed
|
|
100
|
+
}) => [pressed && styles.pressed],
|
|
101
|
+
children: imageContent
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return imageContent;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ---------------------------------------------------------------------------
|
|
108
|
+
// Styles
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
|
|
111
|
+
const styles = _reactNative.StyleSheet.create({
|
|
112
|
+
container: {
|
|
113
|
+
position: 'relative',
|
|
114
|
+
backgroundColor: 'transparent'
|
|
115
|
+
},
|
|
116
|
+
pressed: {
|
|
117
|
+
opacity: 0.85
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
// Export
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
|
|
125
|
+
const AIImage = exports.AIImage = /*#__PURE__*/(0, _react.memo)(AIImageComponent);
|
|
126
|
+
//# sourceMappingURL=AIImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_theme","_Shimmer","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","resolveImageUri","source","uri","mime","mimeType","base64","AIImageComponent","alt","width","explicitWidth","height","explicitHeight","resizeMode","style","onPress","theme","useAIElementsTheme","isLoading","setIsLoading","useState","containerWidth","setContainerWidth","aspectRatio","setAspectRatio","undefined","handleLoad","useCallback","Image","getSize","w","h","handleLayout","event","nativeEvent","layout","displayWidth","displayHeight","imageContent","jsxs","View","onLayout","styles","container","borderRadius","radius","md","overflow","children","jsx","StyleSheet","absoluteFill","Shimmer","accessibilityLabel","onLoad","opacity","Pressable","pressed","create","position","backgroundColor","AIImage","exports","memo"],"sourceRoot":"../../../src","sources":["chatbot/AIImage.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAUA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAAoC,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAD,wBAAAM,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAR,uBAAA,YAAAA,CAAAM,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,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|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Attachments = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _lucideReactNative = require("lucide-react-native");
|
|
10
|
+
var _theme = require("../theme");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Types
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Helpers
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
function formatFileSize(bytes) {
|
|
22
|
+
if (bytes == null) return '';
|
|
23
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
24
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
25
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
26
|
+
}
|
|
27
|
+
function getImageSource(attachment) {
|
|
28
|
+
const source = attachment.uri ?? attachment.url;
|
|
29
|
+
return source ? {
|
|
30
|
+
uri: source
|
|
31
|
+
} : undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// Image thumbnail
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
function ImageThumbnail({
|
|
39
|
+
attachment,
|
|
40
|
+
size,
|
|
41
|
+
style
|
|
42
|
+
}) {
|
|
43
|
+
const theme = (0, _theme.useAIElementsTheme)();
|
|
44
|
+
const source = getImageSource(attachment);
|
|
45
|
+
if (!source) {
|
|
46
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
47
|
+
style: [styles.imagePlaceholder, {
|
|
48
|
+
width: size,
|
|
49
|
+
height: size,
|
|
50
|
+
backgroundColor: theme.colors.muted,
|
|
51
|
+
borderRadius: theme.radius.md
|
|
52
|
+
}, style],
|
|
53
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_lucideReactNative.ImageIcon, {
|
|
54
|
+
size: 24,
|
|
55
|
+
color: theme.colors.mutedForeground
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
|
|
60
|
+
source: source,
|
|
61
|
+
style: [{
|
|
62
|
+
width: size,
|
|
63
|
+
height: size,
|
|
64
|
+
borderRadius: theme.radius.md
|
|
65
|
+
}, style],
|
|
66
|
+
resizeMode: "cover"
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
// File row
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
|
|
74
|
+
function FileRow({
|
|
75
|
+
attachment
|
|
76
|
+
}) {
|
|
77
|
+
const theme = (0, _theme.useAIElementsTheme)();
|
|
78
|
+
const nameStyle = {
|
|
79
|
+
color: theme.colors.foreground,
|
|
80
|
+
fontSize: theme.typography.fontSize.sm,
|
|
81
|
+
fontWeight: theme.typography.fontWeight.medium,
|
|
82
|
+
fontFamily: theme.typography.fontFamily
|
|
83
|
+
};
|
|
84
|
+
const metaStyle = {
|
|
85
|
+
color: theme.colors.mutedForeground,
|
|
86
|
+
fontSize: theme.typography.fontSize.xs,
|
|
87
|
+
fontFamily: theme.typography.fontFamily
|
|
88
|
+
};
|
|
89
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Pressable, {
|
|
90
|
+
style: ({
|
|
91
|
+
pressed
|
|
92
|
+
}) => [styles.fileRow, {
|
|
93
|
+
backgroundColor: pressed ? theme.colors.muted : theme.colors.card,
|
|
94
|
+
borderColor: theme.colors.border,
|
|
95
|
+
borderRadius: theme.radius.md,
|
|
96
|
+
padding: theme.spacing.md,
|
|
97
|
+
gap: theme.spacing.md
|
|
98
|
+
}],
|
|
99
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
100
|
+
style: [styles.fileIcon, {
|
|
101
|
+
backgroundColor: theme.colors.muted,
|
|
102
|
+
borderRadius: theme.radius.sm
|
|
103
|
+
}],
|
|
104
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_lucideReactNative.File, {
|
|
105
|
+
size: 18,
|
|
106
|
+
color: theme.colors.mutedForeground
|
|
107
|
+
})
|
|
108
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
109
|
+
style: styles.fileInfo,
|
|
110
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
111
|
+
style: nameStyle,
|
|
112
|
+
numberOfLines: 1,
|
|
113
|
+
children: attachment.name
|
|
114
|
+
}), (attachment.size != null || attachment.mimeType) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
115
|
+
style: metaStyle,
|
|
116
|
+
numberOfLines: 1,
|
|
117
|
+
children: [attachment.mimeType, attachment.size != null ? formatFileSize(attachment.size) : null].filter(Boolean).join(' - ')
|
|
118
|
+
})]
|
|
119
|
+
})]
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
// Grid layout
|
|
125
|
+
// ---------------------------------------------------------------------------
|
|
126
|
+
|
|
127
|
+
function GridLayout({
|
|
128
|
+
attachments,
|
|
129
|
+
style
|
|
130
|
+
}) {
|
|
131
|
+
const theme = (0, _theme.useAIElementsTheme)();
|
|
132
|
+
const images = attachments.filter(a => a.type === 'image');
|
|
133
|
+
const files = attachments.filter(a => a.type === 'file');
|
|
134
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
135
|
+
style: style,
|
|
136
|
+
children: [images.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
137
|
+
style: [styles.grid, {
|
|
138
|
+
gap: theme.spacing.sm
|
|
139
|
+
}],
|
|
140
|
+
children: images.map((attachment, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(ImageThumbnail, {
|
|
141
|
+
attachment: attachment,
|
|
142
|
+
size: 140,
|
|
143
|
+
style: styles.gridItem
|
|
144
|
+
}, `img-${index}`))
|
|
145
|
+
}), files.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
146
|
+
style: [styles.fileList, {
|
|
147
|
+
gap: theme.spacing.sm,
|
|
148
|
+
marginTop: images.length > 0 ? theme.spacing.sm : 0
|
|
149
|
+
}],
|
|
150
|
+
children: files.map((attachment, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(FileRow, {
|
|
151
|
+
attachment: attachment
|
|
152
|
+
}, `file-${index}`))
|
|
153
|
+
})]
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ---------------------------------------------------------------------------
|
|
158
|
+
// Inline layout (horizontal scroll for images)
|
|
159
|
+
// ---------------------------------------------------------------------------
|
|
160
|
+
|
|
161
|
+
function InlineLayout({
|
|
162
|
+
attachments,
|
|
163
|
+
style
|
|
164
|
+
}) {
|
|
165
|
+
const theme = (0, _theme.useAIElementsTheme)();
|
|
166
|
+
const images = attachments.filter(a => a.type === 'image');
|
|
167
|
+
const files = attachments.filter(a => a.type === 'file');
|
|
168
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
169
|
+
style: style,
|
|
170
|
+
children: [images.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
|
|
171
|
+
horizontal: true,
|
|
172
|
+
showsHorizontalScrollIndicator: false,
|
|
173
|
+
contentContainerStyle: [styles.inlineContainer, {
|
|
174
|
+
gap: theme.spacing.sm
|
|
175
|
+
}],
|
|
176
|
+
children: images.map((attachment, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(ImageThumbnail, {
|
|
177
|
+
attachment: attachment,
|
|
178
|
+
size: 100
|
|
179
|
+
}, `img-${index}`))
|
|
180
|
+
}), files.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
181
|
+
style: [styles.fileList, {
|
|
182
|
+
gap: theme.spacing.sm,
|
|
183
|
+
marginTop: images.length > 0 ? theme.spacing.sm : 0
|
|
184
|
+
}],
|
|
185
|
+
children: files.map((attachment, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(FileRow, {
|
|
186
|
+
attachment: attachment
|
|
187
|
+
}, `file-${index}`))
|
|
188
|
+
})]
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ---------------------------------------------------------------------------
|
|
193
|
+
// List layout
|
|
194
|
+
// ---------------------------------------------------------------------------
|
|
195
|
+
|
|
196
|
+
function ListLayout({
|
|
197
|
+
attachments,
|
|
198
|
+
style
|
|
199
|
+
}) {
|
|
200
|
+
const theme = (0, _theme.useAIElementsTheme)();
|
|
201
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
202
|
+
style: [styles.fileList, {
|
|
203
|
+
gap: theme.spacing.sm
|
|
204
|
+
}, style],
|
|
205
|
+
children: attachments.map((attachment, index) => {
|
|
206
|
+
if (attachment.type === 'image') {
|
|
207
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
208
|
+
style: [styles.fileRow, {
|
|
209
|
+
backgroundColor: theme.colors.card,
|
|
210
|
+
borderColor: theme.colors.border,
|
|
211
|
+
borderRadius: theme.radius.md,
|
|
212
|
+
padding: theme.spacing.sm,
|
|
213
|
+
gap: theme.spacing.md
|
|
214
|
+
}],
|
|
215
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ImageThumbnail, {
|
|
216
|
+
attachment: attachment,
|
|
217
|
+
size: 48
|
|
218
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
219
|
+
style: styles.fileInfo,
|
|
220
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
221
|
+
numberOfLines: 1,
|
|
222
|
+
style: {
|
|
223
|
+
color: theme.colors.foreground,
|
|
224
|
+
fontSize: theme.typography.fontSize.sm,
|
|
225
|
+
fontWeight: theme.typography.fontWeight.medium,
|
|
226
|
+
fontFamily: theme.typography.fontFamily
|
|
227
|
+
},
|
|
228
|
+
children: attachment.name
|
|
229
|
+
})
|
|
230
|
+
})]
|
|
231
|
+
}, `img-${index}`);
|
|
232
|
+
}
|
|
233
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(FileRow, {
|
|
234
|
+
attachment: attachment
|
|
235
|
+
}, `file-${index}`);
|
|
236
|
+
})
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// ---------------------------------------------------------------------------
|
|
241
|
+
// Component
|
|
242
|
+
// ---------------------------------------------------------------------------
|
|
243
|
+
|
|
244
|
+
function AttachmentsComponent({
|
|
245
|
+
attachments,
|
|
246
|
+
variant = 'inline',
|
|
247
|
+
style
|
|
248
|
+
}) {
|
|
249
|
+
if (attachments.length === 0) {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
switch (variant) {
|
|
253
|
+
case 'grid':
|
|
254
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridLayout, {
|
|
255
|
+
attachments: attachments,
|
|
256
|
+
style: style
|
|
257
|
+
});
|
|
258
|
+
case 'inline':
|
|
259
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(InlineLayout, {
|
|
260
|
+
attachments: attachments,
|
|
261
|
+
style: style
|
|
262
|
+
});
|
|
263
|
+
case 'list':
|
|
264
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ListLayout, {
|
|
265
|
+
attachments: attachments,
|
|
266
|
+
style: style
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// ---------------------------------------------------------------------------
|
|
272
|
+
// Styles
|
|
273
|
+
// ---------------------------------------------------------------------------
|
|
274
|
+
|
|
275
|
+
const styles = _reactNative.StyleSheet.create({
|
|
276
|
+
grid: {
|
|
277
|
+
flexDirection: 'row',
|
|
278
|
+
flexWrap: 'wrap'
|
|
279
|
+
},
|
|
280
|
+
gridItem: {
|
|
281
|
+
flexBasis: '48%',
|
|
282
|
+
flexGrow: 1
|
|
283
|
+
},
|
|
284
|
+
inlineContainer: {
|
|
285
|
+
flexDirection: 'row',
|
|
286
|
+
alignItems: 'center'
|
|
287
|
+
},
|
|
288
|
+
fileList: {
|
|
289
|
+
flexDirection: 'column'
|
|
290
|
+
},
|
|
291
|
+
fileRow: {
|
|
292
|
+
flexDirection: 'row',
|
|
293
|
+
alignItems: 'center',
|
|
294
|
+
borderWidth: _reactNative.StyleSheet.hairlineWidth
|
|
295
|
+
},
|
|
296
|
+
fileIcon: {
|
|
297
|
+
width: 36,
|
|
298
|
+
height: 36,
|
|
299
|
+
alignItems: 'center',
|
|
300
|
+
justifyContent: 'center'
|
|
301
|
+
},
|
|
302
|
+
fileInfo: {
|
|
303
|
+
flex: 1,
|
|
304
|
+
gap: 2
|
|
305
|
+
},
|
|
306
|
+
imagePlaceholder: {
|
|
307
|
+
alignItems: 'center',
|
|
308
|
+
justifyContent: 'center'
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
// ---------------------------------------------------------------------------
|
|
313
|
+
// Export
|
|
314
|
+
// ---------------------------------------------------------------------------
|
|
315
|
+
|
|
316
|
+
const Attachments = exports.Attachments = /*#__PURE__*/(0, _react.memo)(AttachmentsComponent);
|
|
317
|
+
//# sourceMappingURL=Attachments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_lucideReactNative","_theme","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","formatFileSize","bytes","toFixed","getImageSource","attachment","source","uri","url","undefined","ImageThumbnail","size","style","theme","useAIElementsTheme","jsx","View","styles","imagePlaceholder","width","height","backgroundColor","colors","muted","borderRadius","radius","md","children","ImageIcon","color","mutedForeground","Image","resizeMode","FileRow","nameStyle","foreground","fontSize","typography","sm","fontWeight","medium","fontFamily","metaStyle","xs","jsxs","Pressable","pressed","fileRow","card","borderColor","border","padding","spacing","gap","fileIcon","File","fileInfo","Text","numberOfLines","name","mimeType","filter","Boolean","join","GridLayout","attachments","images","a","type","files","length","grid","map","index","gridItem","fileList","marginTop","InlineLayout","ScrollView","horizontal","showsHorizontalScrollIndicator","contentContainerStyle","inlineContainer","ListLayout","AttachmentsComponent","variant","StyleSheet","create","flexDirection","flexWrap","flexBasis","flexGrow","alignItems","borderWidth","hairlineWidth","justifyContent","flex","Attachments","exports","memo"],"sourceRoot":"../../../src","sources":["chatbot/Attachments.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAYA,IAAAE,kBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAA8C,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SA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, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ChatErrorBoundary = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _lucideReactNative = require("lucide-react-native");
|
|
10
|
+
var _theme = require("../theme");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Types
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Helpers
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
function arraysShallowEqual(a, b) {
|
|
22
|
+
if (a === b) return true;
|
|
23
|
+
if (!a || !b) return false;
|
|
24
|
+
if (a.length !== b.length) return false;
|
|
25
|
+
for (let i = 0; i < a.length; i += 1) {
|
|
26
|
+
if (a[i] !== b[i]) return false;
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Error boundary
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Class-component boundary that wraps individual chat messages. If a single
|
|
37
|
+
* message's render throws (e.g. malformed markdown, a tool call with bad
|
|
38
|
+
* JSON), only that bubble shows a fallback — the rest of the conversation
|
|
39
|
+
* keeps working.
|
|
40
|
+
*
|
|
41
|
+
* React doesn't expose hooks for error boundaries, so this **must** stay a
|
|
42
|
+
* class component. The themed fallback is delegated to a sibling functional
|
|
43
|
+
* component so it can read the theme via hooks.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <ChatErrorBoundary resetKeys={[message.id]}>
|
|
48
|
+
* <MessageRenderer message={message} />
|
|
49
|
+
* </ChatErrorBoundary>
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
class ChatErrorBoundary extends _react.Component {
|
|
53
|
+
static displayName = 'ChatErrorBoundary';
|
|
54
|
+
state = {
|
|
55
|
+
error: null
|
|
56
|
+
};
|
|
57
|
+
static getDerivedStateFromError(error) {
|
|
58
|
+
return {
|
|
59
|
+
error
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
componentDidCatch(error, errorInfo) {
|
|
63
|
+
this.props.onError?.(error, errorInfo);
|
|
64
|
+
if (__DEV__) {
|
|
65
|
+
// Format following Expo's what / why / how convention so the warning
|
|
66
|
+
// tells you exactly what to fix instead of just dumping a stack.
|
|
67
|
+
console.warn('[chat-components] A message render threw inside <ChatErrorBoundary>.\n' + ` what: ${error.message || 'unknown render error'}\n` + ' why: React unmounted that subtree to prevent a crash.\n' + ' how: inspect the message payload (markdown / tool args / sources)\n' + ' below for invalid input. The user can also tap "Retry" to remount.');
|
|
68
|
+
console.error('[chat-components]', error, errorInfo.componentStack);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
componentDidUpdate(prev) {
|
|
72
|
+
// Auto-reset if any reset key changed since the last render. This lets
|
|
73
|
+
// callers say "the message id changed, so any error from the previous
|
|
74
|
+
// message no longer applies".
|
|
75
|
+
if (this.state.error && !arraysShallowEqual(prev.resetKeys, this.props.resetKeys)) {
|
|
76
|
+
this.reset();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
reset = () => {
|
|
80
|
+
this.setState({
|
|
81
|
+
error: null
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
render() {
|
|
85
|
+
const {
|
|
86
|
+
error
|
|
87
|
+
} = this.state;
|
|
88
|
+
if (error) {
|
|
89
|
+
if (this.props.fallback) {
|
|
90
|
+
return this.props.fallback(error, this.reset);
|
|
91
|
+
}
|
|
92
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(DefaultFallback, {
|
|
93
|
+
error: error,
|
|
94
|
+
onReset: this.reset
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return this.props.children;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
// Default themed fallback
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
exports.ChatErrorBoundary = ChatErrorBoundary;
|
|
105
|
+
function DefaultFallback({
|
|
106
|
+
error,
|
|
107
|
+
onReset
|
|
108
|
+
}) {
|
|
109
|
+
const theme = (0, _theme.useAIElementsTheme)();
|
|
110
|
+
const styles = getStyles(theme);
|
|
111
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
112
|
+
style: styles.wrapper,
|
|
113
|
+
accessible: true,
|
|
114
|
+
accessibilityRole: "alert",
|
|
115
|
+
accessibilityLabel: "Message failed to render",
|
|
116
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
117
|
+
style: styles.bubble,
|
|
118
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
119
|
+
style: styles.title,
|
|
120
|
+
children: "Couldn't render this message"
|
|
121
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
122
|
+
style: styles.message,
|
|
123
|
+
numberOfLines: 2,
|
|
124
|
+
children: error.message || 'Unknown render error.'
|
|
125
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Pressable, {
|
|
126
|
+
onPress: onReset,
|
|
127
|
+
accessibilityRole: "button",
|
|
128
|
+
accessibilityLabel: "Retry rendering this message",
|
|
129
|
+
hitSlop: 8,
|
|
130
|
+
style: ({
|
|
131
|
+
pressed
|
|
132
|
+
}) => [styles.retryButton, pressed && styles.retryButtonPressed],
|
|
133
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_lucideReactNative.RotateCcw, {
|
|
134
|
+
size: 12,
|
|
135
|
+
color: theme.colors.foreground
|
|
136
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
137
|
+
style: styles.retryText,
|
|
138
|
+
children: "Retry"
|
|
139
|
+
})]
|
|
140
|
+
})]
|
|
141
|
+
})
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
DefaultFallback.displayName = 'ChatErrorBoundary.DefaultFallback';
|
|
145
|
+
|
|
146
|
+
// ---------------------------------------------------------------------------
|
|
147
|
+
// Styles
|
|
148
|
+
// ---------------------------------------------------------------------------
|
|
149
|
+
|
|
150
|
+
function getStyles(theme) {
|
|
151
|
+
return _reactNative.StyleSheet.create({
|
|
152
|
+
wrapper: {
|
|
153
|
+
alignItems: 'flex-start',
|
|
154
|
+
paddingHorizontal: theme.spacing.lg,
|
|
155
|
+
marginBottom: theme.spacing.md
|
|
156
|
+
},
|
|
157
|
+
bubble: {
|
|
158
|
+
backgroundColor: theme.colors.muted,
|
|
159
|
+
borderColor: theme.colors.border,
|
|
160
|
+
borderWidth: _reactNative.StyleSheet.hairlineWidth,
|
|
161
|
+
borderRadius: theme.radius.md,
|
|
162
|
+
paddingHorizontal: theme.spacing.md,
|
|
163
|
+
paddingVertical: theme.spacing.sm,
|
|
164
|
+
maxWidth: '88%'
|
|
165
|
+
},
|
|
166
|
+
title: {
|
|
167
|
+
color: theme.colors.foreground,
|
|
168
|
+
fontFamily: theme.typography.fontFamily,
|
|
169
|
+
fontSize: theme.typography.fontSize.sm,
|
|
170
|
+
fontWeight: theme.typography.fontWeight.semibold,
|
|
171
|
+
marginBottom: 2
|
|
172
|
+
},
|
|
173
|
+
message: {
|
|
174
|
+
color: theme.colors.mutedForeground,
|
|
175
|
+
fontFamily: theme.typography.fontFamily,
|
|
176
|
+
fontSize: theme.typography.fontSize.sm,
|
|
177
|
+
lineHeight: theme.typography.fontSize.sm * theme.typography.lineHeight.normal,
|
|
178
|
+
marginBottom: theme.spacing.sm
|
|
179
|
+
},
|
|
180
|
+
retryButton: {
|
|
181
|
+
flexDirection: 'row',
|
|
182
|
+
alignItems: 'center',
|
|
183
|
+
gap: 6,
|
|
184
|
+
alignSelf: 'flex-start',
|
|
185
|
+
paddingHorizontal: theme.spacing.sm,
|
|
186
|
+
paddingVertical: 4,
|
|
187
|
+
borderRadius: theme.radius.sm,
|
|
188
|
+
backgroundColor: theme.colors.secondary
|
|
189
|
+
},
|
|
190
|
+
retryButtonPressed: {
|
|
191
|
+
opacity: 0.7
|
|
192
|
+
},
|
|
193
|
+
retryText: {
|
|
194
|
+
color: theme.colors.foreground,
|
|
195
|
+
fontFamily: theme.typography.fontFamily,
|
|
196
|
+
fontSize: theme.typography.fontSize.sm,
|
|
197
|
+
fontWeight: theme.typography.fontWeight.medium
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=ChatErrorBoundary.js.map
|