@vercel/geistdocs 1.25.1-canary.c58830e → 1.25.1-canary.eec231d

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 (84) hide show
  1. package/dist/cli/index.js +1 -1
  2. package/dist/components/blockquote.js +1 -1
  3. package/dist/components/callout.d.ts +13 -10
  4. package/dist/components/callout.d.ts.map +1 -1
  5. package/dist/components/callout.js +6 -6
  6. package/dist/components/code-block-tabs.d.ts.map +1 -1
  7. package/dist/components/code-block-tabs.js +3 -1
  8. package/dist/components/code-block.d.ts.map +1 -1
  9. package/dist/components/code-block.js +1 -1
  10. package/dist/components/command-prompt.d.ts.map +1 -1
  11. package/dist/components/command-prompt.js +15 -22
  12. package/dist/components/copy-prompt.d.ts +2 -1
  13. package/dist/components/copy-prompt.d.ts.map +1 -1
  14. package/dist/components/copy-prompt.js +2 -2
  15. package/dist/components/heading.d.ts +7 -0
  16. package/dist/components/heading.d.ts.map +1 -0
  17. package/dist/components/heading.js +14 -0
  18. package/dist/components/table.d.ts +3 -0
  19. package/dist/components/table.d.ts.map +1 -0
  20. package/dist/components/table.js +3 -0
  21. package/dist/controls.d.ts.map +1 -1
  22. package/dist/controls.js +4 -3
  23. package/dist/internal/chat/context.d.ts +2 -0
  24. package/dist/internal/chat/context.d.ts.map +1 -1
  25. package/dist/internal/chat/context.js +24 -3
  26. package/dist/internal/chat/dots-spinner.d.ts.map +1 -1
  27. package/dist/internal/chat/dots-spinner.js +15 -9
  28. package/dist/internal/chat/loading-skeleton.d.ts +7 -0
  29. package/dist/internal/chat/loading-skeleton.d.ts.map +1 -0
  30. package/dist/internal/chat/loading-skeleton.js +46 -0
  31. package/dist/internal/chat/message.d.ts.map +1 -1
  32. package/dist/internal/chat/message.js +23 -3
  33. package/dist/internal/chat/shell.d.ts.map +1 -1
  34. package/dist/internal/chat/shell.js +10 -15
  35. package/dist/internal/chat/sources.d.ts.map +1 -1
  36. package/dist/internal/chat/sources.js +4 -1
  37. package/dist/internal/navbar/desktop-menu.js +1 -1
  38. package/dist/internal/navbar/mobile-menu.d.ts.map +1 -1
  39. package/dist/internal/navbar/mobile-menu.js +8 -13
  40. package/dist/internal/page-actions-client.d.ts.map +1 -1
  41. package/dist/internal/page-actions-client.js +36 -32
  42. package/dist/internal/provider-client.d.ts.map +1 -1
  43. package/dist/internal/provider-client.js +39 -5
  44. package/dist/internal/search.d.ts.map +1 -1
  45. package/dist/internal/search.js +1 -1
  46. package/dist/internal/sidebar-responsive.d.ts +0 -1
  47. package/dist/internal/sidebar-responsive.d.ts.map +1 -1
  48. package/dist/internal/sidebar-responsive.js +0 -9
  49. package/dist/internal/sidebar.d.ts.map +1 -1
  50. package/dist/internal/sidebar.js +63 -35
  51. package/dist/internal/table-of-contents.d.ts.map +1 -1
  52. package/dist/internal/table-of-contents.js +1 -1
  53. package/dist/internal/toc-items.d.ts.map +1 -1
  54. package/dist/internal/toc-items.js +16 -6
  55. package/dist/internal/ui/dropdown-menu.js +6 -6
  56. package/dist/internal/ui/navigation-menu.js +2 -2
  57. package/dist/internal/use-mobile.d.ts.map +1 -1
  58. package/dist/internal/use-mobile.js +2 -12
  59. package/dist/layout.d.ts +1 -0
  60. package/dist/layout.d.ts.map +1 -1
  61. package/dist/layout.js +2 -0
  62. package/dist/mdx.d.ts.map +1 -1
  63. package/dist/mdx.js +11 -4
  64. package/dist/pages/docs.d.ts.map +1 -1
  65. package/dist/pages/docs.js +6 -4
  66. package/dist/routes/chat.d.ts +1 -1
  67. package/dist/routes/chat.js +1 -1
  68. package/dist/versions.js +2 -2
  69. package/docs/agents.md +1 -1
  70. package/docs/llms.txt +110 -12
  71. package/docs/manifest.json +1 -1
  72. package/docs/pages/ask-ai.md +2 -2
  73. package/docs/pages/md.md +1 -1
  74. package/docs/pages/syntax.md +106 -8
  75. package/package.json +2 -1
  76. package/template/app/[lang]/layout.tsx +4 -0
  77. package/template/app/styles/geistdocs.css +1 -1
  78. package/template/components/ui/button.tsx +1 -1
  79. package/template/content/docs/ask-ai.cn.mdx +2 -2
  80. package/template/content/docs/ask-ai.mdx +2 -2
  81. package/template/content/docs/md.mdx +1 -1
  82. package/template/content/docs/syntax.mdx +112 -8
  83. package/template/package.json +1 -1
  84. package/theme.css +39 -101
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.c58830e","-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.eec231d","-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);
@@ -1,3 +1,3 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { cn } from "@vercel/geistcn/utils";
3
- export const Blockquote = ({ className, ...props }) => (_jsx("blockquote", { className: cn("my-4 rounded-md border border-gray-300 p-3 font-normal text-sm not-italic", "[&_p:last-child]:mb-0 [&_p]:mt-0 [&_p]:mb-2 [&_p]:leading-[21px]", "[&_p]:before:content-none [&_p]:after:content-none", "[&_code]:inline-block [&_code]:rounded-md [&_code]:border [&_code]:border-gray-300 [&_code]:bg-gray-100 [&_code]:px-[3px] [&_code]:py-[1.44px] [&_code]:text-xs [&_code]:leading-[14.4px]", "[&_ul]:my-2", className), ...props }));
3
+ export const Blockquote = ({ className, ...props }) => (_jsx("blockquote", { className: cn("my-4 rounded-md border border-gray-300 p-3 font-normal text-copy-14 not-italic", "[&_p:last-child]:mb-0 [&_p]:mt-0 [&_p]:mb-2 [&_p]:leading-[21px]", "[&_p]:before:content-none [&_p]:after:content-none", "[&_code]:inline-block [&_code]:rounded-md [&_code]:border [&_code]:border-gray-300 [&_code]:bg-gray-100 [&_code]:px-[3px] [&_code]:py-[1.44px] [&_code]:text-xs [&_code]:leading-[14.4px]", "[&_ul]:my-2", className), ...props }));
@@ -1,12 +1,15 @@
1
- import { CalloutContainer as CalloutContainerPrimitive, CalloutDescription as CalloutDescriptionPrimitive, Callout as CalloutPrimitive, CalloutTitle as CalloutTitlePrimitive } from "fumadocs-ui/components/callout";
2
- import type { ComponentProps } from "react";
3
- type CalloutProps = ComponentProps<typeof CalloutPrimitive>;
4
- export declare const Callout: ({ className, ...props }: CalloutProps) => import("react/jsx-runtime").JSX.Element;
5
- type CalloutContainerProps = ComponentProps<typeof CalloutContainerPrimitive>;
6
- export declare const CalloutContainer: (props: CalloutContainerProps) => import("react/jsx-runtime").JSX.Element;
7
- type CalloutTitleProps = ComponentProps<typeof CalloutTitlePrimitive>;
8
- export declare const CalloutTitle: (props: CalloutTitleProps) => import("react/jsx-runtime").JSX.Element;
9
- type CalloutDescriptionProps = ComponentProps<typeof CalloutDescriptionPrimitive>;
10
- export declare const CalloutDescription: ({ className, ...props }: CalloutDescriptionProps) => import("react/jsx-runtime").JSX.Element;
1
+ import type { ComponentProps, ReactNode } from "react";
2
+ type CalloutType = "info" | "warn" | "error" | "success" | "warning" | "idea";
3
+ interface CalloutContainerProps extends ComponentProps<"div"> {
4
+ icon?: ReactNode;
5
+ type?: CalloutType;
6
+ }
7
+ type CalloutProps = Omit<CalloutContainerProps, "title"> & {
8
+ title?: ReactNode;
9
+ };
10
+ export declare const Callout: ({ children, title, ...props }: CalloutProps) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const CalloutContainer: ({ children, className, icon, type: _type, ...props }: CalloutContainerProps) => import("react/jsx-runtime").JSX.Element;
12
+ export declare const CalloutTitle: ({ className, ...props }: ComponentProps<"p">) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const CalloutDescription: ({ className, ...props }: ComponentProps<"div">) => import("react/jsx-runtime").JSX.Element;
11
14
  export {};
