@vercel/geistdocs 1.25.1-canary.5684bb5 → 1.25.1-canary.6c2bd30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/dist/cli/index.js +1 -1
  2. package/dist/components/callout.d.ts.map +1 -1
  3. package/dist/components/callout.js +3 -3
  4. package/dist/components/code-block-tabs.d.ts.map +1 -1
  5. package/dist/components/code-block-tabs.js +3 -1
  6. package/dist/components/code-block.d.ts.map +1 -1
  7. package/dist/components/code-block.js +1 -1
  8. package/dist/components/command-prompt.d.ts.map +1 -1
  9. package/dist/components/command-prompt.js +15 -22
  10. package/dist/components/copy-prompt.d.ts +2 -1
  11. package/dist/components/copy-prompt.d.ts.map +1 -1
  12. package/dist/components/copy-prompt.js +2 -2
  13. package/dist/components/heading.d.ts +7 -0
  14. package/dist/components/heading.d.ts.map +1 -0
  15. package/dist/components/heading.js +14 -0
  16. package/dist/components/image.d.ts +19 -0
  17. package/dist/components/image.d.ts.map +1 -0
  18. package/dist/components/image.js +9 -0
  19. package/dist/components/table.d.ts +3 -0
  20. package/dist/components/table.d.ts.map +1 -0
  21. package/dist/components/table.js +3 -0
  22. package/dist/controls.d.ts.map +1 -1
  23. package/dist/controls.js +4 -3
  24. package/dist/internal/chat/activity.d.ts +20 -0
  25. package/dist/internal/chat/activity.d.ts.map +1 -0
  26. package/dist/internal/chat/activity.js +43 -0
  27. package/dist/internal/chat/context.d.ts +2 -0
  28. package/dist/internal/chat/context.d.ts.map +1 -1
  29. package/dist/internal/chat/context.js +24 -3
  30. package/dist/internal/chat/dots-spinner.d.ts.map +1 -1
  31. package/dist/internal/chat/dots-spinner.js +15 -9
  32. package/dist/internal/chat/loading-skeleton.d.ts +7 -0
  33. package/dist/internal/chat/loading-skeleton.d.ts.map +1 -0
  34. package/dist/internal/chat/loading-skeleton.js +46 -0
  35. package/dist/internal/chat/message-metadata.d.ts.map +1 -1
  36. package/dist/internal/chat/message-metadata.js +15 -30
  37. package/dist/internal/chat/message-sources.d.ts +3 -0
  38. package/dist/internal/chat/message-sources.d.ts.map +1 -0
  39. package/dist/internal/chat/message-sources.js +23 -0
  40. package/dist/internal/chat/message.d.ts.map +1 -1
  41. package/dist/internal/chat/message.js +59 -5
  42. package/dist/internal/chat/shell.d.ts.map +1 -1
  43. package/dist/internal/chat/shell.js +17 -17
  44. package/dist/internal/chat/source-chunks.d.ts +9 -0
  45. package/dist/internal/chat/source-chunks.d.ts.map +1 -0
  46. package/dist/internal/chat/source-chunks.js +7 -0
  47. package/dist/internal/chat/sources.d.ts +1 -1
  48. package/dist/internal/chat/sources.d.ts.map +1 -1
  49. package/dist/internal/chat/sources.js +7 -1
  50. package/dist/internal/link-href.d.ts +13 -0
  51. package/dist/internal/link-href.d.ts.map +1 -0
  52. package/dist/internal/link-href.js +51 -0
  53. package/dist/internal/mdx-to-markdown.d.ts +3 -0
  54. package/dist/internal/mdx-to-markdown.d.ts.map +1 -0
  55. package/dist/internal/mdx-to-markdown.js +134 -0
  56. package/dist/internal/mousedown-navigation-utils.d.ts +5 -0
  57. package/dist/internal/mousedown-navigation-utils.d.ts.map +1 -0
  58. package/dist/internal/mousedown-navigation-utils.js +95 -0
  59. package/dist/internal/mousedown-navigation.d.ts +10 -0
  60. package/dist/internal/mousedown-navigation.d.ts.map +1 -0
  61. package/dist/internal/mousedown-navigation.js +42 -0
  62. package/dist/internal/navbar/desktop-menu.js +1 -1
  63. package/dist/internal/navbar/mobile-menu.d.ts.map +1 -1
  64. package/dist/internal/navbar/mobile-menu.js +8 -13
  65. package/dist/internal/navbar/navbar-shell.d.ts.map +1 -1
  66. package/dist/internal/navbar/navbar-shell.js +2 -1
  67. package/dist/internal/page-actions-client.d.ts.map +1 -1
  68. package/dist/internal/page-actions-client.js +36 -32
  69. package/dist/internal/provider-client.d.ts.map +1 -1
  70. package/dist/internal/provider-client.js +29 -5
  71. package/dist/internal/search.d.ts.map +1 -1
  72. package/dist/internal/search.js +1 -1
  73. package/dist/internal/sidebar-responsive.d.ts +0 -1
  74. package/dist/internal/sidebar-responsive.d.ts.map +1 -1
  75. package/dist/internal/sidebar-responsive.js +0 -9
  76. package/dist/internal/sidebar-tree.d.ts.map +1 -1
  77. package/dist/internal/sidebar-tree.js +6 -1
  78. package/dist/internal/sidebar.d.ts.map +1 -1
  79. package/dist/internal/sidebar.js +78 -49
  80. package/dist/internal/table-of-contents.d.ts.map +1 -1
  81. package/dist/internal/table-of-contents.js +1 -1
  82. package/dist/internal/toc-items.d.ts.map +1 -1
  83. package/dist/internal/toc-items.js +16 -6
  84. package/dist/internal/ui/dropdown-menu.js +6 -6
  85. package/dist/internal/ui/navigation-menu.js +2 -2
  86. package/dist/internal/use-mobile.d.ts.map +1 -1
  87. package/dist/internal/use-mobile.js +2 -12
  88. package/dist/layout.d.ts +1 -0
  89. package/dist/layout.d.ts.map +1 -1
  90. package/dist/layout.js +2 -0
  91. package/dist/mdx.d.ts.map +1 -1
  92. package/dist/mdx.js +13 -4
  93. package/dist/pages/docs.d.ts.map +1 -1
  94. package/dist/pages/docs.js +17 -9
  95. package/dist/routes/chat.d.ts +1 -1
  96. package/dist/routes/chat.d.ts.map +1 -1
  97. package/dist/routes/chat.js +31 -14
  98. package/dist/routes/llms.d.ts +1 -1
  99. package/dist/routes/llms.d.ts.map +1 -1
  100. package/dist/routes/llms.js +12 -2
  101. package/dist/source.d.ts +10 -1
  102. package/dist/source.d.ts.map +1 -1
  103. package/dist/source.js +75 -34
  104. package/dist/versions.js +2 -2
  105. package/docs/agents.md +4 -3
  106. package/docs/llms.txt +348 -34
  107. package/docs/manifest.json +12 -3
  108. package/docs/pages/ask-ai.md +2 -2
  109. package/docs/pages/deployment.md +30 -5
  110. package/docs/pages/getting-started.md +38 -12
  111. package/docs/pages/guides/nested-navigation.md +1 -1
  112. package/docs/pages/md.md +25 -6
  113. package/docs/pages/migration-2.md +106 -0
  114. package/docs/pages/migration.md +5 -2
  115. package/docs/pages/syntax.md +133 -3
  116. package/docs/sitemap.md +3 -2
  117. package/package.json +10 -5
  118. package/template/app/[lang]/layout.tsx +4 -0
  119. package/template/app/styles/geistdocs.css +1 -1
  120. package/template/components/ui/button.tsx +1 -1
  121. package/template/content/docs/ask-ai.cn.mdx +2 -2
  122. package/template/content/docs/ask-ai.mdx +2 -2
  123. package/template/content/docs/deployment.mdx +31 -6
  124. package/template/content/docs/getting-started.mdx +39 -13
  125. package/template/content/docs/guides/nested-navigation.mdx +1 -1
  126. package/template/content/docs/md.mdx +25 -6
  127. package/template/content/docs/meta.json +1 -0
  128. package/template/content/docs/migration-2.mdx +106 -0
  129. package/template/content/docs/migration.mdx +5 -1
  130. package/template/content/docs/syntax.mdx +139 -3
  131. package/template/next.config.ts +9 -0
  132. package/template/package.json +4 -4
  133. package/theme.css +33 -64
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Skeleton } from "@vercel/geistcn/components/skeleton";
4
+ import { cn } from "@vercel/geistcn/utils";
5
+ import { useEffect, useState } from "react";
6
+ const getMessageCount = async (title) => {
7
+ const name = title.replaceAll(" ", "").toLowerCase();
8
+ if ("databases" in indexedDB) {
9
+ const databases = await indexedDB.databases();
10
+ if (!databases.some((database) => database.name === name)) {
11
+ return 0;
12
+ }
13
+ }
14
+ return new Promise((resolve) => {
15
+ const request = indexedDB.open(name);
16
+ request.onerror = () => resolve(0);
17
+ request.onupgradeneeded = () => {
18
+ request.transaction?.abort();
19
+ resolve(0);
20
+ };
21
+ request.onsuccess = () => {
22
+ const database = request.result;
23
+ if (!database.objectStoreNames.contains("messages")) {
24
+ database.close();
25
+ resolve(0);
26
+ return;
27
+ }
28
+ const transaction = database.transaction("messages", "readonly");
29
+ const count = transaction.objectStore("messages").count();
30
+ count.onerror = () => resolve(0);
31
+ count.onsuccess = () => resolve(count.result);
32
+ transaction.oncomplete = () => database.close();
33
+ };
34
+ });
35
+ };
36
+ export const ChatConversationSkeleton = () => (_jsxs("div", { className: "relative flex flex-1 flex-col justify-start gap-7 overflow-hidden px-4 pt-12 pb-4", children: [_jsxs("div", { className: "relative mr-2 ml-auto w-[260px]", children: [_jsx("div", { className: "relative min-h-10 animate-pulse rounded-[10px] bg-gray-200" }), _jsx("svg", { "aria-hidden": "true", className: "absolute right-[2.5px] -bottom-[0.5px] z-10 translate-x-1/2 fill-gray-200/80", height: "14", viewBox: "0 0 18 14", width: "18", children: _jsx("path", { d: "M0.866025 8.80383L11.2583 0.803833C11.2583 0.803833 12.0621 9.5 17.2583 13.1961C12.0621 13.1961 0.866025 8.80383 0.866025 8.80383Z" }) })] }), _jsx(Skeleton, { height: 25, width: "20%" }), _jsxs("div", { className: "flex shrink-0 flex-col gap-4", children: [_jsxs("div", { className: "w-[80%] flex-1 space-y-2", children: [_jsx(Skeleton, { height: 20, width: "66%" }), _jsx(Skeleton, { height: 20, width: "100%" }), _jsx(Skeleton, { height: 20, width: "75%" })] }), _jsxs("div", { className: "w-[80%] flex-1 space-y-2", children: [_jsx(Skeleton, { height: 20, width: "50%" }), _jsx(Skeleton, { height: 20, width: "100%" }), _jsx(Skeleton, { height: 20, width: "83%" }), _jsx(Skeleton, { height: 20, width: "66%" })] }), _jsxs("div", { className: "w-[80%] flex-1 space-y-2", children: [_jsx(Skeleton, { height: 20, width: "75%" }), _jsx(Skeleton, { height: 20, width: "100%" }), _jsx(Skeleton, { height: 20, width: "50%" })] }), _jsxs("div", { className: "w-[80%] flex-1 space-y-2", children: [_jsx(Skeleton, { height: 20, width: "66%" }), _jsx(Skeleton, { height: 20, width: "100%" }), _jsx(Skeleton, { height: 20, width: "75%" }), _jsx(Skeleton, { height: 20, width: "33%" })] })] }), _jsx("div", { className: "absolute inset-x-0 bottom-0 h-52 bg-gradient-to-t from-background-100 via-background-100 to-transparent" })] }));
37
+ export const ChatEmptySkeleton = () => (_jsxs("div", { className: "flex h-full min-h-0 flex-col", children: [_jsxs("div", { className: "flex h-16 shrink-0 items-center justify-between px-3.5 py-2", children: [_jsx(Skeleton, { height: 20, width: 56 }), _jsx("div", { className: "flex items-center gap-1", children: [0, 1, 2, 3].map((item) => (_jsx(Skeleton, { height: 32, rounded: true, width: 32 }, item))) })] }), _jsxs("div", { className: "flex min-h-0 flex-1 flex-col justify-end", children: [_jsxs("div", { className: "flex flex-col gap-2 px-4 pt-4", children: [[0, 1, 2, 3].map((item) => (_jsx(Skeleton, { block: true, height: 36, width: "100%" }, item))), _jsx(Skeleton, { className: "mt-3 mb-2 ml-2", height: 16, width: "72%" })] }), _jsx("div", { className: "p-4", children: _jsx(Skeleton, { block: true, className: "rounded-[12px]", height: 88, width: "100%" }) })] })] }));
38
+ export const ChatLoadingSkeleton = ({ isMobile, title, }) => {
39
+ const [conversation, setConversation] = useState(false);
40
+ useEffect(() => {
41
+ getMessageCount(title).then((count) => setConversation(count > 0));
42
+ }, [title]);
43
+ return (_jsx("div", { className: cn("fixed z-45 flex flex-col bg-background-100", isMobile
44
+ ? "inset-x-0 bottom-0 h-[80dvh] rounded-t-xl"
45
+ : "inset-y-0 right-0 w-[400px] border-l"), children: conversation ? _jsx(ChatConversationSkeleton, {}) : _jsx(ChatEmptySkeleton, {}) }));
46
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"message-metadata.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/message-metadata.tsx"],"names":[],"mappings":"AAGA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,IAAI,CAAC;AAI/D,UAAU,oBAAoB;IAC5B,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAC3B;AAkBD,eAAO,MAAM,eAAe,GAAI,wBAG7B,oBAAoB,mDA+FtB,CAAC"}
1
+ {"version":3,"file":"message-metadata.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/message-metadata.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,IAAI,CAAC;AAMlD,UAAU,oBAAoB;IAC5B,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAC3B;AAQD,eAAO,MAAM,eAAe,GAAI,wBAG7B,oBAAoB,mDA0DtB,CAAC"}
@@ -1,44 +1,29 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { IconBookmark, IconChevronDown } from "@vercel/geistcn-assets/icons";
4
- import { getToolName, isToolUIPart } from "ai";
4
+ import { isToolUIPart } from "ai";
5
+ import { getMessageActivity } from "./activity";
5
6
  import { DotsSpinner } from "./dots-spinner";
