@vercel/geistdocs 1.25.1-canary.4e75e60 → 1.25.1-canary.62250e6

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 (86) hide show
  1. package/dist/cli/index.js +1 -1
  2. package/dist/components/code-block-tabs.js +1 -1
  3. package/dist/components/code-block.d.ts.map +1 -1
  4. package/dist/components/code-block.js +1 -1
  5. package/dist/components/copy-prompt.js +1 -1
  6. package/dist/components/image.d.ts +19 -0
  7. package/dist/components/image.d.ts.map +1 -0
  8. package/dist/components/image.js +9 -0
  9. package/dist/components/steps.d.ts +9 -0
  10. package/dist/components/steps.d.ts.map +1 -0
  11. package/dist/components/steps.js +9 -0
  12. package/dist/internal/chat/activity.d.ts +20 -0
  13. package/dist/internal/chat/activity.d.ts.map +1 -0
  14. package/dist/internal/chat/activity.js +43 -0
  15. package/dist/internal/chat/message-metadata.d.ts.map +1 -1
  16. package/dist/internal/chat/message-metadata.js +15 -30
  17. package/dist/internal/chat/message-sources.d.ts +3 -0
  18. package/dist/internal/chat/message-sources.d.ts.map +1 -0
  19. package/dist/internal/chat/message-sources.js +23 -0
  20. package/dist/internal/chat/message.d.ts.map +1 -1
  21. package/dist/internal/chat/message.js +44 -10
  22. package/dist/internal/chat/shell.d.ts.map +1 -1
  23. package/dist/internal/chat/shell.js +7 -2
  24. package/dist/internal/chat/source-chunks.d.ts +9 -0
  25. package/dist/internal/chat/source-chunks.d.ts.map +1 -0
  26. package/dist/internal/chat/source-chunks.js +7 -0
  27. package/dist/internal/chat/sources.d.ts +1 -1
  28. package/dist/internal/chat/sources.d.ts.map +1 -1
  29. package/dist/internal/chat/sources.js +6 -3
  30. package/dist/internal/link-href.d.ts +13 -0
  31. package/dist/internal/link-href.d.ts.map +1 -0
  32. package/dist/internal/link-href.js +51 -0
  33. package/dist/internal/mdx-to-markdown.d.ts +3 -0
  34. package/dist/internal/mdx-to-markdown.d.ts.map +1 -0
  35. package/dist/internal/mdx-to-markdown.js +166 -0
  36. package/dist/internal/react-node-text.d.ts +4 -0
  37. package/dist/internal/react-node-text.d.ts.map +1 -0
  38. package/dist/internal/react-node-text.js +11 -0
  39. package/dist/internal/search.js +1 -1
  40. package/dist/internal/sidebar-tree.d.ts.map +1 -1
  41. package/dist/internal/sidebar-tree.js +6 -1
  42. package/dist/internal/toc-items.d.ts.map +1 -1
  43. package/dist/internal/toc-items.js +2 -1
  44. package/dist/mdx.d.ts.map +1 -1
  45. package/dist/mdx.js +5 -0
  46. package/dist/pages/docs.d.ts.map +1 -1
  47. package/dist/pages/docs.js +10 -5
  48. package/dist/routes/chat.d.ts.map +1 -1
  49. package/dist/routes/chat.js +30 -13
  50. package/dist/routes/llms.d.ts +1 -1
  51. package/dist/routes/llms.d.ts.map +1 -1
  52. package/dist/routes/llms.js +12 -2
  53. package/dist/source-config.d.ts +10 -0
  54. package/dist/source-config.d.ts.map +1 -1
  55. package/dist/source-config.js +20 -2
  56. package/dist/source.d.ts +10 -1
  57. package/dist/source.d.ts.map +1 -1
  58. package/dist/source.js +75 -34
  59. package/dist/versions.js +2 -2
  60. package/docs/agents.md +5 -3
  61. package/docs/llms.txt +388 -28
  62. package/docs/manifest.json +21 -3
  63. package/docs/pages/components/steps.md +129 -0
  64. package/docs/pages/deployment.md +30 -5
  65. package/docs/pages/getting-started.md +38 -12
  66. package/docs/pages/guides/nested-navigation.md +1 -1
  67. package/docs/pages/md.md +24 -5
  68. package/docs/pages/migration-2.md +106 -0
  69. package/docs/pages/migration.md +5 -2
  70. package/docs/pages/syntax.md +42 -0
  71. package/docs/sitemap.md +4 -2
  72. package/package.json +14 -4
  73. package/source-config.js +37 -2
  74. package/template/content/docs/components/meta.json +4 -0
  75. package/template/content/docs/components/steps.mdx +125 -0
  76. package/template/content/docs/deployment.mdx +31 -6
  77. package/template/content/docs/getting-started.mdx +39 -13
  78. package/template/content/docs/guides/nested-navigation.mdx +1 -1
  79. package/template/content/docs/md.mdx +24 -5
  80. package/template/content/docs/meta.json +3 -0
  81. package/template/content/docs/migration-2.mdx +106 -0
  82. package/template/content/docs/migration.mdx +5 -1
  83. package/template/content/docs/syntax.mdx +42 -0
  84. package/template/next.config.ts +9 -0
  85. package/template/package.json +3 -3
  86. package/theme.css +50 -4