12
15
  //# sourceMappingURL=callout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"callout.d.ts","sourceRoot":"","sources":["../../src/components/callout.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,IAAI,yBAAyB,EAC7C,kBAAkB,IAAI,2BAA2B,EACjD,OAAO,IAAI,gBAAgB,EAC3B,YAAY,IAAI,qBAAqB,EACtC,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,KAAK,YAAY,GAAG,cAAc,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE5D,eAAO,MAAM,OAAO,GAAI,yBAAyB,YAAY,4CAQ5D,CAAC;AAEF,KAAK,qBAAqB,GAAG,cAAc,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE9E,eAAO,MAAM,gBAAgB,GAAI,OAAO,qBAAqB,4CAE5D,CAAC;AAEF,KAAK,iBAAiB,GAAG,cAAc,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEtE,eAAO,MAAM,YAAY,GAAI,OAAO,iBAAiB,4CAEpD,CAAC;AAEF,KAAK,uBAAuB,GAAG,cAAc,CAC3C,OAAO,2BAA2B,CACnC,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,yBAGhC,uBAAuB,4CAKzB,CAAC"}
1
+ {"version":3,"file":"callout.d.ts","sourceRoot":"","sources":["../../src/components/callout.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAE9E,UAAU,qBAAsB,SAAQ,cAAc,CAAC,KAAK,CAAC;IAC3D,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED,KAAK,YAAY,GAAG,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC,GAAG;IACzD,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,+BAA+B,YAAY,4CASlE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,sDAM9B,qBAAqB,4CAcvB,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,yBAAyB,cAAc,CAAC,GAAG,CAAC,4CAExE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,yBAGhC,cAAc,CAAC,KAAK,CAAC,4CAEvB,CAAC"}
@@ -1,7 +1,7 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cn } from "@vercel/geistcn/utils";
3
- import { CalloutContainer as CalloutContainerPrimitive, CalloutDescription as CalloutDescriptionPrimitive, Callout as CalloutPrimitive, CalloutTitle as CalloutTitlePrimitive, } from "fumadocs-ui/components/callout";
4
- export const Callout = ({ className, ...props }) => (_jsx(CalloutPrimitive, { className: cn("rounded-sm bg-transparent p-3! text-gray-1000 shadow-none [&_.text-fd-muted-foreground]:text-gray-1000 [&_div[role='none']]:hidden", className), ...props }));
5
- export const CalloutContainer = (props) => (_jsx(CalloutContainerPrimitive, { ...props }));
6
- export const CalloutTitle = (props) => (_jsx(CalloutTitlePrimitive, { ...props }));
7
- export const CalloutDescription = ({ className, ...props }) => (_jsx(CalloutDescriptionPrimitive, { className: cn("text-gray-1000", className), ...props }));
3
+ import { IconInformation } from "@vercel/geistcn-assets/icons";
4
+ export const Callout = ({ children, title, ...props }) => (_jsxs(CalloutContainer, { ...props, children: [title ? _jsx(CalloutTitle, { children: title }) : null, _jsx(CalloutDescription, { className: title ? "[&:has(>p:first-child)]:mt-[7px]" : undefined, children: children })] }));
5
+ export const CalloutContainer = ({ children, className, icon, type: _type, ...props }) => (_jsxs("div", { className: cn("my-4 flex items-start justify-start gap-3 rounded-[6px] bg-gray-100 px-4 py-3 font-normal text-copy-14 **:leading-[150%] [&_code]:text-[12px]!", "[&_ul]:list-none [&_ul]:pl-0! [&_ul_li]:relative [&_ul_li]:pl-6! [&_ul_li]:before:absolute [&_ul_li]:before:top-[0.6em] [&_ul_li]:before:left-0 [&_ul_li]:before:size-[5px] [&_ul_li]:before:rounded-full [&_ul_li]:before:bg-gray-600 [&_ul_li]:before:content-['']", className), ...props, children: [icon ?? (_jsx(IconInformation, { className: "mt-0.5 size-4 flex-none", color: "gray-900" })), _jsx("div", { className: "min-w-0 flex-1", children: children })] }));
6
+ export const CalloutTitle = ({ className, ...props }) => (_jsx("p", { className: cn("my-0! font-medium", className), ...props }));
7
+ export const CalloutDescription = ({ className, ...props }) => (_jsx("div", { className: cn("prose-no-margin", className), ...props }));
@@ -1 +1 @@
1
- {"version":3,"file":"code-block-tabs.d.ts","sourceRoot":"","sources":["../../src/components/code-block-tabs.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,WAAW,EACZ,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAEL,KAAK,cAAc,EAIpB,MAAM,OAAO,CAAC;AAEf,eAAO,MAAM,iBAAiB,GAAI,OAAO,cAAc,CAAC,OAAO,QAAQ,CAAC,4CAYvE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,wBAGlC,cAAc,CAAC,OAAO,WAAW,CAAC,4CAUpC,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,uBAG3B,cAAc,CAAC,OAAO,IAAI,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,4CAuDrD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,EAAE,SAAS,CAAC,4CACrB,CAAC;AAE1C,eAAO,MAAM,YAAY,GAAI,OAAO,cAAc,CAAC,OAAO,WAAW,CAAC,4CAErE,CAAC"}
1
+ {"version":3,"file":"code-block-tabs.d.ts","sourceRoot":"","sources":["../../src/components/code-block-tabs.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,WAAW,EACZ,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAEL,KAAK,cAAc,EAIpB,MAAM,OAAO,CAAC;AAEf,eAAO,MAAM,iBAAiB,GAAI,OAAO,cAAc,CAAC,OAAO,QAAQ,CAAC,4CAYvE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,wBAGlC,cAAc,CAAC,OAAO,WAAW,CAAC,4CAUpC,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,uBAG3B,cAAc,CAAC,OAAO,IAAI,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,4CA8DrD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,EAAE,SAAS,CAAC,4CACrB,CAAC;AAE1C,eAAO,MAAM,YAAY,GAAI,OAAO,cAAc,CAAC,OAAO,WAAW,CAAC,4CAErE,CAAC"}
@@ -24,7 +24,9 @@ export const CodeBlockTabs = ({ compact = false, ...props }) => {
24
24
  if (!compact) {
25
25
  return tabs;
26
26
  }
27
- return (_jsxs("div", { className: "relative [&_[role=tablist]]:hidden", children: [_jsxs("label", { className: "absolute top-2 right-12 z-2", children: [_jsx("span", { className: "sr-only", children: "Code language" }), _jsx("select", { "aria-label": "Code language", className: "h-8 cursor-pointer appearance-none rounded-md border-0 bg-transparent py-0 pr-7 pl-2 text-gray-900 text-label-13 outline-none transition-colors duration-150 ease-[cubic-bezier(0.175,0.885,0.32,1.1)] hover:bg-gray-200 focus-visible:shadow-[var(--ds-focus-ring)] motion-reduce:transition-none", onChange: (event) => setValue(event.target.value), value: value, children: options.map((option) => (_jsx("option", { value: option.value, children: option.label }, option.value))) }), _jsx("span", { className: "pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 text-gray-900", children: _jsx(IconChevronDown, { size: 16 }) })] }), tabs] }));
27
+ const selectedLabel = options.find((option) => option.value === value)?.label ??
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] }));
28
30
  };
