@vercel/geistdocs 1.2.2 → 1.2.3-canary.48fea3c
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/dist/cli/index.js +3 -0
- package/dist/components/callout.d.ts +12 -0
- package/dist/components/callout.d.ts.map +1 -0
- package/dist/components/callout.js +7 -0
- package/dist/components/code-block-tabs.d.ts +7 -0
- package/dist/components/code-block-tabs.d.ts.map +1 -0
- package/dist/components/code-block-tabs.js +7 -0
- package/dist/components/code-block.d.ts +14 -0
- package/dist/components/code-block.d.ts.map +1 -0
- package/dist/components/code-block.js +45 -0
- package/dist/components/copy-prompt.d.ts +11 -0
- package/dist/components/copy-prompt.d.ts.map +1 -0
- package/dist/components/copy-prompt.js +58 -0
- package/dist/components/mermaid.d.ts +4 -0
- package/dist/components/mermaid.d.ts.map +1 -0
- package/dist/components/mermaid.js +44 -0
- package/dist/components/theme-aware-image.d.ts +12 -0
- package/dist/components/theme-aware-image.d.ts.map +1 -0
- package/dist/components/theme-aware-image.js +8 -0
- package/dist/components/video.d.ts +6 -0
- package/dist/components/video.d.ts.map +1 -0
- package/dist/components/video.js +3 -0
- package/dist/config.d.ts +71 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +1 -0
- package/dist/controls.d.ts +15 -0
- package/dist/controls.d.ts.map +1 -0
- package/dist/controls.js +52 -0
- package/dist/internal/chat/context.d.ts +19 -0
- package/dist/internal/chat/context.d.ts.map +1 -0
- package/dist/internal/chat/context.js +36 -0
- package/dist/internal/chat/conversation.d.ts +10 -0
- package/dist/internal/chat/conversation.d.ts.map +1 -0
- package/dist/internal/chat/conversation.js +16 -0
- package/dist/internal/chat/copy-chat.d.ts +5 -0
- package/dist/internal/chat/copy-chat.d.ts.map +1 -0
- package/dist/internal/chat/copy-chat.js +35 -0
- package/dist/internal/chat/db.d.ts +13 -0
- package/dist/internal/chat/db.d.ts.map +1 -0
- package/dist/internal/chat/db.js +19 -0
- package/dist/internal/chat/message-metadata.d.ts +8 -0
- package/dist/internal/chat/message-metadata.d.ts.map +1 -0
- package/dist/internal/chat/message-metadata.js +29 -0
- package/dist/internal/chat/message.d.ts +11 -0
- package/dist/internal/chat/message.d.ts.map +1 -0
- package/dist/internal/chat/message.js +11 -0
- package/dist/internal/chat/prompt-input.d.ts +13 -0
- package/dist/internal/chat/prompt-input.d.ts.map +1 -0
- package/dist/internal/chat/prompt-input.js +39 -0
- package/dist/internal/chat/shell.d.ts +2 -0
- package/dist/internal/chat/shell.d.ts.map +1 -0
- package/dist/internal/chat/shell.js +194 -0
- package/dist/internal/chat/shimmer.d.ts +11 -0
- package/dist/internal/chat/shimmer.d.ts.map +1 -0
- package/dist/internal/chat/shimmer.js +18 -0
- package/dist/internal/chat/sources.d.ts +13 -0
- package/dist/internal/chat/sources.d.ts.map +1 -0
- package/dist/internal/chat/sources.js +9 -0
- package/dist/internal/chat/suggestion.d.ts +11 -0
- package/dist/internal/chat/suggestion.d.ts.map +1 -0
- package/dist/internal/chat/suggestion.js +12 -0
- package/dist/internal/cn.d.ts +3 -0
- package/dist/internal/cn.d.ts.map +1 -0
- package/dist/internal/cn.js +3 -0
- package/dist/internal/feedback-action.d.ts +14 -0
- package/dist/internal/feedback-action.d.ts.map +1 -0
- package/dist/internal/feedback-action.js +34 -0
- package/dist/internal/i18n.d.ts +6 -0
- package/dist/internal/i18n.d.ts.map +1 -0
- package/dist/internal/i18n.js +18 -0
- package/dist/internal/languages.d.ts +7 -0
- package/dist/internal/languages.d.ts.map +1 -0
- package/dist/internal/languages.js +18 -0
- package/dist/internal/not-implemented.d.ts +2 -0
- package/dist/internal/not-implemented.d.ts.map +1 -0
- package/dist/internal/not-implemented.js +4 -0
- package/dist/internal/page-actions-client.d.ts +13 -0
- package/dist/internal/page-actions-client.d.ts.map +1 -0
- package/dist/internal/page-actions-client.js +160 -0
- package/dist/internal/page-actions.d.ts +18 -0
- package/dist/internal/page-actions.d.ts.map +1 -0
- package/dist/internal/page-actions.js +4 -0
- package/dist/internal/provider-client.d.ts +9 -0
- package/dist/internal/provider-client.d.ts.map +1 -0
- package/dist/internal/provider-client.js +23 -0
- package/dist/internal/search.d.ts +5 -0
- package/dist/internal/search.d.ts.map +1 -0
- package/dist/internal/search.js +14 -0
- package/dist/internal/sidebar.d.ts +9 -0
- package/dist/internal/sidebar.d.ts.map +1 -0
- package/dist/internal/sidebar.js +38 -0
- package/dist/internal/table-of-contents.d.ts +9 -0
- package/dist/internal/table-of-contents.d.ts.map +1 -0
- package/dist/internal/table-of-contents.js +5 -0
- package/dist/internal/ui/button-group.d.ts +13 -0
- package/dist/internal/ui/button-group.d.ts.map +1 -0
- package/dist/internal/ui/button-group.js +26 -0
- package/dist/internal/ui/button.d.ts +12 -0
- package/dist/internal/ui/button.d.ts.map +1 -0
- package/dist/internal/ui/button.js +33 -0
- package/dist/internal/ui/card.d.ts +6 -0
- package/dist/internal/ui/card.d.ts.map +1 -0
- package/dist/internal/ui/card.js +14 -0
- package/dist/internal/ui/collapsible.d.ts +6 -0
- package/dist/internal/ui/collapsible.d.ts.map +1 -0
- package/dist/internal/ui/collapsible.js +12 -0
- package/dist/internal/ui/drawer.d.ts +6 -0
- package/dist/internal/ui/drawer.d.ts.map +1 -0
- package/dist/internal/ui/drawer.js +13 -0
- package/dist/internal/ui/dropdown-menu.d.ts +22 -0
- package/dist/internal/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/internal/ui/dropdown-menu.js +41 -0
- package/dist/internal/ui/input-group.d.ts +15 -0
- package/dist/internal/ui/input-group.d.ts.map +1 -0
- package/dist/internal/ui/input-group.js +44 -0
- package/dist/internal/ui/input.d.ts +3 -0
- package/dist/internal/ui/input.d.ts.map +1 -0
- package/dist/internal/ui/input.js +5 -0
- package/dist/internal/ui/kbd.d.ts +4 -0
- package/dist/internal/ui/kbd.d.ts.map +1 -0
- package/dist/internal/ui/kbd.js +8 -0
- package/dist/internal/ui/popover.d.ts +6 -0
- package/dist/internal/ui/popover.d.ts.map +1 -0
- package/dist/internal/ui/popover.js +13 -0
- package/dist/internal/ui/scroll-area.d.ts +5 -0
- package/dist/internal/ui/scroll-area.d.ts.map +1 -0
- package/dist/internal/ui/scroll-area.js +12 -0
- package/dist/internal/ui/separator.d.ts +4 -0
- package/dist/internal/ui/separator.d.ts.map +1 -0
- package/dist/internal/ui/separator.js +7 -0
- package/dist/internal/ui/sheet.d.ts +10 -0
- package/dist/internal/ui/sheet.d.ts.map +1 -0
- package/dist/internal/ui/sheet.js +24 -0
- package/dist/internal/ui/sonner.d.ts +3 -0
- package/dist/internal/ui/sonner.d.ts.map +1 -0
- package/dist/internal/ui/sonner.js +20 -0
- package/dist/internal/ui/spinner.d.ts +3 -0
- package/dist/internal/ui/spinner.d.ts.map +1 -0
- package/dist/internal/ui/spinner.js +6 -0
- package/dist/internal/ui/textarea.d.ts +3 -0
- package/dist/internal/ui/textarea.d.ts.map +1 -0
- package/dist/internal/ui/textarea.js +5 -0
- package/dist/internal/ui/tooltip.d.ts +7 -0
- package/dist/internal/ui/tooltip.d.ts.map +1 -0
- package/dist/internal/ui/tooltip.js +16 -0
- package/dist/internal/use-mobile.d.ts +2 -0
- package/dist/internal/use-mobile.d.ts.map +1 -0
- package/dist/internal/use-mobile.js +16 -0
- package/dist/layout.d.ts +14 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +31 -0
- package/dist/mdx.d.ts +36 -0
- package/dist/mdx.d.ts.map +1 -0
- package/dist/mdx.js +74 -0
- package/dist/pages/docs.d.ts +77 -0
- package/dist/pages/docs.d.ts.map +1 -0
- package/dist/pages/docs.js +92 -0
- package/dist/proxy.d.ts +37 -0
- package/dist/proxy.d.ts.map +1 -0
- package/dist/proxy.js +162 -0
- package/dist/routes/chat.d.ts +14 -0
- package/dist/routes/chat.d.ts.map +1 -0
- package/dist/routes/chat.js +242 -0
- package/dist/routes/llms.d.ts +51 -0
- package/dist/routes/llms.d.ts.map +1 -0
- package/dist/routes/llms.js +59 -0
- package/dist/routes/search.d.ts +11 -0
- package/dist/routes/search.d.ts.map +1 -0
- package/dist/routes/search.js +74 -0
- package/dist/routes/sitemap.d.ts +44 -0
- package/dist/routes/sitemap.d.ts.map +1 -0
- package/dist/routes/sitemap.js +168 -0
- package/dist/sidebar.d.ts +11 -0
- package/dist/sidebar.d.ts.map +1 -0
- package/dist/sidebar.js +16 -0
- package/dist/source.d.ts +174 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +129 -0
- package/dist/versions.d.ts +15 -0
- package/dist/versions.d.ts.map +1 -0
- package/dist/versions.js +52 -0
- package/package.json +141 -9
- package/styles.css +193 -0
- package/template/_gitignore +29 -0
- package/template/app/[lang]/(home)/components/centered-section.tsx +26 -0
- package/template/app/[lang]/(home)/components/cta.tsx +19 -0
- package/template/app/[lang]/(home)/components/hero.tsx +27 -0
- package/template/app/[lang]/(home)/components/one-two-section.tsx +25 -0
- package/template/app/[lang]/(home)/components/templates.tsx +50 -0
- package/template/app/[lang]/(home)/components/text-grid-section.tsx +20 -0
- package/template/app/[lang]/(home)/layout.tsx +14 -0
- package/template/app/[lang]/(home)/page.tsx +126 -0
- package/template/app/[lang]/docs/[[...slug]]/page.tsx +19 -0
- package/template/app/[lang]/docs/layout.tsx +14 -0
- package/template/app/[lang]/layout.tsx +29 -0
- package/template/app/[lang]/llms.mdx/[[...slug]]/route.ts +7 -0
- package/template/app/[lang]/llms.txt/route.ts +6 -0
- package/template/app/[lang]/og/[...slug]/background.png +0 -0
- package/template/app/[lang]/og/[...slug]/geist-sans-regular.ttf +0 -0
- package/template/app/[lang]/og/[...slug]/geist-sans-semibold.ttf +0 -0
- package/template/app/[lang]/og/[...slug]/route.tsx +95 -0
- package/template/app/[lang]/rss.xml/route.ts +52 -0
- package/template/app/[lang]/sitemap.md/route.ts +9 -0
- package/template/app/actions/feedback/emotions.ts +18 -0
- package/template/app/actions/feedback/index.ts +45 -0
- package/template/app/api/chat/route.ts +8 -0
- package/template/app/api/search/route.ts +5 -0
- package/template/app/favicon.ico +0 -0
- package/template/app/global.css +2 -0
- package/template/app/robots.ts +14 -0
- package/template/app/sitemap.ts +36 -0
- package/template/app/styles/geistdocs.css +554 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-arrow-up-right-small.tsx +35 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-arrow-up-right.tsx +27 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-check.tsx +27 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-chevron-down-small.tsx +30 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-chevron-right.tsx +27 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-copy.tsx +27 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-file-text.tsx +25 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-menu-alt.tsx +27 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-slash-forward.tsx +36 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/index.tsx +11 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/index.tsx +14 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-ai-elements.tsx +29 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-ai-sdk.tsx +38 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-chat-sdk.tsx +42 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-flags-sdk.tsx +42 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-icon-vercel.tsx +31 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-streamdown.tsx +29 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-vercel-oss.tsx +24 -0
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-workflow-sdk.tsx +73 -0
- package/template/components/geistdocs/callout.tsx +40 -0
- package/template/components/geistdocs/chat.tsx +24 -0
- package/template/components/geistdocs/code-block-tabs.tsx +61 -0
- package/template/components/geistdocs/code-block.tsx +134 -0
- package/template/components/geistdocs/copy-page.tsx +27 -0
- package/template/components/geistdocs/desktop-menu.tsx +52 -0
- package/template/components/geistdocs/docs-layout.tsx +20 -0
- package/template/components/geistdocs/docs-page.tsx +35 -0
- package/template/components/geistdocs/edit-source.tsx +30 -0
- package/template/components/geistdocs/feedback.tsx +139 -0
- package/template/components/geistdocs/footer.tsx +30 -0
- package/template/components/geistdocs/github-button.tsx +19 -0
- package/template/components/geistdocs/home-layout.tsx +46 -0
- package/template/components/geistdocs/icons.tsx +13 -0
- package/template/components/geistdocs/installer.tsx +58 -0
- package/template/components/geistdocs/language-selector.tsx +3 -0
- package/template/components/geistdocs/mdx-components.tsx +5 -0
- package/template/components/geistdocs/mermaid.tsx +68 -0
- package/template/components/geistdocs/mobile-docs-bar.tsx +77 -0
- package/template/components/geistdocs/mobile-menu.tsx +150 -0
- package/template/components/geistdocs/navbar-logo.tsx +124 -0
- package/template/components/geistdocs/navbar.tsx +22 -0
- package/template/components/geistdocs/provider.tsx +31 -0
- package/template/components/geistdocs/rss-button.tsx +10 -0
- package/template/components/geistdocs/scroll-top.tsx +21 -0
- package/template/components/geistdocs/search.tsx +17 -0
- package/template/components/geistdocs/sidebar.tsx +128 -0
- package/template/components/geistdocs/theme-aware-image.tsx +22 -0
- package/template/components/geistdocs/theme-toggle.tsx +3 -0
- package/template/components/geistdocs/video.tsx +16 -0
- package/template/components/ui/badge.tsx +46 -0
- package/template/components/ui/button-group.tsx +83 -0
- package/template/components/ui/button.tsx +60 -0
- package/template/components/ui/card.tsx +92 -0
- package/template/components/ui/collapsible.tsx +33 -0
- package/template/components/ui/command-prompt.tsx +488 -0
- package/template/components/ui/command.tsx +184 -0
- package/template/components/ui/dialog.tsx +143 -0
- package/template/components/ui/drawer.tsx +135 -0
- package/template/components/ui/dropdown-menu.tsx +257 -0
- package/template/components/ui/hover-card.tsx +44 -0
- package/template/components/ui/input-group.tsx +170 -0
- package/template/components/ui/input.tsx +21 -0
- package/template/components/ui/kbd.tsx +28 -0
- package/template/components/ui/navigation-menu.tsx +192 -0
- package/template/components/ui/popover.tsx +48 -0
- package/template/components/ui/scroll-area.tsx +58 -0
- package/template/components/ui/select.tsx +187 -0
- package/template/components/ui/separator.tsx +28 -0
- package/template/components/ui/sheet.tsx +139 -0
- package/template/components/ui/sonner.tsx +40 -0
- package/template/components/ui/spinner.tsx +16 -0
- package/template/components/ui/textarea.tsx +18 -0
- package/template/components/ui/tooltip.tsx +61 -0
- package/template/components.json +22 -0
- package/template/content/docs/ask-ai.cn.mdx +85 -0
- package/template/content/docs/ask-ai.mdx +89 -0
- package/template/content/docs/configuration.cn.mdx +155 -0
- package/template/content/docs/configuration.mdx +200 -0
- package/template/content/docs/deployment.cn.mdx +34 -0
- package/template/content/docs/deployment.mdx +40 -0
- package/template/content/docs/edit-on-github.cn.mdx +47 -0
- package/template/content/docs/edit-on-github.mdx +51 -0
- package/template/content/docs/env.cn.mdx +25 -0
- package/template/content/docs/env.mdx +29 -0
- package/template/content/docs/feedback.cn.mdx +85 -0
- package/template/content/docs/feedback.mdx +89 -0
- package/template/content/docs/getting-started.cn.mdx +86 -0
- package/template/content/docs/getting-started.mdx +107 -0
- package/template/content/docs/index.cn.mdx +57 -0
- package/template/content/docs/index.mdx +92 -0
- package/template/content/docs/internationalization.cn.mdx +111 -0
- package/template/content/docs/internationalization.mdx +122 -0
- package/template/content/docs/llms-txt.cn.mdx +72 -0
- package/template/content/docs/llms-txt.mdx +85 -0
- package/template/content/docs/md.cn.mdx +65 -0
- package/template/content/docs/md.mdx +81 -0
- package/template/content/docs/meta.json +23 -0
- package/template/content/docs/open-in-chat.cn.mdx +78 -0
- package/template/content/docs/open-in-chat.mdx +80 -0
- package/template/content/docs/provider.cn.mdx +70 -0
- package/template/content/docs/provider.mdx +74 -0
- package/template/content/docs/proxy.cn.mdx +96 -0
- package/template/content/docs/proxy.mdx +124 -0
- package/template/content/docs/rss.cn.mdx +104 -0
- package/template/content/docs/rss.mdx +108 -0
- package/template/content/docs/syntax.cn.mdx +416 -0
- package/template/content/docs/syntax.mdx +411 -0
- package/template/content/docs/theme-aware-image.mdx +57 -0
- package/template/content/docs/versioned-docs.cn.mdx +117 -0
- package/template/content/docs/versioned-docs.mdx +181 -0
- package/template/geistdocs.tsx +51 -0
- package/template/hooks/geistdocs/use-sidebar.ts +13 -0
- package/template/hooks/use-mobile.ts +19 -0
- package/template/lib/geistdocs/config.tsx +27 -0
- package/template/lib/geistdocs/fonts.ts +18 -0
- package/template/lib/geistdocs/i18n.ts +13 -0
- package/template/lib/geistdocs/md-tracking.ts +56 -0
- package/template/lib/geistdocs/source.ts +12 -0
- package/template/lib/utils.ts +6 -0
- package/template/next.config.ts +22 -0
- package/template/package.json +63 -0
- package/template/postcss.config.mjs +5 -0
- package/template/proxy.ts +18 -0
- package/template/source.config.ts +62 -0
- package/template/tsconfig.json +37 -0
- package/dist/index.js +0 -2
- /package/dist/{index.d.ts → cli/index.d.ts} +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { toast } from "sonner";
|
|
6
|
+
import { Button } from "../ui/button";
|
|
7
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip";
|
|
8
|
+
export const CopyChat = ({ messages }) => {
|
|
9
|
+
const [copied, setCopied] = useState(false);
|
|
10
|
+
const handleCopyChat = async () => {
|
|
11
|
+
const markdown = messages
|
|
12
|
+
.map((message) => {
|
|
13
|
+
const role = message.role === "user" ? "You" : "AI";
|
|
14
|
+
const content = message.parts
|
|
15
|
+
.filter((part) => part.type === "text")
|
|
16
|
+
.map((part) => part.text)
|
|
17
|
+
.join("\n");
|
|
18
|
+
return `**${role}:**\n${content}`;
|
|
19
|
+
})
|
|
20
|
+
.join("\n\n---\n\n");
|
|
21
|
+
try {
|
|
22
|
+
await navigator.clipboard.writeText(markdown);
|
|
23
|
+
toast.success("Chat copied to clipboard");
|
|
24
|
+
setCopied(true);
|
|
25
|
+
setTimeout(() => setCopied(false), 2000);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
toast.error("Failed to copy chat", {
|
|
29
|
+
description: error instanceof Error ? error.message : "Unknown error",
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const Icon = copied ? CheckIcon : CopyIcon;
|
|
34
|
+
return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { disabled: messages.length === 0, onClick: handleCopyChat, size: "icon-sm", variant: "ghost", children: _jsx(Icon, { className: "size-3.5" }) }) }), _jsx(TooltipContent, { children: "Copy chat" })] }));
|
|
35
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { UIMessage } from "@ai-sdk/react";
|
|
2
|
+
import Dexie, { type EntityTable } from "dexie";
|
|
3
|
+
interface StoredMessage extends UIMessage {
|
|
4
|
+
sequence: number;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
}
|
|
7
|
+
declare class ChatDatabase extends Dexie {
|
|
8
|
+
messages: EntityTable<StoredMessage, "id">;
|
|
9
|
+
constructor(title: string);
|
|
10
|
+
}
|
|
11
|
+
export declare const getChatDatabase: (title: string) => ChatDatabase;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,EAAE,KAAK,WAAW,EAAE,MAAM,OAAO,CAAC;AAEhD,UAAU,aAAc,SAAQ,SAAS;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,cAAM,YAAa,SAAQ,KAAK;IAC9B,QAAQ,EAAG,WAAW,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;gBAEhC,KAAK,EAAE,MAAM;CAO1B;AAID,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,iBAS5C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Dexie from "dexie";
|
|
2
|
+
class ChatDatabase extends Dexie {
|
|
3
|
+
messages;
|
|
4
|
+
constructor(title) {
|
|
5
|
+
super(title.replaceAll(" ", "").toLowerCase());
|
|
6
|
+
this.version(1).stores({
|
|
7
|
+
messages: "id, timestamp, sequence",
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const databases = new Map();
|
|
12
|
+
export const getChatDatabase = (title) => {
|
|
13
|
+
let database = databases.get(title);
|
|
14
|
+
if (!database) {
|
|
15
|
+
database = new ChatDatabase(title);
|
|
16
|
+
databases.set(title, database);
|
|
17
|
+
}
|
|
18
|
+
return database;
|
|
19
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type UIMessage } from "ai";
|
|
2
|
+
interface MessageMetadataProps {
|
|
3
|
+
inProgress: boolean;
|
|
4
|
+
parts: UIMessage["parts"];
|
|
5
|
+
}
|
|
6
|
+
export declare const MessageMetadata: ({ parts, inProgress, }: MessageMetadataProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=message-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-metadata.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/message-metadata.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,IAAI,CAAC;AAKlD,UAAU,oBAAoB;IAC5B,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,eAAe,GAAI,wBAG7B,oBAAoB,mDAmDtB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { isToolUIPart } from "ai";
|
|
4
|
+
import { BookmarkIcon } from "lucide-react";
|
|
5
|
+
import { Shimmer } from "./shimmer";
|
|
6
|
+
import { Source, Sources, SourcesContent, SourcesTrigger } from "./sources";
|
|
7
|
+
export const MessageMetadata = ({ parts, inProgress, }) => {
|
|
8
|
+
const lastPart = parts
|
|
9
|
+
.filter((part) => part.type === "text" || isToolUIPart(part))
|
|
10
|
+
.at(-1);
|
|
11
|
+
if (!lastPart) {
|
|
12
|
+
return _jsx(Shimmer, { className: "text-xs", children: "Thinking..." });
|
|
13
|
+
}
|
|
14
|
+
const tool = isToolUIPart(lastPart) ? lastPart : null;
|
|
15
|
+
const hasTextPart = parts.some((part) => part.type === "text");
|
|
16
|
+
const sources = Array.from(new Map(parts
|
|
17
|
+
.filter((part) => part.type === "source-url")
|
|
18
|
+
.map((part) => [part.url, part])).values());
|
|
19
|
+
if (sources.length > 0 && !hasTextPart && inProgress) {
|
|
20
|
+
return _jsx(Shimmer, { className: "text-xs", children: "Searching sources..." });
|
|
21
|
+
}
|
|
22
|
+
if (sources.length > 0 && !(tool && inProgress)) {
|
|
23
|
+
return (_jsxs(Sources, { children: [_jsxs(SourcesTrigger, { count: sources.length, children: [_jsx(BookmarkIcon, { className: "size-4" }), _jsxs("p", { children: ["Used ", sources.length, " sources"] })] }), _jsx(SourcesContent, { children: _jsx("ul", { className: "flex flex-col gap-2", children: sources.map((source) => (_jsx("li", { className: "ml-4.5 list-disc pl-1", children: _jsx(Source, { href: source.url, title: source.url, children: source.title }) }, source.url))) }) })] }));
|
|
24
|
+
}
|
|
25
|
+
if (!tool && sources.length === 0) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return _jsx("div", { className: "h-12" });
|
|
29
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentProps, HTMLAttributes } from "react";
|
|
2
|
+
import { Streamdown } from "streamdown";
|
|
3
|
+
export type MessageProps = HTMLAttributes<HTMLDivElement> & {
|
|
4
|
+
from: "system" | "user" | "assistant" | "data";
|
|
5
|
+
};
|
|
6
|
+
export declare const Message: ({ className, from, ...props }: MessageProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export type MessageContentProps = HTMLAttributes<HTMLDivElement>;
|
|
8
|
+
export declare const MessageContent: ({ children, className, ...props }: MessageContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export type MessageResponseProps = ComponentProps<typeof Streamdown>;
|
|
10
|
+
export declare const MessageResponse: import("react").MemoExoticComponent<({ className, ...props }: MessageResponseProps) => import("react/jsx-runtime").JSX.Element>;
|
|
11
|
+
//# sourceMappingURL=message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/message.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxC,MAAM,MAAM,YAAY,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IAC1D,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,+BAA+B,YAAY,4CASlE,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAEjE,eAAO,MAAM,cAAc,GAAI,mCAI5B,mBAAmB,4CAYrB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;AAErE,eAAO,MAAM,eAAe,gEACA,oBAAoB,6CAW/C,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cjk } from "@streamdown/cjk";
|
|
4
|
+
import { code } from "@streamdown/code";
|
|
5
|
+
import { memo } from "react";
|
|
6
|
+
import { Streamdown } from "streamdown";
|
|
7
|
+
import { cn } from "../cn";
|
|
8
|
+
export const Message = ({ className, from, ...props }) => (_jsx("div", { className: cn("group flex w-full max-w-[95%] flex-col gap-2", from === "user" ? "is-user ml-auto justify-end" : "is-assistant", className), ...props }));
|
|
9
|
+
export const MessageContent = ({ children, className, ...props }) => (_jsx("div", { className: cn("is-user:dark flex w-fit min-w-0 max-w-full flex-col gap-2 overflow-hidden text-sm", "group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground", "group-[.is-assistant]:text-foreground", className), ...props, children: children }));
|
|
10
|
+
export const MessageResponse = memo(({ className, ...props }) => (_jsx(Streamdown, { className: cn("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", className), plugins: { code, cjk }, ...props })), (prevProps, nextProps) => prevProps.children === nextProps.children);
|
|
11
|
+
MessageResponse.displayName = "MessageResponse";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ChatStatus } from "ai";
|
|
2
|
+
import type { FormEventHandler, RefObject } from "react";
|
|
3
|
+
interface ChatPromptInputProps {
|
|
4
|
+
onChange: (value: string) => void;
|
|
5
|
+
onStop?: () => void;
|
|
6
|
+
onSubmit: FormEventHandler<HTMLFormElement>;
|
|
7
|
+
status?: ChatStatus;
|
|
8
|
+
textareaRef: RefObject<HTMLTextAreaElement | null>;
|
|
9
|
+
value: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const ChatPromptInput: ({ onChange, onStop, onSubmit, status, textareaRef, value, }: ChatPromptInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=prompt-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-input.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/prompt-input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAOrC,OAAO,KAAK,EAAE,gBAAgB,EAAwB,SAAS,EAAE,MAAM,OAAO,CAAC;AAU/E,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,gBAAgB,CAAC,eAAe,CAAC,CAAC;IAC5C,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,WAAW,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IACnD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,eAAe,GAAI,6DAO7B,oBAAoB,4CAsEtB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { CornerDownLeftIcon, Loader2Icon, SquareIcon, XIcon, } from "lucide-react";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { cn } from "../cn";
|
|
6
|
+
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupTextarea, } from "../ui/input-group";
|
|
7
|
+
export const ChatPromptInput = ({ onChange, onStop, onSubmit, status, textareaRef, value, }) => {
|
|
8
|
+
const [isComposing, setIsComposing] = useState(false);
|
|
9
|
+
const isGenerating = status === "submitted" || status === "streaming";
|
|
10
|
+
const handleKeyDown = (event) => {
|
|
11
|
+
if (event.key === "Enter") {
|
|
12
|
+
if (isComposing || event.nativeEvent.isComposing || event.shiftKey) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
const submitButton = event.currentTarget.form?.querySelector('button[type="submit"]');
|
|
17
|
+
if (submitButton?.disabled) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
event.currentTarget.form?.requestSubmit();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
let icon = _jsx(CornerDownLeftIcon, { className: "size-4" });
|
|
24
|
+
if (status === "submitted") {
|
|
25
|
+
icon = _jsx(Loader2Icon, { className: "size-4 animate-spin" });
|
|
26
|
+
}
|
|
27
|
+
else if (status === "streaming") {
|
|
28
|
+
icon = _jsx(SquareIcon, { className: "size-4" });
|
|
29
|
+
}
|
|
30
|
+
else if (status === "error") {
|
|
31
|
+
icon = _jsx(XIcon, { className: "size-4" });
|
|
32
|
+
}
|
|
33
|
+
return (_jsx("form", { onSubmit: onSubmit, children: _jsxs(InputGroup, { children: [_jsx(InputGroupTextarea, { className: cn("field-sizing-content max-h-48 min-h-16"), maxLength: 1000, name: "message", onChange: (event) => onChange(event.currentTarget.value), onCompositionEnd: () => setIsComposing(false), onCompositionStart: () => setIsComposing(true), onKeyDown: handleKeyDown, placeholder: "What would you like to know?", ref: textareaRef, value: value }), _jsxs(InputGroupAddon, { align: "block-end", className: "justify-between gap-1", children: [_jsxs("p", { className: "text-muted-foreground text-xs", children: [value.length, " / 1000"] }), _jsx(InputGroupButton, { "aria-label": isGenerating ? "Stop" : "Submit", onClick: isGenerating && onStop
|
|
34
|
+
? (event) => {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
onStop();
|
|
37
|
+
}
|
|
38
|
+
: undefined, size: "icon-sm", type: isGenerating && onStop ? "button" : "submit", variant: "default", children: icon })] })] }) }));
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/shell.tsx"],"names":[],"mappings":"AAoUA,eAAO,MAAM,kBAAkB,sDAoD9B,CAAC"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useChat } from "@ai-sdk/react";
|
|
4
|
+
import { DefaultChatTransport } from "ai";
|
|
5
|
+
import { useLiveQuery } from "dexie-react-hooks";
|
|
6
|
+
import { ChevronRightIcon, Trash } from "lucide-react";
|
|
7
|
+
import { usePathname } from "next/navigation";
|
|
8
|
+
import { Portal } from "radix-ui";
|
|
9
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
10
|
+
import { toast } from "sonner";
|
|
11
|
+
import { cn } from "../cn";
|
|
12
|
+
import { Button } from "../ui/button";
|
|
13
|
+
import { ButtonGroup } from "../ui/button-group";
|
|
14
|
+
import { Drawer, DrawerContent } from "../ui/drawer";
|
|
15
|
+
import { Kbd, KbdGroup } from "../ui/kbd";
|
|
16
|
+
import { Spinner } from "../ui/spinner";
|
|
17
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip";
|
|
18
|
+
import { useIsMobile } from "../use-mobile";
|
|
19
|
+
import { useGeistdocsChat } from "./context";
|
|
20
|
+
import { Conversation, ConversationContent, ConversationScrollButton, } from "./conversation";
|
|
21
|
+
import { CopyChat } from "./copy-chat";
|
|
22
|
+
import { getChatDatabase } from "./db";
|
|
23
|
+
import { Message, MessageContent, MessageResponse } from "./message";
|
|
24
|
+
import { MessageMetadata } from "./message-metadata";
|
|
25
|
+
import { ChatPromptInput } from "./prompt-input";
|
|
26
|
+
import { Suggestion, Suggestions } from "./suggestion";
|
|
27
|
+
const isFromPreviousDay = (timestamp) => {
|
|
28
|
+
const messageDate = new Date(timestamp);
|
|
29
|
+
const today = new Date();
|
|
30
|
+
return (messageDate.getFullYear() !== today.getFullYear() ||
|
|
31
|
+
messageDate.getMonth() !== today.getMonth() ||
|
|
32
|
+
messageDate.getDate() !== today.getDate());
|
|
33
|
+
};
|
|
34
|
+
const useChatPersistence = (title) => {
|
|
35
|
+
const saveTimeoutRef = useRef(undefined);
|
|
36
|
+
const db = useMemo(() => getChatDatabase(title), [title]);
|
|
37
|
+
const storedMessages = useLiveQuery(() => db.messages.orderBy("sequence").toArray(), [db]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (storedMessages && storedMessages.length > 0) {
|
|
40
|
+
const firstMessage = storedMessages[0];
|
|
41
|
+
if (firstMessage && isFromPreviousDay(firstMessage.timestamp)) {
|
|
42
|
+
db.messages.clear();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, [db, storedMessages]);
|
|
46
|
+
const freshMessages = storedMessages?.filter((message) => !isFromPreviousDay(message.timestamp));
|
|
47
|
+
const initialMessages = freshMessages?.map(({ timestamp, sequence, ...message }) => message) ?? [];
|
|
48
|
+
const isLoading = storedMessages === undefined;
|
|
49
|
+
const saveMessages = useCallback((messages) => {
|
|
50
|
+
if (saveTimeoutRef.current) {
|
|
51
|
+
clearTimeout(saveTimeoutRef.current);
|
|
52
|
+
}
|
|
53
|
+
saveTimeoutRef.current = setTimeout(async () => {
|
|
54
|
+
try {
|
|
55
|
+
const baseTimestamp = Date.now();
|
|
56
|
+
const messagesToStore = messages.map((message, index) => ({
|
|
57
|
+
...message,
|
|
58
|
+
timestamp: baseTimestamp + index * 1000,
|
|
59
|
+
sequence: index,
|
|
60
|
+
}));
|
|
61
|
+
await db.transaction("rw", db.messages, async () => {
|
|
62
|
+
await db.messages.clear();
|
|
63
|
+
await db.messages.bulkAdd(messagesToStore);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error("Failed to save messages:", error);
|
|
68
|
+
}
|
|
69
|
+
}, 300);
|
|
70
|
+
}, [db]);
|
|
71
|
+
const clearMessages = useCallback(async () => {
|
|
72
|
+
try {
|
|
73
|
+
await db.messages.clear();
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error("Failed to clear messages:", error);
|
|
77
|
+
}
|
|
78
|
+
}, [db]);
|
|
79
|
+
useEffect(() => () => {
|
|
80
|
+
if (saveTimeoutRef.current) {
|
|
81
|
+
clearTimeout(saveTimeoutRef.current);
|
|
82
|
+
}
|
|
83
|
+
}, []);
|
|
84
|
+
return {
|
|
85
|
+
initialMessages,
|
|
86
|
+
isLoading,
|
|
87
|
+
saveMessages,
|
|
88
|
+
clearMessages,
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
const GeistdocsChatInner = ({ isOpen }) => {
|
|
92
|
+
const pathname = usePathname();
|
|
93
|
+
const textareaRef = useRef(null);
|
|
94
|
+
const [isInitialized, setIsInitialized] = useState(false);
|
|
95
|
+
const { prompt, setPrompt, setIsOpen, title, basePath, suggestions } = useGeistdocsChat();
|
|
96
|
+
const { initialMessages, isLoading, saveMessages, clearMessages } = useChatPersistence(title);
|
|
97
|
+
const { messages, sendMessage, status, setMessages, stop } = useChat({
|
|
98
|
+
transport: new DefaultChatTransport({
|
|
99
|
+
api: basePath ? `${basePath}/api/chat` : "/api/chat",
|
|
100
|
+
prepareSendMessagesRequest: ({ body }) => ({
|
|
101
|
+
body: {
|
|
102
|
+
...body,
|
|
103
|
+
currentRoute: pathname,
|
|
104
|
+
},
|
|
105
|
+
}),
|
|
106
|
+
}),
|
|
107
|
+
onError: (error) => {
|
|
108
|
+
toast.error(error.message, {
|
|
109
|
+
description: error.message,
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (!(isLoading || isInitialized) && initialMessages.length > 0) {
|
|
115
|
+
setMessages(initialMessages);
|
|
116
|
+
setIsInitialized(true);
|
|
117
|
+
}
|
|
118
|
+
else if (!(isLoading || isInitialized)) {
|
|
119
|
+
setIsInitialized(true);
|
|
120
|
+
}
|
|
121
|
+
}, [initialMessages, isInitialized, isLoading, setMessages]);
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
if (isInitialized && messages.length > 0) {
|
|
124
|
+
saveMessages(messages);
|
|
125
|
+
}
|
|
126
|
+
}, [isInitialized, messages, saveMessages]);
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
if (isOpen) {
|
|
129
|
+
const timer = setTimeout(() => {
|
|
130
|
+
textareaRef.current?.focus();
|
|
131
|
+
}, 100);
|
|
132
|
+
return () => clearTimeout(timer);
|
|
133
|
+
}
|
|
134
|
+
}, [isOpen]);
|
|
135
|
+
const handleSuggestionClick = async (text) => {
|
|
136
|
+
if (status === "streaming" || status === "submitted") {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
setPrompt("");
|
|
140
|
+
await sendMessage({ text });
|
|
141
|
+
};
|
|
142
|
+
const handleSubmit = async () => {
|
|
143
|
+
if (status === "streaming" || status === "submitted" || !prompt) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const currentPrompt = prompt;
|
|
147
|
+
setPrompt("");
|
|
148
|
+
await sendMessage({ text: currentPrompt });
|
|
149
|
+
};
|
|
150
|
+
const handleClearChat = async () => {
|
|
151
|
+
try {
|
|
152
|
+
await clearMessages();
|
|
153
|
+
setMessages([]);
|
|
154
|
+
toast.success("Chat history cleared");
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
toast.error("Failed to clear chat history", {
|
|
158
|
+
description: error instanceof Error ? error.message : "Unknown error",
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
if (isLoading) {
|
|
163
|
+
return (_jsx("div", { className: "flex size-full w-full flex-col items-center justify-center overflow-hidden whitespace-nowrap rounded-xl xl:max-w-md xl:border xl:bg-background", children: _jsx(Spinner, {}) }));
|
|
164
|
+
}
|
|
165
|
+
return (_jsxs("div", { className: "flex size-full w-full flex-col overflow-hidden whitespace-nowrap bg-background", children: [_jsxs("div", { className: "flex items-center justify-between px-4 py-2.5", children: [_jsx("h2", { className: "font-semibold text-sm", children: "Chat" }), _jsx("div", { className: "flex items-center gap-3", children: _jsxs(ButtonGroup, { children: [_jsx(CopyChat, { messages: messages }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { disabled: messages.length === 0, onClick: handleClearChat, size: "icon-sm", variant: "ghost", children: _jsx(Trash, { className: "size-3.5" }) }) }), _jsx(TooltipContent, { children: "Clear chat" })] }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { onClick: () => setIsOpen(false), size: "icon-sm", variant: "ghost", children: _jsx(ChevronRightIcon, { className: "size-3.5" }) }) }), _jsx(TooltipContent, { children: "Close chat" })] })] }) })] }), _jsxs(Conversation, { children: [_jsxs(ConversationContent, { children: [messages.map((message) => (_jsxs(Message, { className: "max-w-[90%]", from: message.role, children: [_jsx(MessageMetadata, { inProgress: status === "submitted" || status === "streaming", parts: message.parts }), message.parts
|
|
166
|
+
.filter((part) => part.type === "text")
|
|
167
|
+
.map((part) => (_jsx(MessageContent, { children: _jsx(MessageResponse, { className: "text-wrap", children: part.text }) }, `${message.id}-${part.type}-${part.text}`)))] }, message.id))), status === "submitted" ? (_jsx("div", { className: "size-12 text-muted-foreground text-sm", children: _jsx(Spinner, {}) })) : null] }), _jsx(ConversationScrollButton, {})] }), _jsxs("div", { className: "relative grid w-auto shrink-0 gap-4 p-4", children: [messages.length ? null : (_jsxs(_Fragment, { children: [_jsx(Suggestions, { className: "flex-col items-start gap-px", children: suggestions.map((text) => (_jsx(Suggestion, { className: "rounded-none p-0", onClick: handleSuggestionClick, suggestion: text, variant: "link" }, text))) }), _jsxs("p", { className: "text-muted-foreground text-sm", children: ["Tip: You can open and close chat with", " ", _jsxs(KbdGroup, { children: [_jsx(Kbd, { className: "border bg-transparent", children: "\u2318" }), _jsx(Kbd, { className: "border bg-transparent", children: "I" })] })] })] })), _jsx(ChatPromptInput, { onChange: setPrompt, onStop: stop, onSubmit: (event) => {
|
|
168
|
+
event.preventDefault();
|
|
169
|
+
handleSubmit().catch((error) => {
|
|
170
|
+
console.error("Failed to submit chat message:", error);
|
|
171
|
+
});
|
|
172
|
+
}, status: status, textareaRef: textareaRef, value: prompt })] })] }));
|
|
173
|
+
};
|
|
174
|
+
export const GeistdocsChatShell = () => {
|
|
175
|
+
const { enabled, isOpen, setIsOpen } = useGeistdocsChat();
|
|
176
|
+
const isMobile = useIsMobile();
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
const handleKeyDown = (event) => {
|
|
179
|
+
if ((event.metaKey || event.ctrlKey) &&
|
|
180
|
+
!event.altKey &&
|
|
181
|
+
!event.shiftKey &&
|
|
182
|
+
event.key.toLowerCase() === "i") {
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
setIsOpen((prev) => !prev);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
188
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
189
|
+
}, [setIsOpen]);
|
|
190
|
+
if (!enabled) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
return (_jsxs(_Fragment, { children: [_jsx(Portal.Root, { className: "hidden md:block", children: _jsx("div", { className: cn("fixed inset-y-0 right-0 z-50 flex h-full w-3/4 max-w-sm flex-col gap-4 border-l bg-background transition-all", "translate-x-full data-[state=open]:translate-x-0"), "data-state": isOpen ? "open" : "closed", children: _jsx(GeistdocsChatInner, { isOpen: isOpen }) }) }), _jsx("div", { className: "md:hidden", children: _jsx(Drawer, { onOpenChange: isMobile ? setIsOpen : undefined, open: isMobile ? isOpen : false, children: _jsx(DrawerContent, { className: "h-[80dvh]", children: _jsx(GeistdocsChatInner, { isOpen: isOpen }) }) }) })] }));
|
|
194
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ElementType } from "react";
|
|
2
|
+
interface TextShimmerProps {
|
|
3
|
+
as?: ElementType;
|
|
4
|
+
children: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
duration?: number;
|
|
7
|
+
spread?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const Shimmer: import("react").MemoExoticComponent<({ children, as: Component, className, duration, spread, }: TextShimmerProps) => import("react/jsx-runtime").JSX.Element>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=shimmer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shimmer.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/shimmer.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAsB,KAAK,WAAW,EAAiB,MAAM,OAAO,CAAC;AAG5E,UAAU,gBAAgB;IACxB,EAAE,CAAC,EAAE,WAAW,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA2CD,eAAO,MAAM,OAAO,kGAnCjB,gBAAgB,6CAmC0B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { motion } from "motion/react";
|
|
4
|
+
import { memo, useMemo } from "react";
|
|
5
|
+
import { cn } from "../cn";
|
|
6
|
+
const ShimmerComponent = ({ children, as: Component = "p", className, duration = 2, spread = 2, }) => {
|
|
7
|
+
const MotionComponent = motion.create(Component);
|
|
8
|
+
const dynamicSpread = useMemo(() => (children?.length ?? 0) * spread, [children, spread]);
|
|
9
|
+
return (_jsx(MotionComponent, { animate: { backgroundPosition: "0% center" }, className: cn("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent", "[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]", className), initial: { backgroundPosition: "100% center" }, style: {
|
|
10
|
+
"--spread": `${dynamicSpread}px`,
|
|
11
|
+
backgroundImage: "var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))",
|
|
12
|
+
}, transition: {
|
|
13
|
+
repeat: Number.POSITIVE_INFINITY,
|
|
14
|
+
duration,
|
|
15
|
+
ease: "linear",
|
|
16
|
+
}, children: children }));
|
|
17
|
+
};
|
|
18
|
+
export const Shimmer = memo(ShimmerComponent);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
import { CollapsibleContent, CollapsibleTrigger } from "../ui/collapsible";
|
|
3
|
+
export type SourcesProps = ComponentProps<"div">;
|
|
4
|
+
export declare const Sources: ({ className, ...props }: SourcesProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export type SourcesTriggerProps = ComponentProps<typeof CollapsibleTrigger> & {
|
|
6
|
+
count: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const SourcesTrigger: ({ className, count, children, ...props }: SourcesTriggerProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export type SourcesContentProps = ComponentProps<typeof CollapsibleContent>;
|
|
10
|
+
export declare const SourcesContent: ({ className, ...props }: SourcesContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export type SourceProps = ComponentProps<"a">;
|
|
12
|
+
export declare const Source: ({ href, title, children, ...props }: SourceProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=sources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/sources.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAEL,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,YAAY,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;AAEjD,eAAO,MAAM,OAAO,GAAI,yBAAyB,YAAY,4CAK5D,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,OAAO,kBAAkB,CAAC,GAAG;IAC5E,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,0CAK5B,mBAAmB,4CAYrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE5E,eAAO,MAAM,cAAc,GAAI,yBAG5B,mBAAmB,4CASrB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;AAE9C,eAAO,MAAM,MAAM,GAAI,qCAAqC,WAAW,4CAetE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { BookIcon, ChevronDownIcon } from "lucide-react";
|
|
4
|
+
import { cn } from "../cn";
|
|
5
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "../ui/collapsible";
|
|
6
|
+
export const Sources = ({ className, ...props }) => (_jsx(Collapsible, { className: cn("not-prose mb-4 text-primary text-xs", className), ...props }));
|
|
7
|
+
export const SourcesTrigger = ({ className, count, children, ...props }) => (_jsx(CollapsibleTrigger, { className: cn("flex items-center gap-2", className), ...props, children: children ?? (_jsxs(_Fragment, { children: [_jsxs("p", { className: "font-medium", children: ["Used ", count, " sources"] }), _jsx(ChevronDownIcon, { className: "h-4 w-4" })] })) }));
|
|
8
|
+
export const SourcesContent = ({ className, ...props }) => (_jsx(CollapsibleContent, { className: cn("mt-3 flex w-fit flex-col gap-2", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", className), ...props }));
|
|
9
|
+
export const Source = ({ href, title, children, ...props }) => (_jsx("a", { className: "flex items-center gap-2", href: href, rel: "noreferrer", target: "_blank", ...props, children: children ?? (_jsxs(_Fragment, { children: [_jsx(BookIcon, { className: "h-4 w-4" }), _jsx("span", { className: "block font-medium", children: title })] })) }));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
import { Button } from "../ui/button";
|
|
3
|
+
import { ScrollArea } from "../ui/scroll-area";
|
|
4
|
+
export type SuggestionsProps = ComponentProps<typeof ScrollArea>;
|
|
5
|
+
export declare const Suggestions: ({ className, children, ...props }: SuggestionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export type SuggestionProps = Omit<ComponentProps<typeof Button>, "onClick"> & {
|
|
7
|
+
suggestion: string;
|
|
8
|
+
onClick?: (suggestion: string) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const Suggestion: ({ suggestion, onClick, className, variant, size, children, ...props }: SuggestionProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=suggestion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggestion.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/suggestion.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,UAAU,EAAa,MAAM,mBAAmB,CAAC;AAE1D,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;AAEjE,eAAO,MAAM,WAAW,GAAI,mCAIzB,gBAAgB,4CAOlB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,EAAE,SAAS,CAAC,GAAG;IAC7E,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,uEAQxB,eAAe,4CAiBjB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../cn";
|
|
4
|
+
import { Button } from "../ui/button";
|
|
5
|
+
import { ScrollArea, ScrollBar } from "../ui/scroll-area";
|
|
6
|
+
export const Suggestions = ({ className, children, ...props }) => (_jsxs(ScrollArea, { className: "w-full overflow-x-auto whitespace-nowrap", ...props, children: [_jsx("div", { className: cn("flex w-max flex-nowrap items-center gap-2", className), children: children }), _jsx(ScrollBar, { className: "hidden", orientation: "horizontal" })] }));
|
|
7
|
+
export const Suggestion = ({ suggestion, onClick, className, variant = "outline", size = "sm", children, ...props }) => {
|
|
8
|
+
const handleClick = () => {
|
|
9
|
+
onClick?.(suggestion);
|
|
10
|
+
};
|
|
11
|
+
return (_jsx(Button, { className: cn("cursor-pointer rounded-full px-4", className), onClick: handleClick, size: size, type: "button", variant: variant, ...props, children: children || suggestion }));
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cn.d.ts","sourceRoot":"","sources":["../../src/internal/cn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,MAAM,CAAC;AAG7C,eAAO,MAAM,EAAE,GAAI,GAAG,QAAQ,UAAU,EAAE,WAA0B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface FeedbackPayload {
|
|
2
|
+
emotion: string;
|
|
3
|
+
message: string;
|
|
4
|
+
}
|
|
5
|
+
interface SendFeedbackOptions {
|
|
6
|
+
feedback: FeedbackPayload;
|
|
7
|
+
siteId?: string;
|
|
8
|
+
url: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const sendFeedback: ({ url, feedback, siteId, }: SendFeedbackOptions) => Promise<{
|
|
11
|
+
success: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=feedback-action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback-action.d.ts","sourceRoot":"","sources":["../../src/internal/feedback-action.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,eAAe,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAYD,eAAO,MAAM,YAAY,GAAU,4BAIhC,mBAAmB,KAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CA4BpD,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
import { headers } from "next/headers";
|
|
3
|
+
const emotions = [
|
|
4
|
+
{ name: "cry", emoji: "😭" },
|
|
5
|
+
{ name: "sad", emoji: "😕" },
|
|
6
|
+
{ name: "happy", emoji: "🙂" },
|
|
7
|
+
{ name: "amazed", emoji: "🤩" },
|
|
8
|
+
];
|
|
9
|
+
const protocol = process.env.NODE_ENV === "production" ? "https" : "http";
|
|
10
|
+
const baseUrl = `${protocol}://${process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL}`;
|
|
11
|
+
export const sendFeedback = async ({ url, feedback, siteId, }) => {
|
|
12
|
+
const emoji = emotions.find((emotion) => emotion.name === feedback.emotion)?.emoji;
|
|
13
|
+
const endpoint = new URL("/feedback", "https://geistdocs.com/feedback");
|
|
14
|
+
const headersList = await headers();
|
|
15
|
+
const response = await fetch(endpoint, {
|
|
16
|
+
method: "POST",
|
|
17
|
+
headers: {
|
|
18
|
+
"Content-Type": "application/json",
|
|
19
|
+
},
|
|
20
|
+
body: JSON.stringify({
|
|
21
|
+
note: feedback.message,
|
|
22
|
+
url: new URL(url, baseUrl).toString(),
|
|
23
|
+
emotion: emoji,
|
|
24
|
+
ua: headersList.get("user-agent") ?? undefined,
|
|
25
|
+
ip: headersList.get("x-real-ip") || headersList.get("x-forwarded-for"),
|
|
26
|
+
label: siteId,
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
console.error(await response.json());
|
|
31
|
+
return { success: false };
|
|
32
|
+
}
|
|
33
|
+
return { success: true };
|
|
34
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GeistdocsConfig } from "../config";
|
|
2
|
+
export declare const createGeistdocsI18n: (config: Pick<GeistdocsConfig, "defaultLanguage" | "translations">) => {
|
|
3
|
+
i18n: import("fumadocs-core/i18n").I18nConfig<string>;
|
|
4
|
+
i18nProvider: (locale?: string) => import("fumadocs-ui/i18n").I18nProviderProps;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/internal/i18n.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAGjD,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,cAAc,CAAC;;;CAmBlE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineI18n } from "fumadocs-core/i18n";
|
|
2
|
+
import { defineI18nUI } from "fumadocs-ui/i18n";
|
|
3
|
+
import { getGeistdocsLanguageConfig } from "./languages";
|
|
4
|
+
export const createGeistdocsI18n = (config) => {
|
|
5
|
+
const { defaultLanguage, languages, translations } = getGeistdocsLanguageConfig(config);
|
|
6
|
+
const i18n = defineI18n({
|
|
7
|
+
defaultLanguage,
|
|
8
|
+
languages,
|
|
9
|
+
hideLocale: "default-locale",
|
|
10
|
+
});
|
|
11
|
+
const { provider } = defineI18nUI(i18n, {
|
|
12
|
+
translations,
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
i18n,
|
|
16
|
+
i18nProvider: provider,
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GeistdocsConfig, GeistdocsTranslations } from "../config";
|
|
2
|
+
export declare const getGeistdocsLanguageConfig: (config: Pick<GeistdocsConfig, "defaultLanguage" | "translations">) => {
|
|
3
|
+
defaultLanguage: string;
|
|
4
|
+
languages: string[];
|
|
5
|
+
translations: GeistdocsTranslations;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=languages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../src/internal/languages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAIxE,eAAO,MAAM,0BAA0B,GACrC,QAAQ,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,cAAc,CAAC;;;;CAoBlE,CAAC"}
|