package/dist/cli/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import{program as T}from"commander";import{access as ce,copyFile as le}from"fs/promises";import{join as pe}from"path";import{cancel as de,intro as ge,isCancel as ue,log as fe,outro as me,spinner as he,text as we}from"@clack/prompts";import{spawn as te}from"child_process";import{readFileSync as se}from"fs";import{cp as ne,readFile as ae,rename as re,writeFile as ie}from"fs/promises";import{join as $}from"path";import{fileURLToPath as oe}from"url";var g="@vercel/geistdocs",m=(e,t=[],s={})=>new Promise((n,a)=>{let r=te(e,t,{stdio:"inherit",...s});r.on("error",a),r.on("close",i=>{if(i===0){n();return}a(new Error(`Command failed with exit code ${i}: ${[e,...t].join(" ")}`))})}),A=["dependencies","devDependencies","optionalDependencies","peerDependencies"],_=()=>JSON.parse(se(new URL("../../package.json",import.meta.url),"utf8")).version,P=async e=>{let t=$(e,"package.json"),s=await ae(t,"utf8");return JSON.parse(s)},x=async(e,t)=>{let s=$(e,"package.json");await ie(s,`${JSON.stringify(t,null,2)}
3
- `,"utf8")},R=(e,t)=>{for(let s of A){let n=e[s];if(n&&t in n)return n[t]}},V=(e,t)=>!!R(e,t),b=(e,t,s)=>{let n=!1;for(let a of A){let r=e[a];r&&t in r&&(r[t]=s,n=!0)}return n},j=()=>oe(new URL("../../template",import.meta.url)),F=async e=>{await ne(j(),e,{recursive:!0});let t=$(e,".gitignore"),s=$(e,"_gitignore");try{await re(s,t)}catch{}};var ye=async e=>{await F(e)},Pe=async e=>{try{return await ce(e),!0}catch{return!1}},ve=async()=>{await Pe(".env.example")&&await le(".env.example",".env.local")},Te=async e=>{let t=await P(e),s=_();return b(t,g,s)?(await x(e,t),!0):!1},ke=async e=>{await m("pnpm",["install"],{cwd:e,env:process.env,stdio:"inherit"})},$e=async e=>{await m("git",["init"],{cwd:e,env:process.env,stdio:"inherit"}),await m("git",["add","."],{cwd:e,env:process.env,stdio:"inherit"}),await m("git",["commit","-m","\u2728 Initial commit"],{cwd:e,env:process.env,stdio:"inherit"})},xe=async()=>{let e=await we({message:"What is your project named?",placeholder:"my-app",validate(t){if(t.length===0)return"Please enter a project name."}});return ue(e)&&(de("Operation cancelled."),process.exit(0)),e.toString()},G=async e=>{try{ge("Let's start a Geistdocs project!");let t=process.cwd(),s=e.name||await xe(),n=he(),a=pe(t,s);n.start("Copying bundled template..."),await ye(s),n.message("Setting up environment variables..."),process.chdir(a),await ve(),n.message("Rewriting package dependency versions..."),await Te(a),n.message("Installing dependencies..."),await ke(a),e.disableGit||(n.message("Initializing Git repository..."),await $e(a)),n.stop("Project initialized successfully!"),me("Run `pnpm dev` to start the development server.")}catch(t){let s=t instanceof Error?t.message:`Failed to initialize project: ${t}`;fe.error(s),process.exit(1)}};import{readFileSync as be,writeFileSync as Fe}from"fs";import{mkdir as De,readFile as N,writeFile as Se}from"fs/promises";import{dirname as Ce,extname as Re,relative as M,resolve as S}from"path";import{intro as je,isCancel as Ee,log as h,multiselect as Ne,outro as D,spinner as Ue}from"@clack/prompts";import{glob as Oe}from"glob";import{Node as v,Project as Ie,SyntaxKind as Je}from"ts-morph";var Le="geistdocs.tsx",Ae="content/docs/**/*.mdx",U=".translation-cache.json",E=8,B=()=>({version:1,entries:{}}),_e=async e=>{let t=await N(e),{createHash:s}=await import("crypto");return s("sha256").update(t).digest("hex")},Ve=e=>{let t=S(process.cwd(),e);return be(t,"utf8")},z=e=>v.isObjectLiteralExpression(e)?e.getProperties().flatMap(t=>{if(v.isPropertyAssignment(t)){let s=t.getNameNode();if(v.isIdentifier(s)||v.isStringLiteral(s))return[s.getText().replaceAll(/['"]/g,"")]}return[]}).filter(Boolean):[],Ge=e=>{try{let t=new Ie({compilerOptions:{allowJs:!0,jsx:4,module:99,target:10},skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0}),s=Ve(e),r=t.createSourceFile(e,s,{overwrite:!0}).getVariableDeclarations().find(l=>l.getName()==="translations")?.getInitializer();if(!r)return[];if(v.isObjectLiteralExpression(r))return z(r);let i=r.getFirstDescendantByKind(Je.ObjectLiteralExpression);return i?z(i):[]}catch(t){let s=t instanceof Error?t.message:`${t}`;return h.warn(`Failed to read locales from ${e}: ${s}`),[]}},Be=async()=>{let e=await Ne({message:"Which locales should be translated?",options:[{value:"cn",label:"Chinese (cn)"},{value:"jp",label:"Japanese (jp)"},{value:"es",label:"Spanish (es)"},{value:"fr",label:"French (fr)"},{value:"de",label:"German (de)"}],required:!0});return Ee(e)&&(D("Translation cancelled"),process.exit(0)),e},ze=async e=>(await Oe(e,{cwd:process.cwd(),absolute:!0,nodir:!0})).sort(),He=async()=>{let e=S(process.cwd(),U);try{let t=await N(e,"utf8"),s=JSON.parse(t);return s.version!==1||!s.entries?B():{version:1,entries:s.entries}}catch{return B()}},H=e=>{let t=S(process.cwd(),U),s=JSON.stringify(e,null,2);Fe(t,s,"utf8")},Me=async e=>{let t=await Promise.all(e.map(async s=>[s,await _e(s)]));return Object.fromEntries(t)},Ke=(e,t)=>{let s=Re(e);return`${e.slice(0,-s.length)}.${t}${s}`},K=(e,t)=>`${M(process.cwd(),e)}::${t}`,qe=(e,t,s,n,a=!1)=>{let r=[],i=0;for(let l of t){let c=s[l];for(let o of e){let d=Ke(l,o),u=K(l,o),f=n.entries[u];if(!a&&f?.hash===c){i+=1;continue}r.push({locale:o,sourceFile:l,sourceHash:c,targetFile:d})}}return{tasks:r,skippedCount:i}},Xe=async e=>{await De(Ce(e),{recursive:!0})},We=async(e,t,s)=>{let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,locale:s})});if(!n.ok){let r=await n.text();throw new Error(`API request failed (${n.status}): ${r}`)}let a=await n.json();if(!a.translation)throw new Error("API response did not include a translation");return a.translation},Ye=async(e,t,s)=>{let n=await N(e.sourceFile,"utf8"),a=await We(t,n,e.locale);await Xe(e.targetFile),await Se(e.targetFile,a,"utf8"),s.entries[K(e.sourceFile,e.locale)]={hash:e.sourceHash,updatedAt:new Date().toISOString()}},q=async(e,t)=>{je("Translate MDX content");let s=e??Ae,n=t.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",a=Ge(t.config??Le),r=await ze(s);r.length===0&&(h.error(`No MDX files found matching pattern: ${s}`),D("Translation cancelled"),process.exit(1)),h.info(`Found ${r.length} MDX file(s) matching pattern`),a.length===0&&(a=await Be());let i=S(process.cwd(),U),l=await He();await H(l),h.info(`Using cache: ${i}`);let c=await Me(r),{tasks:o,skippedCount:d}=qe(a,r,c,l,t.force);if(o.length===0){h.success("All translations are up to date!"),D(`Skipped ${d} file(s) (unchanged)`);return}let u=[];for(let y=0;y<o.length;y+=E)u.push(o.slice(y,y+E));h.info(`Processing ${o.length} translation(s) in ${u.length} batch(es) of up to ${E}`),d>0&&h.info(`Skipped ${d} translation(s) (unchanged)`);let f=Ue();f.start("Translating content...");let k=0;for(let y of u)await Promise.all(y.map(async L=>{await Ye(L,n,l),k+=1,f.message(`Translated ${k}/${o.length}: ${M(process.cwd(),L.targetFile)}`)})),await H(l);f.stop("Translation complete!"),D(`Created/updated ${o.length} file(s)`)};import{access as Ze,copyFile as Qe,mkdir as Z,rm as J}from"fs/promises";import{dirname as et,join as w}from"path";import{intro as tt,log as p,outro as C,spinner as Q}from"@clack/prompts";import{glob as st}from"glob";var nt=["**/*"],at=["content/docs/**"],O=".geistdocs-tmp",rt=async(e,t)=>{let s=w(e,t);await J(s,{recursive:!0,force:!0}),await Z(s,{recursive:!0})},I=async e=>await J(e,{recursive:!0,force:!0}),X=async(e,t,s)=>(await st(e,{cwd:s,nodir:!0,dot:!0,ignore:[".git/**",...t]})).sort(),it=async e=>{try{return await Ze(e),!0}catch{return!1}},ot=async(e,t,s)=>{let n=w(t,e),a=w(s,e);return await it(n)?(await Qe(n,a),{success:!0}):{success:!1,error:`Source file not found: ${n}`}},ct=async(e,t)=>{let s=w(t,e);return await J(s,{force:!0}),{success:!0}},W=20,Y=async(e,t,s)=>{let n=[];for(let a=0;a<e.length;a+=s){let r=e.slice(a,a+s),i=await Promise.all(r.map(t));n.push(...i)}return n},lt=async(e,t,s,n,a)=>{let r={success:[],deleted:[],failed:[]},i=[...new Set(e.map(c=>et(w(n,c))))];a.message(`Creating ${i.length} directories...`),await Promise.all(i.map(c=>Z(c,{recursive:!0}))),a.message(`Updating ${e.length} files...`);let l=await Y(e,async c=>{let o=await ot(c,s,n);return{file:c,...o}},W);for(let{file:c,success:o,error:d}of l)o?r.success.push(c):r.failed.push({file:c,error:d??"Unknown error"});if(t.length>0){a.message(`Deleting ${t.length} files...`);let c=await Y(t,async o=>{try{return await ct(o,n),{file:o,success:!0}}catch(d){let u=d instanceof Error?d.message:`${d}`;return{file:o,success:!1,error:u}}},W);for(let o of c)o.success?r.deleted.push(o.file):r.failed.push({file:o.file,error:o.error})}return r},pt=e=>{if(e.success.length>0){p.success(`Successfully updated ${e.success.length} files:`);for(let t of e.success)p.info(` \u2713 ${t}`)}if(e.deleted.length>0){p.success(`Deleted ${e.deleted.length} files:`);for(let t of e.deleted)p.info(` \u{1F5D1} ${t}`)}if(e.failed.length>0){p.warn(`Failed to update ${e.failed.length} files:`);for(let{file:t,error:s}of e.failed)p.error(` \u2717 ${t}: ${s}`)}},dt=e=>e.includes("canary")?"canary":"latest",gt=async e=>{let t=await fetch(`https://registry.npmjs.org/${encodeURIComponent(g)}`);if(!t.ok)throw new Error(`Failed to resolve ${g}@${e}`);let n=(await t.json())["dist-tags"]?.[e];if(!n)throw new Error(`Could not find dist-tag ${e} for ${g}`);return n},ut=async e=>{let t=await P(e),s=R(t,g);if(!s)return{currentVersion:s,nextVersion:void 0,updated:!1};let n=dt(s),a=await gt(n);return s===a?{currentVersion:s,nextVersion:a,updateTag:n,updated:!1}:(b(t,g,a),await x(e,t),{currentVersion:s,nextVersion:a,updateTag:n,updated:!0})},ft=async(e,t,s)=>{let n=await P(e);if(!V(n,g))return!1;t&&t.length>0&&p.warn("Ignoring file patterns for a package-based site. This update will bump the package version instead."),s?.sync&&p.warn("Ignoring --sync for a package-based site. Runtime updates now come from the package version.");let{currentVersion:a,nextVersion:r,updateTag:i,updated:l}=await ut(e);if(!l)return p.success(a?`@vercel/geistdocs is already at ${r} (${i}).`:"No package version update was needed."),C("Package-based site is already up to date."),!0;p.info(`Bumping ${g} from ${a} to ${r} (${i})`);let c=Q();return c.start("Installing updated package version..."),await m("pnpm",["install"],{cwd:e}),c.stop("Package update complete!"),C("Please review and test the upgraded package version."),!0},mt=async(e,t,s,n,a)=>{let r=w(e,O),i=Q(),l=a?.sync?r:t;i.start("Preparing template snapshot..."),a?.sync&&(await rt(e,O),await F(r)),i.message("Scanning for files...");let c=await X(s,n,l),o=[];if(a?.sync){i.message("Comparing with local files...");let u=await X(s,n,e),f=new Set(c);o=u.filter(k=>!f.has(k))}if(i.stop(`Found ${c.length} files to update`),c.length===0&&o.length===0){p.warn("No files matched the patterns. Nothing to update."),a?.sync&&await I(r),C("Update cancelled.");return}p.info(`Patterns: ${s.length}`),p.info(`Files to update: ${c.length}`),a?.sync&&p.info(`Files to delete: ${o.length}`),i.start("Updating files...");let d=await lt(c,o,l,e,i);a?.sync&&(i.message("Cleaning up..."),await I(r)),i.stop("Update complete!"),pt(d),C("Please review and test the changes carefully.")},ee=async(e,t)=>{let s=process.cwd(),n=j(),a=e&&e.length>0?e:nt,r=e&&e.length>0?[]:at;try{if(tt("Let's update your Geistdocs project!"),await ft(s,e,t))return;p.info("Template source: bundled package snapshot"),e&&e.length>0&&p.info(`Updating specific files: ${e.join(", ")}`),t?.sync&&p.info("Sync mode enabled: will delete files removed from template"),await mt(s,n,a,r,t)}catch(i){let l=i instanceof Error?i.message:`${i}`;try{await I(w(s,O))}catch{}p.error(`Failed to update project: ${l}`),process.exit(1)}};T.name("geistdocs").description("CLI for Geistdocs projects").version("1.25.1-canary.4e75e60","-v, --version","Output the current version");T.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").option("--disable-git","Disable git initialization").action(G);T.command("update [files...]").description("Update a Geistdocs project (optionally specify files/patterns to update)").option("--sync","Delete local files that no longer exist in the template").action(ee);T.command("translate [pattern]").description("Translate MDX file(s) to one or more locales (default: content/docs/**/*.mdx)").option("--config <path>","Path to config file to load locales from (defaults to geistdocs.tsx)").option("--url <url>","Custom translation API URL (defaults to GEISTDOCS_TRANSLATE_URL or https://geistdocs.com/translate)").option("--force","Force re-translation of all files, ignoring cache").action(q);T.parse(process.argv);
3
+ `,"utf8")},R=(e,t)=>{for(let s of A){let n=e[s];if(n&&t in n)return n[t]}},V=(e,t)=>!!R(e,t),b=(e,t,s)=>{let n=!1;for(let a of A){let r=e[a];r&&t in r&&(r[t]=s,n=!0)}return n},j=()=>oe(new URL("../../template",import.meta.url)),F=async e=>{await ne(j(),e,{recursive:!0});let t=$(e,".gitignore"),s=$(e,"_gitignore");try{await re(s,t)}catch{}};var ye=async e=>{await F(e)},Pe=async e=>{try{return await ce(e),!0}catch{return!1}},ve=async()=>{await Pe(".env.example")&&await le(".env.example",".env.local")},Te=async e=>{let t=await P(e),s=_();return b(t,g,s)?(await x(e,t),!0):!1},ke=async e=>{await m("pnpm",["install"],{cwd:e,env:process.env,stdio:"inherit"})},$e=async e=>{await m("git",["init"],{cwd:e,env:process.env,stdio:"inherit"}),await m("git",["add","."],{cwd:e,env:process.env,stdio:"inherit"}),await m("git",["commit","-m","\u2728 Initial commit"],{cwd:e,env:process.env,stdio:"inherit"})},xe=async()=>{let e=await we({message:"What is your project named?",placeholder:"my-app",validate(t){if(t.length===0)return"Please enter a project name."}});return ue(e)&&(de("Operation cancelled."),process.exit(0)),e.toString()},G=async e=>{try{ge("Let's start a Geistdocs project!");let t=process.cwd(),s=e.name||await xe(),n=he(),a=pe(t,s);n.start("Copying bundled template..."),await ye(s),n.message("Setting up environment variables..."),process.chdir(a),await ve(),n.message("Rewriting package dependency versions..."),await Te(a),n.message("Installing dependencies..."),await ke(a),e.disableGit||(n.message("Initializing Git repository..."),await $e(a)),n.stop("Project initialized successfully!"),me("Run `pnpm dev` to start the development server.")}catch(t){let s=t instanceof Error?t.message:`Failed to initialize project: ${t}`;fe.error(s),process.exit(1)}};import{readFileSync as be,writeFileSync as Fe}from"fs";import{mkdir as De,readFile as N,writeFile as Se}from"fs/promises";import{dirname as Ce,extname as Re,relative as M,resolve as S}from"path";import{intro as je,isCancel as Ee,log as h,multiselect as Ne,outro as D,spinner as Ue}from"@clack/prompts";import{glob as Oe}from"glob";import{Node as v,Project as Ie,SyntaxKind as Je}from"ts-morph";var Le="geistdocs.tsx",Ae="content/docs/**/*.mdx",U=".translation-cache.json",E=8,B=()=>({version:1,entries:{}}),_e=async e=>{let t=await N(e),{createHash:s}=await import("crypto");return s("sha256").update(t).digest("hex")},Ve=e=>{let t=S(process.cwd(),e);return be(t,"utf8")},z=e=>v.isObjectLiteralExpression(e)?e.getProperties().flatMap(t=>{if(v.isPropertyAssignment(t)){let s=t.getNameNode();if(v.isIdentifier(s)||v.isStringLiteral(s))return[s.getText().replaceAll(/['"]/g,"")]}return[]}).filter(Boolean):[],Ge=e=>{try{let t=new Ie({compilerOptions:{allowJs:!0,jsx:4,module:99,target:10},skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0}),s=Ve(e),r=t.createSourceFile(e,s,{overwrite:!0}).getVariableDeclarations().find(l=>l.getName()==="translations")?.getInitializer();if(!r)return[];if(v.isObjectLiteralExpression(r))return z(r);let i=r.getFirstDescendantByKind(Je.ObjectLiteralExpression);return i?z(i):[]}catch(t){let s=t instanceof Error?t.message:`${t}`;return h.warn(`Failed to read locales from ${e}: ${s}`),[]}},Be=async()=>{let e=await Ne({message:"Which locales should be translated?",options:[{value:"cn",label:"Chinese (cn)"},{value:"jp",label:"Japanese (jp)"},{value:"es",label:"Spanish (es)"},{value:"fr",label:"French (fr)"},{value:"de",label:"German (de)"}],required:!0});return Ee(e)&&(D("Translation cancelled"),process.exit(0)),e},ze=async e=>(await Oe(e,{cwd:process.cwd(),absolute:!0,nodir:!0})).sort(),He=async()=>{let e=S(process.cwd(),U);try{let t=await N(e,"utf8"),s=JSON.parse(t);return s.version!==1||!s.entries?B():{version:1,entries:s.entries}}catch{return B()}},H=e=>{let t=S(process.cwd(),U),s=JSON.stringify(e,null,2);Fe(t,s,"utf8")},Me=async e=>{let t=await Promise.all(e.map(async s=>[s,await _e(s)]));return Object.fromEntries(t)},Ke=(e,t)=>{let s=Re(e);return`${e.slice(0,-s.length)}.${t}${s}`},K=(e,t)=>`${M(process.cwd(),e)}::${t}`,qe=(e,t,s,n,a=!1)=>{let r=[],i=0;for(let l of t){let c=s[l];for(let o of e){let d=Ke(l,o),u=K(l,o),f=n.entries[u];if(!a&&f?.hash===c){i+=1;continue}r.push({locale:o,sourceFile:l,sourceHash:c,targetFile:d})}}return{tasks:r,skippedCount:i}},Xe=async e=>{await De(Ce(e),{recursive:!0})},We=async(e,t,s)=>{let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,locale:s})});if(!n.ok){let r=await n.text();throw new Error(`API request failed (${n.status}): ${r}`)}let a=await n.json();if(!a.translation)throw new Error("API response did not include a translation");return a.translation},Ye=async(e,t,s)=>{let n=await N(e.sourceFile,"utf8"),a=await We(t,n,e.locale);await Xe(e.targetFile),await Se(e.targetFile,a,"utf8"),s.entries[K(e.sourceFile,e.locale)]={hash:e.sourceHash,updatedAt:new Date().toISOString()}},q=async(e,t)=>{je("Translate MDX content");let s=e??Ae,n=t.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",a=Ge(t.config??Le),r=await ze(s);r.length===0&&(h.error(`No MDX files found matching pattern: ${s}`),D("Translation cancelled"),process.exit(1)),h.info(`Found ${r.length} MDX file(s) matching pattern`),a.length===0&&(a=await Be());let i=S(process.cwd(),U),l=await He();await H(l),h.info(`Using cache: ${i}`);let c=await Me(r),{tasks:o,skippedCount:d}=qe(a,r,c,l,t.force);if(o.length===0){h.success("All translations are up to date!"),D(`Skipped ${d} file(s) (unchanged)`);return}let u=[];for(let y=0;y<o.length;y+=E)u.push(o.slice(y,y+E));h.info(`Processing ${o.length} translation(s) in ${u.length} batch(es) of up to ${E}`),d>0&&h.info(`Skipped ${d} translation(s) (unchanged)`);let f=Ue();f.start("Translating content...");let k=0;for(let y of u)await Promise.all(y.map(async L=>{await Ye(L,n,l),k+=1,f.message(`Translated ${k}/${o.length}: ${M(process.cwd(),L.targetFile)}`)})),await H(l);f.stop("Translation complete!"),D(`Created/updated ${o.length} file(s)`)};import{access as Ze,copyFile as Qe,mkdir as Z,rm as J}from"fs/promises";import{dirname as et,join as w}from"path";import{intro as tt,log as p,outro as C,spinner as Q}from"@clack/prompts";import{glob as st}from"glob";var nt=["**/*"],at=["content/docs/**"],O=".geistdocs-tmp",rt=async(e,t)=>{let s=w(e,t);await J(s,{recursive:!0,force:!0}),await Z(s,{recursive:!0})},I=async e=>await J(e,{recursive:!0,force:!0}),X=async(e,t,s)=>(await st(e,{cwd:s,nodir:!0,dot:!0,ignore:[".git/**",...t]})).sort(),it=async e=>{try{return await Ze(e),!0}catch{return!1}},ot=async(e,t,s)=>{let n=w(t,e),a=w(s,e);return await it(n)?(await Qe(n,a),{success:!0}):{success:!1,error:`Source file not found: ${n}`}},ct=async(e,t)=>{let s=w(t,e);return await J(s,{force:!0}),{success:!0}},W=20,Y=async(e,t,s)=>{let n=[];for(let a=0;a<e.length;a+=s){let r=e.slice(a,a+s),i=await Promise.all(r.map(t));n.push(...i)}return n},lt=async(e,t,s,n,a)=>{let r={success:[],deleted:[],failed:[]},i=[...new Set(e.map(c=>et(w(n,c))))];a.message(`Creating ${i.length} directories...`),await Promise.all(i.map(c=>Z(c,{recursive:!0}))),a.message(`Updating ${e.length} files...`);let l=await Y(e,async c=>{let o=await ot(c,s,n);return{file:c,...o}},W);for(let{file:c,success:o,error:d}of l)o?r.success.push(c):r.failed.push({file:c,error:d??"Unknown error"});if(t.length>0){a.message(`Deleting ${t.length} files...`);let c=await Y(t,async o=>{try{return await ct(o,n),{file:o,success:!0}}catch(d){let u=d instanceof Error?d.message:`${d}`;return{file:o,success:!1,error:u}}},W);for(let o of c)o.success?r.deleted.push(o.file):r.failed.push({file:o.file,error:o.error})}return r},pt=e=>{if(e.success.length>0){p.success(`Successfully updated ${e.success.length} files:`);for(let t of e.success)p.info(` \u2713 ${t}`)}if(e.deleted.length>0){p.success(`Deleted ${e.deleted.length} files:`);for(let t of e.deleted)p.info(` \u{1F5D1} ${t}`)}if(e.failed.length>0){p.warn(`Failed to update ${e.failed.length} files:`);for(let{file:t,error:s}of e.failed)p.error(` \u2717 ${t}: ${s}`)}},dt=e=>e.includes("canary")?"canary":"latest",gt=async e=>{let t=await fetch(`https://registry.npmjs.org/${encodeURIComponent(g)}`);if(!t.ok)throw new Error(`Failed to resolve ${g}@${e}`);let n=(await t.json())["dist-tags"]?.[e];if(!n)throw new Error(`Could not find dist-tag ${e} for ${g}`);return n},ut=async e=>{let t=await P(e),s=R(t,g);if(!s)return{currentVersion:s,nextVersion:void 0,updated:!1};let n=dt(s),a=await gt(n);return s===a?{currentVersion:s,nextVersion:a,updateTag:n,updated:!1}:(b(t,g,a),await x(e,t),{currentVersion:s,nextVersion:a,updateTag:n,updated:!0})},ft=async(e,t,s)=>{let n=await P(e);if(!V(n,g))return!1;t&&t.length>0&&p.warn("Ignoring file patterns for a package-based site. This update will bump the package version instead."),s?.sync&&p.warn("Ignoring --sync for a package-based site. Runtime updates now come from the package version.");let{currentVersion:a,nextVersion:r,updateTag:i,updated:l}=await ut(e);if(!l)return p.success(a?`@vercel/geistdocs is already at ${r} (${i}).`:"No package version update was needed."),C("Package-based site is already up to date."),!0;p.info(`Bumping ${g} from ${a} to ${r} (${i})`);let c=Q();return c.start("Installing updated package version..."),await m("pnpm",["install"],{cwd:e}),c.stop("Package update complete!"),C("Please review and test the upgraded package version."),!0},mt=async(e,t,s,n,a)=>{let r=w(e,O),i=Q(),l=a?.sync?r:t;i.start("Preparing template snapshot..."),a?.sync&&(await rt(e,O),await F(r)),i.message("Scanning for files...");let c=await X(s,n,l),o=[];if(a?.sync){i.message("Comparing with local files...");let u=await X(s,n,e),f=new Set(c);o=u.filter(k=>!f.has(k))}if(i.stop(`Found ${c.length} files to update`),c.length===0&&o.length===0){p.warn("No files matched the patterns. Nothing to update."),a?.sync&&await I(r),C("Update cancelled.");return}p.info(`Patterns: ${s.length}`),p.info(`Files to update: ${c.length}`),a?.sync&&p.info(`Files to delete: ${o.length}`),i.start("Updating files...");let d=await lt(c,o,l,e,i);a?.sync&&(i.message("Cleaning up..."),await I(r)),i.stop("Update complete!"),pt(d),C("Please review and test the changes carefully.")},ee=async(e,t)=>{let s=process.cwd(),n=j(),a=e&&e.length>0?e:nt,r=e&&e.length>0?[]:at;try{if(tt("Let's update your Geistdocs project!"),await ft(s,e,t))return;p.info("Template source: bundled package snapshot"),e&&e.length>0&&p.info(`Updating specific files: ${e.join(", ")}`),t?.sync&&p.info("Sync mode enabled: will delete files removed from template"),await mt(s,n,a,r,t)}catch(i){let l=i instanceof Error?i.message:`${i}`;try{await I(w(s,O))}catch{}p.error(`Failed to update project: ${l}`),process.exit(1)}};T.name("geistdocs").description("CLI for Geistdocs projects").version("1.25.1-canary.62250e6","-v, --version","Output the current version");T.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").option("--disable-git","Disable git initialization").action(G);T.command("update [files...]").description("Update a Geistdocs project (optionally specify files/patterns to update)").option("--sync","Delete local files that no longer exist in the template").action(ee);T.command("translate [pattern]").description("Translate MDX file(s) to one or more locales (default: content/docs/**/*.mdx)").option("--config <path>","Path to config file to load locales from (defaults to geistdocs.tsx)").option("--url <url>","Custom translation API URL (defaults to GEISTDOCS_TRANSLATE_URL or https://geistdocs.com/translate)").option("--force","Force re-translation of all files, ignoring cache").action(q);T.parse(process.argv);
@@ -26,7 +26,7 @@ export const CodeBlockTabs = ({ compact = false, ...props }) => {
26
26
  }
27
27
  const selectedLabel = options.find((option) => option.value === value)?.label ??
28
28
  options[0]?.label;
29
- return (_jsxs("div", { className: "relative [&_[role=tablist]]:hidden", children: [_jsxs("div", { className: "group absolute top-2 right-12 z-2 h-8", children: [_jsxs("div", { "aria-hidden": "true", className: "flex h-full cursor-pointer items-center gap-1 whitespace-nowrap rounded-md border-none bg-background-200 px-2 py-0 font-sans text-gray-900 text-label-13 leading-none transition-colors duration-200 group-focus-within:shadow-[var(--ds-focus-ring)] group-hover:bg-gray-200", children: [_jsx("span", { children: selectedLabel }), _jsx(IconChevronDown, { size: 16 })] }), _jsx("select", { "aria-label": "Code language", className: "absolute inset-0 cursor-pointer bg-gray-100 opacity-0 outline-hidden", onChange: (event) => setValue(event.target.value), value: value, children: options.map((option) => (_jsx("option", { value: option.value, children: option.label }, option.value))) })] }), tabs] }));
29
+ return (_jsxs("div", { className: "not-prose relative [&_[role=tablist]]:hidden", children: [_jsxs("div", { className: "group absolute top-1.5 right-12 z-2 h-7", children: [_jsxs("div", { "aria-hidden": "true", className: "flex h-full cursor-pointer items-center gap-1 whitespace-nowrap rounded-md border-none bg-background-200 px-2 py-0 font-sans text-gray-900 text-label-13 leading-none transition-colors duration-200 group-focus-within:shadow-[var(--ds-focus-ring)] group-hover:bg-gray-200", children: [_jsx("span", { children: selectedLabel }), _jsx(IconChevronDown, { size: 16 })] }), _jsx("select", { "aria-label": "Code language", className: "absolute inset-0 cursor-pointer bg-gray-100 opacity-0 outline-hidden", onChange: (event) => setValue(event.target.value), value: value, children: options.map((option) => (_jsx("option", { value: option.value, children: option.label }, option.value))) })] }), tabs] }));
30
30
  };
31
31
  export const CompactCodeBlockTabs = (props) => _jsx(CodeBlockTabs, { ...props, compact: true });
32
32
  export const CodeBlockTab = (props) => (_jsx(TabsContent, { ...props, className: cn("[&>div]:mb-0", props.className) }));
@@ -1 +1 @@
1
- {"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../src/components/code-block.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,UAAU,cAAc;IACtB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAuBD,eAAO,MAAM,SAAS,GAAI,mEAKvB,cAAc,4CAuChB,CAAC"}
1
+ {"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../src/components/code-block.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,UAAU,cAAc;IACtB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAuBD,eAAO,MAAM,SAAS,GAAI,mEAKvB,cAAc,4CA0ChB,CAAC"}
@@ -25,5 +25,5 @@ export const CodeBlock = ({ children, className, "data-line-numbers": lineNumber
25
25
  const code = isValidElement(children)
26
26
  ? children.props.children
27
27
  : children;
28
- return (_jsx(CodeBlockServer, { className: cn("[&_code]:min-w-full [&_code]:border-0 [&_code]:bg-transparent [&_code]:p-0", "[&_:is(.line,.highlighted-line)]:relative [&_:is(.line,.highlighted-line)]:inline-block [&_:is(.line,.highlighted-line)]:h-5 [&_:is(.line,.highlighted-line)]:w-max [&_:is(.line,.highlighted-line)]:min-w-full [&_:is(.line,.highlighted-line)]:px-5!", "[&_:is(.highlighted-line,.line.highlighted,[data-highlighted=true])]:border-l-0! [&_:is(.highlighted-line,.line.highlighted,[data-highlighted=true])]:bg-blue-300! [&_:is(.highlighted-line,.line.highlighted,[data-highlighted=true])]:shadow-[inset_2px_0_0_0_var(--ds-blue-900)]", "[&_.line[data-active=true]]:bg-amber-300! [&_.line[data-active=true]]:shadow-[inset_2px_0_0_0_var(--ds-amber-900)]", "[&_:is([data-added=true],.line.diff.add)]:bg-green-300! [&_:is([data-added=true],.line.diff.add)]:shadow-[inset_2px_0_0_0_var(--ds-green-900)]", "[&_:is([data-removed=true],.line.diff.remove)]:bg-red-300! [&_:is([data-removed=true],.line.diff.remove)]:opacity-100! [&_:is([data-removed=true],.line.diff.remove)]:shadow-[inset_2px_0_0_0_var(--ds-red-900)]", "[&_:is(.line.diff.add,.line.diff.remove)::before]:content-none!", "[&_:is([data-added=true],[data-removed=true],.line.diff.add,.line.diff.remove)::after]:pointer-events-none [&_:is([data-added=true],[data-removed=true],.line.diff.add,.line.diff.remove)::after]:absolute [&_:is([data-added=true],[data-removed=true],.line.diff.add,.line.diff.remove)::after]:inset-0 [&_:is([data-added=true],[data-removed=true],.line.diff.add,.line.diff.remove)::after]:pl-2 [&_:is([data-added=true],[data-removed=true],.line.diff.add,.line.diff.remove)::after]:font-medium", "[&_:is([data-added=true],.line.diff.add)::after]:text-green-900 [&_:is([data-added=true],.line.diff.add)::after]:content-['+']", "[&_:is([data-removed=true],.line.diff.remove)::after]:text-red-900 [&_:is([data-removed=true],.line.diff.remove)::after]:content-['-']", lineNumbers !== undefined && "line-numbers", frameworkTitle && "[&_[data-section=tabs]>div:first-child]:hidden", className), filename: frameworkTitle?.title ?? title, headerActions: frameworkTitle ? (_jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2 text-gray-900 text-label-13", children: [_jsx("span", { className: "flex w-4 shrink-0 items-center", children: frameworkTitle.icon }), _jsx("span", { className: "truncate", children: frameworkTitle.title })] })) : undefined, hideLineNumbers: lineNumbers === undefined, children: code }));
28
+ return (_jsx(CodeBlockServer, { className: cn("not-prose", "[&_code]:min-w-full [&_code]:border-0 [&_code]:bg-transparent [&_code]:p-0", "[&>[data-section=tabs]]:h-(--ds-size-large)! [&>[data-section=tabs]]:pr-[5px]!", "[&>[data-section=tabs]_button[aria-label^=Copy]]:size-7!", "[&_:is(.line,.highlighted-line)]:relative [&_:is(.line,.highlighted-line)]:inline-block [&_:is(.line,.highlighted-line)]:h-5 [&_:is(.line,.highlighted-line)]:w-max [&_:is(.line,.highlighted-line)]:min-w-full [&_:is(.line,.highlighted-line)]:px-5!", "[&_:is(.highlighted-line,.line.highlighted,[data-highlighted=true])]:border-l-0! [&_:is(.highlighted-line,.line.highlighted,[data-highlighted=true])]:bg-blue-300! [&_:is(.highlighted-line,.line.highlighted,[data-highlighted=true])]:shadow-[inset_2px_0_0_0_var(--ds-blue-900)]", "[&_.line[data-active=true]]:bg-amber-300! [&_.line[data-active=true]]:shadow-[inset_2px_0_0_0_var(--ds-amber-900)]", "[&_:is([data-added=true],.line.diff.add)]:bg-green-300! [&_:is([data-added=true],.line.diff.add)]:shadow-[inset_2px_0_0_0_var(--ds-green-900)]", "[&_:is([data-removed=true],.line.diff.remove)]:bg-red-300! [&_:is([data-removed=true],.line.diff.remove)]:opacity-100! [&_:is([data-removed=true],.line.diff.remove)]:shadow-[inset_2px_0_0_0_var(--ds-red-900)]", "[&_:is(.line.diff.add,.line.diff.remove)::before]:content-none!", "[&_:is([data-added=true],[data-removed=true],.line.diff.add,.line.diff.remove)::after]:pointer-events-none [&_:is([data-added=true],[data-removed=true],.line.diff.add,.line.diff.remove)::after]:absolute [&_:is([data-added=true],[data-removed=true],.line.diff.add,.line.diff.remove)::after]:inset-0 [&_:is([data-added=true],[data-removed=true],.line.diff.add,.line.diff.remove)::after]:pl-2 [&_:is([data-added=true],[data-removed=true],.line.diff.add,.line.diff.remove)::after]:font-medium", "[&_:is([data-added=true],.line.diff.add)::after]:text-green-900 [&_:is([data-added=true],.line.diff.add)::after]:content-['+']", "[&_:is([data-removed=true],.line.diff.remove)::after]:text-red-900 [&_:is([data-removed=true],.line.diff.remove)::after]:content-['-']", lineNumbers !== undefined && "line-numbers", frameworkTitle && "[&_[data-section=tabs]>div:first-child]:hidden", className), filename: frameworkTitle?.title ?? title, headerActions: frameworkTitle ? (_jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2 text-gray-900 text-label-13", children: [_jsx("span", { className: "flex w-4 shrink-0 items-center", children: frameworkTitle.icon }), _jsx("span", { className: "truncate", children: frameworkTitle.title })] })) : undefined, hideLineNumbers: lineNumbers === undefined, children: code }));
29
29
  };
@@ -49,7 +49,7 @@ export const CopyPrompt = ({ children, className, collapsible = false, projectOn
49
49
  ]),
50
50
  { icon: _jsx(CursorLogo, {}), label: "Open in Cursor", platform: "Cursor" },
51
51
  ];
52
- return (_jsx("div", { className: cn("not-prose my-4 mb-10 hidden w-full md:block", className), children: _jsxs("div", { className: "rounded-md border border-gray-400 bg-background-100", children: [_jsx("div", { className: "min-h-12 rounded-t-md border-gray-400 border-b bg-background-200 py-2 pr-2 pl-4", children: _jsxs("div", { className: "flex items-center justify-between gap-4", children: [_jsx("div", { className: "flex items-center gap-2 text-gray-900 text-label-13", children: title }), _jsxs("div", { className: "inline-flex shrink-0 overflow-hidden rounded-md border border-gray-400 bg-background-100", children: [_jsxs("button", { className: "inline-flex h-8 items-center gap-1.5 px-3 font-medium text-sm transition-colors hover:bg-gray-100 hover:text-gray-1000 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-gray-600/50", onClick: copy, type: "button", children: [_jsxs("span", { className: "relative size-4", children: [_jsx(CopyPromptIcon, { className: cn("absolute inset-0 transition-[transform,opacity] duration-200", isCopied ? "scale-75 opacity-0" : "scale-100 opacity-100") }), _jsx(IconCheck, { className: cn("absolute inset-0 size-4 transition-[transform,opacity] duration-200", isCopied ? "scale-100 opacity-100" : "scale-75 opacity-0") })] }), _jsx("span", { children: "Copy" })] }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { "aria-label": "Copy prompt actions", className: "inline-flex h-8 w-8 items-center justify-center border-gray-400 border-l transition-colors hover:bg-gray-100 hover:text-gray-1000 focus-visible:shadow-[inset_0_0_0_2px_var(--ds-focus-color)] focus-visible:outline-none", type: "button", children: _jsx(IconChevronDown, { className: "size-4" }) }) }), _jsx(DropdownMenuContent, { align: "end", className: "w-60", children: menuItems.map((item, index) => (_jsxs("div", { children: [index === 1 ? _jsx(DropdownMenuSeparator, {}) : null, _jsxs(DropdownMenuItem, { onClick: () => openPlatform(item.platform), children: [item.icon, _jsx("span", { className: "flex-1", children: item.label }), _jsx(IconExternal, { className: "size-4" })] })] }, item.platform))) })] })] })] }) }), _jsxs("div", { className: "relative isolate rounded-b-md bg-background-100 p-4 pb-5", children: [_jsxs("div", { className: "relative overflow-hidden", children: [_jsx("div", { className: cn("break-words text-gray-900 text-sm leading-relaxed [&_a]:font-normal [&_a]:text-gray-1000 [&_a]:no-underline hover:[&_a]:underline [&_code]:rounded [&_code]:bg-gray-100 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.9em]", collapsible && !isExpanded ? "line-clamp-2" : ""), children: children ?? text }), collapsible && !isExpanded ? (_jsx("div", { className: "pointer-events-none absolute inset-0 bg-linear-to-b from-transparent via-transparent to-background-100" })) : null] }), collapsible ? (_jsx("div", { className: "absolute left-1/2 -translate-x-1/2 translate-y-1/5", children: _jsxs(Button, { className: "mt-0 h-7 rounded-full bg-background-100 px-2 text-gray-900 text-xs shadow-(--ds-shadow-border-medium) hover:text-gray-1000 [&>span]:inline-flex [&>span]:items-center [&>span]:gap-1", onClick: () => setIsExpanded((current) => !current), size: "small", typeName: "button", variant: "secondary", children: [isExpanded ? (_jsx(IconChevronUp, { className: "size-3.5" })) : (_jsx(IconChevronDown, { className: "size-3.5" })), isExpanded ? "Show less" : "Show more"] }) })) : null] })] }) }));
52
+ return (_jsx("div", { className: cn("not-prose my-4 mb-10 hidden w-full md:block", className), children: _jsxs("div", { className: "rounded-md border border-gray-400 bg-background-100", children: [_jsx("div", { className: "flex h-(--ds-size-large) items-center rounded-t-md border-gray-400 border-b bg-background-200 py-0 pr-[5px] pl-4", children: _jsxs("div", { className: "flex w-full items-center justify-between gap-4", children: [_jsx("div", { className: "flex items-center gap-2 text-gray-900 text-label-13", children: title }), _jsxs("div", { className: "inline-flex shrink-0 overflow-hidden rounded-md border border-gray-400 bg-background-100", children: [_jsxs("button", { className: "inline-flex h-7 items-center gap-1.5 px-3 font-medium text-sm transition-colors hover:bg-gray-100 hover:text-gray-1000 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-gray-600/50", onClick: copy, type: "button", children: [_jsxs("span", { className: "relative size-4", children: [_jsx(CopyPromptIcon, { className: cn("absolute inset-0 transition-[transform,opacity] duration-200", isCopied ? "scale-75 opacity-0" : "scale-100 opacity-100") }), _jsx(IconCheck, { className: cn("absolute inset-0 size-4 transition-[transform,opacity] duration-200", isCopied ? "scale-100 opacity-100" : "scale-75 opacity-0") })] }), _jsx("span", { children: "Copy" })] }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { "aria-label": "Copy prompt actions", className: "inline-flex size-7 items-center justify-center border-gray-400 border-l transition-colors hover:bg-gray-100 hover:text-gray-1000 focus-visible:shadow-[inset_0_0_0_2px_var(--ds-focus-color)] focus-visible:outline-none", type: "button", children: _jsx(IconChevronDown, { className: "size-4" }) }) }), _jsx(DropdownMenuContent, { align: "end", className: "w-60", children: menuItems.map((item, index) => (_jsxs("div", { children: [index === 1 ? _jsx(DropdownMenuSeparator, {}) : null, _jsxs(DropdownMenuItem, { onClick: () => openPlatform(item.platform), children: [item.icon, _jsx("span", { className: "flex-1", children: item.label }), _jsx(IconExternal, { className: "size-4" })] })] }, item.platform))) })] })] })] }) }), _jsxs("div", { className: "relative isolate rounded-b-md bg-background-100 p-4 pb-5", children: [_jsxs("div", { className: "relative overflow-hidden", children: [_jsx("div", { className: cn("break-words text-gray-900 text-sm leading-relaxed [&_a]:font-normal [&_a]:text-gray-1000 [&_a]:no-underline hover:[&_a]:underline [&_code]:rounded [&_code]:bg-gray-100 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.9em]", collapsible && !isExpanded ? "line-clamp-2" : ""), children: children ?? text }), collapsible && !isExpanded ? (_jsx("div", { className: "pointer-events-none absolute inset-0 bg-linear-to-b from-transparent via-transparent to-background-100" })) : null] }), collapsible ? (_jsx("div", { className: "absolute left-1/2 -translate-x-1/2 translate-y-1/5", children: _jsxs(Button, { className: "mt-0 h-7 rounded-full bg-background-100 px-2 text-gray-900 text-xs shadow-(--ds-shadow-border-medium) hover:text-gray-1000 [&>span]:inline-flex [&>span]:items-center [&>span]:gap-1", onClick: () => setIsExpanded((current) => !current), size: "small", typeName: "button", variant: "secondary", children: [isExpanded ? (_jsx(IconChevronUp, { className: "size-3.5" })) : (_jsx(IconChevronDown, { className: "size-3.5" })), isExpanded ? "Show less" : "Show more"] }) })) : null] })] }) }));
53
53
  };
54
54
  const CopyPromptIcon = ({ className }) => (_jsxs("svg", { "aria-hidden": true, className: className, fill: "none", height: "16", viewBox: "0 0 16 16", width: "16", children: [_jsx("title", { children: "Copy prompt" }), _jsx("path", { d: "M6.75 14a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m3.75 0a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m3.75 0a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m-7.5-3.25a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m7.5 0a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5M8.25.5C9.22.5 10 1.28 10 2.25V3H8.5v-.75A.25.25 0 0 0 8.25 2h-5.5a.25.25 0 0 0-.25.25v7.5c0 .14.11.25.25.25H4.5v1.5H2.75C1.78 11.5 1 10.72 1 9.75v-7.5C1 1.28 1.78.5 2.75.5zm-1.5 7.25a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m7.5 0a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5M6.75 4.5a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m3.75 0a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m3.75 0a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5", fill: "currentColor" })] }));
55
55
  const V0Logo = () => (_jsxs("svg", { "aria-hidden": true, className: "size-4", fill: "none", viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("title", { children: "v0" }), _jsx("path", { d: "M6.1 9.46V5.52h1.52v5.03c0 .59-.48 1.07-1.07 1.07-.28 0-.56-.11-.76-.31L0 5.52h2.15zM16 10.1h-1.52V6.6l-3.5 3.5h3.5v1.52h-3.96a2.14 2.14 0 0 1-2.14-2.14V5.52H9.9v3.5l3.5-3.5H9.9V4h3.96C15.04 4 16 4.96 16 6.14z", fill: "currentColor" })] }));