29
31
  export const CompactCodeBlockTabs = (props) => _jsx(CodeBlockTabs, { ...props, compact: true });
30
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,4CA8BhB,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,4CAuChB,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", 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("[&_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 }));
29
29
  };
@@ -1 +1 @@
1
- {"version":3,"file":"command-prompt.d.ts","sourceRoot":"","sources":["../../src/components/command-prompt.tsx"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,wBAAwB,EAG7B,KAAK,GAAG,EACR,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AA+Bf,KAAK,sBAAsB,GAAG,IAAI,CAChC,wBAAwB,CAAC,KAAK,CAAC,EAC/B,UAAU,CACX,GAAG;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EAAE,SAAS,EAChB,YAAY,EACZ,aAAa,EACb,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,CA0EtC;AAED,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,GAAG,KAAK,EACT,EAAE,wBAAwB,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,OAAO,CAE/C;AAED,KAAK,yBAAyB,GAAG,wBAAwB,CAAC,QAAQ,CAAC,GAAG;IACpE,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,SAAS,EACT,OAAO,EACP,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,yBAAyB,GAAG,GAAG,CAAC,OAAO,CA6BzC;AAED,wBAAgB,2BAA2B,CAAC,EAC1C,SAAS,EACT,GAAG,KAAK,EACT,EAAE,wBAAwB,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,OAAO,CAQ/C;AAED,wBAAgB,oBAAoB,CAAC,EACnC,SAAS,EACT,OAAO,EACP,QAAQ,GACT,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,wBAAwB,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC;CACtD,GAAG,GAAG,CAAC,OAAO,CA8Bd;AAED,wBAAgB,mBAAmB,CAAC,EAClC,SAAS,EACT,GAAG,KAAK,EACT,EAAE,wBAAwB,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,CAOhD;AAED,UAAU,yBAAyB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,QAAQ,GACT,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAoJd;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,yBAAyB,GAChC,GAAG,CAAC,OAAO,GAAG,IAAI,CAEpB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,OAAO,EACP,GAAG,KAAK,EACT,EAAE,wBAAwB,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,OAAO,CAsFlD"}
1
+ {"version":3,"file":"command-prompt.d.ts","sourceRoot":"","sources":["../../src/components/command-prompt.tsx"],"names":[],"mappings":"AAOA,OAAO,EAEL,KAAK,wBAAwB,EAG7B,KAAK,GAAG,EACR,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AA+Bf,KAAK,sBAAsB,GAAG,IAAI,CAChC,wBAAwB,CAAC,KAAK,CAAC,EAC/B,UAAU,CACX,GAAG;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EAAE,SAAS,EAChB,YAAY,EACZ,aAAa,EACb,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,CA0EtC;AAED,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,GAAG,KAAK,EACT,EAAE,wBAAwB,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,OAAO,CAE/C;AAED,KAAK,yBAAyB,GAAG,wBAAwB,CAAC,QAAQ,CAAC,GAAG;IACpE,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,SAAS,EACT,OAAO,EACP,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,yBAAyB,GAAG,GAAG,CAAC,OAAO,CA6BzC;AAED,wBAAgB,2BAA2B,CAAC,EAC1C,SAAS,EACT,GAAG,KAAK,EACT,EAAE,wBAAwB,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,OAAO,CAQ/C;AAED,wBAAgB,oBAAoB,CAAC,EACnC,SAAS,EACT,OAAO,EACP,QAAQ,GACT,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,wBAAwB,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC;CACtD,GAAG,GAAG,CAAC,OAAO,CA8Bd;AAED,wBAAgB,mBAAmB,CAAC,EAClC,SAAS,EACT,GAAG,KAAK,EACT,EAAE,wBAAwB,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,CAOhD;AAED,UAAU,yBAAyB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,QAAQ,GACT,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAwId;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,yBAAyB,GAChC,GAAG,CAAC,OAAO,GAAG,IAAI,CAEpB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,OAAO,EACP,GAAG,KAAK,EACT,EAAE,wBAAwB,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,OAAO,CAsFlD"}
@@ -4,6 +4,7 @@ import { cn } from "@vercel/geistcn/utils";
4
4
  import { IconCheck } from "@vercel/geistcn-assets/icons/icon-check";
5
5
  import { IconCopy } from "@vercel/geistcn-assets/icons/icon-copy";
6
6
  import { AnimatePresence, motion, useReducedMotion } from "motion/react";
7
+ import { useSize } from "phase/react";
7
8
  import { Children, createContext, isValidElement, useContext, useEffect, useLayoutEffect, useRef, useState, } from "react";
8
9
  const CommandPromptContext = createContext(null);
9
10
  function useCommandPromptContext(component) {
@@ -108,8 +109,17 @@ export function CommandPromptViewport({ className, children, }) {
108
109
  const context = useCommandPromptContext("CommandPrompt.Viewport");
109
110
  const shouldReduceMotion = useReducedMotion();
110
111
  const { commandWidth, canShowGradient, isOverflowing, setActiveCopyValue, setCanShowGradient, setCommandWidth, setIsOverflowing, } = context;
111
- const measureRef = useRef(null);
112
- const scrollObserverCleanup = useRef(null);
112
+ const { ref: measureRef } = useSize({
113
+ onResize: ({ width }) => setCommandWidth(width),
114
+ });
115
+ const { ref: activeContentRef } = useSize({
116
+ onResize: () => {
117
+ const element = activeContentRef.current;
118
+ if (element) {
119
+ setIsOverflowing(element.scrollWidth > element.clientWidth);
120
+ }
121
+ },
122
+ });
113
123
  const items = Children.toArray(children)
114
124
  .filter((child) => isValidElement(child))
115
125
  .map((child) => child.props);
@@ -130,17 +140,8 @@ export function CommandPromptViewport({ className, children, }) {
130
140
  setActiveCopyValue(copyValue);
131
141
  return () => {
132
142
  setIsOverflowing(false);
133
- scrollObserverCleanup.current?.();
134
- scrollObserverCleanup.current = null;
135
143
  };
136
144
  }, [copyValue, setActiveCopyValue, setIsOverflowing]);
137
- // biome-ignore lint/correctness/useExhaustiveDependencies: command/copyValue must re-measure the width to drive the resize animation when the active command changes.
138
- useLayoutEffect(() => {
139
- if (!measureRef.current) {
140
- return;
141
- }
142
- setCommandWidth(measureRef.current.getBoundingClientRect().width);
143
- }, [command, copyValue, setCommandWidth]);
144
145
  return (_jsxs(motion.span, { animate: commandWidth === undefined
145
146
  ? undefined
146
147
  : { width: shouldReduceMotion ? "auto" : commandWidth }, className: cn("relative block min-w-0 overflow-hidden text-gray-1000 text-label-14-mono!", className), initial: false, onAnimationComplete: () => {
@@ -157,18 +158,10 @@ export function CommandPromptViewport({ className, children, }) {
157
158
  return (_jsx(motion.span, { animate: { opacity: 1, filter: "blur(0px)" }, className: cn("block min-w-0 whitespace-nowrap py-2", canShowGradient && isOverflowing
158
159
  ? "overflow-x-auto"
159
160
  : "overflow-x-hidden", child.props.className), exit: { opacity: 0, filter: "blur(1px)" }, initial: { opacity: 0, filter: "blur(1px)" }, ref: (element) => {
160
- scrollObserverCleanup.current?.();
161
- scrollObserverCleanup.current = null;
162
- if (!element) {
163
- return;
164
- }
165
- const checkOverflow = () => {
161
+ activeContentRef.current = element;
162
+ if (element) {
166
163
  setIsOverflowing(element.scrollWidth > element.clientWidth);
167
- };
168
- checkOverflow();
169
- const observer = new ResizeObserver(checkOverflow);
170
- observer.observe(element);
171
- scrollObserverCleanup.current = () => observer.disconnect();
164
+ }
172
165
  }, transition: shouldReduceMotion ? { duration: 0 } : { duration: 0.15 }, children: child.props.children }, copyValue));
173
166
  }) }), _jsx(AnimatePresence, { children: canShowGradient && isOverflowing && (_jsx(motion.span, { animate: { opacity: 1 }, "aria-hidden": true, className: "pointer-events-none absolute top-0 right-0 bottom-0 z-10 block w-4 bg-gradient-to-r from-transparent to-background-100", exit: { opacity: 0 }, initial: { opacity: 0 }, transition: shouldReduceMotion ? { duration: 0 } : { duration: 0.2 } })) })] }));
