@vercel/geistdocs 1.25.1-canary.5684bb5 → 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.
- package/dist/cli/index.js +1 -1
- package/dist/components/callout.d.ts.map +1 -1
- package/dist/components/callout.js +3 -3
- package/dist/components/code-block-tabs.d.ts.map +1 -1
- package/dist/components/code-block-tabs.js +3 -1
- package/dist/components/code-block.d.ts.map +1 -1
- package/dist/components/code-block.js +1 -1
- package/dist/components/command-prompt.d.ts.map +1 -1
- package/dist/components/command-prompt.js +15 -22
- package/dist/components/copy-prompt.d.ts +2 -1
- package/dist/components/copy-prompt.d.ts.map +1 -1
- package/dist/components/copy-prompt.js +2 -2
- package/dist/components/heading.d.ts +7 -0
- package/dist/components/heading.d.ts.map +1 -0
- package/dist/components/heading.js +14 -0
- package/dist/components/image.d.ts +19 -0
- package/dist/components/image.d.ts.map +1 -0
- package/dist/components/image.js +9 -0
- package/dist/components/steps.d.ts +9 -0
- package/dist/components/steps.d.ts.map +1 -0
- package/dist/components/steps.js +9 -0
- package/dist/components/table.d.ts +3 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/table.js +3 -0
- package/dist/controls.d.ts.map +1 -1
- package/dist/controls.js +4 -3
- package/dist/internal/chat/activity.d.ts +20 -0
- package/dist/internal/chat/activity.d.ts.map +1 -0
- package/dist/internal/chat/activity.js +43 -0
- package/dist/internal/chat/context.d.ts +2 -0
- package/dist/internal/chat/context.d.ts.map +1 -1
- package/dist/internal/chat/context.js +24 -3
- package/dist/internal/chat/dots-spinner.d.ts.map +1 -1
- package/dist/internal/chat/dots-spinner.js +15 -9
- package/dist/internal/chat/loading-skeleton.d.ts +7 -0
- package/dist/internal/chat/loading-skeleton.d.ts.map +1 -0
- package/dist/internal/chat/loading-skeleton.js +46 -0
- package/dist/internal/chat/message-metadata.d.ts.map +1 -1
- package/dist/internal/chat/message-metadata.js +15 -30
- package/dist/internal/chat/message-sources.d.ts +3 -0
- package/dist/internal/chat/message-sources.d.ts.map +1 -0
- package/dist/internal/chat/message-sources.js +23 -0
- package/dist/internal/chat/message.d.ts.map +1 -1
- package/dist/internal/chat/message.js +59 -5
- package/dist/internal/chat/shell.d.ts.map +1 -1
- package/dist/internal/chat/shell.js +17 -17
- package/dist/internal/chat/source-chunks.d.ts +9 -0
- package/dist/internal/chat/source-chunks.d.ts.map +1 -0
- package/dist/internal/chat/source-chunks.js +7 -0
- package/dist/internal/chat/sources.d.ts +1 -1
- package/dist/internal/chat/sources.d.ts.map +1 -1
- package/dist/internal/chat/sources.js +7 -1
- package/dist/internal/link-href.d.ts +13 -0
- package/dist/internal/link-href.d.ts.map +1 -0
- package/dist/internal/link-href.js +51 -0
- package/dist/internal/mdx-to-markdown.d.ts +3 -0
- package/dist/internal/mdx-to-markdown.d.ts.map +1 -0
- package/dist/internal/mdx-to-markdown.js +166 -0
- package/dist/internal/mousedown-navigation-utils.d.ts +5 -0
- package/dist/internal/mousedown-navigation-utils.d.ts.map +1 -0
- package/dist/internal/mousedown-navigation-utils.js +95 -0
- package/dist/internal/mousedown-navigation.d.ts +10 -0
- package/dist/internal/mousedown-navigation.d.ts.map +1 -0
- package/dist/internal/mousedown-navigation.js +42 -0
- package/dist/internal/navbar/desktop-menu.js +1 -1
- package/dist/internal/navbar/mobile-menu.d.ts.map +1 -1
- package/dist/internal/navbar/mobile-menu.js +8 -13
- package/dist/internal/navbar/navbar-shell.d.ts.map +1 -1
- package/dist/internal/navbar/navbar-shell.js +2 -1
- package/dist/internal/page-actions-client.d.ts.map +1 -1
- package/dist/internal/page-actions-client.js +36 -32
- package/dist/internal/provider-client.d.ts.map +1 -1
- package/dist/internal/provider-client.js +29 -5
- package/dist/internal/react-node-text.d.ts +4 -0
- package/dist/internal/react-node-text.d.ts.map +1 -0
- package/dist/internal/react-node-text.js +11 -0
- package/dist/internal/search.d.ts.map +1 -1
- package/dist/internal/search.js +1 -1
- package/dist/internal/sidebar-responsive.d.ts +0 -1
- package/dist/internal/sidebar-responsive.d.ts.map +1 -1
- package/dist/internal/sidebar-responsive.js +0 -9
- package/dist/internal/sidebar-tree.d.ts.map +1 -1
- package/dist/internal/sidebar-tree.js +6 -1
- package/dist/internal/sidebar.d.ts.map +1 -1
- package/dist/internal/sidebar.js +78 -49
- package/dist/internal/table-of-contents.d.ts.map +1 -1
- package/dist/internal/table-of-contents.js +1 -1
- package/dist/internal/toc-items.d.ts.map +1 -1
- package/dist/internal/toc-items.js +18 -7
- package/dist/internal/ui/dropdown-menu.js +6 -6
- package/dist/internal/ui/navigation-menu.js +2 -2
- package/dist/internal/use-mobile.d.ts.map +1 -1
- package/dist/internal/use-mobile.js +2 -12
- package/dist/layout.d.ts +1 -0
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +2 -0
- package/dist/mdx.d.ts.map +1 -1
- package/dist/mdx.js +16 -4
- package/dist/pages/docs.d.ts.map +1 -1
- package/dist/pages/docs.js +17 -9
- package/dist/routes/chat.d.ts +1 -1
- package/dist/routes/chat.d.ts.map +1 -1
- package/dist/routes/chat.js +31 -14
- package/dist/routes/llms.d.ts +1 -1
- package/dist/routes/llms.d.ts.map +1 -1
- package/dist/routes/llms.js +12 -2
- package/dist/source-config.d.ts +10 -0
- package/dist/source-config.d.ts.map +1 -1
- package/dist/source-config.js +20 -2
- package/dist/source.d.ts +10 -1
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +75 -34
- package/dist/versions.js +2 -2
- package/docs/agents.md +5 -3
- package/docs/llms.txt +486 -34
- package/docs/manifest.json +21 -3
- package/docs/pages/ask-ai.md +2 -2
- package/docs/pages/components/steps.md +129 -0
- package/docs/pages/deployment.md +30 -5
- package/docs/pages/getting-started.md +38 -12
- package/docs/pages/guides/nested-navigation.md +1 -1
- package/docs/pages/md.md +25 -6
- package/docs/pages/migration-2.md +106 -0
- package/docs/pages/migration.md +5 -2
- package/docs/pages/syntax.md +137 -3
- package/docs/sitemap.md +4 -2
- package/package.json +16 -5
- package/source-config.js +37 -2
- package/template/app/[lang]/layout.tsx +4 -0
- package/template/app/styles/geistdocs.css +1 -1
- package/template/components/ui/button.tsx +1 -1
- package/template/content/docs/ask-ai.cn.mdx +2 -2
- package/template/content/docs/ask-ai.mdx +2 -2
- package/template/content/docs/components/meta.json +4 -0
- package/template/content/docs/components/steps.mdx +125 -0
- package/template/content/docs/deployment.mdx +31 -6
- package/template/content/docs/getting-started.mdx +39 -13
- package/template/content/docs/guides/nested-navigation.mdx +1 -1
- package/template/content/docs/md.mdx +25 -6
- package/template/content/docs/meta.json +3 -0
- package/template/content/docs/migration-2.mdx +106 -0
- package/template/content/docs/migration.mdx +5 -1
- package/template/content/docs/syntax.mdx +143 -3
- package/template/next.config.ts +9 -0
- package/template/package.json +4 -4
- package/theme.css +80 -61
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.5684bb5","-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);
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "@vercel/geistcn/utils";
|
|
3
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, { 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]!", className), ...props, children: [icon ?? (_jsx(IconInformation, { className: "
|
|
6
|
-
export const CalloutTitle = ({ className, ...props }) => (_jsx("p", { className: cn("
|
|
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
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,
|
|
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
|
-
|
|
27
|
+
const selectedLabel = options.find((option) => option.value === value)?.label ??
|
|
28
|
+
options[0]?.label;
|
|
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] }));
|
|
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,
|
|
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", 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
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-prompt.d.ts","sourceRoot":"","sources":["../../src/components/command-prompt.tsx"],"names":[],"mappings":"
|
|
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 =
|
|
112
|
-
|
|
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
|
-
|
|
161
|
-
|
|
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,
|
|
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: "
|
|
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,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,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 @@
|
|
|
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 }) }));
|
package/dist/controls.d.ts.map
CHANGED
|
@@ -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,
|
|
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
|
|
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
|
};
|
|
@@ -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
|
+
};
|
|
@@ -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":"
|
|
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
|
-
|
|
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
|
-
}), [
|
|
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":"
|
|
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"}
|