@@ -0,0 +1,19 @@
1
+ import { type ImageProps as GeistImageProps } from "@vercel/geistcn/components/image";
2
+ import type { ReactNode } from "react";
3
+ type ImageSource = {
4
+ src: string;
5
+ srcDark?: never;
6
+ srcLight?: never;
7
+ } | {
8
+ src?: never;
9
+ srcDark: string;
10
+ srcLight: string;
11
+ };
12
+ export type ImageProps = Omit<GeistImageProps, "srcDark" | "srcLight"> & ImageSource & {
13
+ caption?: ReactNode;
14
+ figureClassName?: string;
15
+ };
16
+ /** A non-interactive documentation image with an optional caption. */
17
+ export declare const Image: ({ caption, className, figureClassName, src, srcDark, srcLight, ...props }: ImageProps) => import("react/jsx-runtime").JSX.Element;
18
+ export {};
19
+ //# sourceMappingURL=image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/components/image.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,IAAI,eAAe,EACnC,MAAM,kCAAkC,CAAC;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,KAAK,WAAW,GACZ;IACE,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,GACD;IACE,GAAG,CAAC,EAAE,KAAK,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEN,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,UAAU,CAAC,GACpE,WAAW,GAAG;IACZ,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEJ,sEAAsE;AACtE,eAAO,MAAM,KAAK,GAAI,2EAQnB,UAAU,4CA2BZ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Image as GeistImage, } from "@vercel/geistcn/components/image";
3
+ import { cn } from "@vercel/geistcn/utils";
4
+ /** A non-interactive documentation image with an optional caption. */
5
+ export const Image = ({ caption, className, figureClassName, src, srcDark, srcLight, ...props }) => {
6
+ const lightSource = srcLight ?? src;
7
+ const darkSource = srcDark ?? src;
8
+ return (_jsxs("figure", { className: cn("not-prose my-8 flex w-full max-w-full flex-col items-stretch justify-start gap-4", figureClassName), children: [_jsx(GeistImage, { className: cn("m-0 w-full rounded-lg border border-gray-400 bg-background-100 object-contain shadow-[var(--ds-shadow-small)]", className), srcDark: darkSource, srcLight: lightSource, ...props }), caption ? (_jsx("figcaption", { className: "mx-auto max-w-[640px] text-center text-copy-14 text-gray-900 max-[600px]:px-4", children: caption })) : null] }));
9
+ };
@@ -0,0 +1,9 @@
1
+ import type { ComponentProps } from "react";
2
+ /**
3
+ * Numbered step container. Markdown headings written as `### 1. Title` are
4
+ * converted into this structure automatically; use the JSX form when a step
5
+ * heading has to be wrapped in another component.
6
+ */
7
+ export declare const Steps: ({ className, ...props }: ComponentProps<"div">) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const Step: ({ className, ...props }: ComponentProps<"div">) => import("react/jsx-runtime").JSX.Element;
9
+ //# sourceMappingURL=steps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"steps.d.ts","sourceRoot":"","sources":["../../src/components/steps.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,yBAAyB,cAAc,CAAC,KAAK,CAAC,4CAEnE,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,yBAAyB,cAAc,CAAC,KAAK,CAAC,4CAElE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cn } from "@vercel/geistcn/utils";
3
+ /**
4
+ * Numbered step container. Markdown headings written as `### 1. Title` are
5
+ * converted into this structure automatically; use the JSX form when a step
6
+ * heading has to be wrapped in another component.
7
+ */
8
+ export const Steps = ({ className, ...props }) => (_jsx("div", { className: cn("fd-steps", className), ...props }));
9
+ export const Step = ({ className, ...props }) => (_jsx("div", { className: cn("fd-step", className), ...props }));
@@ -0,0 +1,20 @@
1
+ import { type ChatStatus, type UIMessage } from "ai";
2
+ export interface MessageActivity {
3
+ kind: "searching" | "thinking" | "tool";
4
+ label?: string;
5
+ }
6
+ export declare const isChatInProgress: (status: ChatStatus) => boolean;
7
+ export declare const isActiveAssistantMessage: ({ index, messages, status, }: {
8
+ index: number;
9
+ messages: UIMessage[];
10
+ status: ChatStatus;
11
+ }) => boolean;
12
+ export declare const shouldShowPendingActivity: ({ messages, status, }: {
13
+ messages: UIMessage[];
14
+ status: ChatStatus;
15
+ }) => boolean;
16
+ export declare const getMessageActivity: ({ inProgress, parts, }: {
17
+ inProgress: boolean;
18
+ parts: UIMessage["parts"];
19
+ }) => MessageActivity | null;
20
+ //# sourceMappingURL=activity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/activity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAA6B,KAAK,SAAS,EAAE,MAAM,IAAI,CAAC;AAKhF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AASD,eAAO,MAAM,gBAAgB,GAAI,QAAQ,UAAU,KAAG,OACJ,CAAC;AAEnD,eAAO,MAAM,wBAAwB,GAAI,8BAItC;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,MAAM,EAAE,UAAU,CAAC;CACpB,KAAG,OAGmC,CAAC;AAExC,eAAO,MAAM,yBAAyB,GAAI,uBAGvC;IACD,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,MAAM,EAAE,UAAU,CAAC;CACpB,KAAG,OAC+D,CAAC;AAUpE,eAAO,MAAM,kBAAkB,GAAI,wBAGhC;IACD,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAC3B,KAAG,eAAe,GAAG,IAsCrB,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { getToolName, isToolUIPart } from "ai";
2
+ import { getMessageSources } from "./message-sources";
3
+ const WORD_SEPARATOR_PATTERN = /[_-]+/g;
4
+ const isVisibleTextPart = (part) => part.type === "text" && part.text.trim().length > 0;
5
+ export const isChatInProgress = (status) => status === "submitted" || status === "streaming";
6
+ export const isActiveAssistantMessage = ({ index, messages, status, }) => isChatInProgress(status) &&
7
+ index === messages.length - 1 &&
8
+ messages[index]?.role === "assistant";
9
+ export const shouldShowPendingActivity = ({ messages, status, }) => isChatInProgress(status) && messages.at(-1)?.role !== "assistant";
10
+ const getToolActivityLabel = (part) => {
11
+ const name = getToolName(part).replace(WORD_SEPARATOR_PATTERN, " ").trim();
12
+ return name ? `Running ${name}...` : "Working...";
13
+ };
14
+ export const getMessageActivity = ({ inProgress, parts, }) => {
15
+ if (!inProgress) {
16
+ return null;
17
+ }
18
+ const lastPart = parts
19
+ .filter((part) => isVisibleTextPart(part) ||
20
+ part.type === "reasoning" ||
21
+ isToolUIPart(part))
22
+ .at(-1);
23
+ const hasTextPart = parts.some(isVisibleTextPart);
24
+ const hasSources = getMessageSources(parts).length > 0;
25
+ if (!lastPart) {
26
+ return hasSources
27
+ ? { kind: "searching", label: "Searching..." }
28
+ : { kind: "thinking" };
29
+ }
30
+ if (lastPart.type === "reasoning") {
31
+ return { kind: "thinking", label: "Thinking..." };
32
+ }
33
+ if (hasSources && !hasTextPart) {
34
+ return { kind: "searching", label: "Searching..." };
35
+ }
36
+ if (isToolUIPart(lastPart)) {
37
+ return {
38
+ kind: "tool",
39
+ label: getToolActivityLabel(lastPart),
40
+ };
41
+ }
42
+ return null;
43
+ };
@@ -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":"AAeA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAA6B,UAAU,EAAE,MAAM,YAAY,CAAC;AAoGnE,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
+ {"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,31 +1,65 @@
1
1
  "use client";
2
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
5
  import { Modal, ModalAction, ModalActions, ModalBody, ModalHeader, ModalSubtitle, ModalTitle, } from "@vercel/geistcn/components/modal";
6
6
  import { cn } from "@vercel/geistcn/utils";
7
7
  import { IconArrowUpRightSmall } from "@vercel/geistcn-assets/icons";
8
8
  import { memo, useState } from "react";
9
- import { Streamdown } from "streamdown";
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="([^"]+)"/;
10
14
  const LinkSafetyModal = ({ isOpen, onClose, onConfirm, url, }) => {
11
15
  return (_jsxs(Modal, { active: isOpen, drawer: false, onClickOutside: onClose, style: {
12
16
  background: "var(--ds-background-200)",
13
17
  boxShadow: "var(--ds-shadow-modal)",
14
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" })] })] }));
15
19
  };
16
- const ChatLink = ({ children, className, href, node: _node, ...props }) => {
20
+ const ChatLink = ({ children, className, href, node: _node, rel, target, ...props }) => {
17
21
  const [isOpen, setIsOpen] = useState(false);
18
- const external = typeof href === "string" &&
19
- (href.startsWith("http://") || href.startsWith("https://"));
20
- if (!external) {
21
- 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: href, ...props, children: children }));
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 }));
22
26
  }
23
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: () => {
24
- window.open(href, "_blank", "noreferrer");
28
+ window.open(resolved.href, "_blank", "noreferrer");
25
29
  setIsOpen(false);
26
- }, url: href })] }));
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 }),
27
61
  };
28
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 }));
29
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" }) })] }));
30
- 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: { a: ChatLink }, linkSafety: { enabled: true, renderModal: LinkSafetyModal }, 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);
31
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,sDAsD9B,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);
@@ -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,4CAgBtE,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,11 +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 }) => {
10
- const external = href.startsWith("http://") || href.startsWith("https://");
11
- return (_jsx("a", { className: "inline-flex min-w-0 max-w-full items-center underline underline-offset-1", href: href, rel: external ? "noreferrer" : undefined, target: external ? "_blank" : undefined, ...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 })) }));
12
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"}