174
167
  }
@@ -2,10 +2,11 @@ import { type ReactNode } from "react";
2
2
  interface CopyPromptProps {
3
3
  children?: ReactNode;
4
4
  className?: string;
5
+ collapsible?: boolean;
5
6
  projectOnly?: boolean;
6
7
  text: string;
7
8
  title?: string;
8
9
  }
9
- export declare const CopyPrompt: ({ children, className, projectOnly, text, title, }: CopyPromptProps) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const CopyPrompt: ({ children, className, collapsible, projectOnly, text, title, }: CopyPromptProps) => import("react/jsx-runtime").JSX.Element;
10
11
  export {};
11
12
  //# sourceMappingURL=copy-prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"copy-prompt.d.ts","sourceRoot":"","sources":["../../src/components/copy-prompt.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AASjD,UAAU,eAAe;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAqBD,eAAO,MAAM,UAAU,GAAI,oDAMxB,eAAe,4CAoIjB,CAAC"}
1
+ {"version":3,"file":"copy-prompt.d.ts","sourceRoot":"","sources":["../../src/components/copy-prompt.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AASjD,UAAU,eAAe;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAqBD,eAAO,MAAM,UAAU,GAAI,iEAOxB,eAAe,4CAqIjB,CAAC"}
@@ -20,7 +20,7 @@ const getPlatformUrl = (platform, prompt) => {
20
20
  return encoded;
21
21
  }
22
22
  };