7
+ import { getMessageSources } from "./message-sources";
6
8
  import { Source, Sources, SourcesContent, SourcesTrigger } from "./sources";
7
- const WORD_SEPARATOR_PATTERN = /[_-]+/g;
8
9
  const LoadingContainer = ({ children }) => (_jsx("div", { className: "h-12 animate-pulse pt-2 text-gray-900 text-sm", children: children }));
9
- const getToolActivityLabel = (part) => {
10
- const name = getToolName(part).replace(WORD_SEPARATOR_PATTERN, " ").trim();
11
- return name ? `Running ${name}...` : "Working...";
12
- };
13
10
  export const MessageMetadata = ({ parts, inProgress, }) => {
11
+ const activity = getMessageActivity({ inProgress, parts });
12
+ if (activity) {
13
+ return (_jsxs(LoadingContainer, { children: [_jsx(DotsSpinner, {}), " ", activity.label] }));
14
+ }
14
15
  const lastPart = parts
15
- .filter((part) => part.type === "text" || part.type === "reasoning" || isToolUIPart(part))
16
+ .filter((part) => part.type === "text" || isToolUIPart(part))
16
17
  .at(-1);
17
- if (!lastPart) {
18
- return (_jsx(LoadingContainer, { children: _jsx(DotsSpinner, {}) }));
19
- }
20
- if (lastPart.type === "reasoning" &&
21
- lastPart.state !== "done" &&
22
- inProgress) {
23
- return (_jsxs(LoadingContainer, { children: [_jsx(DotsSpinner, {}), " Thinking..."] }));
24
- }
25
- const tool = isToolUIPart(lastPart) ? lastPart : null;
26
- const hasTextPart = parts.some((part) => part.type === "text");
27
- const sources = Array.from(new Map(parts
28
- .filter((part) => part.type === "source-url")
29
- .map((part) => [part.url, part])).values());
30
- if (sources.length > 0 && !hasTextPart && inProgress) {
31
- return (_jsxs(LoadingContainer, { children: [_jsx(DotsSpinner, {}), " Searching..."] }));
32
- }
33
- if (tool &&
34
- inProgress &&
35
- (tool.state === "input-streaming" || tool.state === "input-available")) {
36
- return (_jsxs(LoadingContainer, { children: [_jsx(DotsSpinner, {}), " ", getToolActivityLabel(tool)] }));
37
- }
38
- if (sources.length > 0 && !(tool && inProgress)) {
18
+ const tool = lastPart && isToolUIPart(lastPart) ? lastPart : null;
19
+ const sources = getMessageSources(parts);
20
+ if (sources.length > 0) {
39
21
  return (_jsxs(Sources, { className: "mb-4", children: [_jsxs(SourcesTrigger, { className: "w-full max-w-fit cursor-pointer justify-between gap-2 py-1 pr-3 pl-0 text-left", count: sources.length, children: [_jsxs("div", { className: "flex items-center gap-1.5", children: [_jsx(IconBookmark, { className: "size-4", color: "gray-900" }), _jsxs("p", { className: "text-gray-900 text-xs", children: ["Used ", sources.length, " source", sources.length === 1 ? "" : "s"] })] }), _jsx(IconChevronDown, { className: "size-4 transition-transform duration-200 group-data-[state=open]:rotate-180", color: "gray-900" })] }), _jsx(SourcesContent, { children: _jsx("ul", { className: "mt-1.5 list-disc pl-4", children: sources.map((source) => (_jsx("li", { className: "my-1.5", children: _jsx(Source, { href: source.url, title: source.title }) }, source.url))) }) })] }));
40
22
  }
41
- if (!tool && sources.length === 0) {
23
+ if (!tool) {
24
+ return null;
25
+ }
26
+ if (tool.state === "output-available") {
42
27
  return null;
43
28
  }
44
29
  return _jsx("div", { className: "h-12" });
@@ -0,0 +1,3 @@
1
+ import { type SourceUrlUIPart, type UIMessage } from "ai";
2
+ export declare const getMessageSources: (parts: UIMessage["parts"]) => SourceUrlUIPart[];
3
+ //# sourceMappingURL=message-sources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-sources.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/message-sources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,eAAe,EAAE,KAAK,SAAS,EAAE,MAAM,IAAI,CAAC;AAgBxE,eAAO,MAAM,iBAAiB,GAC5B,OAAO,SAAS,CAAC,OAAO,CAAC,KACxB,eAAe,EAuBf,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { isToolUIPart } from "ai";
2
+ const isToolSource = (value) => typeof value === "object" &&
3
+ value !== null &&
4
+ "documentUri" in value &&
5
+ typeof value.documentUri === "string" &&
6
+ "documentTitle" in value &&
7
+ typeof value.documentTitle === "string";
8
+ export const getMessageSources = (parts) => Array.from(new Map([
9
+ ...parts.filter((part) => part.type === "source-url"),
10
+ ...parts
11
+ .filter((part) => isToolUIPart(part) && part.state === "output-available")
12
+ .flatMap((part) => {
13
+ if (!Array.isArray(part.output)) {
14
+ return [];
15
+ }
16
+ return part.output.filter(isToolSource).map((source, index) => ({
17
+ type: "source-url",
18
+ sourceId: `tool-${part.toolCallId}-${source.chunkIndex ?? index}-${source.documentUri}`,
19
+ url: source.documentUri,
20
+ title: source.documentTitle,
21
+ }));
22
+ }),
23
+ ].map((source) => [source.url, source])).values());
@@ -1 +1 @@
1
- {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/message.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,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,4CAqBrB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;AAErE,eAAO,MAAM,eAAe,gEACA,oBAAoB,6CAW/C,CAAC"}
1
+ {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/message.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAEL,UAAU,EAEX,MAAM,YAAY,CAAC;AAyLpB,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,4CAqBrB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;AAErE,eAAO,MAAM,eAAe,gEACA,oBAAoB,6CAa/C,CAAC"}
@@ -1,11 +1,65 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { cjk } from "@streamdown/cjk";
4
- import { code } from "@streamdown/code";
4
+ import { CodeBlock } from "@vercel/geistcn/components/code-block";
5
+ import { Modal, ModalAction, ModalActions, ModalBody, ModalHeader, ModalSubtitle, ModalTitle, } from "@vercel/geistcn/components/modal";
5
6
  import { cn } from "@vercel/geistcn/utils";
6
- import { memo } from "react";
7
- import { Streamdown } from "streamdown";
7
+ import { IconArrowUpRightSmall } from "@vercel/geistcn-assets/icons";
8
+ import { memo, useState } from "react";
9
+ import { Streamdown, } from "streamdown";
10
+ import { useGeistdocsConfig } from "../config-context";
11
+ import { resolveLinkHref } from "../link-href";
12
+ const CODE_LANGUAGE_PATTERN = /language-([\w-]+)/;
13
+ const FILENAME_PATTERN = /filename="([^"]+)"/;
14
+ const LinkSafetyModal = ({ isOpen, onClose, onConfirm, url, }) => {
15
+ return (_jsxs(Modal, { active: isOpen, drawer: false, onClickOutside: onClose, style: {
16
+ background: "var(--ds-background-200)",
17
+ boxShadow: "var(--ds-shadow-modal)",
18
+ }, width: 448, children: [_jsxs(ModalBody, { className: "bg-background-200", padding: 24, children: [_jsxs(ModalHeader, { children: [_jsx(ModalTitle, { children: "Open external link?" }), _jsx(ModalSubtitle, { children: "You\u2019re about to visit an external website." })] }), _jsx("div", { className: "break-all rounded-md bg-gray-100 p-3 font-mono text-copy-13", children: url })] }), _jsxs(ModalActions, { children: [_jsx(ModalAction, { onClick: onClose, variant: "secondary", children: "Cancel" }), _jsx(ModalAction, { onClick: onConfirm, children: "Open link" })] })] }));
19
+ };
20
+ const ChatLink = ({ children, className, href, node: _node, rel, target, ...props }) => {
21
+ const [isOpen, setIsOpen] = useState(false);
22
+ const { siteUrl } = useGeistdocsConfig();
23
+ const resolved = resolveLinkHref(String(href ?? ""), siteUrl);
24
+ if (!resolved.external) {
25
+ return (_jsx("a", { className: cn("font-normal text-gray-1000! underline decoration-1 decoration-gray-700 underline-offset-4 hover:text-gray-1000! hover:decoration-gray-1000 hover:opacity-100!", className), href: resolved.href, rel: resolved.external ? rel : undefined, target: resolved.external ? target : undefined, ...props, children: children }));
26
+ }
27
+ return (_jsxs(_Fragment, { children: [_jsxs("button", { className: cn("group wrap-anywhere cursor-pointer appearance-none text-left font-normal text-gray-1000! no-underline hover:text-gray-1000! hover:opacity-100!", className), onClick: () => setIsOpen(true), type: "button", children: [_jsx("span", { className: "underline decoration-1 decoration-gray-700 underline-offset-4 group-hover:decoration-gray-1000", children: children }), _jsxs("span", { className: "whitespace-nowrap", children: ["\u00a0", _jsx("span", { className: "inline-flex -translate-y-1 align-text-bottom", children: _jsx(IconArrowUpRightSmall, { size: 16 }) })] })] }), _jsx(LinkSafetyModal, { isOpen: isOpen, onClose: () => setIsOpen(false), onConfirm: () => {
28
+ window.open(resolved.href, "_blank", "noreferrer");
29
+ setIsOpen(false);
30
+ }, url: resolved.href })] }));
31
+ };
32
+ const CHAT_RESPONSE_COMPONENTS = {
33
+ a: ChatLink,
34
+ code: ({ children, className, node, ...props }) => {
35
+ const inline = node?.position?.start.line === node?.position?.end.line;
36
+ if (inline) {
37
+ return (_jsx("code", { className: cn("rounded bg-gray-100 px-1 py-0.5 font-mono text-sm", className), ...props, children: children }));
38
+ }
39
+ const codeContent = Array.isArray(children)
40
+ ? children.join("")
41
+ : String(children);
42
+ const language = CODE_LANGUAGE_PATTERN.exec(className ?? "")?.[1] ?? "text";
43
+ const meta = node?.data?.meta;
44
+ const filename = typeof meta === "string" ? FILENAME_PATTERN.exec(meta)?.[1] : undefined;
45
+ const cleanedCode = codeContent
46
+ .replaceAll("```$", "")
47
+ .replaceAll("```*", "")
48
+ .replaceAll("```-", "")
49
+ .replaceAll("```_", "")
50
+ .replaceAll("```_$", "")
51
+ .trim();
52
+ return (_jsx(CodeBlock, { className: cn("my-4", className), filename: filename, language: language, children: cleanedCode }));
53
+ },
54
+ h1: ({ children, className, node: _node, ...props }) => (_jsx("h1", { className: cn("font-semibold text-xl", className), ...props, children: children })),
55
+ h2: ({ children, className, node: _node, ...props }) => (_jsx("h2", { className: cn("font-semibold text-xl", className), ...props, children: children })),
56
+ h3: ({ children, className, node: _node, ...props }) => (_jsx("h3", { className: cn("font-semibold text-lg", className), ...props, children: children })),
57
+ h4: ({ children, className, node: _node, ...props }) => (_jsx("h4", { className: cn("font-semibold text-lg", className), ...props, children: children })),
58
+ h5: ({ children, className, node: _node, ...props }) => (_jsx("h5", { className: cn("font-semibold text-base", className), ...props, children: children })),
59
+ h6: ({ children, className, node: _node, ...props }) => (_jsx("h6", { className: cn("font-semibold text-sm", className), ...props, children: children })),
60
+ pre: ({ children, className }) => _jsx("pre", { className: className, children: children }),
61
+ };
8
62
  export const Message = ({ className, from, ...props }) => (_jsx("div", { className: cn("group flex w-full flex-col gap-2 py-4 [&>div]:max-w-[80%]", from === "user" ? "is-user items-end" : "is-assistant items-start", className), ...props }));
9
63
  export const MessageContent = ({ children, className, ...props }) => (_jsxs("div", { className: cn("relative flex min-h-10 w-fit min-w-0 max-w-full flex-col gap-2 whitespace-normal rounded-[12px] px-4 py-2 text-left text-sm leading-relaxed", "group-[.is-user]:bg-gray-1000 group-[.is-user]:text-white group-[.is-user]:dark:bg-gray-100 group-[.is-user]:dark:text-gray-1000", "group-[.is-assistant]:min-h-0 group-[.is-assistant]:px-0 group-[.is-assistant]:py-0 group-[.is-assistant]:text-gray-1000", className), ...props, children: [_jsx("div", { className: "is-user:dark", children: children }), _jsx("svg", { "aria-hidden": "true", className: "absolute right-[2.5px] -bottom-[0.5px] hidden translate-x-1/2 group-[.is-user]:block group-[.is-user]:fill-gray-1000 group-[.is-user]:dark:fill-gray-100", height: "14", viewBox: "0 0 18 14", width: "18", children: _jsx("path", { d: "M0.866025 8.80383L11.2583 0.803833C11.2583 0.803833 12.0621 9.5 17.2583 13.1961C12.0621 13.1961 0.866025 8.80383 0.866025 8.80383Z" }) })] }));
10
- export const MessageResponse = memo(({ className, ...props }) => (_jsx(Streamdown, { className: cn("size-full whitespace-normal text-left text-sm leading-relaxed [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", className), plugins: { code, cjk }, ...props })), (prevProps, nextProps) => prevProps.children === nextProps.children);
64
+ export const MessageResponse = memo(({ className, ...props }) => (_jsx(Streamdown, { className: cn("size-full whitespace-normal text-left text-sm leading-relaxed [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", className), components: CHAT_RESPONSE_COMPONENTS, linkSafety: { enabled: true, renderModal: LinkSafetyModal }, plugins: { cjk }, ...props })), (prevProps, nextProps) => prevProps.children === nextProps.children);
11
65
  MessageResponse.displayName = "MessageResponse";
@@ -1 +1 @@
1
- {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/shell.tsx"],"names":[],"mappings":"AAgYA,eAAO,MAAM,kBAAkB,sDA6D9B,CAAC"}
1
+ {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/shell.tsx"],"names":[],"mappings":"AAwYA,eAAO,MAAM,kBAAkB,sDAsD9B,CAAC"}
@@ -18,6 +18,7 @@ import { Portal } from "radix-ui";
18
18
  import { useCallback, useEffect, useId, useMemo, useRef, useState, } from "react";
19
19
  import { getPublicPath } from "../../config";
20
20
  import { useIsMobile } from "../use-mobile";
21
+ import { isActiveAssistantMessage, shouldShowPendingActivity, } from "./activity";
21
22
  import { useGeistdocsChat } from "./context";
22
23
  import { Conversation, ConversationContent, ConversationScrollButton, } from "./conversation";
23
24
  import { CopyChat } from "./copy-chat";
@@ -175,9 +176,13 @@ const GeistdocsChatInner = ({ isOpen }) => {
175
176
  if (isLoading) {
176
177
  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-100", children: _jsx(Spinner, {}) }));
177
178
  }
178
- return (_jsxs("aside", { "aria-label": "Ask AI chat", className: "flex size-full w-full flex-col overflow-hidden whitespace-nowrap bg-background-100", children: [_jsxs("div", { className: "sticky top-0 z-10 flex h-16 items-center justify-between bg-background-100 py-2 pr-2 pl-3.5", children: [_jsx("h2", { className: "font-semibold text-sm", children: "Ask AI" }), _jsxs("div", { className: "flex items-center gap-0.5", children: [_jsx(CopyChat, { messages: messages }), _jsx(Tooltip, { position: "bottom", text: "Delete chat", children: _jsx(Button, { "aria-label": "Delete chat", className: "text-gray-800! disabled:bg-gray-alpha-100!", disabled: messages.length === 0, onClick: handleClearChat, shape: "square", size: "small", svgOnly: true, typeName: "button", variant: "tertiary", children: _jsx(IconTrash, { size: 14 }) }) }), _jsx(Tooltip, { position: "bottom", text: "Close chat", children: _jsx(Button, { "aria-label": "Close chat", className: "text-gray-800! shadow-none", onClick: () => setIsOpen(false), shape: "square", size: "small", svgOnly: true, typeName: "button", variant: "tertiary", children: _jsx(IconChevronDoubleRight, { size: 14 }) }) })] })] }), _jsxs(Conversation, { children: [_jsxs(ConversationContent, { children: [messages.map((message) => (_jsxs(Message, { from: message.role, children: [_jsx(MessageMetadata, { inProgress: status === "submitted" || status === "streaming", parts: message.parts }), message.parts
179
+ return (_jsxs("aside", { "aria-label": "Ask AI chat", className: "flex size-full w-full flex-col overflow-hidden whitespace-nowrap bg-background-100", children: [_jsxs("div", { className: "sticky top-0 z-10 flex h-16 items-center justify-between bg-background-100 py-2 pr-2 pl-3.5", children: [_jsx("h2", { className: "font-semibold text-sm", children: "Ask AI" }), _jsxs("div", { className: "flex items-center gap-0.5", children: [_jsx(CopyChat, { messages: messages }), _jsx(Tooltip, { position: "bottom", text: "Delete chat", children: _jsx(Button, { "aria-label": "Delete chat", className: "text-gray-800! disabled:bg-gray-alpha-100!", disabled: messages.length === 0, onClick: handleClearChat, shape: "square", size: "small", svgOnly: true, typeName: "button", variant: "tertiary", children: _jsx(IconTrash, { size: 14 }) }) }), _jsx(Tooltip, { position: "bottom", text: "Close chat", children: _jsx(Button, { "aria-label": "Close chat", className: "text-gray-800! shadow-none", onClick: () => setIsOpen(false), shape: "square", size: "small", svgOnly: true, typeName: "button", variant: "tertiary", children: _jsx(IconChevronDoubleRight, { size: 14 }) }) })] })] }), _jsxs(Conversation, { children: [_jsxs(ConversationContent, { children: [messages.map((message, index) => (_jsxs(Message, { from: message.role, children: [_jsx(MessageMetadata, { inProgress: isActiveAssistantMessage({
180
+ index,
181
+ messages,
182
+ status,
183
+ }), parts: message.parts }), message.parts
179
184
  .filter((part) => part.type === "text")
180
- .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: "h-12 animate-pulse pt-2 text-gray-900 text-sm", children: _jsx(DotsSpinner, {}) })) : null] }), _jsx(ConversationScrollButton, {})] }), _jsxs("div", { className: "relative grid w-auto shrink-0 gap-3 whitespace-normal p-4 text-left", children: [messages.length ? null : (_jsxs(_Fragment, { children: [_jsx(Suggestions, { className: "w-full cursor-text", children: suggestions.slice(0, 4).map((text, index) => (_jsx(Suggestion, { className: "w-full", icon: suggestionIcons[index], onClick: handleSuggestionClick, suggestion: text, variant: "tertiary" }, text))) }), _jsxs("p", { className: "mb-3 whitespace-normal px-2 text-left text-gray-900 text-label-14", children: ["Tip: You can open and close chat with", _jsx(Kbd, { className: "material-base ml-1.5 text-gray-900", meta: true, small: true }), _jsx(Kbd, { className: "material-base ml-1 font-mono! text-gray-900", small: true, children: "I" })] })] })), _jsx(ChatPromptInput, { onChange: setPrompt, onStop: stop, onSubmit: (event) => {
185
+ .map((part) => (_jsx(MessageContent, { children: _jsx(MessageResponse, { className: "text-wrap", children: part.text }) }, `${message.id}-${part.type}-${part.text}`)))] }, message.id))), shouldShowPendingActivity({ messages, status }) ? (_jsx("div", { className: "h-12 animate-pulse pt-2 text-gray-900 text-sm", children: _jsx(DotsSpinner, {}) })) : null] }), _jsx(ConversationScrollButton, {})] }), _jsxs("div", { className: "relative grid w-auto shrink-0 gap-3 whitespace-normal p-4 text-left", children: [messages.length ? null : (_jsxs(_Fragment, { children: [_jsx(Suggestions, { className: "w-full cursor-text", children: suggestions.slice(0, 4).map((text, index) => (_jsx(Suggestion, { className: "w-full", icon: suggestionIcons[index], onClick: handleSuggestionClick, suggestion: text, variant: "tertiary" }, text))) }), _jsxs("p", { className: "mb-3 whitespace-normal px-2 text-left text-gray-900 text-label-14", children: ["Tip: You can open and close chat with", _jsx(Kbd, { className: "material-base ml-1.5 text-gray-900", meta: true, small: true }), _jsx(Kbd, { className: "material-base ml-1 font-mono! text-gray-900", small: true, children: "I" })] })] })), _jsx(ChatPromptInput, { onChange: setPrompt, onStop: stop, onSubmit: (event) => {
181
186
  event.preventDefault();
182
187
  handleSubmit().catch((error) => {
183
188
  console.error("Failed to submit chat message:", error);
@@ -189,26 +194,21 @@ const GeistdocsChatErrorBoundary = catchError(GeistdocsChatErrorFallback);
189
194
  export const GeistdocsChatShell = () => {
190
195
  const { enabled, isOpen, setIsOpen } = useGeistdocsChat();
191
196
  const isMobile = useIsMobile();
192
- useEffect(() => {
193
- const handleKeyDown = (event) => {
194
- if ((event.metaKey || event.ctrlKey) &&
195
- !event.altKey &&
196
- !event.shiftKey &&
197
- event.key.toLowerCase() === "i") {
198
- event.preventDefault();
199
- setIsOpen((prev) => !prev);
200
- }
201
- };
202
- window.addEventListener("keydown", handleKeyDown);
203
- return () => window.removeEventListener("keydown", handleKeyDown);
204
- }, [setIsOpen]);
205
197
  if (!enabled) {
206
198
  return null;
207
199
  }
208
- return (_jsxs(_Fragment, { children: [_jsx(Portal.Root, { className: "hidden md:block", children: _jsx("div", { className: cn(
200
+ return (_jsxs(_Fragment, { children: [isOpen ? (_jsx("style", { children: `
201
+ html {
202
+ scrollbar-width: none !important;
203
+ -ms-overflow-style: none !important;
204
+ }
205
+ html::-webkit-scrollbar {
206
+ display: none !important;
207
+ }
208
+ ` })) : null, _jsx(Portal.Root, { children: _jsx("div", { className: cn(
209
209
  // z-45 keeps the panel above the sticky navbar (z-40) but below
210
210
  // modal surfaces like the search command menu, dialogs, and
211
211
  // dropdowns (z-50), so opening the command menu paints over an
212
212
  // open chat panel.
213
- "fixed inset-y-0 right-0 z-45 flex h-full w-[400px] max-w-[75vw] flex-col gap-4 border-l bg-background-100 transition-all", "translate-x-full data-[state=open]:translate-x-0"), "data-state": isOpen ? "open" : "closed", children: _jsx(GeistdocsChatErrorBoundary, { onClose: () => setIsOpen(false), children: _jsx(GeistdocsChatInner, { isOpen: isOpen }) }) }) }), _jsx("div", { className: "md:hidden", children: _jsxs(Drawer, { className: "flex flex-col bg-background-100", height: "80dvh", onDismiss: () => setIsOpen(false), show: isMobile && isOpen, children: [_jsx(DrawerTitle, { className: "sr-only", children: "Ask AI" }), _jsx(GeistdocsChatErrorBoundary, { onClose: () => setIsOpen(false), children: _jsx(GeistdocsChatInner, { isOpen: isOpen }) })] }) })] }));
213
+ "fixed inset-y-0 right-0 z-45 hidden h-full w-[400px] max-w-[75vw] flex-col gap-4 border-l bg-background-100 transition-transform min-[768px]:flex", "translate-x-full data-[state=open]:translate-x-0"), "data-state": isOpen ? "open" : "closed", children: _jsx(GeistdocsChatErrorBoundary, { onClose: () => setIsOpen(false), children: _jsx(GeistdocsChatInner, { isOpen: isOpen }) }) }) }), _jsx("div", { className: "min-[768px]:hidden", children: _jsxs(Drawer, { className: "flex flex-col bg-background-100", height: "80dvh", onDismiss: () => setIsOpen(false), show: isMobile && isOpen, children: [_jsx(DrawerTitle, { className: "sr-only", children: "Ask AI" }), _jsx(GeistdocsChatErrorBoundary, { onClose: () => setIsOpen(false), children: _jsx(GeistdocsChatInner, { isOpen: isOpen }) })] }) })] }));
214
214
  };
@@ -0,0 +1,9 @@
1
+ import type { UIMessageChunk } from "ai";
2
+ export interface CitableDocument {
3
+ slug: string;
4
+ title: string;
5
+ url: string;
6
+ }
7
+ export declare const createSourceChunk: (doc: CitableDocument, index?: number) => UIMessageChunk;
8
+ export declare const createSourceChunks: (docs: CitableDocument[]) => UIMessageChunk[];
9
+ //# sourceMappingURL=source-chunks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-chunks.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/source-chunks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;AAEzC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,iBAAiB,GAC5B,KAAK,eAAe,EACpB,cAAS,KACR,cAKD,CAAC;AAEH,eAAO,MAAM,kBAAkB,GAAI,MAAM,eAAe,EAAE,KAAG,cAAc,EAC9C,CAAC"}
@@ -0,0 +1,7 @@
1
+ export const createSourceChunk = (doc, index = 0) => ({
2
+ type: "source-url",
3
+ sourceId: `doc-${index}-${doc.slug}`,
4
+ url: doc.url,
5
+ title: doc.title,
6
+ });
7
+ export const createSourceChunks = (docs) => docs.map(createSourceChunk);
@@ -11,5 +11,5 @@ export declare const SourcesContent: ({ className, ...props }: SourcesContentPro
11
11
  export type SourceProps = ComponentProps<"a"> & {
12
12
  href: string;
13
13
  };
14
- export declare const Source: ({ href, title, children, ...props }: SourceProps) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const Source: ({ href, title, children, rel, target, ...props }: SourceProps) => import("react/jsx-runtime").JSX.Element;
15
15
  //# sourceMappingURL=sources.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/sources.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,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,4CAerB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE5E,eAAO,MAAM,cAAc,GAAI,yBAG5B,mBAAmB,4CAErB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjE,eAAO,MAAM,MAAM,GAAI,qCAAqC,WAAW,4CAYtE,CAAC"}
1
+ {"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/sources.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAG5C,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,4CAerB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE5E,eAAO,MAAM,cAAc,GAAI,yBAG5B,mBAAmB,4CAErB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjE,eAAO,MAAM,MAAM,GAAI,kDAOpB,WAAW,4CAiBb,CAAC"}
@@ -2,8 +2,14 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { cn } from "@vercel/geistcn/utils";
4
4
  import { IconChevronDown } from "@vercel/geistcn-assets/icons";
5
+ import { useGeistdocsConfig } from "../config-context";
6
+ import { resolveLinkHref } from "../link-href";
5
7
  import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "../ui/collapsible";
6
8
  export const Sources = ({ className, ...props }) => (_jsx(Collapsible, { className: cn("not-prose text-gray-600 text-xs", className), ...props }));
7
9
  export const SourcesTrigger = ({ className, count, children, ...props }) => (_jsx(CollapsibleTrigger, { className: cn("group flex items-center rounded-md border-none bg-transparent", className), ...props, children: children ?? (_jsxs(_Fragment, { children: [_jsxs("p", { className: "font-medium", children: ["Used ", count, " sources"] }), _jsx(IconChevronDown, { className: "h-4 w-4 transition-transform duration-200 group-data-[state=open]:rotate-180" })] })) }));
8
10
  export const SourcesContent = ({ className, ...props }) => (_jsx(CollapsibleContent, { className: cn("flex flex-col", className), ...props }));
9
- export const Source = ({ href, title, children, ...props }) => (_jsx("a", { className: "inline-flex min-w-0 max-w-full items-center underline underline-offset-1", href: href, rel: "noreferrer", target: "_blank", ...props, children: children ?? (_jsx("span", { className: "truncate font-medium text-gray-1000", children: title })) }));
11
+ export const Source = ({ href, title, children, rel, target, ...props }) => {
12
+ const { siteUrl } = useGeistdocsConfig();
13
+ const resolved = resolveLinkHref(href, siteUrl);
14
+ return (_jsx("a", { className: "inline-flex min-w-0 max-w-full items-center underline underline-offset-1", href: resolved.href, rel: resolved.external ? (rel ?? "noreferrer") : undefined, target: resolved.external ? (target ?? "_blank") : undefined, ...props, children: children ?? (_jsx("span", { className: "truncate font-medium text-gray-1000", children: title })) }));
15
+ };
@@ -0,0 +1,13 @@
1
+ export interface ResolvedLinkHref {
2
+ external: boolean;
3
+ href: string;
4
+ }
5
+ /**
6
+ * Treat an absolute URL on the configured production origin as app-local.
7
+ * Keeping the path, query, and hash makes canonical links navigate internally
8
+ * on production domains and previews alike.
9
+ */
10
+ export declare const resolveLinkHref: (href: string, siteUrl?: string) => ResolvedLinkHref;
11
+ /** Strip the Next.js base path before handing an href to `next/link`. */
12
+ export declare const stripBasePathFromHref: (href: string, basePath?: string) => string;
13
+ //# sourceMappingURL=link-href.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-href.d.ts","sourceRoot":"","sources":["../../src/internal/link-href.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,MAAM,MAAM,EACZ,UAAU,MAAM,KACf,gBAwBF,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,qBAAqB,GAAI,MAAM,MAAM,EAAE,WAAW,MAAM,WAmBpE,CAAC"}
@@ -0,0 +1,51 @@
1
+ const HTTP_URL = /^https?:\/\//;
2
+ const normalizeBasePath = (basePath) => {
3
+ if (!(basePath && basePath !== "/")) {
4
+ return "";
5
+ }
6
+ return `/${basePath.replace(/^\/+|\/+$/g, "")}`;
7
+ };
8
+ /**
9
+ * Treat an absolute URL on the configured production origin as app-local.
10
+ * Keeping the path, query, and hash makes canonical links navigate internally
11
+ * on production domains and previews alike.
12
+ */
13
+ export const resolveLinkHref = (href, siteUrl) => {
14
+ if (!HTTP_URL.test(href)) {
15
+ return { external: false, href };
16
+ }
17
+ if (!siteUrl) {
18
+ return { external: true, href };
19
+ }
20
+ try {
21
+ const url = new URL(href);
22
+ const site = new URL(siteUrl);
23
+ if (url.origin === site.origin) {
24
+ return {
25
+ external: false,
26
+ href: `${url.pathname}${url.search}${url.hash}`,
27
+ };
28
+ }
29
+ }
30
+ catch {
31
+ // Preserve the existing external treatment for malformed absolute URLs.
32
+ }
33
+ return { external: true, href };
34
+ };
35
+ /** Strip the Next.js base path before handing an href to `next/link`. */
36
+ export const stripBasePathFromHref = (href, basePath) => {
37
+ const prefix = normalizeBasePath(basePath);
38
+ if (!prefix) {
39
+ return href;
40
+ }
41
+ if (href === prefix) {
42
+ return "/";
43
+ }
44
+ if (href.startsWith(`${prefix}/`)) {
45
+ return href.slice(prefix.length);
46
+ }
47
+ if (href.startsWith(`${prefix}?`) || href.startsWith(`${prefix}#`)) {
48
+ return `/${href.slice(prefix.length)}`;
49
+ }
50
+ return href;
51
+ };
@@ -0,0 +1,3 @@
1
+ /** Convert authored MDX into component-free, agent-readable Markdown. */
2
+ export declare const mdxToMarkdown: (source: string) => Promise<string>;
3
+ //# sourceMappingURL=mdx-to-markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mdx-to-markdown.d.ts","sourceRoot":"","sources":["../../src/internal/mdx-to-markdown.ts"],"names":[],"mappings":"AAwKA,yEAAyE;AACzE,eAAO,MAAM,aAAa,GAAU,QAAQ,MAAM,oBACF,CAAC"}
@@ -0,0 +1,134 @@
1
+ import remarkFrontmatter from "remark-frontmatter";
2
+ import remarkGfm from "remark-gfm";
3
+ import remarkMdx from "remark-mdx";
4
+ import remarkParse from "remark-parse";
5
+ import remarkStringify from "remark-stringify";
6
+ import { unified } from "unified";
7
+ const getAttribute = (node, name) => {
8
+ const attribute = node.attributes?.find((entry) => entry.type === "mdxJsxAttribute" && entry.name === name);
9
+ if (!attribute) {
10
+ return undefined;
11
+ }
12
+ if (typeof attribute.value === "string") {
13
+ return attribute.value;
14
+ }
15
+ const expression = attribute.value?.value?.trim();
16
+ if (!expression) {
17
+ return undefined;
18
+ }
19
+ try {
20
+ const parsed = JSON.parse(expression);
21
+ return typeof parsed === "string" ? parsed : undefined;
22
+ }
23
+ catch {
24
+ return undefined;
25
+ }
26
+ };
27
+ const paragraph = (value) => ({
28
+ children: [{ type: "text", value }],
29
+ type: "paragraph",
30
+ });
31
+ const OMITTED_NODE_TYPES = new Set([
32
+ "mdxFlowExpression",
33
+ "mdxTextExpression",
34
+ "mdxjsEsm",
35
+ "yaml",
36
+ ]);
37
+ const OMITTED_COMPONENTS = new Set([
38
+ "CodeBlockTabsList",
39
+ "CodeBlockTabsTrigger",
40
+ ]);
41
+ const imageNodes = (node) => {
42
+ const nodes = [];
43
+ const alt = getAttribute(node, "alt") ?? "";
44
+ const source = getAttribute(node, "srcLight") ?? getAttribute(node, "src");
45
+ if (source) {
46
+ nodes.push({
47
+ children: [{ alt, type: "image", url: source }],
48
+ type: "paragraph",
49
+ });
50
+ }
51
+ const caption = getAttribute(node, "caption");
52
+ if (caption) {
53
+ nodes.push(paragraph(caption));
54
+ }
55
+ return nodes;
56
+ };
57
+ const calloutNode = (node) => {
58
+ const title = getAttribute(node, "title");
59
+ const heading = title
60
+ ? [
61
+ {
62
+ children: [
63
+ {
64
+ children: [{ type: "text", value: `${title}:` }],
65
+ type: "strong",
66
+ },
67
+ ],
68
+ type: "paragraph",
69
+ },
70
+ ]
71
+ : [];
72
+ return {
73
+ children: [...heading, ...(node.children ?? [])],
74
+ type: "blockquote",
75
+ };
76
+ };
77
+ const replaceComponent = (node) => {
78
+ if (OMITTED_COMPONENTS.has(node.name ?? "")) {
79
+ return [];
80
+ }
81
+ if (node.name === "Check" || node.name === "Cross") {
82
+ return [{ type: "text", value: node.name === "Check" ? "✓" : "✗" }];
83
+ }
84
+ if (node.name === "Image") {
85
+ return imageNodes(node);
86
+ }
87
+ if (node.name === "Callout") {
88
+ return [calloutNode(node)];
89
+ }
90
+ const text = getAttribute(node, "text");
91
+ if ((node.name === "CopyPrompt" || node.name === "Prompt") && text) {
92
+ return [paragraph(text)];
93
+ }
94
+ // Presentation-only components (including CodeBlockTabs and CodeBlockTab)
95
+ // should not leak into agent-readable Markdown. Their meaningful children
96
+ // remain in document order, so every tab's fenced code is written out.
97
+ return node.children ?? [];
98
+ };
99
+ const cleanNode = (node) => {
100
+ if (OMITTED_NODE_TYPES.has(node.type)) {
101
+ return [];
102
+ }
103
+ if (node.children) {
104
+ node.children = node.children.flatMap(cleanNode);
105
+ }
106
+ if (node.type !== "mdxJsxFlowElement" && node.type !== "mdxJsxTextElement") {
107
+ return [node];
108
+ }
109
+ // Native HTML can carry meaning Markdown has no equivalent for (`details`,
110
+ // `summary`, media, and so on). Keep it; only component-shaped JSX is a
111
+ // presentation abstraction that needs flattening.
112
+ if (node.name && node.name === node.name.toLowerCase()) {
113
+ return [node];
114
+ }
115
+ return replaceComponent(node);
116
+ };
117
+ const cleanChildren = (parent) => {
118
+ parent.children = (parent.children ?? []).flatMap(cleanNode);
119
+ };
120
+ const cleanMdx = () => (tree) => {
121
+ cleanChildren(tree);
122
+ };
123
+ const processor = unified()
124
+ .use(remarkParse)
125
+ .use(remarkGfm)
126
+ .use(remarkMdx)
127
+ .use(remarkFrontmatter, ["yaml"])
128
+ .use(cleanMdx)
129
+ .use(remarkStringify, {
130
+ bullet: "-",
131
+ fences: true,
132
+ });
133
+ /** Convert authored MDX into component-free, agent-readable Markdown. */
134
+ export const mdxToMarkdown = async (source) => String(await processor.process(source)).trim();
@@ -0,0 +1,5 @@
1
+ import type { PointerEvent as ReactPointerEvent } from "react";
2
+ export declare const getMouseDownRouterHref: (href: string, basePath: string | undefined) => string;
3
+ export declare const findMouseDownNavigationAnchor: (target: EventTarget | null, boundary: EventTarget | null) => HTMLAnchorElement | null;
4
+ export declare const shouldNavigateOnPointerDown: (event: ReactPointerEvent, anchor: HTMLAnchorElement) => boolean;
5
+ //# sourceMappingURL=mousedown-navigation-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mousedown-navigation-utils.d.ts","sourceRoot":"","sources":["../../src/internal/mousedown-navigation-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAwB/D,eAAO,MAAM,sBAAsB,GACjC,MAAM,MAAM,EACZ,UAAU,MAAM,GAAG,SAAS,WAoB7B,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,QAAQ,WAAW,GAAG,IAAI,EAC1B,UAAU,WAAW,GAAG,IAAI,KAC3B,iBAAiB,GAAG,IAWtB,CAAC;AAyBF,eAAO,MAAM,2BAA2B,GACtC,OAAO,iBAAiB,EACxB,QAAQ,iBAAiB,YA0C1B,CAAC"}