23
- export const CopyPrompt = ({ children, className, projectOnly = false, text, title = "Prompt for coding agents", }) => {
23
+ export const CopyPrompt = ({ children, className, collapsible = false, projectOnly = false, text, title = "Prompt for coding agents", }) => {
24
24
  const [isCopied, setIsCopied] = useState(false);
25
25
  const [isExpanded, setIsExpanded] = useState(false);
26
26
  const copy = async () => {
@@ -49,7 +49,7 @@ export const CopyPrompt = ({ children, className, projectOnly = false, text, tit
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 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-all duration-200", isCopied ? "scale-75 opacity-0" : "scale-100 opacity-100") }), _jsx(IconCheck, { className: cn("absolute inset-0 size-4 transition-all 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-l transition-colors hover:bg-gray-100 hover:text-gray-1000 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-gray-600/50", 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]", isExpanded ? "" : "line-clamp-2", isExpanded ? "whitespace-pre-wrap" : ""), children: children ?? text }), isExpanded ? null : (_jsx("div", { className: "pointer-events-none absolute inset-0 bg-linear-to-b from-transparent via-transparent to-background-100" }))] }), _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"] }) })] })] }) }));
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] })] }) }));
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,7 @@
1
+ import { type ComponentProps, type ElementType } from "react";
2
+ type HeadingProps = ComponentProps<"h1"> & {
3
+ as: ElementType;
4
+ };
5
+ export declare const Heading: ({ as, children, className, id, ...props }: HeadingProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
6
+ export {};
7
+ //# sourceMappingURL=heading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../src/components/heading.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAiB,KAAK,WAAW,EAAE,MAAM,OAAO,CAAC;AAE7E,KAAK,YAAY,GAAG,cAAc,CAAC,IAAI,CAAC,GAAG;IACzC,EAAE,EAAE,WAAW,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,2CAMrB,YAAY,2FAqBd,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cn } from "@vercel/geistcn/utils";
3
+ import { IconLink } from "@vercel/geistcn-assets/icons";
4
+ import { createElement } from "react";
5
+ export const Heading = ({ as, children, className, id, ...props }) => {
6
+ if (!id) {
7
+ return createElement(as, { className, ...props }, children);
8
+ }
9
+ return createElement(as, {
10
+ className: cn("flex scroll-m-28 flex-row items-center gap-2", className),
11
+ id,
12
+ ...props,
13
+ }, _jsx("a", { className: "peer", "data-card": "", href: `#${id}`, children: children }), _jsx(IconLink, { "aria-hidden": "true", className: "size-3.5 shrink-0 opacity-0 transition-opacity peer-hover:opacity-100", color: "gray-900" }));
14
+ };
@@ -0,0 +1,3 @@
1
+ import type { ComponentProps } from "react";
2
+ export declare const Table: ({ className, ...props }: ComponentProps<"table">) => import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/components/table.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,eAAO,MAAM,KAAK,GAAI,yBAAyB,cAAc,CAAC,OAAO,CAAC,4CAmBrE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cn } from "@vercel/geistcn/utils";
3
+ export const Table = ({ className, ...props }) => (_jsx("div", { className: "relative overflow-auto", children: _jsx("table", { className: cn("my-[2em] w-full table-auto border-collapse border-spacing-0 rounded-none border-0 bg-transparent text-sm leading-[1.4]", "[&_td]:border-x-0 [&_td]:text-start [&_th]:border-x-0 [&_th]:text-start", "[&_thead]:border-gray-200 [&_thead]:border-b [&_thead]:bg-transparent", "[&_thead_th]:bg-transparent [&_thead_th]:pb-[0.8em] [&_thead_th]:align-bottom [&_thead_th]:text-gray-1000 [&_thead_th]:text-heading-16", "[&_thead_th:first-child]:pl-0 [&_thead_th:last-child]:pr-0 [&_thead_th]:px-[0.6em]", "[&_tbody_tr:last-child]:border-b-0 [&_tbody_tr]:border-gray-200 [&_tbody_tr]:border-b", "[&_tbody_td:first-child]:pl-0 [&_tbody_td:last-child]:pr-0 [&_tbody_td]:px-[0.6em] [&_tbody_td]:py-[0.8em] [&_tbody_td]:align-baseline", "[&_tfoot]:border-gray-200 [&_tfoot]:border-t", "[&_tfoot_td:first-child]:pl-0 [&_tfoot_td:last-child]:pr-0 [&_tfoot_td]:px-[0.6em] [&_tfoot_td]:py-[0.8em] [&_tfoot_td]:align-top", "[&_td_code]:text-[0.8125rem]", className), ...props }) }));
@@ -1 +1 @@
1
- {"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../src/controls.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAS5D,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,YAAY,GAAI,wBAAwB,iBAAiB,4CAqBrE,CAAC;AAEF,eAAO,MAAM,WAAW,+CA0CvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,sDA+B5B,CAAC;AAEF,UAAU,gBAAgB;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,CAAC;IACpD,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;CAChD;AAED,eAAO,MAAM,WAAW,GAAI,0DAOzB,gBAAgB,mDA2BlB,CAAC"}
1
+ {"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../src/controls.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAS5D,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,YAAY,GAAI,wBAAwB,iBAAiB,4CAqBrE,CAAC;AAEF,eAAO,MAAM,WAAW,+CA0CvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,sDA+B5B,CAAC;AAEF,UAAU,gBAAgB;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,CAAC;IACpD,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;CAChD;AAED,eAAO,MAAM,WAAW,GAAI,0DAOzB,gBAAgB,mDA+BlB,CAAC"}
package/dist/controls.js CHANGED
@@ -12,7 +12,7 @@ import { useGeistdocsChat } from "./internal/chat/context";
12
12
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "./internal/ui/dropdown-menu";
13
13
  export const SearchButton = ({ className, onClick }) => {
14
14
  const { setOpenSearch } = useSearchContext();
15
- return (_jsxs("button", { className: cn("flex h-8 cursor-pointer items-center justify-between rounded-md border-0 bg-background-100 px-1.5 py-0 font-normal font-sans text-gray-1000 text-sm shadow-[0_0_0_1px_var(--ds-gray-400)] outline-none hover:bg-gray-100 focus-visible:shadow-focus-ring", className), onClick: () => {
15
+ return (_jsxs("button", { className: cn("flex h-8 cursor-pointer items-center justify-between rounded-md border-0 bg-background-100 py-0 pr-1.5 pl-3.5 font-normal font-sans text-gray-1000 text-sm shadow-[0_0_0_1px_var(--ds-gray-400)] outline-none hover:bg-gray-100 focus-visible:shadow-focus-ring", className), onClick: () => {
16
16
  setOpenSearch(true);
17
17
  onClick?.();
18
18
  }, type: "button", children: [_jsx("span", { className: "pr-6", children: "Search\u2026" }), _jsx(Kbd, { className: "inline-flex items-center justify-center rounded", small: true, children: "\u2318K" })] }));
@@ -39,16 +39,17 @@ export const LanguageSelector = () => {
39
39
  return (_jsxs(DropdownMenu, { children: [_jsxs(DropdownMenuTrigger, { "aria-label": "Select Language", className: "flex items-center justify-center rounded-md p-2 hover:bg-gray-alpha-100 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none active:bg-gray-alpha-300", children: [_jsx(IconLanguages, { className: "size-4.5" }), _jsx("span", { className: "sr-only", children: "Select Language" })] }), _jsx(DropdownMenuContent, { align: "end", children: locales.map((lang) => (_jsxs(DropdownMenuItem, { className: "flex cursor-pointer items-center justify-between", disabled: locale === lang.locale, onClick: () => onChange?.(lang.locale), children: [lang.name, locale === lang.locale && _jsx(IconCheck, { className: "size-4" })] }, lang.locale))) })] }));
40
40
  };
41
41
  export const AskAIButton = ({ children, className, prompt, size = "small", variant = "secondary", ...props }) => {
42
- const { enabled, isOpen, setIsOpen, setPrompt } = useGeistdocsChat();
42
+ const { enabled, isOpen, preloadChat, setIsOpen, setPrompt } = useGeistdocsChat();
43
43
  if (!enabled) {
44
44
  return null;
45
45
  }
46
46
  return (_jsx(Button, { className: cn("shrink-0", className), onClick: () => {
47
+ preloadChat();
47
48
  if (prompt) {
48
49
  setPrompt(prompt);
49
50
  setIsOpen(true);
50
51
  return;
51
52
  }
52
53
  setIsOpen(!isOpen);
53
- }, size: size, typeName: "button", variant: variant, ...props, children: children ?? _jsx("span", { children: "Ask AI" }) }));
54
+ }, onFocus: preloadChat, onMouseEnter: preloadChat, size: size, typeName: "button", variant: variant, ...props, children: children ?? _jsx("span", { children: "Ask AI" }) }));
54
55
  };
@@ -3,7 +3,9 @@ interface GeistdocsChatContextValue {
3
3
  basePath?: string;
4
4
  enabled: boolean;
5
5
  footer?: React.ReactNode;
6
+ hasBeenOpened: boolean;
6
7
  isOpen: boolean;
8
+ preloadChat: () => void;
7
9
  prompt: string;
8
10
  setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
9
11
  setPrompt: React.Dispatch<React.SetStateAction<string>>;
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/context.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,UAAU,yBAAyB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAMD,eAAO,MAAM,gBAAgB,iCAQ5B,CAAC;AAEF,UAAU,0BAA0B;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,GAAG,UAAU,GAAG,OAAO,CAAC,CAAC;CAC5D;AAED,eAAO,MAAM,qBAAqB,GAAI,uBAGnC,0BAA0B,4CAmC5B,CAAC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/context.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,UAAU,yBAAyB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACzD,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAMD,eAAO,MAAM,gBAAgB,iCAQ5B,CAAC;AAEF,UAAU,0BAA0B;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,GAAG,UAAU,GAAG,OAAO,CAAC,CAAC;CAC5D;AAED,eAAO,MAAM,qBAAqB,GAAI,uBAGnC,0BAA0B,4CAyD5B,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { createContext, useContext, useEffect, useMemo, useState } from "react";
3
+ import { createContext, useCallback, useContext, useEffect, useMemo, useState, } from "react";
4
4
  const CHAT_OPEN_STORAGE_KEY = "geistdocs:chat-open";
5
5
  const GeistdocsChatContext = createContext(null);
6
6
  export const useGeistdocsChat = () => {
@@ -12,13 +12,24 @@ export const useGeistdocsChat = () => {
12
12
  };
13
13
  export const GeistdocsChatProvider = ({ children, config, }) => {
14
14
  const [isOpen, setIsOpen] = useState(false);
15
+ const [hasBeenOpened, setHasBeenOpened] = useState(false);
15
16
  const [prompt, setPrompt] = useState("");
17
+ const preloadChat = useCallback(() => setHasBeenOpened(true), []);
16
18
  useEffect(() => {
17
19
  const stored = window.localStorage.getItem(CHAT_OPEN_STORAGE_KEY);
18
20
  if (stored !== null) {
19
- setIsOpen(stored === "true");
21
+ const open = stored === "true";
22
+ setIsOpen(open);
23
+ if (open) {
24
+ setHasBeenOpened(true);
25
+ }
20
26
  }
21
27
  }, []);
28
+ useEffect(() => {
29
+ if (isOpen) {
30
+ setHasBeenOpened(true);
31
+ }
32
+ }, [isOpen]);
22
33
  useEffect(() => {
23
34
  window.localStorage.setItem(CHAT_OPEN_STORAGE_KEY, String(isOpen));
24
35
  }, [isOpen]);
@@ -26,12 +37,22 @@ export const GeistdocsChatProvider = ({ children, config, }) => {
26
37
  basePath: config.basePath,
27
38
  footer: config.ai?.footer,
28
39
  enabled: config.ai?.enabled !== false,
40
+ hasBeenOpened,
29
41
  isOpen,
42
+ preloadChat,
30
43
  prompt,
31
44
  setIsOpen,
32
45
  setPrompt,
33
46
  suggestions: config.ai?.suggestions ?? [],
34
47
  title: config.title,
35
- }), [config.ai, config.basePath, config.title, isOpen, prompt]);
48
+ }), [
49
+ config.ai,
50
+ config.basePath,
51
+ config.title,
52
+ hasBeenOpened,
53
+ isOpen,
54
+ preloadChat,
55
+ prompt,
56
+ ]);
36
57
  return (_jsx(GeistdocsChatContext.Provider, { value: value, children: children }));
37
58
  };
@@ -1 +1 @@
1
- {"version":3,"file":"dots-spinner.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/dots-spinner.tsx"],"names":[],"mappings":"AAOA,wBAAgB,WAAW,CAAC,EAC1B,SAAS,EACT,KAAW,GACZ,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,2CAgBA"}
1
+ {"version":3,"file":"dots-spinner.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/dots-spinner.tsx"],"names":[],"mappings":"AAQA,wBAAgB,WAAW,CAAC,EAC1B,SAAS,EACT,KAAW,GACZ,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,2CAmBA"}
@@ -1,15 +1,21 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { cn } from "@vercel/geistcn/utils";
4
- import { useEffect, useState } from "react";
4
+ import { useLoop } from "phase/react";
5
+ import { useRef } from "react";
5
6
  const FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
6
7
  export function DotsSpinner({ className, speed = 150, }) {
7
- const [currentFrame, setCurrentFrame] = useState(0);
8
- useEffect(() => {
9
- const interval = window.setInterval(() => {
10
- setCurrentFrame((frame) => (frame + 1) % FRAMES.length);
11
- }, speed);
12
- return () => window.clearInterval(interval);
13
- }, [speed]);
14
- return (_jsx("span", { className: cn("inline-block w-4 text-center", className), children: FRAMES[currentFrame] }));
8
+ const previousFrame = useRef(-1);
9
+ const { ref } = useLoop({
10
+ fps: 1000 / speed,
11
+ onTick: (frame) => {
12
+ const currentFrame = Math.floor(frame.elapsed / speed) % FRAMES.length;
13
+ if (currentFrame === previousFrame.current || !ref.current) {
14
+ return;
15
+ }
16
+ previousFrame.current = currentFrame;
17
+ ref.current.textContent = FRAMES[currentFrame];
18
+ },
19
+ });
20
+ return (_jsx("span", { className: cn("inline-block w-4 text-center", className), ref: ref, children: FRAMES[0] }));
15
21
  }
@@ -0,0 +1,7 @@
1
+ export declare const ChatConversationSkeleton: () => import("react/jsx-runtime").JSX.Element;
2
+ export declare const ChatEmptySkeleton: () => import("react/jsx-runtime").JSX.Element;
3
+ export declare const ChatLoadingSkeleton: ({ isMobile, title, }: {
4
+ isMobile: boolean;
5
+ title: string;
6
+ }) => import("react/jsx-runtime").JSX.Element;
7
+ //# sourceMappingURL=loading-skeleton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loading-skeleton.d.ts","sourceRoot":"","sources":["../../../src/internal/chat/loading-skeleton.tsx"],"names":[],"mappings":"AAsCA,eAAO,MAAM,wBAAwB,+CAyCpC,CAAC;AAEF,eAAO,MAAM,iBAAiB,+CAsB7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,sBAGjC;IACD,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,4CAmBA,CAAC"}
@@ -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.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,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"}